Skip to content
← Back to rules

jsx-a11y/no-aria-hidden-on-focusable Correctness

🛠️ An auto-fix is available for this rule.

作用

强制不要将 aria-hidden="true" 设置在可聚焦元素上。

为什么这很糟糕?

可聚焦元素上的 aria-hidden="true" 可能会让屏幕阅读器用户感到困惑,或导致意外行为。

示例

以下是此规则的错误代码示例:

jsx
<div aria-hidden="true" tabIndex="0" />

以下是此规则的正确代码示例:

jsx
<div aria-hidden="true" />

如何使用

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["jsx-a11y"],
  "rules": {
    "jsx-a11y/no-aria-hidden-on-focusable": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["jsx-a11y"],
  rules: {
    "jsx-a11y/no-aria-hidden-on-focusable": "error",
  },
});
bash
oxlint --deny jsx-a11y/no-aria-hidden-on-focusable --jsx-a11y-plugin

版本

此规则于 v0.0.22 中添加。

参考资料