import { readdirSync, readFileSync, statSync } from "node:fs"; import { join, relative } from "node:path"; /** * Guardrails for the UI rules in docs/ui and the ui-conventions skill. Each * one was broken somewhere before the 2026-09 UI pass fixed it; this keeps it * from drifting back. */ const SRC = join(__dirname, ".."); function sourceFiles(dir: string): string[] { return readdirSync(dir).flatMap((name) => { const path = join(dir, name); if (statSync(path).isDirectory()) return sourceFiles(path); return /\.tsx?$/.test(name) && !/\.test\.tsx?$/.test(name) ? [path] : []; }); } const files = sourceFiles(SRC).map((path) => ({ path: relative(SRC, path), text: readFileSync(path, "utf8") })); const offenders = (pattern: RegExp, allow: (path: string) => boolean = () => false) => files.filter((file) => !allow(file.path) && pattern.test(file.text)).map((file) => file.path); it("domain code renders tables through DataTable, not raw