build(lint): fix false-positive any matching in comments and add t11 validator to husky pre-commit hook

This commit is contained in:
diegosouzapw
2026-04-03 03:42:02 -03:00
parent 9ccc7feb58
commit 81ebcc9a72
2 changed files with 5 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
npx lint-staged
node scripts/check-docs-sync.mjs
npm run check:any-budget:t11
npm run test:unit

View File

@@ -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";