react/syntax 限制
功能
报告 React Compiler 在分析组件或 hook 时遇到的无效 JavaScript,例如重新赋值 const 绑定
此规则由 React Compiler 提供支持,React Compiler 每个文件运行一次,并与其他 React Compiler 规则共享。移植自 react-hooks/syntax
为什么这很糟糕?
代码将在运行时抛出异常;编译器会跳过该函数,而不是对其进行优化
如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["react"],
"rules": {
"react/syntax": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["react"],
rules: {
"react/syntax": "error",
},
});bash
oxlint --deny react/syntax --react-plugin版本
此规则在 vnext 中添加
