Lint Rules

useAltText (since v10.0.0)

This rule is recommended by Rome.

It asserts that alternative text to images or areas, help to rely on to screen readers to understand the purpose and the context of the image.

Examples

Invalid

<img src="image.png" />
a11y/useAltText.js:1:1 lint/a11y/useAltText ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Provide the attribute alt when using img, area or input type='image'
  
  > 1 │ <img src="image.png" />
   ^^^^^^^^^^^^^^^^^^^^^^^
    2 │ 
  
   Meaningful alternative text on elements helps users relying on screen
                readers to understand content's purpose within a page.
  
<input type="image" src="image.png" />
a11y/useAltText.js:1:1 lint/a11y/useAltText ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Provide the attribute alt when using img, area or input type='image'
  
  > 1 │ <input type="image" src="image.png" />
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    2 │ 
  
   Meaningful alternative text on elements helps users relying on screen
                readers to understand content's purpose within a page.
  

Valid

<img src="image.png" alt="image alt" />
<input type="image" src="image.png" alt="alt text" />
<input type="image" src="image.png" aria-label="alt text" />
<input type="image" src="image.png" aria-labelledby="someId" />