Skip to content
← Back to rules

jsx-a11y/aria-proptypes Correctness

作用

强制元素不要使用无效的 ARIA 状态和值。

为什么这很糟糕?

使用无效的 ARIA 状态和值可能会误导屏幕阅读器和其他辅助技术。 这可能导致网站的无障碍功能失效,使残障用户难以有效使用该网站。

示例

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

jsx
<div aria-level="yes" />
<div aria-relevant="additions removalss" />

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

jsx
<div aria-label="foo" />
<div aria-labelledby="foo bar" />
<div aria-checked={false} />
<div aria-invalid="grammar" />

如何使用

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

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

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

版本

此规则于 v1.36.0 中添加。

参考资料