sonarjs/no-fallthrough
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-fallthrough": "error",
},
},
];Switch cases should end with an unconditional "break" statement
switch (myVariable) {
case 1:
foo();
break;
case 2: // Both 'doSomething()' and 'doSomethingElse()' will be executed. Is it on purpose ?
doSomething();
default:
doSomethingElse();
break;
}switch (myVariable) {
case 1:
foo();
break;
case 2:
doSomething();
break;
default:
doSomethingElse();
break;
}Examples from the ESLint documentation.
sonarjs/no-fallthrough
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-fallthrough": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Disallow fallthrough of case statements
Function calls should not pass extra arguments
Exclusive tests should not be committed to version control
Floating point numbers should not be tested for equality
Equality operators should not be used in "for" loop termination conditions