noPositiveTabindex
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
诊断类别:
lint/a11y/noPositiveTabindex¥Diagnostic Category:
lint/a11y/noPositiveTabindex -
此规则为推荐规则,默认启用。
¥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/tabindex-no-positive相同¥Same as
jsx-a11y/tabindex-no-positive
-
¥How to configure
{ "linter": { "rules": { "a11y": { "noPositiveTabindex": "error" } } }}¥Description
防止在 tabIndex 属性上使用正整数
¥Prevent the usage of positive integers on tabIndex property
避免使用正的 tabIndex 属性值来同步页面流和键盘制表符顺序。
¥Avoid positive tabIndex property values to synchronize the flow of the page with keyboard tab order.
可访问性指南
Section titled “可访问性指南”¥Accessibility guidelines
¥Examples
¥Invalid
<div tabIndex={1}>foo</div>code-block.jsx:1:15 lint/a11y/noPositiveTabindex FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid positive values for the tabIndex prop.
> 1 │ <div tabIndex={1}>foo</div>
│ ^^^
2 │
ℹ Elements with a positive tabIndex override natural page content order. This causes elements without a positive tab index to come last when navigating using a keyboard.
ℹ Use only 0 and -1 as tabIndex values. Avoid using tabIndex values greater than 0 and CSS properties that can change the order of focusable HTML elements.
ℹ Unsafe fix: Replace the tableIndex prop value with 0.
1 │ - <div·tabIndex={1}>foo</div>
1 │ + <div·tabIndex=“0”>foo</div>
2 2 │
<div tabIndex={"1"} />code-block.jsx:1:15 lint/a11y/noPositiveTabindex FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid positive values for the tabIndex prop.
> 1 │ <div tabIndex={“1”} />
│ ^^^^^
2 │
ℹ Elements with a positive tabIndex override natural page content order. This causes elements without a positive tab index to come last when navigating using a keyboard.
ℹ Use only 0 and -1 as tabIndex values. Avoid using tabIndex values greater than 0 and CSS properties that can change the order of focusable HTML elements.
ℹ Unsafe fix: Replace the tableIndex prop value with 0.
1 │ - <div·tabIndex={“1”}·/>
1 │ + <div·tabIndex=“0”·/>
2 2 │
React.createElement("div", { tabIndex: 1 })code-block.js:1:40 lint/a11y/noPositiveTabindex FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid positive values for the tabIndex prop.
> 1 │ React.createElement(“div”, { tabIndex: 1 })
│ ^
2 │
ℹ Elements with a positive tabIndex override natural page content order. This causes elements without a positive tab index to come last when navigating using a keyboard.
ℹ Use only 0 and -1 as tabIndex values. Avoid using tabIndex values greater than 0 and CSS properties that can change the order of focusable HTML elements.
ℹ Unsafe fix: Replace the tableIndex prop value with 0.
1 │ - React.createElement(“div”,·{·tabIndex:·1·})
1 │ + React.createElement(“div”,·{·tabIndex:·“0”·})
2 2 │
¥Valid
<div tabIndex="0" />React.createElement("div", { tabIndex: -1 })¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号