Skip to content

unicorn/no-negation-in-equality-check Pedantic

🚧 An auto-fix is still under development.

What it does

Disallow negated expressions on the left of (in)equality checks.

Why is this bad?

A negated expression on the left of an (in)equality check is likely a mistake from trying to negate the whole condition.

Example

Examples of incorrect code for this rule:

javascript
if (!foo === bar) {
}

if (!foo !== bar) {
}

Examples of correct code for this rule:

javascript
if (foo !== bar) {
}

if (!(foo === bar)) {
}

References

Released under the MIT License.