Skip to content
← Back to rules

react/no-namespace 可疑

它的作用

强制禁止在 React 元素中使用命名空间。

为什么这是个问题?

React 元素中的命名空间(如 svg:circle)不受 React 支持。

示例

此规则的错误代码示例:

jsx
<ns:TestComponent />
<Ns:TestComponent />

此规则的正确代码示例:

jsx
<TestComponent />
<testComponent />

如何使用

要通过配置文件或 CLI 启用此规则,可以使用:

json
{
  "plugins": ["react"],
  "rules": {
    "react/no-namespace": "error"
  }
}
bash
oxlint --deny react/no-namespace --react-plugin

参考资料