sonarjs/no-gratuitous-expressions
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-gratuitous-expressions": "error",
},
},
];if (a) {
if (a) { // Noncompliant
doSomething();
}
}if (a) {
if (b) {
doSomething();
}
}
// or
if (a) {
doSomething();
}Examples from the ESLint documentation.
sonarjs/no-gratuitous-expressions
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-gratuitous-expressions": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Special identifiers should not be bound or assigned
Forced browser interactions should not bypass actionability checks