impeccable 2.3.2 → 3.0.1
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 +417 -53
- package/cli/engine/engines/regex/detect-text.mjs +23 -6
- 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 +401 -46
- 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;
|
|
@@ -98,9 +110,14 @@ const REGEX_MATCHERS = [
|
|
|
98
110
|
{ id: 'bounce-easing', regex: /\banimate-bounce\b/g,
|
|
99
111
|
test: () => true,
|
|
100
112
|
fmt: () => 'animate-bounce (Tailwind)' },
|
|
101
|
-
{ id: 'bounce-easing', regex: /animation(?:-name)?\s*:\s*[^;]
|
|
113
|
+
{ id: 'bounce-easing', regex: /animation(?:-name)?\s*:\s*([^;{}]*(?:bounce|elastic|wobble|jiggle|spring)[^;{}]*)/gi,
|
|
102
114
|
test: () => true,
|
|
103
|
-
fmt: (m) =>
|
|
115
|
+
fmt: (m) => {
|
|
116
|
+
const token = m[1]
|
|
117
|
+
.split(/[,\s]+/)
|
|
118
|
+
.find((part) => /bounce|elastic|wobble|jiggle|spring/i.test(part));
|
|
119
|
+
return `animation: ${token || m[1].trim()}`;
|
|
120
|
+
} },
|
|
104
121
|
{ id: 'bounce-easing', regex: /cubic-bezier\(\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*\)/g,
|
|
105
122
|
test: (m) => {
|
|
106
123
|
const y1 = parseFloat(m[2]), y2 = parseFloat(m[4]);
|
|
@@ -422,7 +439,7 @@ const TEXT_CONTENT_ANALYZER_IDS = [
|
|
|
422
439
|
|
|
423
440
|
function runTextContentAnalyzers(content, filePath, options = {}) {
|
|
424
441
|
const profile = options?.profile;
|
|
425
|
-
if (!
|
|
442
|
+
if (!shouldRunPageAnalyzers(content, filePath)) return [];
|
|
426
443
|
// The 4 text-content analyzers are at indices 3-6 in REGEX_ANALYZERS.
|
|
427
444
|
const findings = [];
|
|
428
445
|
for (let i = 0; i < TEXT_CONTENT_ANALYZER_IDS.length; i++) {
|
|
@@ -442,11 +459,11 @@ function detectText(content, filePath, options = {}) {
|
|
|
442
459
|
const profile = options?.profile;
|
|
443
460
|
const findings = [];
|
|
444
461
|
const lines = content.split('\n');
|
|
445
|
-
const ext =
|
|
462
|
+
const ext = extFromFilePath(filePath);
|
|
446
463
|
|
|
447
464
|
// Run regex matchers on the full file content (catches Tailwind classes, inline styles)
|
|
448
465
|
// Enable block context for CSS files where related properties span multiple lines
|
|
449
|
-
const cssLike = new Set(['.css', '.scss', '.less']);
|
|
466
|
+
const cssLike = new Set(['.css', '.scss', '.sass', '.less']);
|
|
450
467
|
findings.push(...runRegexMatchers(lines, filePath, 0, cssLike.has(ext) || null, {
|
|
451
468
|
profile,
|
|
452
469
|
phase: 'source',
|
|
@@ -498,7 +515,7 @@ function detectText(content, filePath, options = {}) {
|
|
|
498
515
|
}
|
|
499
516
|
|
|
500
517
|
// Page-level analyzers only run on full pages
|
|
501
|
-
if (
|
|
518
|
+
if (shouldRunPageAnalyzers(content, filePath)) {
|
|
502
519
|
const analyzerIds = [
|
|
503
520
|
'single-font',
|
|
504
521
|
'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);
|