Skip to content

numberStaticMethods

Reports using legacy global functions instead of Number static methods.

✅ This rule is included in the ts logicalStrict presets.

This rule enforces using Number static methods and properties instead of global equivalents.

The global methods isFinite() and isNaN() coerce their arguments to numbers before checking, which can lead to unexpected behavior. Number.isNaN() and Number.isFinite() do not perform coercion and are more predictable.

isNaN(value);
isFinite(value);
const value = NaN;

This rule is not configurable.

If you are targeting older JavaScript environments that do not support Number.isNaN() or Number.isFinite(), you may need to continue using the global versions. Additionally, if you intentionally rely on the type coercion behavior of the global isNaN() and isFinite() functions, disabling this rule may be appropriate.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.