sonarjs/no-collapsible-if
eslint-plugin-sonarjs
No autofix
eslint.config.js
export default [
{
rules: {
"sonarjs/no-collapsible-if": "error",
},
},
];if (x != undefined) {
if (y === 2) {
// ...
}
}if (x != undefined && y === 2) {
// ...
}Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
sonarjs/no-collapsible-if
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-collapsible-if": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply