debt.ts
This file
Path
examples/burrow/scripts/debt.ts
50 lines · 1.5 KiB · TypeScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 1–50why, one step back1/**2 * burrow's escape count. Every directive that switches a check off (a lint3 * disable, a TypeScript suppression) must say why after ` -- `, and their4 * number may only fall: raising `debt.baseline.json` is a decision for a5 * maintainer, made in review.6 */7import { readdirSync, readFileSync } from "node:fs";8import path from "node:path";910interface Baseline {11 readonly escapes: number;12}1314const ROOTS = ["packages", "scripts", "tools"];1516// A directive opens a comment line, or ends a line of code (the `-line`17// forms).18const ESCAPE =19 /(?:\/\/|\/\*)\s*(?:(?:oxlint|eslint)-disable|@ts-(?:expect-error|ignore|nocheck)|biome-ignore)/u;2021const escapes = ROOTS.flatMap((root) =>22 readdirSync(root, { encoding: "utf-8", recursive: true })23 .filter((file) => /\.tsx?$/u.test(file) && !file.includes("node_modules"))24 .flatMap((file) =>25 readFileSync(path.join(root, file), "utf-8")26 .split("\n")27 .flatMap((text, index) =>28 ESCAPE.test(text)29 ? [{ at: `${path.join(root, file)}:${index + 1}`, text }]30 : []31 )32 )33);3435const baseline: Baseline = JSON.parse(36 readFileSync("debt.baseline.json", "utf-8")37);38const unreasoned = escapes.filter(({ text }) => !/ -- \S/u.test(text));3940for (const { at, text } of unreasoned) {41 console.error(42 `${at}: an escape without a reason after " -- ": ${text.trim()}`43 );44}4546console.log(`debt: ${escapes.length} escapes (baseline ${baseline.escapes})`);4748if (unreasoned.length > 0 || escapes.length > baseline.escapes) {49 process.exitCode = 1;50}