math/prefer-number-is-nan
enforce the use of Number.isNaN() instead of other checking ways
- ⚙️ This rule is included in
"plugin:math/recommended"
. - 🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule. - 💡 Some problems reported by this rule are manually fixable by editor suggestions.
📖 Rule Details
This rule aims to enforce the use of Number.isNaN()
instead of other checking ways.
/* eslint math/prefer-number-is-nan: 'error' */
/* ✓ GOOD */
x = Number.isNaN(n);
/* ✗ BAD */
x = typeof n == 'number' && isNaN(n);
x = n !== n;
x = Object.is(n, NaN);
🔧 Options
Nothing.
📚 Further reading
🚀 Version
This rule was introduced in eslint-plugin-math v0.4.0