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 显式识别 var() fallback 为混合间距

Kirozengbf95bf72ac19
diff --git a/scripts/__tests__/hardcoded-color-audit.test.mjs b/scripts/__tests__/hardcoded-color-audit.test.mjs
index 79eacea6d7..c08625a891 100644
--- a/scripts/__tests__/hardcoded-color-audit.test.mjs
+++ b/scripts/__tests__/hardcoded-color-audit.test.mjs
@@ -145,6 +145,9 @@ test('spacing reports distinguish real generated references, unknown variables a
['p-[var(--size-input-lg)]', 'unknown-spacing-reference'],
['px-[calc(var(--space-4)+1px)]', 'mixed-spacing-expression'],
['p-[var(--space-4,13px)]', 'mixed-spacing-expression'],
+ ['p-[var(--space-4,initial)]', 'mixed-spacing-expression'],
+ ['p-[var(--space-4,auto)]', 'mixed-spacing-expression'],
+ ['p-[var(--space-4,var(--space-2))]', 'mixed-spacing-expression'],
['p-[calc(var(--space-4)*2)]', 'mixed-spacing-expression'],
['gap-[calc(var(--space-4)-var(--space-2))]', 'spacing-expression'],
['p-[var(--space-4,var(--missing))]', 'unknown-spacing-reference'],
diff --git a/scripts/shared/design-layer-report.mjs b/scripts/shared/design-layer-report.mjs
index 34d26b5037..3680071159 100644
--- a/scripts/shared/design-layer-report.mjs
+++ b/scripts/shared/design-layer-report.mjs
@@ -55,7 +55,10 @@ function classifySpacing(value, spacingVariables = getSpacingVariables()) {
reason: 'Contains a variable outside the generated spacing bindings; verify its source, fallbacks and component role. A variable name alone is not approval.' };
}
if (references.length) {
- const mixed = /\d/.test(expression.replace(/--[\w-]+/g, ''));
+ // A var() fallback is a second value even when it carries no digit
+ // (initial, auto, a nested var): recognise it explicitly, never by
+ // whether a digit happens to appear in the rest of the expression.
+ const mixed = /var\(\s*--[\w-]+\s*,/.test(expression) || /\d/.test(expression.replace(/--[\w-]+/g, ''));
return { classification: mixed ? 'mixed-spacing-expression' : 'spacing-expression',
reason: mixed ? 'Combines spacing references with literal values (including fallbacks); review each literal and the component role.'
: 'Derived spacing expression; verify the calculation and component role. References do not approve the whole expression.' };