jsx-a11y/role-supports-aria-props
eslint-plugin-jsx-a11y
import jsxA11y from "eslint-plugin-jsx-a11y";
export default [
{
plugins: { "jsx-a11y": jsxA11y },
rules: {
"jsx-a11y/role-supports-aria-props": "error",
},
},
];Enforce that elements with explicit or implicit roles defined contain only aria-* properties supported by that role.
<!-- Bad: the radio role does not support the aria-required property -->
<ul role="radiogroup" aria-labelledby="foo">
<li aria-required tabIndex="-1" role="radio" aria-checked="false">Rainbow Trout</li>
<li aria-required tabIndex="-1" role="radio" aria-checked="false">Brook Trout</li>
<li aria-required tabIndex="0" role="radio" aria-checked="true">Lake Trout</li>
</ul><!-- Good: the radiogroup role does support the aria-required property -->
<ul role="radiogroup" aria-required aria-labelledby="foo">
<li tabIndex="-1" role="radio" aria-checked="false">Rainbow Trout</li>
<li tabIndex="-1" role="radio" aria-checked="false">Brook Trout</li>
<li tabIndex="0" role="radio" aria-checked="true">Lake Trout</li>
</ul>Examples from the ESLint documentation.
jsx-a11y/role-supports-aria-props
eslint-plugin-jsx-a11y
import jsxA11y from "eslint-plugin-jsx-a11y";
export default [
{
plugins: { "jsx-a11y": jsxA11y },
rules: {
"jsx-a11y/role-supports-aria-props": "error",
},
},
];jsx-a11y/role-supports-aria-props
jsx-a11y plugin · correctness
{
"plugins": [
"jsx-a11y"
],
"rules": {
"jsx-a11y/role-supports-aria-props": "error"
}
}a11y/useAriaPropsSupportedByRole
a11y · since 1.9.0
{
"linter": {
"rules": {
"a11y": {
"useAriaPropsSupportedByRole": "error"
}
}
}
}Enforce that elements with ARIA roles must have all required attributes for that role.
Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes.
Enforce ARIA state and property values are valid.
Enforce all elements that require alternative text have meaningful information to relay back to end user.
Enforce all anchors to contain accessible content.