TypeScript S6847 False Positive

  • What language is this for?


  • Which rule?

S6847 - Non-interactive elements shouldn’t have event handlers

  • Why do you believe it’s a false-positive/false-negative?

Attaching onError or onLoad event listeners to non-interactive elements like an image doesn’t hinder accessibility, they are not listeners for mouse/keyboard inputs and do not fall under SQ rule, which is described as:

Attaching event handlers to non-interactive HTML elements can lead to significant accessibility issues. These elements, such as <div> and <span> , are not designed to interact with assistive technologies like screen readers, making it difficult for users with disabilities to navigate and interact with the website. Additionally, these elements may not be focusable or provide visual feedback when interacted with, resulting in a confusing and potentially frustrating user experience. Therefore, to maintain an accessible and user-friendly website, event handlers should be used exclusively with interactive elements.

  • Are you using

SonarQube -

  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
<img onError={onError} />

Hello Martin,

Thank you for the feedback.

We have opened an issue to fix this FP: [JS-145] - Jira