From 31d1c36a48398462ac75a3d44304e63ee1e1ddf0 Mon Sep 17 00:00:00 2001 From: David Larlet Date: Wed, 26 Jun 2024 13:05:24 -0400 Subject: [PATCH] chore: explicit comment for global isNaN usage --- umap/static/umap/js/modules/rules.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/umap/static/umap/js/modules/rules.js b/umap/static/umap/js/modules/rules.js index dbeb88e0..518339c1 100644 --- a/umap/static/umap/js/modules/rules.js +++ b/umap/static/umap/js/modules/rules.js @@ -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