sonarjs/elseif-without-else
eslint-plugin-sonarjs
No autofix
eslint.config.js
export default [
{
rules: {
"sonarjs/elseif-without-else": "error",
},
},
];"if ... else if" constructs should end with "else" clauses
if (x == 0) {
doSomething();
} else if (x == 1) {
doSomethingElse();
}if (x == 0) {
doSomething();
} else if (x == 1) {
doSomethingElse();
} else {
throw "Unexpected value for x";
}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/elseif-without-else
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/elseif-without-else": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Destructuring syntax should be used for assignments
Variables and functions should not be declared in the global scope
Cyclomatic Complexity of functions should not be too high
Default export names and file names should match