Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(design-system): DS-10 裸间距单位按 CSS 维度语法识别

Kirozengf2b5b81ecb84
diff --git a/scripts/__tests__/hardcoded-color-audit.test.mjs b/scripts/__tests__/hardcoded-color-audit.test.mjs
index c22ca5346d..49fa0405fd 100644
--- a/scripts/__tests__/hardcoded-color-audit.test.mjs
+++ b/scripts/__tests__/hardcoded-color-audit.test.mjs
@@ -165,6 +165,12 @@ test('spacing reports distinguish real generated references, unknown variables a
['p-[14px_16px]', 'literal-spacing'],
['px-[8px_12px]', 'literal-spacing'],
['p-[-14px_-16px]', 'literal-spacing'],
+ ['p-[1lh]', 'literal-spacing'],
+ ['mt-[2dvh]', 'literal-spacing'],
+ ['gap-[1cqw]', 'literal-spacing'],
+ ['p-[12PX]', 'literal-spacing'],
+ ['p-[17pt]', 'literal-spacing'],
+ ['p-[1lh_2dvh]', 'literal-spacing'],
]) {
const source = `<div className="${value}" />`;
const [hit] = inspect(file, source);
diff --git a/scripts/shared/design-layer-report.mjs b/scripts/shared/design-layer-report.mjs
index a88c09561c..1ca68972ae 100644
--- a/scripts/shared/design-layer-report.mjs
+++ b/scripts/shared/design-layer-report.mjs
@@ -68,8 +68,10 @@ function classifySpacing(value, spacingVariables = getSpacingVariables()) {
: 'Derived spacing expression; verify the calculation and component role. References do not approve the whole expression.' };
}
// Tailwind writes spaces in arbitrary values as underscores: a bare value
- // may be a list (p-[14px_16px]). Every item must be a literal on its own.
- const literal = /^-?(?:\d*\.)?\d+(?:px|rem|em|%|vh|vw)?$/;
+ // may be a list (p-[14px_16px]). Every item must be a literal on its own —
+ // a number with any CSS dimension unit (1lh, 2dvh, 12PX, 17pt …), never a
+ // unit enumeration, mirroring the typography gate's own discipline.
+ const literal = /^-?(?:\d*\.)?\d+[a-z%]*$/i;
return { classification: expression.split('_').every(part => literal.test(part)) ? 'literal-spacing' : 'unclassified-spacing',
reason: 'No verified spacing source reference; use the matching standard spacing class or document the component-specific geometry.' };
}