Skip to content
← Back to rules

react/no-unescaped-entities Pedantic

🚧 An auto-fix is planned for this rule, but not implemented at this time.

作用

此规则可防止你可能原本想作为 JSX 转义字符使用的字符,意外地在 JSX 语句中作为文本节点注入。

为什么这很糟糕?

JSX 转义字符用于向 JSX 语句中注入字符,否则这些字符会被解释为代码。

示例

错误

jsx
<div> > </div>

正确

jsx
<div> &gt; </div>
jsx
<div> {">"} </div>

如何使用

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

json
{
  "plugins": ["react"],
  "rules": {
    "react/no-unescaped-entities": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["react"],
  rules: {
    "react/no-unescaped-entities": "error",
  },
});
bash
oxlint --deny react/no-unescaped-entities --react-plugin

版本

此规则在 v0.0.15 中添加。

参考资料