sonarjs/no-small-switch
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-small-switch": "error",
},
},
];"if" statements should be preferred over "switch" when simpler
switch (variable) {
case 0:
doSomething();
break;
default:
doSomethingElse();
break;
}if (variable == 0) {
doSomething();
} else {
doSomethingElse();
}Examples from the ESLint documentation.
sonarjs/no-small-switch
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-small-switch": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Tests should not be skipped without providing a reason
HTML "<table>" should not be used for layout purposes
Static Assets should not serve session cookies
Methods should not contain selector parameters
Promise rejections should not be caught by "try" blocks