diff --git a/.husky/pre-commit b/.husky/pre-commit index 376d9947c6..727757cb7f 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,3 +1,4 @@ npx lint-staged node scripts/check-docs-sync.mjs +npm run check:any-budget:t11 npm run test:unit diff --git a/scripts/check-t11-any-budget.mjs b/scripts/check-t11-any-budget.mjs index 895e670a9c..b12ee1da41 100644 --- a/scripts/check-t11-any-budget.mjs +++ b/scripts/check-t11-any-budget.mjs @@ -110,7 +110,10 @@ for (const item of budget) { } const content = fs.readFileSync(absolutePath, "utf8"); - const matches = content.match(anyRegex); + // Remove block and line comments to avoid false positives with the word "any" in comments + let cleanContent = content.replace(/\/\*[\s\S]*?\*\//g, ""); + cleanContent = cleanContent.replace(/\/\/.*$/gm, ""); + const matches = cleanContent.match(anyRegex); const count = matches ? matches.length : 0; const status = count <= item.maxAny ? "OK" : "FAIL";