Skip to content

unicorn/prefer-number-properties Restriction

🚧 An auto-fix is still under development.

What it does

Disallows use of parseInt(), parseFloat(), isNan(), isFinite(), Nan, Infinity and -Infinity as global variables.

Why is this bad?

ECMAScript 2015 moved globals onto the Number constructor for consistency and to slightly improve them. This rule enforces their usage to limit the usage of globals:

Examples

Examples of incorrect code for this rule:

javascript
const foo = parseInt("10", 2);
const bar = parseFloat("10.5");

Examples of correct code for this rule:

javascript
const foo = Number.parseInt("10", 2);
const bar = Number.parseFloat("10.5");

References

Released under the MIT License.