sonarjs/no-identical-conditions
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-identical-conditions": "error",
},
},
];"if/else if" chains and "switch" cases should not have the same condition
if (param == 1)
openWindow();
else if (param == 2)
closeWindow();
else if (param == 1) // Noncompliant
moveWindowToTheBackground();if (param == 1)
openWindow();
else if (param == 2)
closeWindow();
else if (param == 3)
moveWindowToTheBackground();Examples from the ESLint documentation.
sonarjs/no-identical-conditions
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-identical-conditions": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
React's useState hook should not be used directly in the render function or body of a component
Identical expressions should not be used on both sides of a binary operator
Functions should not have identical implementations