react/syntax Restriction
What it does
Reports invalid JavaScript encountered by React Compiler while analyzing a component or hook, such as reassigning a const binding.
Powered by the React Compiler, which runs once per file and is shared with the other React Compiler rules. Port of react-hooks/syntax.
Why is this bad?
The code would throw at runtime; the compiler skips the function instead of optimizing it.
How to use
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-pluginVersion
This rule was added in vnext.
