Skip to content

Latest commit

 

History

History

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

@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