Pattern: Use of non-primitive comparison
Issue: -
Only allow comparisons between primitives.
Rationale: When using comparison operators to compare objects, they compare references and not values. This is often done accidentally. With this rule, >
, >=
, <
, <=
operators are only allowed when comparing numbers
. ===
, !==
are allowed for number
string
and boolean
types and if one of the operands is null
or undefined
.