`scripts` sat in oxlint's ignorePatterns since c94c30e, grouped with
dist, coverage and .pnpm-store. Those are build artifacts; scripts holds
the quality gates themselves, which went unlinted as a result.
Removing it raises coverage from 265 to 273 files and surfaced four
findings:
prefer-regexp-exec in three files — swapped String#match for RegExp#exec.
All three patterns are non-global, where the two methods return the same
result, so behaviour is unchanged.
require-array-sort-compare in generate-bestiary-index.mjs — the rule
skips string arrays, and fired only because `new Set()` infers Set<any>.
Typed it Set<string>, which it already is, rather than adding a
comparator the bare sort does not need.
Also anchors the lint-gate probe's no-console canary to CLI scripts that
exist to write to the console, rather than to app error paths that could
reasonably be removed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
42 lines
988 B
JavaScript
42 lines
988 B
JavaScript
/**
|
|
* Zero-tolerance check for biome-ignore comments.
|
|
*
|
|
* Any `biome-ignore` in tracked .ts/.tsx files fails the build.
|
|
* Fix the underlying issue instead of suppressing the rule.
|
|
*/
|
|
|
|
import { execSync } from "node:child_process";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const IGNORE_PATTERN = /biome-ignore\s+([\w/]+)/;
|
|
|
|
function findFiles() {
|
|
return execSync("git ls-files -- '*.ts' '*.tsx'", { encoding: "utf-8" })
|
|
.trim()
|
|
.split("\n")
|
|
.filter(Boolean);
|
|
}
|
|
|
|
let count = 0;
|
|
|
|
for (const file of findFiles()) {
|
|
const lines = readFileSync(file, "utf-8").split("\n");
|
|
|
|
for (let i = 0; i < lines.length; i++) {
|
|
const match = IGNORE_PATTERN.exec(lines[i]);
|
|
if (!match) continue;
|
|
|
|
count++;
|
|
console.error(`FORBIDDEN: ${file}:${i + 1} — biome-ignore ${match[1]}`);
|
|
}
|
|
}
|
|
|
|
if (count > 0) {
|
|
console.error(
|
|
`\n${count} biome-ignore comment(s) found. Fix the issue or restructure the code.`,
|
|
);
|
|
process.exit(1);
|
|
} else {
|
|
console.log("biome-ignore: 0 — all clear.");
|
|
}
|