forked from c-fu/arah2
fix(01-design-tokens-rams-foundation): WR-02 repair familiesFromShorthand + flag literal font: shorthands
This commit is contained in:
@@ -33,6 +33,10 @@
|
||||
* bare `rounded` → var(--radius) = 0px (controlled
|
||||
* build); non-zero bare key → exit 2; the inert
|
||||
* v3-style DEFAULT sub-key must not reappear
|
||||
* T10 literal font: shorthands flagged regardless of
|
||||
* family (convention: font: var(--type-*)); var()
|
||||
* shorthands pass; familiesFromShorthand extracts
|
||||
* the family for the message → flagged (exit 1)
|
||||
*/
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { existsSync, mkdirSync, readFileSync, symlinkSync, writeFileSync } from 'node:fs';
|
||||
@@ -164,6 +168,17 @@ writeFileSync(styleAttrPage, `<!DOCTYPE html>
|
||||
</body></html>
|
||||
`);
|
||||
|
||||
/* T10 — literal font: shorthands (WR-02: the familiesFromShorthand
|
||||
* strip bug left "14px/18px Arial" behind, which the numeric filter
|
||||
* then dropped — no font: shorthand could ever be flagged). */
|
||||
const fontShorthand = join(FIX, 'font-shorthand.css');
|
||||
writeFileSync(fontShorthand, `/* literal font: shorthand — flagged regardless of family (package
|
||||
convention: font: var(--type-*)); var() shorthands pass */
|
||||
.a-font-shorthand { font: 700 14px/18px Arial; }
|
||||
.b-font-shorthand { font: italic 700 12px/16px "Space Grotesk", sans-serif; }
|
||||
.c-font-shorthand-var { font: var(--type-body-md); }
|
||||
`);
|
||||
|
||||
/* ————— tests ————— */
|
||||
|
||||
// T1 — clean stylesheet exits 0
|
||||
@@ -289,6 +304,21 @@ writeFileSync(styleAttrPage, `<!DOCTYPE html>
|
||||
'bare rounded still compiles to the v3 .25rem default');
|
||||
}
|
||||
|
||||
// T10 — literal font: shorthands are flagged; var() shorthands pass
|
||||
{
|
||||
const r = runAudit([fontShorthand]);
|
||||
check('T10 literal font: shorthand → exit 1', r.status === 1,
|
||||
`status=${r.status} error=${r.error} out=${r.out.slice(0, 300)}`);
|
||||
check('T10 off-token shorthand family extracted (Arial)',
|
||||
/font: 700 14px\/18px Arial/.test(r.out) && /Arial/.test(r.out),
|
||||
`out=${r.out.slice(0, 300)}`);
|
||||
check('T10 sanctioned-family shorthand still flagged (convention: font: var(--type-*))',
|
||||
/font: italic 700 12px\/16px "Space Grotesk", sans-serif/.test(r.out),
|
||||
`out=${r.out.slice(0, 300)}`);
|
||||
check('T10 var() shorthand passes', !/var\(--type-body-md\)/.test(r.out),
|
||||
`out=${r.out.slice(0, 300)}`);
|
||||
}
|
||||
|
||||
/* ————— report ————— */
|
||||
console.log(`audit.test: ${passes.length} passed, ${failures.length} failed`);
|
||||
passes.forEach((p) => console.log(` PASS ${p}`));
|
||||
|
||||
Reference in New Issue
Block a user