noGlobalIsFinite
Ce contenu n’est pas encore disponible dans votre langue.
Diagnostic Category: lint/suspicious/noGlobalIsFinite
Since: v1.0.0
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 ExamplesInvalid
Section titled Invalidcode-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 │