react/rule-suppression Restriction
What it does
Reports ESLint/Oxlint suppressions of React rules (for example eslint-disable-next-line react-hooks/exhaustive-deps) inside a component or hook. The React Compiler skips functions containing such suppressions, since the suppressed violation may make compilation unsafe.
Powered by the React Compiler, which runs once per file and is shared with the other React Compiler rules. Port of react-hooks/rule-suppression.
Why is this bad?
Suppressing a React rule hides a violation the compiler must assume is real; the whole function loses optimization until the suppression is removed and the underlying error fixed.
Examples
Examples of incorrect code for this rule:
function Component({ value }) {
// eslint-disable-next-line react-hooks/exhaustive-deps
const doubled = value * 2;
return <div>{doubled}</div>;
}Examples of correct code for this rule:
function Component({ value }) {
const doubled = value * 2;
return <div>{doubled}</div>;
}How to use
To enable this rule using the config file or in the CLI, you can use:
{
"plugins": ["react"],
"rules": {
"react/rule-suppression": "error"
}
}import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["react"],
rules: {
"react/rule-suppression": "error",
},
});oxlint --deny react/rule-suppression --react-pluginVersion
This rule was added in vnext.
