chore: explicit comment for global isNaN usage

This commit is contained in:
David Larlet 2024-06-26 13:05:24 -04:00
parent b5cb092cd4
commit 31d1c36a48
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD

View file

@ -74,6 +74,10 @@ class Rule {
if (vars.length !== 2) return
this.key = vars[0]
this.expected = vars[1]
// Special cases where we want to be lousy when checking isNaN without
// coercing to a Number first because we handle multiple types.
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/
// Reference/Global_Objects/Number/isNaN
// biome-ignore lint/suspicious/noGlobalIsNan: expected might not be a number.
if (!isNaN(this.expected)) this.cast = Number.parseFloat
else if (['true', 'false'].includes(this.expected)) this.cast = (v) => !!v