jsx-a11y/role-has-required-aria-props 正确性
它做了什么
强制要求具有 ARIA 角色的元素必须包含该角色所需的所有属性。
为什么这是个问题?
某些 ARIA 角色需要特定的属性来表达辅助技术所需的语义信息。
示例
此规则的错误代码示例:
jsx
<div role="checkbox" />此规则的正确代码示例:
jsx
<div role="checkbox" aria-checked="false" />如何使用
通过配置文件或 CLI 启用此规则,可以使用:
json
{
"plugins": ["jsx-a11y"],
"rules": {
"jsx-a11y/role-has-required-aria-props": "error"
}
}bash
oxlint --deny jsx-a11y/role-has-required-aria-props --jsx-a11y-plugin