noRedundantRoles
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
诊断类别:
lint/a11y/noRedundantRoles¥Diagnostic Category:
lint/a11y/noRedundantRoles -
此规则为推荐规则,默认启用。
¥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/no-redundant-roles相同¥Same as
jsx-a11y/no-redundant-roles
-
¥How to configure
{ "linter": { "rules": { "a11y": { "noRedundantRoles": "error" } } }}¥Description
强制默认函数参数和可选函数参数位于最后。
¥Enforce explicit role property is not the same as implicit/default role property on an element.
¥Examples
¥Invalid
<article role='article'></article>code-block.jsx:1:15 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Using the role attribute ‘article’ on the ‘article’ element is redundant, because it is implied by its semantic.
> 1 │ <article role=‘article’></article>
│ ^^^^^^^^^
2 │
ℹ Unsafe fix: Remove the role attribute.
1 │ <article·role=‘article’></article>
│ --------------
<button role='button'></button>code-block.jsx:1:14 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Using the role attribute ‘button’ on the ‘button’ element is redundant, because it is implied by its semantic.
> 1 │ <button role=‘button’></button>
│ ^^^^^^^^
2 │
ℹ Unsafe fix: Remove the role attribute.
1 │ <button·role=‘button’></button>
│ -------------
<h1 role='heading' aria-level='1'>title</h1>code-block.jsx:1:10 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Using the role attribute ‘heading’ on the ‘h1’ element is redundant, because it is implied by its semantic.
> 1 │ <h1 role=‘heading’ aria-level=‘1’>title</h1>
│ ^^^^^^^^^
2 │
ℹ Unsafe fix: Remove the role attribute.
1 │ <h1·role=‘heading’·aria-level=‘1’>title</h1>
│ ---------------
¥Valid
<article role='presentation'></article><Button role='button'></Button><span></span>¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号