noDoubleEquals (since v1.0.0)
Diagnostic Category: lint/suspicious/noDoubleEquals
Sources:
- Same as:
eqeqeq
Require the use of === and !==
It is generally bad practice to use == for comparison instead of
===. Double operators will trigger implicit type coercion
and are thus not prefered. Using strict equality operators is almost
always best practice.
For ergonomic reasons, this rule makes an exception for == null for
comparing to both null and undefined.
Examples
Section titled ExamplesInvalid
Section titled Invalidfoo == barcode-block.js:1:5 lint/suspicious/noDoubleEquals FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Use === instead of ==
> 1 │ foo == bar
│ ^^
2 │
ℹ == is only allowed when comparing against null
> 1 │ foo == bar
│ ^^
2 │
ℹ Using == may be unsafe if you are relying on type coercion
ℹ Unsafe fix: Use ===
1 │ foo·===·bar
│ +
Valid
Section titled Validfoo == nullfoo != nullnull == foonull != foo