noGlobalIsFinite
Esta página aún no está disponible en tu idioma.
Summary
Section titled “Summary”- Rule available since:
v1.0.0 - Diagnostic Category:
lint/suspicious/noGlobalIsFinite - This rule is recommended, which means is enabled by default.
- This rule has an unsafe fix.
- The default severity of this rule is warning.
How to configure
Section titled “How to configure”{ "linter": { "rules": { "suspicious": { "noGlobalIsFinite": "error" } } }}Description
Section titled “Description”Use Number.isFinite instead of global isFinite.
Number.isFinite() and isFinite() do not have the same behavior.
When the argument to isFinite() is not a number, the value is first coerced to a number.
Number.isFinite() does not perform this coercion.
Therefore, it is a more reliable way to test whether a number is finite.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”isFinite(false); // truecode-block.js:1:1 lint/suspicious/noGlobalIsFinite FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
> 1 │ isFinite(false); // true
│ ^^^^^^^^
2 │
ℹ See the MDN documentation for more details.
ℹ Unsafe fix: Use Number.isFinite instead.
1 │ - isFinite(false);·//·true
1 │ + Number.isFinite(false);·//·true
2 2 │
Number.isFinite(false); // falseRelated links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.