Skip to content

Files

Latest commit

 

History

History
21 lines (15 loc) · 482 Bytes

no-negation-in-equality-check.md

File metadata and controls

21 lines (15 loc) · 482 Bytes

Pattern: Negation on left side of equality check

Issue: -

Description

Putting a negation operator on the left side of an equality check is likely a mistake from trying to negate the entire condition. Use the appropriate comparison operator or negate the entire expression instead.

Examples

Example of incorrect code:

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

Example of correct code:

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