useAriaPropsSupportedByRole
¥Summary
-
规则生效日期:
v1.9.0¥Rule available since:
v1.9.0 -
诊断类别:
lint/a11y/useAriaPropsSupportedByRole¥Diagnostic Category:
lint/a11y/useAriaPropsSupportedByRole -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 error。
¥The default severity of this rule is error.
-
来源:
¥Sources:
¥How to configure
{ "linter": { "rules": { "a11y": { "useAriaPropsSupportedByRole": "error" } } }}¥Description
强制 ARIA 属性对于元素支持的角色有效。
¥Enforce that ARIA properties are valid for the roles that are supported by the element.
无效的 ARIA 属性会使辅助技术的用户难以理解元素的用途。
¥Invalid ARIA properties can make it difficult for users of assistive technologies to understand the purpose of the element.
¥Examples
¥Invalid
<a href="#" aria-checked />code-block.jsx:1:1 lint/a11y/useAriaPropsSupportedByRole ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ The ARIA attribute ‘aria-checked’ is not supported by this element.
> 1 │ <a href=”#” aria-checked />
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Ensure that ARIA attributes are valid for the role of the element.
<img alt="foobar" aria-checked />code-block.jsx:1:1 lint/a11y/useAriaPropsSupportedByRole ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ The ARIA attribute ‘aria-checked’ is not supported by this element.
> 1 │ <img alt=“foobar” aria-checked />
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Ensure that ARIA attributes are valid for the role of the element.
¥Valid
<> <a href="#" aria-expanded /> <img alt="foobar" aria-hidden /> <div role="heading" aria-level="1" /></>¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号