fix(01-design-tokens-rams-foundation): WR-04 audit spacing + typography numerics per D-13 (token scales, font-face exempt)

This commit is contained in:
araharah-executor
2026-10-22 09:39:16 +08:00
parent ee48e760f8
commit 5e254cb851
3 changed files with 163 additions and 7 deletions
+42
View File
@@ -41,6 +41,10 @@
* hwb()/color()/color-mix(), text-shadow → flagged
* (exit 1); currentcolor/inherit/transparent stay
* sanctioned
* T12 spacing + typography numerics audited against
* the --spacing and --type scale sets; token-value
* literals, var(), zero/auto pass; @font-face asset
* metadata exempt → flagged (exit 1)
*/
import { spawnSync } from 'node:child_process';
import { existsSync, mkdirSync, readFileSync, symlinkSync, writeFileSync } from 'node:fs';
@@ -200,6 +204,25 @@ writeFileSync(colorEvasions, `/* every flagged declaration must be listed; sanct
.t-ok { outline: 2px solid inherit; }
`);
/* T12 — D-13 spacing + typography numerics (WR-04): off-scale
* literals flagged; token-value literals, var(), zero/auto, and
* @font-face asset metadata pass. */
const numerics = join(FIX, 'numerics.css');
writeFileSync(numerics, `/* off-scale numerics — every flagged declaration must be listed */
.a-spacing { padding: 13px; }
.b-spacing { gap: 7px; }
.c-type { font-size: 17px; }
.d-type { font-weight: 650; }
.e-type { line-height: 1.7; }
.f-track { letter-spacing: 0.05em; }
/* on-token literal forms + sanctioned values pass */
.g-ok { padding: 1rem 0.25rem; gap: 3rem; margin: 0 auto; }
.h-ok { font-size: 14px; font-weight: 700; line-height: 20px; letter-spacing: -0.04em; }
.i-ok-var { padding: var(--spacing-space-md); margin: var(--spacing-margin); }
/* @font-face asset metadata (D-16) is not rendered typography */
@font-face { font-family: "Geist"; font-style: normal; font-weight: 500; src: url("Geist-Medium.woff2") format("woff2"); }
`);
/* ————— tests ————— */
// T1 — clean stylesheet exits 0
@@ -355,6 +378,25 @@ writeFileSync(colorEvasions, `/* every flagged declaration must be listed; sanct
`out=${r.out.slice(0, 300)}`);
}
// T12 — spacing + typography numerics audited against the token scales
{
const r = runAudit([numerics]);
const markers = ['padding: 13px', 'gap: 7px', 'font-size: 17px', 'font-weight: 650',
'line-height: 1.7', 'letter-spacing: 0.05em'];
const missing = markers.filter((m) => !r.out.includes(m));
check('T12 off-scale numerics → exit 1', r.status === 1,
`status=${r.status} error=${r.error}`);
check('T12 every off-scale numeric listed', missing.length === 0,
`missing markers: ${missing.join(', ')}`);
check('T12 token-value literals pass (1rem/0.25rem/14px/700/20px/-0.04em)',
!/1rem 0\.25rem/.test(r.out) && !/font-size: 14px/.test(r.out) && !/letter-spacing: -0\.04em/.test(r.out),
`out=${r.out.slice(0, 400)}`);
check('T12 zero/auto margin passes', !/margin: 0 auto/.test(r.out),
`out=${r.out.slice(0, 400)}`);
check('T12 @font-face asset metadata (font-weight 500) passes', !/font-weight: 500/.test(r.out),
`out=${r.out.slice(0, 400)}`);
}
/* ————— report ————— */
console.log(`audit.test: ${passes.length} passed, ${failures.length} failed`);
passes.forEach((p) => console.log(` PASS ${p}`));