archivo del paquete→ .shtukbase/packages/design-scales/checks/measure.ts
checks/measure.ts
31 líneas, 1.5 KB.
El archivo tal como está en el paquete: el código y sus comentarios no se traducen.
- // SCL-R04 sensor (not a check: always exits 0). Lists widths written in `ch` (CSS max-width/width/inline-size and
- // Tailwind max-w-[Nch], w-[Nch]) that fall outside the readable measure (45–75 characters, from `measure` of
- // /design/scales.md). A narrow ch width on a label or a cell is often meant — the judge decides; the sensor only
- // shows where to look.
- import { classes, config, cssDecls, utility } from './scaleslib.ts';
- const PROP = /^(max-width|width|inline-size|max-inline-size)$/;
- export function look(root = process.cwd()): string[] {
- const [lo, hi] = config(root).measure;
- const out: string[] = [];
- const ch = (at: string, what: string, v: string) => {
- const m = /^(\d*\.?\d+)ch$/.exec(v.trim());
- if (!m) return;
- const n = Number(m[1]);
- if (n > hi) out.push(`${at}: ${what} — ${n} characters per line, longer than ${hi}: for text, the line tires the reader`);
- else if (n < lo) out.push(`${at}: ${what} — ${n} characters per line, shorter than ${lo}: for a paragraph, the line is ragged`);
- };
- for (const d of cssDecls(root)) if (PROP.test(d.prop)) ch(d.at, `${d.prop}: ${d.value}`, d.value);
- for (const k of classes(root)) {
- const m = /^(?:max-w|w)-\[([^\]]+)\]$/.exec(utility(k.cls));
- if (m) ch(k.at, k.cls, m[1]);
- }
- return out;
- }
- if (import.meta.main) {
- const out = look();
- console.log(out.length ? out.join('\n') : 'no widths in ch outside 45–75');
- console.log('Judge: .shtukbase/packages/design-scales/judges/measure.md');
- }