use-isnan
Configuration
rslint.config.ts
Rule Details
Requires calls to isNaN() when checking for NaN. Because NaN is unique in JavaScript in that it is not equal to anything, including itself, the results of comparisons to NaN are confusing: NaN === NaN is false. Therefore, use Number.isNaN() or the global isNaN() function to test whether a value is NaN.
Options
enforceForSwitchCase(default:true): Disallowsswitch(NaN)andcase NaN:in switch statements.enforceForIndexOf(default:false): Disallows callingindexOfandlastIndexOfwithNaNas an argument.
Examples of incorrect code for this rule:
Examples of correct code for this rule: