ShtukbaseStandard
файл пакета→ .shtukbase/packages/design-components/checks/uses-exist.ts

checks/uses-exist.ts

18 строк, 838 Б.

Файл как есть в пакете: код и комментарии в нём не переводятся.

  1. // DSC-R02. Every component a header lists in `uses` exists: it has a header somewhere in the libraries, or a page in
  2. // /design/components (a planned component the authors wrote by hand).
  3. import { collect, pageIds } from '../lib/project.ts';
  4. import { report } from '../lib/report.ts';
  5. export const RULE = { id: 'dsc-r02', title: 'Every used component exists' };
  6. export function check(root = process.cwd()): string[] {
  7. const col = collect(root);
  8. const known = new Set([...col.comps.map((c) => c.id), ...pageIds(root)]);
  9. const out: string[] = [];
  10. for (const c of col.comps)
  11. for (const u of c.header.uses)
  12. if (!known.has(u)) out.push(`${c.source}: "${c.id}" uses "${u}", and there is no component with that id — fix the id in the header, or add the component`);
  13. return out;
  14. }
  15. if (import.meta.main) report(check());