Reports comparisons with NaN, which should use Number.isNaN() instead.
✅ This rule is included in the ts logical and logicalStrict presets.
In JavaScript, NaN (Not-a-Number) has a unique property: it is not equal to anything, including itself.
This means that comparisons like x === NaN or x !== NaN always produce unexpected results - the equality check always returns false, and the inequality check always returns true.
To reliably check if a value is NaN, use Number.isNaN() instead.
AE53 (valuAE=<==sp ansty="le--0:#D6DEEB;--1:#403F">5==sp><3 sp ansty="le--0:#82AAFF;--1:#3B61">B0N3 sp>53)< {d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53conso sp>AB0l5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dvalue is N1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp> {d><);d ivclassNa="meec-li">5);d><3}d ivclassNa="meco"><}d>}d>3}d>AEconsB0isNotANumbAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53resu= sp>AE !=<= sp ansty="le--0:#82AAFF;--1:#3B61">B0N= sp>5<3;d ivclassNa="meco">3;d>AE53 (valuAsp ansty="le--0:#D6DEEB;--1:#403F">5sp><3 sp ansty="le--0:#82AAFF;--1:#3B61">B0N3 sp>53)< {d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53conso sp>AB0l5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dcomparison resu1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp> {d><);d ivclassNa="meec-li">5);d><3}d ivclassNa="meco"> NaN) { console.log("comparison result");"><}d>}d>3}d> 443F53 (Nu4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0i4AE.>3F53(value<)) {divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53con53 >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B4AE.><0log spans="tyle--0:#D6DEEB;--1:#40">30log>1<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dvalue is111">< NaN spans="tyle--0:#D9F5DD;--1:#11">1 NaN><111" spans="tyle--0:#D6DEEB;--1:#40">3F111">)) ><53) ;divclass="Nameec-">353)><);>);><}di vdivclass="Nameexpressive-">44AEco61B0isNotANu44AE< = ! spans="tyle--0:#D6DEEB;--1:#40">3F53Nu = !>4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0i4AE.>3F53(resu}di>
This rule is not configurable.
There is no legitimate reason to compare directly with NaN.
This rule should always be enabled to prevent subtle bugs.