jsx-a11y/tabindex-no-positive 正确性
它的作用
强制在 JSX 中不要使用 tabIndex 属性的正值。
为什么这不好?
使用大于 0 的 tabIndex 值会让键盘用户和辅助技术用户更难进行导航和交互, 从而破坏内容的逻辑顺序。
示例
此规则的错误代码示例:
jsx
<span tabIndex="1">foo</span>此规则的正确代码示例:
jsx
<span tabIndex="0">foo</span>
<span tabIndex="-1">bar</span>如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["jsx-a11y"],
"rules": {
"jsx-a11y/tabindex-no-positive": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["jsx-a11y"],
rules: {
"jsx-a11y/tabindex-no-positive": "error",
},
});bash
oxlint --deny jsx-a11y/tabindex-no-positive --jsx-a11y-plugin版本
此规则是在 v0.0.21 中添加的。
