This rule detects comparison patterns that are logically unnecessary, impossible, or can be simplified.
Such patterns often indicate logic errors, copy-paste mistakes, or overly complex code that should be refactored.
The rule covers several categories of problematic comparisons:
Self-comparisons: Comparing a value to itself (e.g., x === x)
Impossible ranges: Range checks that can never be satisfied (e.g., x <= 400 && x > 500)
Redundant double comparisons: OR patterns that can be simplified (e.g., x === y || x < y can become x <= y)
Ineffective checks: Redundant bounds in AND chains (e.g., x < 200 && x <= 299 where the second check is always true when the first is)
An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.
Number.
NumberConstructor.isNaN(number: unknown): boolean
Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
to a number. Only values of the type number, that are also NaN, result in true.
If your codebase relies on dynamic getters or other side effects that could make seemingly-identical expressions return different values, you might want to disable this rule for those specific cases.