no-negated-condition
Disallow negated conditions
❄️ Frozen
This rule is currently frozen and is not accepting changes.
Negated conditions are more difficult to understand. Code can be made more readable by inverting the condition instead.
Rule Details
This rule disallows negated conditions in either of the following:
if
statements which have anelse
branch- ternary expressions
Examples of incorrect code for this rule:
Open in Playground
/*eslint no-negated-condition: "error"*/
Examples of correct code for this rule:
Open in Playground
/*eslint no-negated-condition: "error"*/
if (!a) {
doSomething();
}
if (!a) {
doSomething();
} else if (b) {
doSomething();
}
if (a != b) {
doSomething();
}
a ? b : c
Version
This rule was introduced in ESLint v1.6.0.