impeccable 3.4.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/README.npm.md +3 -3
- package/README.repo.md +26 -3
- package/cli/bin/cli.js +6 -0
- package/cli/bin/commands/skills.mjs +234 -29
- package/cli/engine/browser/injected/index.mjs +56 -6
- package/cli/engine/design-system.mjs +140 -2
- package/cli/engine/detect-antipatterns-browser.js +1174 -694
- package/cli/engine/detect-antipatterns.mjs +1 -0
- package/cli/engine/engines/browser/detect-url.mjs +35 -3
- package/cli/engine/engines/regex/detect-text.mjs +431 -45
- package/cli/engine/engines/static-html/css-cascade.mjs +10 -1
- package/cli/engine/engines/static-html/detect-html.mjs +47 -6
- package/cli/engine/node/file-system.mjs +23 -22
- package/cli/engine/registry/antipatterns.mjs +0 -10
- package/cli/engine/rules/checks.mjs +384 -384
- package/cli/engine/shared/color.mjs +466 -2
- package/cli/lib/download-providers.js +7 -0
- package/cli/lib/impeccable-config.mjs +44 -59
- package/package.json +5 -3
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
checkCreamPalette,
|
|
29
29
|
checkHtmlPatterns,
|
|
30
30
|
checkKickerAboveHeadingFromDoc,
|
|
31
|
+
scopedIgnoreActive,
|
|
31
32
|
checkNumberedSectionLabelsFromDoc,
|
|
32
33
|
checkPageLayout,
|
|
33
34
|
checkPageQualityFromDoc,
|
|
@@ -60,9 +61,6 @@ function checkStaticPageTypography(document, window) {
|
|
|
60
61
|
for (const font of overusedFound) {
|
|
61
62
|
findings.push({ id: 'overused-font', snippet: `Primary font: ${font}` });
|
|
62
63
|
}
|
|
63
|
-
if (fonts.size === 1 && document.querySelectorAll('*').length >= 20) {
|
|
64
|
-
findings.push({ id: 'single-font', snippet: `only font used is ${[...fonts][0]}` });
|
|
65
|
-
}
|
|
66
64
|
const sizes = new Set();
|
|
67
65
|
for (const el of document.querySelectorAll('h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, button, div')) {
|
|
68
66
|
const fontSize = parseFloat(window.getComputedStyle(el).fontSize);
|
|
@@ -141,10 +139,21 @@ async function detectHtml(filePath, options = {}) {
|
|
|
141
139
|
domutils,
|
|
142
140
|
};
|
|
143
141
|
});
|
|
144
|
-
} catch {
|
|
145
|
-
|
|
142
|
+
} catch (err) {
|
|
143
|
+
if (!globalThis.__impeccableStaticHtmlWarned) {
|
|
144
|
+
globalThis.__impeccableStaticHtmlWarned = true;
|
|
145
|
+
|
|
146
|
+
process.stderr.write(
|
|
147
|
+
'impeccable detect: DEGRADED - HTML parser modules unavailable ' +
|
|
148
|
+
'(htmlparser2, css-select, css-tree, domutils).\n' +
|
|
149
|
+
'Falling back to regex matching. Custom properties, selector matching and computed ' +
|
|
150
|
+
'contrast are NOT evaluated; findings are an undercount, not a clean bill of health.\n'
|
|
151
|
+
);
|
|
146
152
|
}
|
|
147
153
|
|
|
154
|
+
return detectText(html, filePath, options);
|
|
155
|
+
}
|
|
156
|
+
|
|
148
157
|
const resolvedPath = path.resolve(filePath);
|
|
149
158
|
const fileDir = path.dirname(resolvedPath);
|
|
150
159
|
const root = profileStep(profile, {
|
|
@@ -174,6 +183,9 @@ async function detectHtml(filePath, options = {}) {
|
|
|
174
183
|
const tag = el.tagName.toLowerCase();
|
|
175
184
|
const style = window.getComputedStyle(el);
|
|
176
185
|
for (const f of runElementCheck(rule.id, () => rule.run(el, tag, style, window, customPropMap))) {
|
|
186
|
+
// Element-scoped waivers: a data-impeccable-ignore ancestor suppresses
|
|
187
|
+
// matching findings for its subtree, same as the browser walk.
|
|
188
|
+
if (scopedIgnoreActive(el, f.id)) continue;
|
|
177
189
|
findings.push(finding(f.id, filePath, f.snippet));
|
|
178
190
|
}
|
|
179
191
|
}
|
|
@@ -220,9 +232,38 @@ async function detectHtml(filePath, options = {}) {
|
|
|
220
232
|
for (const f of runPageCheck('skipped-heading', () => checkPageQualityFromDoc(document))) {
|
|
221
233
|
findings.push(finding(f.id, filePath, f.snippet));
|
|
222
234
|
}
|
|
223
|
-
|
|
235
|
+
// Scoped corpora for the pattern checks (see buildHtmlPatternCorpora in
|
|
236
|
+
// rules/checks.mjs): CSS-property regexes must not fire on prose ABOUT
|
|
237
|
+
// css — `<code>background-clip: text</code>` in a changelog is
|
|
238
|
+
// documentation, not styling. cssText already carries the <style>
|
|
239
|
+
// blocks and any linked local stylesheets; style/class attributes come
|
|
240
|
+
// from the parsed document, so escaped code samples never contribute.
|
|
241
|
+
const styleAttrParts = [];
|
|
242
|
+
const classAttrParts = [];
|
|
243
|
+
for (const el of document.querySelectorAll('*')) {
|
|
244
|
+
const styleAttr = el.getAttribute('style');
|
|
245
|
+
if (styleAttr) styleAttrParts.push(`style="${styleAttr}"`);
|
|
246
|
+
const classAttr = el.getAttribute('class');
|
|
247
|
+
if (classAttr) classAttrParts.push(classAttr);
|
|
248
|
+
}
|
|
249
|
+
const patternCorpora = {
|
|
250
|
+
styleText: [cssText, ...styleAttrParts].join('\n'),
|
|
251
|
+
classText: classAttrParts.join('\n'),
|
|
252
|
+
};
|
|
253
|
+
for (const f of runPageCheck('html-patterns', () => checkHtmlPatterns(html, patternCorpora).filter(item =>
|
|
224
254
|
item.id !== 'bounce-easing' && item.id !== 'layout-transition'
|
|
225
255
|
))) {
|
|
256
|
+
// Selector-backed page findings honor scoped waivers here too, matching
|
|
257
|
+
// the browser pass: resolve the selector and drop the finding when an
|
|
258
|
+
// ignoring ancestor covers a match. Unlike the browser, an unmatched
|
|
259
|
+
// selector keeps the finding — static scans see partial documents.
|
|
260
|
+
if (f.selector) {
|
|
261
|
+
let matches = null;
|
|
262
|
+
try {
|
|
263
|
+
matches = document.querySelectorAll(String(f.selector).replace(/::?[a-zA-Z-]+(\([^)]*\))?/g, '').trim());
|
|
264
|
+
} catch { matches = null; }
|
|
265
|
+
if (matches && matches.length > 0 && [...matches].every(el => scopedIgnoreActive(el, f.id))) continue;
|
|
266
|
+
}
|
|
226
267
|
const item = finding(f.id, filePath, f.snippet);
|
|
227
268
|
// Position-aware severity promotion: checks may attach a per-finding
|
|
228
269
|
// severity (e.g. a pulsing dot inside a header/nav landmark) that
|
|
@@ -26,11 +26,26 @@ const HIDDEN_SOURCE_DIRS = new Set(['.vitepress', '.vuepress', '.storybook']);
|
|
|
26
26
|
const SCANNABLE_EXTENSIONS = new Set([
|
|
27
27
|
'.html', '.htm', '.css', '.scss', '.sass', '.less',
|
|
28
28
|
'.jsx', '.tsx', '.js', '.ts',
|
|
29
|
-
'.vue', '.svelte', '.astro',
|
|
29
|
+
'.vue', '.svelte', '.astro', '.blade.php',
|
|
30
30
|
]);
|
|
31
31
|
|
|
32
32
|
const HTML_EXTENSIONS = new Set(['.html', '.htm']);
|
|
33
33
|
|
|
34
|
+
function hasScannableExtension(filename) {
|
|
35
|
+
const lower = filename.toLowerCase();
|
|
36
|
+
if (SCANNABLE_EXTENSIONS.has(path.extname(lower))) return true;
|
|
37
|
+
for (const ext of SCANNABLE_EXTENSIONS) {
|
|
38
|
+
if (ext.indexOf('.', 1) !== -1 && lower.endsWith(ext)) return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const IMPORT_SPECIFIER_PATTERNS = [
|
|
44
|
+
/import\s+(?:[\s\S]*?from\s+)?['"]([^'"]+)['"]/g,
|
|
45
|
+
/@import\s+(?:url\(\s*)?['"]?([^'");\s]+)['"]?\s*\)?/g,
|
|
46
|
+
/@(?:use|forward)\s+['"]([^'"]+)['"]/g,
|
|
47
|
+
];
|
|
48
|
+
|
|
34
49
|
function walkDir(dir) {
|
|
35
50
|
const files = [];
|
|
36
51
|
let entries;
|
|
@@ -40,7 +55,7 @@ function walkDir(dir) {
|
|
|
40
55
|
if (entry.isDirectory() && entry.name.startsWith('.') && !HIDDEN_SOURCE_DIRS.has(entry.name)) continue;
|
|
41
56
|
const full = path.join(dir, entry.name);
|
|
42
57
|
if (entry.isDirectory()) files.push(...walkDir(full));
|
|
43
|
-
else if (
|
|
58
|
+
else if (hasScannableExtension(entry.name)) files.push(full);
|
|
44
59
|
}
|
|
45
60
|
return files;
|
|
46
61
|
}
|
|
@@ -75,26 +90,11 @@ function buildImportGraph(files) {
|
|
|
75
90
|
const dir = path.dirname(file);
|
|
76
91
|
const imports = new Set();
|
|
77
92
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (resolved) imports.add(resolved);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// CSS @import
|
|
87
|
-
const cssRe = /@import\s+(?:url\(\s*)?['"]?([^'");\s]+)['"]?\s*\)?/g;
|
|
88
|
-
while ((m = cssRe.exec(content)) !== null) {
|
|
89
|
-
const resolved = resolveImport(m[1], dir, fileSet);
|
|
90
|
-
if (resolved) imports.add(resolved);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// SCSS @use / @forward
|
|
94
|
-
const scssRe = /@(?:use|forward)\s+['"]([^'"]+)['"]/g;
|
|
95
|
-
while ((m = scssRe.exec(content)) !== null) {
|
|
96
|
-
const resolved = resolveImport(m[1], dir, fileSet);
|
|
97
|
-
if (resolved) imports.add(resolved);
|
|
93
|
+
for (const pattern of IMPORT_SPECIFIER_PATTERNS) {
|
|
94
|
+
for (const match of content.matchAll(pattern)) {
|
|
95
|
+
const resolved = resolveImport(match[1], dir, fileSet);
|
|
96
|
+
if (resolved) imports.add(resolved);
|
|
97
|
+
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
graph.set(file, imports);
|
|
@@ -203,6 +203,7 @@ export {
|
|
|
203
203
|
SKIP_DIRS,
|
|
204
204
|
SCANNABLE_EXTENSIONS,
|
|
205
205
|
HTML_EXTENSIONS,
|
|
206
|
+
hasScannableExtension,
|
|
206
207
|
walkDir,
|
|
207
208
|
resolveImport,
|
|
208
209
|
buildImportGraph,
|
|
@@ -28,16 +28,6 @@ const ANTIPATTERNS = [
|
|
|
28
28
|
skillSection: 'Typography',
|
|
29
29
|
skillGuideline: 'overused fonts like Inter',
|
|
30
30
|
},
|
|
31
|
-
{
|
|
32
|
-
id: 'single-font',
|
|
33
|
-
category: 'slop',
|
|
34
|
-
scopes: ['type'],
|
|
35
|
-
name: 'Single font without hierarchy',
|
|
36
|
-
description:
|
|
37
|
-
'Only one font family is used for the entire page. A single family can work when weight and size contrast carry the hierarchy; otherwise pair a distinctive display font with a refined body font.',
|
|
38
|
-
skillSection: 'Typography',
|
|
39
|
-
skillGuideline: 'only one font family for the entire page',
|
|
40
|
-
},
|
|
41
31
|
{
|
|
42
32
|
id: 'flat-type-hierarchy',
|
|
43
33
|
category: 'slop',
|