jsx-a11y/prefer-tag-over-role Correctness
它的作用
强制使用语义化的 HTML 标签,而不是 role 属性。
为什么这不好?
使用语义化的 HTML 标签可以提高可访问性和代码可读性。
示例
以下是此规则的 错误 代码示例:
jsx
<div role="button" />以下是此规则的 正确 代码示例:
jsx
<button />如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["jsx-a11y"],
"rules": {
"jsx-a11y/prefer-tag-over-role": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["jsx-a11y"],
rules: {
"jsx-a11y/prefer-tag-over-role": "error",
},
});bash
oxlint --deny jsx-a11y/prefer-tag-over-role --jsx-a11y-plugin版本
此规则是在 v0.1.1 中添加的。
