impeccable 2.3.2 → 3.0.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 +17 -5
- package/README.npm.md +17 -5
- package/README.repo.md +79 -25
- package/cli/bin/cli.js +48 -29
- package/cli/bin/commands/skills.mjs +1194 -100
- package/cli/engine/browser/injected/index.mjs +17 -7
- package/cli/engine/detect-antipatterns-browser.js +410 -50
- package/cli/engine/engines/regex/detect-text.mjs +16 -4
- package/cli/engine/engines/static-html/css-cascade.mjs +27 -0
- package/cli/engine/node/file-system.mjs +1 -1
- package/cli/engine/rules/checks.mjs +394 -43
- package/cli/lib/impeccable-config.mjs +119 -0
- package/package.json +30 -18
|
@@ -23,6 +23,18 @@ function stripHtmlToText(html) {
|
|
|
23
23
|
.replace(/\s+/g, ' ');
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
const PAGE_ANALYZER_EXTS = new Set(['.html', '.htm', '.astro', '.vue', '.svelte']);
|
|
27
|
+
|
|
28
|
+
function extFromFilePath(filePath) {
|
|
29
|
+
return filePath ? (filePath.match(/\.\w+$/)?.[0] || '').toLowerCase() : '';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function shouldRunPageAnalyzers(content, filePath) {
|
|
33
|
+
if (!isFullPage(content)) return false;
|
|
34
|
+
const ext = extFromFilePath(filePath);
|
|
35
|
+
return !ext || PAGE_ANALYZER_EXTS.has(ext);
|
|
36
|
+
}
|
|
37
|
+
|
|
26
38
|
function isNeutralBorderColor(str) {
|
|
27
39
|
const m = str.match(/solid\s+(#[0-9a-f]{3,8}|rgba?\([^)]+\)|\w+)/i);
|
|
28
40
|
if (!m) return false;
|
|
@@ -422,7 +434,7 @@ const TEXT_CONTENT_ANALYZER_IDS = [
|
|
|
422
434
|
|
|
423
435
|
function runTextContentAnalyzers(content, filePath, options = {}) {
|
|
424
436
|
const profile = options?.profile;
|
|
425
|
-
if (!
|
|
437
|
+
if (!shouldRunPageAnalyzers(content, filePath)) return [];
|
|
426
438
|
// The 4 text-content analyzers are at indices 3-6 in REGEX_ANALYZERS.
|
|
427
439
|
const findings = [];
|
|
428
440
|
for (let i = 0; i < TEXT_CONTENT_ANALYZER_IDS.length; i++) {
|
|
@@ -442,11 +454,11 @@ function detectText(content, filePath, options = {}) {
|
|
|
442
454
|
const profile = options?.profile;
|
|
443
455
|
const findings = [];
|
|
444
456
|
const lines = content.split('\n');
|
|
445
|
-
const ext =
|
|
457
|
+
const ext = extFromFilePath(filePath);
|
|
446
458
|
|
|
447
459
|
// Run regex matchers on the full file content (catches Tailwind classes, inline styles)
|
|
448
460
|
// Enable block context for CSS files where related properties span multiple lines
|
|
449
|
-
const cssLike = new Set(['.css', '.scss', '.less']);
|
|
461
|
+
const cssLike = new Set(['.css', '.scss', '.sass', '.less']);
|
|
450
462
|
findings.push(...runRegexMatchers(lines, filePath, 0, cssLike.has(ext) || null, {
|
|
451
463
|
profile,
|
|
452
464
|
phase: 'source',
|
|
@@ -498,7 +510,7 @@ function detectText(content, filePath, options = {}) {
|
|
|
498
510
|
}
|
|
499
511
|
|
|
500
512
|
// Page-level analyzers only run on full pages
|
|
501
|
-
if (
|
|
513
|
+
if (shouldRunPageAnalyzers(content, filePath)) {
|
|
502
514
|
const analyzerIds = [
|
|
503
515
|
'single-font',
|
|
504
516
|
'flat-type-hierarchy',
|
|
@@ -267,7 +267,16 @@ const STATIC_DEFAULT_STYLE = {
|
|
|
267
267
|
paddingRight: '0px',
|
|
268
268
|
paddingBottom: '0px',
|
|
269
269
|
paddingLeft: '0px',
|
|
270
|
+
marginTop: '0px',
|
|
271
|
+
marginRight: '0px',
|
|
272
|
+
marginBottom: '0px',
|
|
273
|
+
marginLeft: '0px',
|
|
270
274
|
position: 'static',
|
|
275
|
+
top: 'auto',
|
|
276
|
+
right: 'auto',
|
|
277
|
+
bottom: 'auto',
|
|
278
|
+
left: 'auto',
|
|
279
|
+
inset: '',
|
|
271
280
|
display: '',
|
|
272
281
|
overflow: 'visible',
|
|
273
282
|
overflowX: 'visible',
|
|
@@ -312,7 +321,16 @@ const STATIC_PROP_MAP = {
|
|
|
312
321
|
'padding-right': 'paddingRight',
|
|
313
322
|
'padding-bottom': 'paddingBottom',
|
|
314
323
|
'padding-left': 'paddingLeft',
|
|
324
|
+
'margin-top': 'marginTop',
|
|
325
|
+
'margin-right': 'marginRight',
|
|
326
|
+
'margin-bottom': 'marginBottom',
|
|
327
|
+
'margin-left': 'marginLeft',
|
|
315
328
|
'position': 'position',
|
|
329
|
+
'top': 'top',
|
|
330
|
+
'right': 'right',
|
|
331
|
+
'bottom': 'bottom',
|
|
332
|
+
'left': 'left',
|
|
333
|
+
'inset': 'inset',
|
|
316
334
|
'display': 'display',
|
|
317
335
|
'overflow': 'overflow',
|
|
318
336
|
'overflow-x': 'overflowX',
|
|
@@ -579,6 +597,15 @@ function expandStaticDeclaration(prop, value) {
|
|
|
579
597
|
['paddingLeft', vals[3]],
|
|
580
598
|
];
|
|
581
599
|
}
|
|
600
|
+
if (p === 'margin') {
|
|
601
|
+
const vals = expandStaticBoxValues(splitCssTokens(v));
|
|
602
|
+
return [
|
|
603
|
+
['marginTop', vals[0]],
|
|
604
|
+
['marginRight', vals[1]],
|
|
605
|
+
['marginBottom', vals[2]],
|
|
606
|
+
['marginLeft', vals[3]],
|
|
607
|
+
];
|
|
608
|
+
}
|
|
582
609
|
if (p === 'font') return parseStaticFont(v);
|
|
583
610
|
if (p === 'transition') {
|
|
584
611
|
const parsed = parseStaticTransition(v);
|