sonarjs/no-all-duplicated-branches
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-all-duplicated-branches": "error",
},
},
];All branches in a conditional structure should not have exactly the same implementation
if (b == 0) { // Noncompliant
doOneMoreThing();
}
else {
doOneMoreThing();
}
let a = (b == 0) ? getValue() : getValue(); // Noncompliant
switch (i) { // Noncompliant
case 1:
doSomething();
break;
case 2:
doSomething();
break;
case 3:
doSomething();
break;
default:
doSomething();
}The documentation shows no correct example for this rule.
Examples from the ESLint documentation.
sonarjs/no-all-duplicated-branches
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-all-duplicated-branches": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
"new" should only be used with functions and classes
"Array.prototype.sort()" and "Array.prototype.toSorted()" should use a compare function
"for" loop increment clauses should modify the loops' counters
Angular built-in sanitization should not be disabled
Lodash and Underscore.js memoize calls on functions with multiple parameters should use an explicit cache key function