useValidAriaRole
¥Summary
-
规则生效日期:
v1.4.0¥Rule available since:
v1.4.0 -
诊断类别:
lint/a11y/useValidAriaRole¥Diagnostic Category:
lint/a11y/useValidAriaRole -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则包含 unsafe 修复程序。
¥This rule has an unsafe fix.
-
此规则的默认严重级别为 error。
¥The default severity of this rule is error.
-
来源:
¥Sources:
-
与
jsx-a11y/aria-role相同¥Same as
jsx-a11y/aria-role
-
¥How to configure
{ "linter": { "rules": { "a11y": { "useValidAriaRole": "error" } } }}¥Description
具有 ARIA 角色的元素必须使用有效的非抽象 ARIA 角色。
¥Elements with ARIA roles must use a valid, non-abstract ARIA role.
¥Examples
¥Invalid
<div role="datepicker"></div>code-block.jsx: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.jsx: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.jsx: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>
│ -------
<Foo role="foo"></Foo>code-block.jsx:1:1 lint/a11y/useValidAriaRole FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Enforce that elements with ARIA roles must use a valid, non-abstract ARIA role.
> 1 │ <Foo role=“foo”></Foo>
│ ^^^^^^^^^^^^^^^^
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 │ <Foo·role=“foo”></Foo>
│ ----------
¥Valid
<> <div role="button"></div> <div role={role}></div> <div></div></>¥Options
allowInvalidRoles
Section titled “allowInvalidRoles”它允许指定一个角色列表,否则这些角色可能无效。
¥It allows specifying a list of roles that might be invalid otherwise
{ "linter": { "rules": { "a11y": { "useValidAriaRole": { "options": { "allowInvalidRoles": [ "datepicker" ] } } } } }}<div role="datepicker"></div>ignoreNonDom
Section titled “ignoreNonDom”使用此选项忽略非 DOM 元素,例如组件。
¥Use this option to ignore non-DOM elements, such as components
{ "linter": { "rules": { "a11y": { "useValidAriaRole": { "options": { "ignoreNonDom": true } } } } }}<Datepicker role="foo"></Datepicker>可访问性指南
Section titled “可访问性指南”¥Accessibility guidelines
¥Resources
¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号