Pular para o conteúdo

useSemanticElements

Este conteúdo não está disponível em sua língua ainda.

Diagnostic Category: lint/a11y/useSemanticElements

Since: v1.8.0

Sources:

It detects the use of role attributes in JSX elements and suggests using semantic elements instead.

The role attribute is used to define the purpose of an element, but it should be used as a last resort. Using semantic elements like <button>, <nav> and others are more accessible and provide better semantics.

<div role="checkbox"></div>
code-block.jsx:1:6 lint/a11y/useSemanticElements ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The elements with the following roles can be changed to the following elements:
<input type=“checkbox”>


> 1 │ <div role=“checkbox”></div>
^^^^^^^^^^^^^^^
2 │

For examples and more information, see WAI-ARIA Roles

<div role="separator"></div>
code-block.jsx:1:6 lint/a11y/useSemanticElements ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The elements with the following roles can be changed to the following elements:
<hr>


> 1 │ <div role=“separator”></div>
^^^^^^^^^^^^^^^^
2 │

For examples and more information, see WAI-ARIA Roles

<>
<input type="checkbox">label</input>
<hr/>
</>;

All elements with role="img" are ignored:

<div role="img" aria-label="That cat is so cute">
<p>&#x1F408; &#x1F602;</p>
</div>