impeccable 3.5.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.
@@ -35,6 +35,7 @@ export { detectUrl, createBrowserDetector } from './engines/browser/detect-url.m
35
35
  export { detectText, extractStyleBlocks, extractCSSinJS } from './engines/regex/detect-text.mjs';
36
36
  export {
37
37
  walkDir,
38
+ hasScannableExtension,
38
39
  SCANNABLE_EXTENSIONS,
39
40
  SKIP_DIRS,
40
41
  buildImportGraph,
@@ -41,6 +41,221 @@ function shouldRunPageAnalyzers(content, filePath) {
41
41
  return !ext || PAGE_ANALYZER_EXTS.has(ext);
42
42
  }
43
43
 
44
+ const JS_SOURCE_EXTS = new Set(['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs']);
45
+ const REGEX_PREFIX_KEYWORDS = new Set(['await', 'case', 'default', 'delete', 'do', 'else', 'in', 'instanceof', 'new', 'of', 'return', 'throw', 'typeof', 'void', 'yield']);
46
+ const BLOCK_BRACE_PREFIX_KEYWORDS = new Set(['do', 'else', 'finally', 'try']);
47
+
48
+ function isInsideOpeningJsxTag(source) {
49
+ const tagStart = source.lastIndexOf('<');
50
+ if (tagStart === -1 || !/^<[A-Za-z][\w.:-]*/.test(source.slice(tagStart))) return false;
51
+
52
+ let quote = '';
53
+ for (let cursor = tagStart + 1; cursor < source.length; cursor++) {
54
+ const char = source[cursor];
55
+ if (quote) {
56
+ if (char === '\\') cursor++;
57
+ else if (char === quote) quote = '';
58
+ } else if (char === "'" || char === '"') {
59
+ quote = char;
60
+ } else if (char === '>') {
61
+ return false;
62
+ }
63
+ }
64
+ return true;
65
+ }
66
+
67
+ /**
68
+ * Blank JavaScript comments without moving any following source. Regex
69
+ * findings keep their original line numbers, while prose examples inside
70
+ * comments cannot masquerade as rendered markup.
71
+ */
72
+ function stripJsComments(content, options = {}) {
73
+ let state = 'code';
74
+ let output = '';
75
+ let lastSignificant = '';
76
+ let previousSignificant = '';
77
+ let antePreviousSignificant = '';
78
+ let currentWord = '';
79
+ let currentWordPrefix = '';
80
+ let wordSeparated = false;
81
+ let regexCharClass = false;
82
+ let jsxExpressionDepth = 0;
83
+ let lastClosedBraceKind = '';
84
+ const braceKinds = [];
85
+ const templateExpressionDepths = [];
86
+
87
+ const braceKind = (startsJsxExpression = false) => (
88
+ !startsJsxExpression && (
89
+ !lastSignificant ||
90
+ lastSignificant === ')' ||
91
+ lastSignificant === ';' ||
92
+ lastSignificant === '}' ||
93
+ (previousSignificant === '=' && lastSignificant === '>') ||
94
+ BLOCK_BRACE_PREFIX_KEYWORDS.has(currentWord)
95
+ ) ? 'block' : 'expression'
96
+ );
97
+
98
+ const recordSignificant = (char) => {
99
+ if (/\s/.test(char)) {
100
+ wordSeparated = true;
101
+ return;
102
+ }
103
+ const isWordChar = /[\w$]/.test(char);
104
+ if (isWordChar && (wordSeparated || !currentWord)) {
105
+ currentWord = '';
106
+ currentWordPrefix = lastSignificant;
107
+ } else if (!isWordChar) {
108
+ currentWordPrefix = '';
109
+ }
110
+ wordSeparated = false;
111
+ antePreviousSignificant = previousSignificant;
112
+ previousSignificant = lastSignificant;
113
+ lastSignificant = char;
114
+ currentWord = isWordChar ? currentWord + char : '';
115
+ };
116
+
117
+ for (let i = 0; i < content.length; i++) {
118
+ const char = content[i];
119
+ const next = content[i + 1];
120
+
121
+ if (state === 'line-comment') {
122
+ if (char === '\n') {
123
+ output += char;
124
+ state = 'code';
125
+ } else {
126
+ output += ' ';
127
+ }
128
+ continue;
129
+ }
130
+
131
+ if (state === 'block-comment') {
132
+ if (char === '*' && next === '/') {
133
+ output += ' ';
134
+ i++;
135
+ state = 'code';
136
+ } else {
137
+ output += char === '\n' ? '\n' : ' ';
138
+ }
139
+ continue;
140
+ }
141
+
142
+ if (state === 'regex') {
143
+ output += char;
144
+ if (char === '\\' && next) {
145
+ output += next;
146
+ i++;
147
+ } else if (char === '[') {
148
+ regexCharClass = true;
149
+ } else if (char === ']') {
150
+ regexCharClass = false;
151
+ } else if (char === '/' && !regexCharClass) {
152
+ state = 'code';
153
+ recordSignificant('/');
154
+ }
155
+ continue;
156
+ }
157
+
158
+ if (state === 'template' && char === '$' && next === '{') {
159
+ output += '${';
160
+ i++;
161
+ recordSignificant('$');
162
+ recordSignificant('{');
163
+ templateExpressionDepths.push(1);
164
+ braceKinds.push('expression');
165
+ if (jsxExpressionDepth) jsxExpressionDepth++;
166
+ state = 'code';
167
+ continue;
168
+ }
169
+
170
+ if (state !== 'code') {
171
+ output += char;
172
+ if (char === '\\' && next) {
173
+ output += next;
174
+ i++;
175
+ } else if (
176
+ (state === 'single-quote' && char === "'") ||
177
+ (state === 'double-quote' && char === '"') ||
178
+ (state === 'template' && char === '`')
179
+ ) {
180
+ state = 'code';
181
+ recordSignificant(char);
182
+ }
183
+ continue;
184
+ }
185
+
186
+ const jsxUrlSeparator = options.jsx && char === '/' && next === '/' &&
187
+ jsxExpressionDepth === 0 &&
188
+ (output.endsWith('http:') ||
189
+ output.endsWith('https:') ||
190
+ (/<[A-Za-z](?:[^>]*[^/])?>[^<]*$/.test(output.slice(output.lastIndexOf('\n') + 1)) &&
191
+ /^[\w.-]+\.[A-Za-z]{2,}(?=[:/?#\s<]|$)/.test(content.slice(i + 2))));
192
+ const afterPostfixUpdate = (lastSignificant === '+' || lastSignificant === '-') &&
193
+ previousSignificant === lastSignificant &&
194
+ antePreviousSignificant !== lastSignificant;
195
+ if (char === '/' && next === '/' && jsxUrlSeparator) {
196
+ output += '//';
197
+ i++;
198
+ recordSignificant('/');
199
+ recordSignificant('/');
200
+ } else if (char === '/' && next === '/') {
201
+ output += ' ';
202
+ i++;
203
+ state = 'line-comment';
204
+ } else if (char === '/' && next === '*') {
205
+ output += ' ';
206
+ i++;
207
+ state = 'block-comment';
208
+ } else if (templateExpressionDepths.length && char === '{') {
209
+ output += char;
210
+ templateExpressionDepths[templateExpressionDepths.length - 1]++;
211
+ braceKinds.push(braceKind());
212
+ if (jsxExpressionDepth) jsxExpressionDepth++;
213
+ recordSignificant(char);
214
+ } else if (templateExpressionDepths.length && char === '}') {
215
+ output += char;
216
+ const depthIndex = templateExpressionDepths.length - 1;
217
+ templateExpressionDepths[depthIndex]--;
218
+ lastClosedBraceKind = braceKinds.pop() || '';
219
+ if (jsxExpressionDepth) jsxExpressionDepth--;
220
+ recordSignificant(char);
221
+ if (templateExpressionDepths[depthIndex] === 0) {
222
+ templateExpressionDepths.pop();
223
+ state = 'template';
224
+ }
225
+ } else if (
226
+ char === '/' &&
227
+ (!lastSignificant ||
228
+ (/[=([{!?:;,&|+\-*%^~<>]/.test(lastSignificant) && !afterPostfixUpdate) ||
229
+ (lastSignificant === '}' && lastClosedBraceKind === 'block') ||
230
+ (previousSignificant === '=' && lastSignificant === '>') ||
231
+ (currentWordPrefix !== '.' && REGEX_PREFIX_KEYWORDS.has(currentWord)))
232
+ ) {
233
+ output += char;
234
+ state = 'regex';
235
+ regexCharClass = false;
236
+ } else {
237
+ output += char;
238
+ const startsJsxExpression = options.jsx && char === '{' && jsxExpressionDepth === 0 &&
239
+ (/<[A-Za-z](?:[^>]*[^/])?>[^<]*$/.test(output.slice(output.lastIndexOf('\n') + 1, -1)) ||
240
+ isInsideOpeningJsxTag(output.slice(0, -1)));
241
+ if (char === '{') braceKinds.push(braceKind(startsJsxExpression));
242
+ else if (char === '}') lastClosedBraceKind = braceKinds.pop() || '';
243
+ if (char === '{' && (jsxExpressionDepth || startsJsxExpression)) jsxExpressionDepth++;
244
+ else if (char === '}' && jsxExpressionDepth) jsxExpressionDepth--;
245
+ recordSignificant(char);
246
+ if (char === "'") state = 'single-quote';
247
+ else if (char === '"') state = 'double-quote';
248
+ else if (char === '`') state = 'template';
249
+ }
250
+ }
251
+
252
+ return output;
253
+ }
254
+
255
+ function stripCssComments(content) {
256
+ return content.replace(/\/\*[\s\S]*?\*\//g, comment => comment.replace(/[^\n]/g, ' '));
257
+ }
258
+
44
259
  function firstOverusedGoogleFont(text) {
45
260
  return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
46
261
  }
@@ -210,25 +425,28 @@ const REGEX_MATCHERS = [
210
425
  },
211
426
  fmt: (m) => `cubic-bezier(${m[1]}, ${m[2]}, ${m[3]}, ${m[4]})` },
212
427
  // --- Layout property transition ---
213
- { id: 'layout-transition', regex: /transition\s*:\s*([^;{}]+)/gi,
428
+ // JSX inline style objects use comma-delimited quoted values, not semicolons (issue #548).
429
+ { id: 'layout-transition', regex: /transition\s*:\s*(?:(['"])((?:(?!\1)[^\\]|\\.)*)\1|([^;{}]+))/gi,
214
430
  test: (m) => {
215
- const val = m[1].toLowerCase();
431
+ const val = (m[2] ?? m[3] ?? '').toLowerCase();
216
432
  if (/\ball\b/.test(val)) return false;
217
433
  return /\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding\b|\bmargin\b/.test(val);
218
434
  },
219
435
  fmt: (m) => {
220
- const found = m[1].match(/\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding(?:-(?:top|right|bottom|left))?\b|\bmargin(?:-(?:top|right|bottom|left))?\b/gi);
221
- return `transition: ${found ? found.join(', ') : m[1].trim()}`;
436
+ const raw = m[2] ?? m[3] ?? '';
437
+ const found = raw.match(/\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding(?:-(?:top|right|bottom|left))?\b|\bmargin(?:-(?:top|right|bottom|left))?\b/gi);
438
+ return `transition: ${found ? found.join(', ') : raw.trim()}`;
222
439
  } },
223
- { id: 'layout-transition', regex: /transition-property\s*:\s*([^;{}]+)/gi,
440
+ { id: 'layout-transition', regex: /transition-property\s*:\s*(?:(['"])((?:(?!\1)[^\\]|\\.)*)\1|([^;{}]+))/gi,
224
441
  test: (m) => {
225
- const val = m[1].toLowerCase();
442
+ const val = (m[2] ?? m[3] ?? '').toLowerCase();
226
443
  if (/\ball\b/.test(val)) return false;
227
444
  return /\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding\b|\bmargin\b/.test(val);
228
445
  },
229
446
  fmt: (m) => {
230
- const found = m[1].match(/\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding(?:-(?:top|right|bottom|left))?\b|\bmargin(?:-(?:top|right|bottom|left))?\b/gi);
231
- return `transition-property: ${found ? found.join(', ') : m[1].trim()}`;
447
+ const raw = m[2] ?? m[3] ?? '';
448
+ const found = raw.match(/\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding(?:-(?:top|right|bottom|left))?\b|\bmargin(?:-(?:top|right|bottom|left))?\b/gi);
449
+ return `transition-property: ${found ? found.join(', ') : raw.trim()}`;
232
450
  } },
233
451
  // --- Broken image: src="" or src="#" or src=" " ---
234
452
  { id: 'broken-image', regex: /<img\b[^>]*?\bsrc\s*=\s*(?:""|''|"\s+"|'\s+'|"#"|'#')/gi,
@@ -528,18 +746,198 @@ function extractStyleBlocks(content, ext) {
528
746
 
529
747
  const CSS_IN_JS_EXTENSIONS = new Set(['.js', '.ts', '.jsx', '.tsx']);
530
748
 
749
+ function findQuotedStringEnd(content, start, quote) {
750
+ for (let cursor = start + 1; cursor < content.length; cursor++) {
751
+ if (content[cursor] === '\\') cursor++;
752
+ else if (content[cursor] === quote) return cursor;
753
+ }
754
+ return -1;
755
+ }
756
+
757
+ function findRegexLiteralEnd(content, start) {
758
+ let inCharacterClass = false;
759
+ for (let cursor = start + 1; cursor < content.length; cursor++) {
760
+ const char = content[cursor];
761
+ if (char === '\\') {
762
+ cursor++;
763
+ } else if (char === '[') {
764
+ inCharacterClass = true;
765
+ } else if (char === ']') {
766
+ inCharacterClass = false;
767
+ } else if (char === '/' && !inCharacterClass) {
768
+ while (/[A-Za-z]/.test(content[cursor + 1] || '')) cursor++;
769
+ return cursor;
770
+ } else if (char === '\n' || char === '\r') {
771
+ return -1;
772
+ }
773
+ }
774
+ return -1;
775
+ }
776
+
777
+ function findTemplateExpressionEnd(content, start) {
778
+ let depth = 1;
779
+ let lastSignificant = '';
780
+ let previousSignificant = '';
781
+ let antePreviousSignificant = '';
782
+ let currentWord = '';
783
+ let currentWordPrefix = '';
784
+ let wordSeparated = false;
785
+ let lastClosedBraceKind = '';
786
+ const braceKinds = [];
787
+
788
+ const braceKind = () => (
789
+ lastSignificant === ')' ||
790
+ lastSignificant === ';' ||
791
+ lastSignificant === '}' ||
792
+ (previousSignificant === '=' && lastSignificant === '>') ||
793
+ BLOCK_BRACE_PREFIX_KEYWORDS.has(currentWord)
794
+ ? 'block'
795
+ : 'expression'
796
+ );
797
+
798
+ const recordSignificant = (char) => {
799
+ if (/\s/.test(char)) {
800
+ wordSeparated = true;
801
+ return;
802
+ }
803
+ const isWordChar = /[\w$]/.test(char);
804
+ if (isWordChar && (wordSeparated || !currentWord)) {
805
+ currentWord = '';
806
+ currentWordPrefix = lastSignificant;
807
+ } else if (!isWordChar) {
808
+ currentWordPrefix = '';
809
+ }
810
+ wordSeparated = false;
811
+ antePreviousSignificant = previousSignificant;
812
+ previousSignificant = lastSignificant;
813
+ lastSignificant = char;
814
+ currentWord = isWordChar ? currentWord + char : '';
815
+ };
816
+
817
+ for (let cursor = start; cursor < content.length; cursor++) {
818
+ const char = content[cursor];
819
+ const next = content[cursor + 1];
820
+ const afterPostfixUpdate = (lastSignificant === '+' || lastSignificant === '-') &&
821
+ previousSignificant === lastSignificant &&
822
+ antePreviousSignificant !== lastSignificant;
823
+ if (char === "'" || char === '"') {
824
+ cursor = findQuotedStringEnd(content, cursor, char);
825
+ if (cursor === -1) return -1;
826
+ recordSignificant(')');
827
+ } else if (char === '/' && next === '/') {
828
+ const lineEnd = content.indexOf('\n', cursor + 2);
829
+ if (lineEnd === -1) return -1;
830
+ cursor = lineEnd;
831
+ } else if (char === '/' && next === '*') {
832
+ const commentEnd = content.indexOf('*/', cursor + 2);
833
+ if (commentEnd === -1) return -1;
834
+ cursor = commentEnd + 1;
835
+ } else if (
836
+ char === '/' &&
837
+ (!lastSignificant ||
838
+ (/[=([{!?:;,&|+\-*%^~<>]/.test(lastSignificant) && !afterPostfixUpdate) ||
839
+ (lastSignificant === '}' && lastClosedBraceKind === 'block') ||
840
+ (previousSignificant === '=' && lastSignificant === '>') ||
841
+ (currentWordPrefix !== '.' && REGEX_PREFIX_KEYWORDS.has(currentWord)))
842
+ ) {
843
+ cursor = findRegexLiteralEnd(content, cursor);
844
+ if (cursor === -1) return -1;
845
+ recordSignificant(')');
846
+ } else if (char === '`') {
847
+ cursor = findTemplateLiteralEnd(content, cursor);
848
+ if (cursor === -1) return -1;
849
+ recordSignificant(')');
850
+ } else if (char === '{') {
851
+ depth++;
852
+ braceKinds.push(braceKind());
853
+ recordSignificant(char);
854
+ } else if (char === '}') {
855
+ depth--;
856
+ if (depth === 0) return cursor;
857
+ lastClosedBraceKind = braceKinds.pop() || '';
858
+ recordSignificant(char);
859
+ } else {
860
+ recordSignificant(char);
861
+ }
862
+ }
863
+ return -1;
864
+ }
865
+
866
+ function findTemplateLiteralEnd(content, start) {
867
+ for (let cursor = start + 1; cursor < content.length; cursor++) {
868
+ const char = content[cursor];
869
+ if (char === '\\') {
870
+ cursor++;
871
+ } else if (char === '`') {
872
+ return cursor;
873
+ } else if (char === '$' && content[cursor + 1] === '{') {
874
+ cursor = findTemplateExpressionEnd(content, cursor + 2);
875
+ if (cursor === -1) return -1;
876
+ }
877
+ }
878
+ return -1;
879
+ }
880
+
881
+ function findCSSinJSTemplates(content) {
882
+ const templates = [];
883
+ const tagRe = /\b(?:styled(?:\.\w+|\([^)]+\))|css)/g;
884
+ let match;
885
+ while ((match = tagRe.exec(content)) !== null) {
886
+ let cursor = match.index + match[0].length;
887
+ while (/\s/.test(content[cursor] || '')) cursor++;
888
+
889
+ if (content[cursor] === '<') {
890
+ let depth = 0;
891
+ while (cursor < content.length) {
892
+ const char = content[cursor];
893
+ if (char === '<') depth++;
894
+ else if (char === '>' && content[cursor - 1] !== '=') depth--;
895
+ cursor++;
896
+ if (depth === 0) break;
897
+ }
898
+ if (depth !== 0) continue;
899
+ while (/\s/.test(content[cursor] || '')) cursor++;
900
+ }
901
+
902
+ if (content[cursor] !== '`') continue;
903
+ const contentStart = cursor + 1;
904
+ cursor = findTemplateLiteralEnd(content, cursor);
905
+ if (cursor === -1) continue;
906
+
907
+ templates.push({
908
+ tagStart: match.index,
909
+ contentStart,
910
+ contentEnd: cursor,
911
+ });
912
+ tagRe.lastIndex = cursor + 1;
913
+ }
914
+ return templates;
915
+ }
916
+
531
917
  function extractCSSinJS(content, ext) {
532
918
  ext = ext.toLowerCase();
533
919
  if (!CSS_IN_JS_EXTENSIONS.has(ext)) return [];
534
- const blocks = [];
535
- const re = /(?:styled(?:\.\w+|\([^)]+\))|css)\s*`([\s\S]*?)`/g;
536
- let m;
537
- while ((m = re.exec(content)) !== null) {
538
- const before = content.substring(0, m.index);
920
+ return findCSSinJSTemplates(content).map((template) => {
921
+ const before = content.substring(0, template.tagStart);
539
922
  const startLine = before.split('\n').length;
540
- blocks.push({ content: m[1], startLine });
923
+ return {
924
+ content: content.slice(template.contentStart, template.contentEnd),
925
+ startLine,
926
+ };
927
+ });
928
+ }
929
+
930
+ function stripCssInJsComments(content, ext) {
931
+ if (!CSS_IN_JS_EXTENSIONS.has(ext.toLowerCase())) return content;
932
+ const templates = findCSSinJSTemplates(content);
933
+ let output = '';
934
+ let cursor = 0;
935
+ for (const template of templates) {
936
+ output += content.slice(cursor, template.contentStart);
937
+ output += stripCssComments(content.slice(template.contentStart, template.contentEnd));
938
+ cursor = template.contentEnd;
541
939
  }
542
- return blocks;
940
+ return output + content.slice(cursor);
543
941
  }
544
942
 
545
943
  function runRegexMatchers(lines, filePath, lineOffset = 0, blockContext = null, options = {}) {
@@ -627,8 +1025,12 @@ function runTextContentAnalyzers(content, filePath, options = {}) {
627
1025
  function detectText(content, filePath, options = {}) {
628
1026
  const profile = options?.profile;
629
1027
  const findings = [];
630
- const lines = content.split('\n');
631
1028
  const ext = extFromFilePath(filePath);
1029
+ const commentStrippedSource = JS_SOURCE_EXTS.has(ext) ? stripJsComments(content, {
1030
+ jsx: ext === '.js' || ext === '.jsx' || ext === '.tsx',
1031
+ }) : content;
1032
+ const source = stripCssInJsComments(commentStrippedSource, ext);
1033
+ const lines = source.split('\n');
632
1034
 
633
1035
  // Run regex matchers on the full file content (catches Tailwind classes, inline styles)
634
1036
  // Enable block context for CSS files where related properties span multiple lines
@@ -661,8 +1063,8 @@ function detectText(content, filePath, options = {}) {
661
1063
  phase: 'source',
662
1064
  ruleId: 'codex-grid-background',
663
1065
  target: filePath,
664
- }, () => scanCssTextForGridBackground(content).map(hit => {
665
- const line = content.substring(0, hit.index).split('\n').length;
1066
+ }, () => scanCssTextForGridBackground(source).map(hit => {
1067
+ const line = source.substring(0, hit.index).split('\n').length;
666
1068
  return finding('codex-grid-background', filePath, hit.snippet, line);
667
1069
  })));
668
1070
 
@@ -698,16 +1100,17 @@ function detectText(content, filePath, options = {}) {
698
1100
  phase: 'extract',
699
1101
  ruleId: 'css-in-js',
700
1102
  target: filePath,
701
- }, () => extractCSSinJS(content, ext))
702
- : extractCSSinJS(content, ext);
1103
+ }, () => extractCSSinJS(source, ext))
1104
+ : extractCSSinJS(source, ext);
703
1105
  for (const block of cssJsBlocks) {
704
- const blockLines = block.content.split('\n');
1106
+ const blockContent = stripCssComments(block.content);
1107
+ const blockLines = blockContent.split('\n');
705
1108
  findings.push(...runRegexMatchers(blockLines, filePath, block.startLine - 1, true, {
706
1109
  profile,
707
1110
  phase: 'css-in-js',
708
1111
  }));
709
- findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
710
- findings.push(...pseudoStripeFindings(block.content, block.startLine - 1));
1112
+ findings.push(...scanInsetStripeCss(blockContent, filePath, block.startLine - 1));
1113
+ findings.push(...pseudoStripeFindings(blockContent, block.startLine - 1));
711
1114
  }
712
1115
 
713
1116
  if (options?.designSystem) {
@@ -226,6 +226,10 @@ const STATIC_INHERITED_PROPS = new Set([
226
226
  'color', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'fontVariant',
227
227
  'lineHeight', 'letterSpacing', 'textTransform', 'textAlign', 'hyphens',
228
228
  'webkitHyphens',
229
+ // visibility inherits in real CSS, and the invisible-at-rest contrast skip
230
+ // relies on descendants of a hidden container computing as hidden. A child
231
+ // that declares `visibility: visible` still overrides the inherited value.
232
+ 'visibility',
229
233
  ]);
230
234
 
231
235
  const STATIC_DEFAULT_STYLE = {
@@ -278,6 +282,7 @@ const STATIC_DEFAULT_STYLE = {
278
282
  marginLeft: '0px',
279
283
  position: 'static',
280
284
  visibility: 'visible',
285
+ opacity: '1',
281
286
  top: 'auto',
282
287
  right: 'auto',
283
288
  bottom: 'auto',
@@ -334,6 +339,7 @@ const STATIC_PROP_MAP = {
334
339
  'margin-left': 'marginLeft',
335
340
  'position': 'position',
336
341
  'visibility': 'visibility',
342
+ 'opacity': 'opacity',
337
343
  'top': 'top',
338
344
  'right': 'right',
339
345
  'bottom': 'bottom',
@@ -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,
@@ -138,10 +139,21 @@ async function detectHtml(filePath, options = {}) {
138
139
  domutils,
139
140
  };
140
141
  });
141
- } catch {
142
- return detectText(html, filePath, options);
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
+ );
143
152
  }
144
153
 
154
+ return detectText(html, filePath, options);
155
+ }
156
+
145
157
  const resolvedPath = path.resolve(filePath);
146
158
  const fileDir = path.dirname(resolvedPath);
147
159
  const root = profileStep(profile, {
@@ -171,6 +183,9 @@ async function detectHtml(filePath, options = {}) {
171
183
  const tag = el.tagName.toLowerCase();
172
184
  const style = window.getComputedStyle(el);
173
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;
174
189
  findings.push(finding(f.id, filePath, f.snippet));
175
190
  }
176
191
  }
@@ -238,6 +253,17 @@ async function detectHtml(filePath, options = {}) {
238
253
  for (const f of runPageCheck('html-patterns', () => checkHtmlPatterns(html, patternCorpora).filter(item =>
239
254
  item.id !== 'bounce-easing' && item.id !== 'layout-transition'
240
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
+ }
241
267
  const item = finding(f.id, filePath, f.snippet);
242
268
  // Position-aware severity promotion: checks may attach a per-finding
243
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 (SCANNABLE_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) files.push(full);
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
- // ES imports: import ... from '...' and import '...'
79
- const esRe = /import\s+(?:[\s\S]*?from\s+)?['"]([^'"]+)['"]/g;
80
- let m;
81
- while ((m = esRe.exec(content)) !== null) {
82
- const resolved = resolveImport(m[1], dir, fileSet);
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,