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.
@@ -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*[^;]*\b(bounce|elastic|wobble|jiggle|spring)\b/gi,
113
+ { id: 'bounce-easing', regex: /animation(?:-name)?\s*:\s*([^;{}]*(?:bounce|elastic|wobble|jiggle|spring)[^;{}]*)/gi,
102
114
  test: () => true,
103
- fmt: (m) => m[0] },
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 (!isFullPage(content)) return [];
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 = filePath ? (filePath.match(/\.\w+$/)?.[0] || '').toLowerCase() : '';
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 (isFullPage(content)) {
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);
@@ -11,7 +11,7 @@ const SKIP_DIRS = new Set([
11
11
  ]);
12
12
 
13
13
  const SCANNABLE_EXTENSIONS = new Set([
14
- '.html', '.htm', '.css', '.scss', '.less',
14
+ '.html', '.htm', '.css', '.scss', '.sass', '.less',
15
15
  '.jsx', '.tsx', '.js', '.ts',
16
16
  '.vue', '.svelte', '.astro',
17
17
  ]);