ShtukbaseStandard
包文件→ .shtukbase/packages/shtukbase-ui-html/checks/tokens-only.ts

checks/tokens-only.ts

18 行, 789 B.

文件按包中的原样显示:代码及其注释不做翻译。

  1. // SUI-R02. Component CSS takes colours, radii and shadows only from the token contract (no raw colour, no plain radius),
  2. // so swapping the style swaps the look of every component.
  3. import { readFileSync } from 'node:fs';
  4. import { join } from 'node:path';
  5. import { scan } from '../lib/components.ts';
  6. import { rawValues } from '../lib/tokens.ts';
  7. export const RULE = { id: 'sui-r02', title: 'Component CSS uses only contract tokens for colours, radii and shadows' };
  8. export function check(root = process.cwd()): string[] {
  9. return scan(root).flatMap((c) => (c.css ? rawValues(readFileSync(join(root, c.css), 'utf8')).map((p) => `${c.css}: ${p}`) : []));
  10. }
  11. if (import.meta.main) {
  12. const out = check();
  13. for (const l of out) console.log(l);
  14. process.exitCode = out.length ? 1 : 0;
  15. }