mirror of
https://github.com/makecindy/cindy.git
synced 2026-12-03 21:49:46 +08:00
fix(design-system): DS-10 间距报告纳入 space-x/y 任意值
复审指出:space-x-[…] 与 space-y-[…] 也是间距消费者,但 模式不匹配,新增 space-y-[4px] 或 space-x-[var(--space-4)] 不产生 role-spacing 报告(仓内 AtMentionPanel.tsx:490、 QuotaHoverCard.tsx:310 有真实用法)。 pattern 增加 space-[xy] 进同一分类链,suggestion 文案同步; 尺度类 space-x-2 与 space-y-reverse 仍不报。 Signed-off-by: Kirozeng <kirozeng@gmail.com>
This commit is contained in:
@@ -154,6 +154,8 @@ test('spacing reports distinguish real generated references, unknown variables a
|
||||
['p-[env(safe-area-inset-top)]', 'unclassified-spacing'],
|
||||
['p-[calc(100%-4px)]', 'unclassified-spacing'],
|
||||
['mt-[var(--space-4)]', 'spacing-source-reference'],
|
||||
['space-x-[var(--space-4)]', 'spacing-source-reference'],
|
||||
['space-y-[4px]', 'literal-spacing'],
|
||||
['ms-[var(--space-4,initial)]', 'mixed-spacing-expression'],
|
||||
['mt-[3px]', 'literal-spacing'],
|
||||
['mx-[7px]', 'literal-spacing'],
|
||||
@@ -172,7 +174,7 @@ test('spacing reports distinguish real generated references, unknown variables a
|
||||
assert.match(hit.suggestion, /foundations.spacing/);
|
||||
assert.doesNotMatch(hit.suggestion, /radius overrides/);
|
||||
}
|
||||
for (const value of ['p-4', 'm-4', 'mt-2', 'gap-x-2', 'gap-y-2', 'gapx-[13px]', 'gapy-[13px]']) {
|
||||
for (const value of ['p-4', 'm-4', 'mt-2', 'gap-x-2', 'gap-y-2', 'space-x-2', 'space-y-reverse', 'gapx-[13px]', 'gapy-[13px]']) {
|
||||
assert.deepEqual(inspect(file, `<div className="${value}" />`), [], value);
|
||||
}
|
||||
const source = '// gap-x-[13px]\n<div className="gap-x-[13px]" />\n<div className="p-[var(--space-4)]" />';
|
||||
|
||||
@@ -89,7 +89,7 @@ export function classifyDesignLayer({ member, layer, radius, evidence = false })
|
||||
|
||||
export function reportDesignLayers(file, source, changed, locate, spacingVariables) {
|
||||
const findings = [];
|
||||
const patterns = /\brounded(?:-(?:\[[^\]\n]+\]|[\w-]+))?|\bborder(?:-radius|Radius)\s*:\s*[^;,}\n]+|\b(?:[pm][xytrblse]?|gap(?:-[xy])?)-\[[^\]\n]+\]/g;
|
||||
const patterns = /\brounded(?:-(?:\[[^\]\n]+\]|[\w-]+))?|\bborder(?:-radius|Radius)\s*:\s*[^;,}\n]+|\b(?:[pm][xytrblse]?|gap(?:-[xy])?|space-[xy])-\[[^\]\n]+\]/g;
|
||||
for (const match of source.matchAll(patterns)) {
|
||||
const pos = locate(match.index);
|
||||
if (!changed.has(pos.line)) continue;
|
||||
@@ -113,7 +113,7 @@ export function reportDesignLayers(file, source, changed, locate, spacingVariabl
|
||||
value: match[0], disposition: 'report', ...judgement,
|
||||
suggestion: isRadius
|
||||
? 'Review the visible frame, contained mark and hit/indicator layers separately against DESIGN §5 and governance §13; register missing evidence/decisions. Do not change user radius overrides.'
|
||||
: 'Use the existing p/px/py, m/mx/my and gap/gap-x/gap-y scales from desktop-bindings.json foundations.spacing and the component treatment in DESIGN §4/5. Verify unknown variables, calculations and fallbacks; do not infer button spacing from a DOM tag.' });
|
||||
: 'Use the existing p/px/py, m/mx/my, gap/gap-x/gap-y and space-x/space-y scales from desktop-bindings.json foundations.spacing and the component treatment in DESIGN §4/5. Verify unknown variables, calculations and fallbacks; do not infer button spacing from a DOM tag.' });
|
||||
}
|
||||
if (/components\/settings\/.*(?:Dialog|Wizard)\.tsx$/.test(file) && changed.size) {
|
||||
findings.push({ file, line: Math.min(...changed), column: 1, rule: 'form-adoption', disposition: 'report',
|
||||
|
||||
Reference in New Issue
Block a user