package file→ .shtukbase/packages/icons/checks/i03_required.ts
checks/i03_required.ts
24 lines, 1.3 KB.
- // ICN-R03: every record of a collection that requires an icon (`icons: {required: true}`) shows one.
- // Inherited counts: the record's own icon (as its tier allows), else the collection's icons.item, else the collection page's icon.
- import { Icons, finish, isGlyph, isSvgPath, norm, ownIcons } from '../lib/iconlib.ts';
- const ic = new Icons();
- const n = norm(ic.root, 'ICN-R03');
- const out: string[] = [];
- if (n.active) {
- const colls = ic.collections();
- const inherited: Record<string, string> = {};
- for (const c of Object.values(colls)) {
- const own = typeof c.fm.icon === 'string' ? c.fm.icon.trim() : '';
- inherited[c.coll] = c.item || (own && (isGlyph(own) || isSvgPath(own)) ? own : '');
- if (c.required && c.tier === 'none') out.push(`${c.coll}.md: icons.required with tier none → drop required or choose another tier`);
- }
- for (const p of ic.pages()) {
- if (!p.coll || !colls[p.coll].required || p.tier === 'none') continue;
- const { icon } = ownIcons(p);
- const ownOk = p.tier !== 'kind' && icon && (isGlyph(icon) || isSvgPath(icon));
- if (!ownOk && !inherited[p.coll]) out.push(`${p.id}: no icon, and ${p.coll}.md gives none to inherit → ${p.tier === 'kind' ? 'set icons.item on the collection' : 'set icon (an emoji; run shtuk run icons prompt ' + p.id.slice(1) + ') or icons.item on the collection'}`);
- }
- }
- finish(n, out);