From e546e20cd6883f1a0e4c235bc25545c61add60d7 Mon Sep 17 00:00:00 2001 From: Stephen Cresswell <229672+cressie176@users.noreply.github.com> Date: Thu, 4 Sep 2025 20:30:48 +0100 Subject: [PATCH] Replace global isFinite with Number.isFinite for safer numeric validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace all instances of the global isFinite function with Number.isFinite to avoid unsafe type coercion and improve numeric validation reliability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .claude/commands/lint-enforce.md | 2 ++ CHANGELOG.md | 1 + biome.json | 2 +- test/data.js | 4 ++-- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.claude/commands/lint-enforce.md b/.claude/commands/lint-enforce.md index b5e0b23f..fb7826aa 100644 --- a/.claude/commands/lint-enforce.md +++ b/.claude/commands/lint-enforce.md @@ -10,3 +10,5 @@ Please follow the following process when I ask you to enfore a new lint rule usi 8. Add the changes 9. Commit the changes 10. Push the changes + +You do not need to ask before updating biome.json, running tests, using --fix in safe mode, fetching coment from biomejs.dev, or updating the changelog diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ddf3f65..652fb00f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Enforce strict equality checks (=== and !==) instead of loose equality (== and !=) - Replace global isNaN with Number.isNaN for safer type checking - Ensure no variable redeclarations exist to prevent shadowing issues +- Replace global isFinite with Number.isFinite for safer numeric validation ## v0.10.9 - Add support for IPv6 urls diff --git a/biome.json b/biome.json index 3184e823..e5ff7d3a 100644 --- a/biome.json +++ b/biome.json @@ -23,7 +23,7 @@ "noRedundantUseStrict": "error", "noAsyncPromiseExecutor": "off", "noGlobalIsNan": "error", - "noGlobalIsFinite": "off", + "noGlobalIsFinite": "error", "noPrototypeBuiltins": "off", "noVar": "error" } diff --git a/test/data.js b/test/data.js index c80dc4ea..cb55c4ec 100644 --- a/test/data.js +++ b/test/data.js @@ -268,13 +268,13 @@ const domainProps = [ [ Double, function (f) { - return !Number.isNaN(f) && isFinite(f); + return !Number.isNaN(f) && Number.isFinite(f); }, ], [ Float, function (f) { - return !Number.isNaN(f) && isFinite(f) && Math.log(Math.abs(f)) * Math.LOG10E < 309; + return !Number.isNaN(f) && Number.isFinite(f) && Math.log(Math.abs(f)) * Math.LOG10E < 309; }, ], [