Skip to content

Latest commit

 

History

History
 
 

plugin-convert-is-nan-to-number-is-nan

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@putout/plugin-convert-is-nan-to-number-is-nan NPM version

🐊Putout plugin adds ability to convert isNaN to more robust Number.isNaN.

Not bundled because Number.isNaN do not try to convert to Number, and checks that isNaN was a number instead.

Number.isNaN('hello');
// returns
false;

isNaN('hello');
// returns
true;

Install

npm i @putout/plugin-convert-is-nan-to-number-is-nan -D

Rule

{
    "rules": {
        "convert-is-nan-to-number-is-nan": "on"
    }
}

❌ Example of incorrect code

if (isNaN(x)) {
    return 'NaN';
}

✅ Example of correct code

if (Number.isNaN(x)) {
    return 'Number NaN';
}

License

MIT