package file→ .shtukbase/packages/shtukbase-ui-html/checks/tokens-only.ts
checks/tokens-only.ts
18 lines, 789 B.
- // SUI-R02. Component CSS takes colours, radii and shadows only from the token contract (no raw colour, no plain radius),
- // so swapping the style swaps the look of every component.
- import { readFileSync } from 'node:fs';
- import { join } from 'node:path';
- import { scan } from '../lib/components.ts';
- import { rawValues } from '../lib/tokens.ts';
- export const RULE = { id: 'sui-r02', title: 'Component CSS uses only contract tokens for colours, radii and shadows' };
- export function check(root = process.cwd()): string[] {
- return scan(root).flatMap((c) => (c.css ? rawValues(readFileSync(join(root, c.css), 'utf8')).map((p) => `${c.css}: ${p}`) : []));
- }
- if (import.meta.main) {
- const out = check();
- for (const l of out) console.log(l);
- process.exitCode = out.length ? 1 : 0;
- }