jsx-a11y/html-has-lang 正确性
它的作用
确保每个 HTML 文档都具有 lang 属性。
为什么这不好?
如果网页未指定语言, 屏幕阅读器会假定为用户设置的默认语言。 对于使用多种语言并以多种语言访问网站的用户来说, 语言设置会成为一个问题。
示例
以下是此规则的错误代码示例:
jsx
<html />以下是此规则的正确代码示例:
jsx
<html lang="en" />如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["jsx-a11y"],
"rules": {
"jsx-a11y/html-has-lang": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["jsx-a11y"],
rules: {
"jsx-a11y/html-has-lang": "error",
},
});bash
oxlint --deny jsx-a11y/html-has-lang --jsx-a11y-plugin版本
此规则于 v0.0.18 中添加。
