mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-18 17:16:46 +03:00
Require populated frontmatter coverage
AI assistance: Codex validated and addressed the Greptile review finding with focused regression coverage.
This commit is contained in:
@@ -117,6 +117,15 @@ export function checkDesignDrift({ designPath, projectRoot, threshold = 25 }) {
|
||||
* a section can be absent because it never applied, so this is reported as a
|
||||
* documentation gap for a human to judge, never as an error.
|
||||
*/
|
||||
function hasCoverageValue(value) {
|
||||
if (Array.isArray(value)) return value.some(hasCoverageValue);
|
||||
if (value && typeof value === 'object') {
|
||||
return Object.values(value).some(hasCoverageValue);
|
||||
}
|
||||
if (typeof value === 'string') return value.trim().length > 0;
|
||||
return value !== null && value !== undefined;
|
||||
}
|
||||
|
||||
export function checkDesignCoverage({ design, designPath, parseDesignMd }) {
|
||||
if (!design || typeof parseDesignMd !== 'function') return [];
|
||||
let model;
|
||||
@@ -126,7 +135,7 @@ export function checkDesignCoverage({ design, designPath, parseDesignMd }) {
|
||||
return [];
|
||||
}
|
||||
const missing = ['colors', 'typography', 'components']
|
||||
.filter((section) => !model[section] && !model.frontmatter?.[section]);
|
||||
.filter((section) => !model[section] && !hasCoverageValue(model.frontmatter?.[section]));
|
||||
if (!missing.length) return [];
|
||||
return [finding({
|
||||
id: 'design-md-coverage',
|
||||
|
||||
@@ -194,6 +194,28 @@ describe('checkDesignCoverage', () => {
|
||||
assert.deepEqual(checkDesignCoverage({ design, designPath: 'DESIGN.md', parseDesignMd }), []);
|
||||
});
|
||||
|
||||
it('does not count empty frontmatter mappings as section coverage', () => {
|
||||
const design = [
|
||||
'---',
|
||||
'name: X',
|
||||
'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/);
|
||||
assert.doesNotMatch(findings[0].summary, /typography|components/);
|
||||
});
|
||||
|
||||
it('reports nothing without a DESIGN.md', () => {
|
||||
assert.deepEqual(checkDesignCoverage({ design: null, parseDesignMd }), []);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user