fix(design-system): 디자인 검사가 기능 CSS·gradient·인라인 style의 날 값을 잡는다

`check:design-system`이 잡지 못하는 길이 다섯 남았다(1101/12-03, 지금 위반
없음). gradient의 색상각 보간(`linear-gradient(in oklch, …)`)은 UI-02가
`color-mix`만 봐서 지난다. TSX 인라인 `color-mix`도 그렇다. 기능 폴더의 CSS는
아예 읽지 않는다. style sheet에서 `:root`로 토큰을 다시 정의해도, focus ring을
`outline-offset: 0`으로 그려 UI-01의 대비 계산 밖으로 내보내도 지난다. 그리고
primitive의 `className`·`style`이 범위 없이 열려 있어 화면이 primitive 위에
`style={{ color: "red", padding: 13 }}`을 얹어도 막는 것이 없다(04-14).

고른 방법: UI-02 정규식이 gradient의 색 공간까지 보고 TS·TSX 소스에도 돈다.
토큰 파일 밖 CSS는 `src/` 아래 전부를 읽고, 날 색·토큰 재정의·offset 0
focus ring을 거절한다. 04-14는 결정(2026-11-12, 총괄: 공개 props는 두고
검사를 더한다)대로 TSX `style={{ … }}`의 손 색(키워드·`var()` 말고)과 손
간격·글자·반경·층·그림자 값을 거절한다. `className`·`style`의 범위(배치용)를
`docs/styling/design-tokens.md`에 적고, fe-design-system 스킬의 「검사가 안
보는 것」 문장을 새 범위에 맞췄다. 거절 fixture `raw-inline-style.tsx`를
더했다. 버린 대안: primitive 공개 props에서 `style`을 빼기(배럴 표면 BREAKING).

위험·한계: 다운스트림이 기능 CSS나 인라인 style에 날 값을 두었으면 다음
동기화에서 그 줄이 이름과 함께 실패한다. 문자열로 조립한 class와 Tailwind
임의 값은 여전히 보지 않는다.

검증: 규칙 단위 시험, check-design-system 연결 시험(기능 폴더 probe CSS),
`check:design-system:fixture`(FE-GATE-029)는 desktop에서 돌려 PR 본문에 적는다.

Refs: 1101/12-03, 1112/04-14
This commit is contained in:
DongHyeonka
2026-11-13 23:27:47 +09:00
parent 838ed410f7
commit 5fa4ebe189
6 changed files with 212 additions and 12 deletions
+27 -6
View File
@@ -16,7 +16,11 @@ import {
focusContrastFailures,
hueMixFailures,
rawSemanticColourFailures,
focusOffsetFailures,
inlineStyleFailures,
rawStyleValueFailures,
styleSheetColourFailures,
tokenRedefinitionFailures,
undeclaredComponentTokenFailures,
unreadTokenFailures,
} from "./lib/design-system-rules.ts";
@@ -44,12 +48,14 @@ for (const [layer, file, tokens] of tokenLayers) {
}
}
// theme.css only imports the files under styles/theme/, so check them all.
const styleFiles = (
await readdir("src/presentation/styles", { recursive: true })
)
// Every style sheet under src/, not only the ones theme.css imports: a
// feature's own CSS is a style sheet too (1101/12-03).
const tokenFileSet = new Set<string>(Object.values(tokenFiles));
const styleFiles = (await readdir("src", { recursive: true }))
.filter((file) => file.endsWith(".css"))
.map((file) => path.join("src/presentation/styles", file));
.map((file) => path.join("src", file))
.filter((file) => !tokenFileSet.has(file))
.sort();
const cssSources = await Promise.all(
[...Object.values(tokenFiles), ...styleFiles].map(
async (file) => ({ file, source: await readFile(file, "utf8") }),
@@ -67,7 +73,21 @@ for (const { file, source } of cssSources) {
}
}
failures.push(...hueMixFailures({ file, source }));
if (styleFiles.includes(file)) failures.push(...rawStyleValueFailures({ file, source }));
if (!tokenFileSet.has(file)) {
failures.push(
...rawStyleValueFailures({ file, source }),
...styleSheetColourFailures({ file, source }),
...focusOffsetFailures({ file, source }),
);
}
}
const tokenNames = new Set(
cssSources
.filter(({ file }) => tokenFileSet.has(file))
.flatMap(({ source }) => [...source.matchAll(/(--[a-z0-9-]+)\s*:/g)].map((match) => match[1])),
);
for (const { file, source } of cssSources) {
if (!tokenFileSet.has(file)) failures.push(...tokenRedefinitionFailures({ file, source }, tokenNames));
}
const semanticSource = await readFile(tokenFiles.semantic, "utf8");
@@ -166,6 +186,7 @@ for (const file of sources) {
) {
failures.push(`raw palette value in ${file}`);
}
failures.push(...hueMixFailures({ file, source }), ...inlineStyleFailures({ file, source }));
if (
file.includes("tests/fixtures/design-system/forbidden") &&
source.includes("TOOLTIP_ONLY_REQUIRED_INFORMATION")