no-negated-condition
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"no-negated-condition": "error",
},
},
];if (!a) {
doSomething();
} else {
doSomethingElse();
}
if (a != b) {
doSomething();
} else {
doSomethingElse();
}
if (a !== b) {
doSomething();
} else {
doSomethingElse();
}
!a ? c : bif (!a) {
doSomething();
}
if (!a) {
doSomething();
} else if (b) {
doSomething();
}
if (a != b) {
doSomething();
}
a ? b : cExamples from the ESLint documentation.
no-negated-condition
eslint
export default [
{
rules: {
"no-negated-condition": "error",
},
},
];no-negated-condition
eslint plugin · pedantic
{
"rules": {
"no-negated-condition": "error"
}
}style/noNegationElse
style · since 1.0.0
{
"linter": {
"rules": {
"style": {
"noNegationElse": "error"
}
}
}
}Enforce using named capture group in regular expression
Require or disallow logical assignment operator shorthand
Disallow specified warning terms in comments
Disallow specified modules when loaded by import