noAccessKey
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
¥Diagnostic Category:
lint/a11y/noAccessKey -
此规则为推荐规则,默认启用。
¥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:
-
¥Same as
jsx-a11y/no-access-key
-
¥How to configure
{ "linter": { "rules": { "a11y": { "noAccessKey": "error" } } }}¥Description
强制不在任何 HTML 元素上使用 accessKey 属性。
¥Enforce that the accessKey attribute is not used on any HTML element.
accessKey 为当前元素分配键盘快捷键。但是,accessKey 值可能与屏幕阅读器和仅使用键盘的用户使用的键盘命令相冲突,从而导致应用之间的键盘操作不一致。为了避免可访问性复杂化,此规则建议用户删除元素上的 accessKey 属性。
¥The accessKey assigns a keyboard shortcut to the current element. However, the accessKey value
can conflict with keyboard commands used by screen readers and keyboard-only users, which leads to
inconsistent keyboard actions across applications. To avoid accessibility complications,
this rule suggests users remove the accessKey attribute on elements.
¥Examples
¥Invalid
<input type="submit" accessKey="s" value="Submit" />code-block.jsx:1:22 lint/a11y/noAccessKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid the accessKey attribute to reduce inconsistencies between keyboard shortcuts and screen reader keyboard comments.
> 1 │ <input type=“submit” accessKey=“s” value=“Submit” />
│ ^^^^^^^^^^^^^
2 │
ℹ Assigning keyboard shortcuts using the accessKey attribute leads to inconsistent keyboard actions across applications.
ℹ Unsafe fix: Remove the accessKey attribute.
1 │ <input·type=“submit”·accessKey=“s”·value=“Submit”·/>
│ --------------
<a href="https://webaim.org/" accessKey="w">WebAIM.org</a>code-block.jsx:1:31 lint/a11y/noAccessKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid the accessKey attribute to reduce inconsistencies between keyboard shortcuts and screen reader keyboard comments.
> 1 │ <a href=“https://webaim.org/” accessKey=“w”>WebAIM.org</a>
│ ^^^^^^^^^^^^^
2 │
ℹ Assigning keyboard shortcuts using the accessKey attribute leads to inconsistent keyboard actions across applications.
ℹ Unsafe fix: Remove the accessKey attribute.
1 │ <a·href=“https://webaim.org/“·accessKey=“w”>WebAIM.org</a>
│ -------------
<button accessKey="n">Next</button>code-block.jsx:1:9 lint/a11y/noAccessKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid the accessKey attribute to reduce inconsistencies between keyboard shortcuts and screen reader keyboard comments.
> 1 │ <button accessKey=“n”>Next</button>
│ ^^^^^^^^^^^^^
2 │
ℹ Assigning keyboard shortcuts using the accessKey attribute leads to inconsistent keyboard actions across applications.
ℹ Unsafe fix: Remove the accessKey attribute.
1 │ <button·accessKey=“n”>Next</button>
│ -------------
¥Resources
¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号