useValidAriaRole (HTML)
Summary
Section titled “Summary”- Rule available since:
v2.4.0 - Diagnostic Category:
lint/a11y/useValidAriaRole - This rule is recommended, meaning it is enabled by default.
- This rule has an unsafe fix.
- The default severity of this rule is error.
- Sources:
- Inspired from
jsx-a11y/aria-role - Same as
@html-eslint/no-invalid-role
- Inspired from
How to configure
Section titled “How to configure”{ "linter": { "rules": { "a11y": { "useValidAriaRole": "error" } } }}Description
Section titled “Description”Elements with ARIA roles must use a valid, non-abstract ARIA role.
Remember that this rule only supports static values for the role attribute.
Dynamic role values are not checked.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<div role="datepicker"></div>code-block.html:1:1 lint/a11y/useValidAriaRole FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Enforce that elements with ARIA roles must use a valid, non-abstract ARIA role.
> 1 │ <div role="datepicker"></div>
│ ^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Check WAI-ARIA for valid roles or provide options accordingly.
ℹ Unsafe fix: Remove the invalid role attribute.
Check the list of all valid role attributes.
1 │ <div·role="datepicker"></div>
│ -----------------
<div role="range"></div>code-block.html:1:1 lint/a11y/useValidAriaRole FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Enforce that elements with ARIA roles must use a valid, non-abstract ARIA role.
> 1 │ <div role="range"></div>
│ ^^^^^^^^^^^^^^^^^^
2 │
ℹ Check WAI-ARIA for valid roles or provide options accordingly.
ℹ Unsafe fix: Remove the invalid role attribute.
Check the list of all valid role attributes.
1 │ <div·role="range"></div>
│ ------------
<div role=""></div>code-block.html:1:1 lint/a11y/useValidAriaRole FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Enforce that elements with ARIA roles must use a valid, non-abstract ARIA role.
> 1 │ <div role=""></div>
│ ^^^^^^^^^^^^^
2 │
ℹ Check WAI-ARIA for valid roles or provide options accordingly.
ℹ Unsafe fix: Remove the invalid role attribute.
Check the list of all valid role attributes.
1 │ <div·role=""></div>
│ -------
<div role="button"></div><div></div>Options
Section titled “Options”allowInvalidRoles
Section titled “allowInvalidRoles”It allows specifying a list of roles that might be invalid otherwise
{ "linter": { "rules": { "a11y": { "useValidAriaRole": { "level": "on", "options": { "allowInvalidRoles": [ "datepicker" ] } } } } }}<div role="datepicker"></div>Accessibility guidelines
Section titled “Accessibility guidelines”Resources
Section titled “Resources”Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.