mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 06:06:37 +03:00
Fix radius var fallback detection (#687)
Strip closing var() parentheses before resolving fallback radius tokens, preserving on-scale values and actionable ignore values. AI-assisted change: implemented with Codex under @pbakaus direction.
This commit is contained in:
@@ -995,7 +995,9 @@ function extractRadiusTokens(value) {
|
||||
return String(value || '')
|
||||
.replace(/\s*\/\s*/g, ' ')
|
||||
.split(/\s+/)
|
||||
.map(token => token.trim())
|
||||
// var() fallbacks leave the closing parenthesis on the final token. Strip
|
||||
// it before length resolution so `8px)` is not treated as unitless 8rem.
|
||||
.map(token => token.trim().replace(/\)+$/, ''))
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
|
||||
@@ -389,6 +389,25 @@ describe('checkSourceDesignSystem()', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('judges var() radius fallbacks without keeping the closing parenthesis', () => {
|
||||
const designSystem = normalizeDesignSystem({
|
||||
frontmatter: { rounded: { md: '8px' } },
|
||||
});
|
||||
const findings = checkSourceDesignSystem(`
|
||||
.good {
|
||||
border-radius: var(--radius-md, 8px);
|
||||
}
|
||||
.bad {
|
||||
border-radius: var(--radius-custom, 18px);
|
||||
}
|
||||
`, '/tmp/radius-fallbacks.css', { designSystem });
|
||||
|
||||
assert.deepEqual(
|
||||
findings.map((item) => [item.antipattern, item.ignoreValue]),
|
||||
[['design-system-radius', '18px']],
|
||||
);
|
||||
});
|
||||
|
||||
it('strips CSS priority markers before checking font-family declarations', () => {
|
||||
const designSystem = sampleDesignSystem();
|
||||
const findings = checkSourceDesignSystem(`
|
||||
|
||||
Reference in New Issue
Block a user