mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 14:16:28 +03:00
Reject empty collection coverage
AI assistance: Codex validated and addressed the Greptile empty-collection review finding with focused regression coverage.
This commit is contained in:
@@ -122,7 +122,10 @@ function hasCoverageValue(value) {
|
||||
if (value && typeof value === 'object') {
|
||||
return Object.values(value).some(hasCoverageValue);
|
||||
}
|
||||
if (typeof value === 'string') return value.trim().length > 0;
|
||||
if (typeof value === 'string') {
|
||||
const trimmed = value.trim();
|
||||
return trimmed.length > 0 && !/^(?:\[\s*\]|\{\s*\})$/.test(trimmed);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -239,6 +239,44 @@ describe('checkDesignCoverage', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not count empty frontmatter collection literals as section coverage', () => {
|
||||
for (const colors of ['[]', '{}']) {
|
||||
const design = [
|
||||
'---',
|
||||
'name: X',
|
||||
`colors: ${colors}`,
|
||||
'typography:',
|
||||
' body:',
|
||||
' fontFamily: Inter',
|
||||
'components:',
|
||||
' button:',
|
||||
' backgroundColor: "#111111"',
|
||||
'---',
|
||||
'',
|
||||
'# Design System: X',
|
||||
'',
|
||||
].join('\n');
|
||||
const findings = checkDesignCoverage({ design, designPath: 'DESIGN.md', parseDesignMd });
|
||||
assert.deepEqual(ids(findings), ['design-md-coverage']);
|
||||
assert.match(findings[0].summary, /no colors section/);
|
||||
}
|
||||
});
|
||||
|
||||
it('counts populated frontmatter array literals as section coverage', () => {
|
||||
const design = [
|
||||
'---',
|
||||
'name: X',
|
||||
'colors: ["#111111"]',
|
||||
'typography: [Inter]',
|
||||
'components: [button]',
|
||||
'---',
|
||||
'',
|
||||
'# Design System: X',
|
||||
'',
|
||||
].join('\n');
|
||||
assert.deepEqual(checkDesignCoverage({ design, designPath: 'DESIGN.md', parseDesignMd }), []);
|
||||
});
|
||||
|
||||
it('reports nothing without a DESIGN.md', () => {
|
||||
assert.deepEqual(checkDesignCoverage({ design: null, parseDesignMd }), []);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user