Disable the no-negated-condition
rule
#223
leroykorterink
started this conversation in
General
Replies: 1 comment 1 reply
-
Negated conditions are more difficult to understand. Code can be made more readable by inverting the condition instead. Disallowing negated conditions will also prevent unnecessary logical operations. Incorrect code: if (!a) {
c();
} else {
b();
}
if (a !== b) {
c();
} else {
b();
}
!a ? c : b Correct code: if (a) {
b();
} else {
c();
}
if (a === b) {
b();
} else {
c();
}
a ? b : c Please see the documentation of the rule. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There is a proposal to disable the
no-negated-condition
rule.Beta Was this translation helpful? Give feedback.
All reactions