файл пакета→ .shtukbase/packages/design-components/checks/tokens-only.ts
checks/tokens-only.ts
19 строк, 899 Б.
Файл как есть в пакете: код и комментарии в нём не переводятся.
- // DSC-R04. Component CSS takes colours from the token contract: no hex, rgb, hsl, oklch (or other colour function)
- // literal in a declaration, except in the fallback of a var(). So a style can be swapped without touching components.
- import { readFileSync } from 'node:fs';
- import { join } from 'node:path';
- import { rawColours } from '../lib/css.ts';
- import { collect } from '../lib/project.ts';
- import { report } from '../lib/report.ts';
- export const RULE = { id: 'dsc-r04', title: 'Component CSS has tokens only' };
- export function check(root = process.cwd()): string[] {
- const out: string[] = [];
- for (const file of collect(root).cssFiles)
- for (const r of rawColours(readFileSync(join(root, file), 'utf8')))
- out.push(`${file}:${r.line}: raw colour ${r.literal} in "${r.prop}" — use a var(--…) of the token contract`);
- return out;
- }
- if (import.meta.main) report(check());