From a010cc3e416e6c642c1a8cc383263c2cc81013a3 Mon Sep 17 00:00:00 2001 From: mateaix <7333791@qq.com> Date: Tue, 15 Sep 2026 10:41:32 +0800 Subject: [PATCH] fix(ui): harden snowflake precision checker --- mateclaw-ui/scripts/check-snowflake-precision.mjs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mateclaw-ui/scripts/check-snowflake-precision.mjs b/mateclaw-ui/scripts/check-snowflake-precision.mjs index 5b14a09e..9985633a 100644 --- a/mateclaw-ui/scripts/check-snowflake-precision.mjs +++ b/mateclaw-ui/scripts/check-snowflake-precision.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env node -import { readdirSync, readFileSync, statSync } from 'node:fs' +import { lstatSync, readdirSync, readFileSync } from 'node:fs' import { dirname, join, relative } from 'node:path' import { fileURLToPath } from 'node:url' @@ -9,18 +9,18 @@ const sourceRoot = join(uiRoot, 'src') const allowlist = 'snowflake-precision-ok' const checks = [ - ['v-model.number bound to an *Id field', /v-model\.number=".*[Ii]d"?/], + ['v-model.number bound to an *Id field', /v-model\.number\s*=\s*['"][^'"]*[Ii]d['"]/], ['Number()/parseInt() on an *Id value', /(Number|parseInt)\(\s*\w*[Ii]d\b/], ['Number()/parseInt() on an *Id member-access / lookup', /(Number|parseInt)\([^)]*(?:[a-z]Id\b|[Ii]d['"]|\.[Ii]d\b)/], - ['input[type="number"] bound to an *Id field', /]*\btype="number")(?=[^>]*\bv-model(?:\.[^=\s]+)?="[^"]*[Ii]d")/], - ["typeof === 'number' silently drops string IDs", /typeof\s+\S*[Ii]d\b\s*===\s*'number'/], + ['input[type="number"] bound to an *Id field', /]*\btype\s*=\s*['"]number['"])(?=[^>]*\bv-model(?:\.[^=\s]+)?\s*=\s*['"][^'"]*[Ii]d['"])/], + ["typeof === 'number' silently drops string IDs", /typeof\s+\S*[Ii]d\b\s*===\s*['"]number['"]/], ] function filesUnder(directory) { const files = [] for (const entry of readdirSync(directory).sort()) { const path = join(directory, entry) - const stat = statSync(path) + const stat = lstatSync(path) if (stat.isDirectory()) files.push(...filesUnder(path)) else if (stat.isFile()) files.push(path) }