impeccable 3.2.0 → 3.3.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.
@@ -3,9 +3,36 @@ import path from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
 
5
5
  import { finding } from '../../findings.mjs';
6
- import { filterByProviders } from '../../registry/antipatterns.mjs';
7
6
  import { profileFindingsAsync, profileStep, profileStepAsync } from '../../profile/profiler.mjs';
8
7
  import { captureVisualContrastCandidate } from '../visual/screenshot-contrast.mjs';
8
+ import { checkContentHiddenAtRest } from '../../rules/checks.mjs';
9
+
10
+ // Reveal sweep + invisible-text measurement for the content-hidden-at-rest
11
+ // rule. Scrolls through the document with instant jumps (bypasses CSS
12
+ // scroll-behavior: smooth) so IntersectionObserver / scroll reveal handlers
13
+ // get every chance to fire, returns to the top, lets transitions settle,
14
+ // then measures how much text still renders invisible. A healthy
15
+ // reveal-on-scroll page drops to ~0 after the sweep; a page whose reveal
16
+ // script died keeps most of its text at opacity 0.
17
+ async function measureContentHiddenAfterReveal(page) {
18
+ await page.evaluate(async () => {
19
+ const step = Math.max(200, Math.floor(window.innerHeight * 0.7));
20
+ const max = Math.max(
21
+ document.documentElement.scrollHeight || 0,
22
+ document.body?.scrollHeight || 0,
23
+ );
24
+ for (let y = 0; y <= max; y += step) {
25
+ window.scrollTo({ top: y, left: 0, behavior: 'instant' });
26
+ await new Promise(resolve => requestAnimationFrame(() => setTimeout(resolve, 40)));
27
+ }
28
+ window.scrollTo({ top: 0, left: 0, behavior: 'instant' });
29
+ await new Promise(resolve => setTimeout(resolve, 700));
30
+ });
31
+ return page.evaluate(() => {
32
+ if (typeof window.impeccableMeasureHiddenText !== 'function') return null;
33
+ return window.impeccableMeasureHiddenText();
34
+ });
35
+ }
9
36
 
10
37
  function serializeDesignSystemForBrowser(designSystem) {
11
38
  if (!designSystem?.present) return null;
@@ -158,6 +185,19 @@ async function detectUrl(url, options = {}) {
158
185
  ruleId: 'new-page',
159
186
  target: url,
160
187
  }, () => browser.newPage());
188
+
189
+ // Uncaught exceptions and parse errors surface as pageerror events. The
190
+ // listener must attach before goto: a syntax error fires during the
191
+ // initial parse, long before the load event. Dedupe by message; a single
192
+ // broken loop can otherwise throw hundreds of identical errors.
193
+ const pageErrors = [];
194
+ if (options?.scriptErrors !== false) {
195
+ page.on('pageerror', (err) => {
196
+ const message = String(err?.message || err).split('\n')[0].trim().slice(0, 160);
197
+ if (message && !pageErrors.includes(message)) pageErrors.push(message);
198
+ });
199
+ }
200
+
161
201
  let results = [];
162
202
  try {
163
203
  await profileStepAsync(profile, {
@@ -213,9 +253,29 @@ async function detectUrl(url, options = {}) {
213
253
  return window.impeccableDetect({ decorate: false, serialize: true });
214
254
  });
215
255
  return serializedGroups.flatMap(({ findings }) =>
216
- findings.map(f => ({ id: f.type, snippet: f.detail, ignoreValue: f.ignoreValue || '' }))
256
+ findings.map(f => ({ id: f.type, snippet: f.detail, ignoreValue: f.ignoreValue || '', severity: f.severity || '' }))
217
257
  );
218
258
  });
259
+ // Content invisible at rest: reveal sweep, then re-measure. Runs after
260
+ // the main scan (which must see the true at-rest state) and before the
261
+ // visual contrast fallback (the sweep restores scroll to the top).
262
+ if (options?.contentHidden !== false) {
263
+ const hiddenFindings = await profileFindingsAsync(profile, {
264
+ engine: 'browser',
265
+ phase: 'scan',
266
+ ruleId: 'content-hidden-at-rest',
267
+ target: url,
268
+ }, async () => {
269
+ const measured = await measureContentHiddenAfterReveal(page);
270
+ return measured ? checkContentHiddenAtRest(measured) : [];
271
+ });
272
+ results.push(...hiddenFindings);
273
+ }
274
+
275
+ for (const message of pageErrors.slice(0, 3)) {
276
+ results.push({ id: 'script-error', snippet: message });
277
+ }
278
+
219
279
  const visualFindings = await runVisualContrastFallback(page, serializedGroups, options, profile, url);
220
280
  results.push(...visualFindings);
221
281
  } finally {
@@ -234,11 +294,14 @@ async function detectUrl(url, options = {}) {
234
294
  }, () => browser.close());
235
295
  }
236
296
  }
237
- return filterByProviders(results.map(f => {
297
+ return results.map(f => {
238
298
  const item = finding(f.id, url, f.snippet);
239
299
  if (f.ignoreValue) item.ignoreValue = f.ignoreValue;
300
+ // Per-finding severity promotion (e.g. hero-region pulsing dot)
301
+ // overrides the registry default carried by finding().
302
+ if (f.severity && f.severity !== item.severity) item.severity = f.severity;
240
303
  return item;
241
- }), options.providers);
304
+ });
242
305
  }
243
306
 
244
307
  async function createBrowserDetector(options = {}) {
@@ -1,10 +1,11 @@
1
- import { GENERIC_FONTS } from '../../shared/constants.mjs';
1
+ import { GENERIC_FONTS, OVERUSED_FONTS } from '../../shared/constants.mjs';
2
2
  import { isNeutralColor } from '../../shared/color.mjs';
3
+ import { extractGoogleFontFamilies } from '../../shared/fonts.mjs';
3
4
  import { checkSourceDesignSystem } from '../../design-system.mjs';
5
+ import { scanCssTextForGlow, scanCssTextForGridBackground, scanCssTextForMarquee, scanCssTextForRadialHalo } from '../../rules/checks.mjs';
4
6
  import { isFullPage } from '../../shared/page.mjs';
5
7
  import { applyInlineIgnores } from '../../shared/inline-ignores.mjs';
6
8
  import { finding } from '../../findings.mjs';
7
- import { filterByProviders } from '../../registry/antipatterns.mjs';
8
9
  import { profileFindings, profileStep } from '../../profile/profiler.mjs';
9
10
 
10
11
  // ---------------------------------------------------------------------------
@@ -38,25 +39,100 @@ function shouldRunPageAnalyzers(content, filePath) {
38
39
  return !ext || PAGE_ANALYZER_EXTS.has(ext);
39
40
  }
40
41
 
41
- function isNeutralBorderColor(str) {
42
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
43
- if (!m) return false;
44
- const c = m[1].toLowerCase();
45
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
46
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
47
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
48
- if (hex) {
49
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
50
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
42
+ function firstOverusedGoogleFont(text) {
43
+ return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
44
+ }
45
+
46
+ // CSS named colors whose channels are equal (achromatic). Anything outside
47
+ // this set falls through to the format parsers, and an unrecognized spelling
48
+ // stays non-neutral so a real accent is never skipped.
49
+ const NEUTRAL_COLOR_KEYWORDS = new Set([
50
+ 'transparent', 'currentcolor',
51
+ 'black', 'white', 'gray', 'grey', 'silver',
52
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
53
+ 'gainsboro', 'whitesmoke',
54
+ ]);
55
+
56
+ function hexChannels(color) {
57
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
58
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
59
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
60
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
61
+ return null;
62
+ }
63
+
64
+ /**
65
+ * Split one box-shadow layer into top-level tokens.
66
+ *
67
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
68
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
69
+ * read their innards as separate lengths.
70
+ */
71
+ function tokenizeShadowLayer(layer) {
72
+ const tokens = [];
73
+ let depth = 0;
74
+ let current = '';
75
+ for (const char of String(layer || '')) {
76
+ if (char === '(') depth++;
77
+ else if (char === ')') depth--;
78
+ else if (depth === 0 && /\s/.test(char)) {
79
+ if (current) tokens.push(current);
80
+ current = '';
81
+ continue;
82
+ }
83
+ current += char;
51
84
  }
52
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
53
- if (shex) {
54
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
55
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
85
+ if (current) tokens.push(current);
86
+ return tokens;
87
+ }
88
+
89
+ function lastMatch(text, re) {
90
+ const all = [...String(text || '').matchAll(re)];
91
+ return all.length ? all[all.length - 1] : null;
92
+ }
93
+
94
+ function isShadowLength(token) {
95
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
96
+ }
97
+
98
+ /**
99
+ * Neutrality test for colors as written in source CSS.
100
+ *
101
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
102
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
103
+ * other spelling as chromatic so an unknown format is never silently skipped.
104
+ * That default is wrong for authored CSS, where `#000` and `black` are the
105
+ * normal spellings: calling it directly reports a plain black hairline as a
106
+ * colored stripe. Handle hex and named neutrals here, then defer.
107
+ */
108
+ function isNeutralAuthoredColor(rawColor) {
109
+ const c = String(rawColor || '').trim().toLowerCase();
110
+ if (!c) return false;
111
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
112
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
113
+ // parses only the comma form a browser's getComputedStyle emits, so authored
114
+ // space-separated neutrals fell through it and reported as chromatic — the
115
+ // exemption this function exists for, missed. Normalize before delegating.
116
+ if (/^rgba?\(/i.test(c)) {
117
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
118
+ if (channels) {
119
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
120
+ return (Math.max(...values) - Math.min(...values)) < 30;
121
+ }
122
+ return isNeutralColor(c);
56
123
  }
124
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
125
+ const channels = hexChannels(c);
126
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
57
127
  return false;
58
128
  }
59
129
 
130
+ function isNeutralBorderColor(str) {
131
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
132
+ if (!m) return false;
133
+ return isNeutralAuthoredColor(m[1]);
134
+ }
135
+
60
136
  const REGEX_MATCHERS = [
61
137
  // --- Side-tab ---
62
138
  { id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -88,9 +164,12 @@ const REGEX_MATCHERS = [
88
164
  { id: 'overused-font', regex: /font-family\s*:\s*['"]?(Inter|Roboto|Open Sans|Lato|Montserrat|Arial|Helvetica|Fraunces|Geist Sans|Geist Mono|Geist|Mona Sans|Plus Jakarta Sans|Space Grotesk|Recoleta|Instrument Sans|Instrument Serif)\b/gi,
89
165
  test: () => true,
90
166
  fmt: (m) => m[0] },
91
- { id: 'overused-font', regex: /fonts\.googleapis\.com\/css2?\?family=(Inter|Roboto|Open\+Sans|Lato|Montserrat|Fraunces|Plus\+Jakarta\+Sans|Space\+Grotesk|Instrument\+Sans|Instrument\+Serif|Mona\+Sans|Geist)\b/gi,
92
- test: () => true,
93
- fmt: (m) => `Google Fonts: ${m[1].replace(/\+/g, ' ')}` },
167
+ { id: 'overused-font', regex: /fonts\.googleapis\.com\/css2?\?[^"'\s)<>]*/gi,
168
+ test: (m) => {
169
+ m.overusedGoogleFont = firstOverusedGoogleFont(m[0]);
170
+ return Boolean(m.overusedGoogleFont);
171
+ },
172
+ fmt: (m) => `Google Fonts: ${m.overusedGoogleFont || firstOverusedGoogleFont(m[0])}` },
94
173
  // --- Gradient text ---
95
174
  { id: 'gradient-text', regex: /background-clip\s*:\s*text|-webkit-background-clip\s*:\s*text/gi,
96
175
  test: (m, line) => /gradient/i.test(line),
@@ -170,10 +249,7 @@ const REGEX_ANALYZERS = [
170
249
  if (f && !GENERIC_FONTS.has(f)) fonts.add(f);
171
250
  }
172
251
  }
173
- const gfRe = /fonts\.googleapis\.com\/css2?\?family=([^&"'\s]+)/gi;
174
- while ((m = gfRe.exec(content)) !== null) {
175
- for (const f of m[1].split('|').map(f => f.split(':')[0].replace(/\+/g, ' ').toLowerCase())) fonts.add(f);
176
- }
252
+ for (const f of extractGoogleFontFamilies(content)) fonts.add(f);
177
253
  if (fonts.size !== 1 || content.split('\n').length < 20) return [];
178
254
  const name = [...fonts][0];
179
255
  const lines = content.split('\n');
@@ -274,22 +350,6 @@ const REGEX_ANALYZERS = [
274
350
  if (count === 0) return [];
275
351
  return [finding('marketing-buzzword', filePath, `${count} buzzword phrase${count === 1 ? '' : 's'}: "${firstSample}"`)];
276
352
  },
277
- // Numbered section markers (01 / 02 / 03 ...)
278
- (content, filePath) => {
279
- const text = stripHtmlToText(content);
280
- const re = /\b(0[1-9]|1[0-2])\b/g;
281
- const seen = new Set();
282
- let m;
283
- while ((m = re.exec(text)) !== null) seen.add(m[1]);
284
- if (seen.size < 3) return [];
285
- const sorted = [...seen].sort();
286
- let sequential = 0;
287
- for (let i = 1; i < sorted.length; i++) {
288
- if (parseInt(sorted[i], 10) === parseInt(sorted[i - 1], 10) + 1) sequential++;
289
- }
290
- if (sequential < 2) return [];
291
- return [finding('numbered-section-markers', filePath, `Sequence: ${sorted.slice(0, 6).join(', ')}`)];
292
- },
293
353
  // Aphoristic cadence: manufactured-contrast + short-rebuttal
294
354
  (content, filePath) => {
295
355
  const text = stripHtmlToText(content);
@@ -311,41 +371,143 @@ const REGEX_ANALYZERS = [
311
371
  if (count < 3) return [];
312
372
  return [finding('aphoristic-cadence', filePath, `${count} aphoristic constructions: "${firstSample}"`)];
313
373
  },
314
- // Dark glow (page-level: dark bg + colored box-shadow with blur)
374
+ // Dark glow / chromatic halo shadows (page-level). Shared scanner handles
375
+ // any color format, single-level var() resolution, zero-offset halos on
376
+ // any background, and text-shadow glows.
315
377
  (content, filePath) => {
316
- // Check if page has a dark background
317
- const darkBgRe = /background(?:-color)?\s*:\s*(?:#(?:0[0-9a-f]|1[0-9a-f]|2[0-3])[0-9a-f]{4}\b|#(?:0|1)[0-9a-f]{2}\b|rgb\(\s*(\d{1,2})\s*,\s*(\d{1,2})\s*,\s*(\d{1,2})\s*\))/gi;
318
- const twDarkBg = /\bbg-(?:gray|slate|zinc|neutral|stone)-(?:9\d{2}|800)\b/;
319
- const hasDarkBg = darkBgRe.test(content) || twDarkBg.test(content);
320
- if (!hasDarkBg) return [];
321
-
322
- // Check for colored box-shadow with blur > 4px
323
- const shadowRe = /box-shadow\s*:\s*([^;{}]+)/gi;
324
- let m;
325
- while ((m = shadowRe.exec(content)) !== null) {
326
- const val = m[1];
327
- const colorMatch = val.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
328
- if (!colorMatch) continue;
329
- const [r, g, b] = [+colorMatch[1], +colorMatch[2], +colorMatch[3]];
330
- if ((Math.max(r, g, b) - Math.min(r, g, b)) < 30) continue; // skip gray
331
- // Check blur: look for pattern like "0 0 20px" (third number > 4)
332
- const pxVals = [...val.matchAll(/(\d+)px|(?<![.\d])\b(0)\b(?![.\d])/g)].map(p => +(p[1] || p[2]));
333
- if (pxVals.length >= 3 && pxVals[2] > 4) {
334
- const lines = content.substring(0, m.index).split('\n');
335
- return [finding('dark-glow', filePath, `Colored glow (rgb(${r},${g},${b})) on dark page`, lines.length)];
336
- }
337
- }
338
- return [];
378
+ const hits = scanCssTextForGlow(content);
379
+ if (hits.length === 0) return [];
380
+ const lines = content.substring(0, hits[0].index).split('\n');
381
+ return [finding('dark-glow', filePath, hits[0].snippet, lines.length)];
382
+ },
383
+ // Radial-gradient background halo on a dark page (the gradient sibling
384
+ // of the dark-glow shadow tell).
385
+ (content, filePath) => {
386
+ const hits = scanCssTextForRadialHalo(content);
387
+ if (hits.length === 0) return [];
388
+ const lines = content.substring(0, hits[0].index).split('\n');
389
+ return [finding('radial-halo', filePath, hits[0].snippet, lines.length)];
339
390
  },
391
+ // Auto-scrolling marquees (<marquee> or infinite horizontal loop
392
+ // animations).
393
+ (content, filePath) => scanCssTextForMarquee(content).map(hit => finding('marquee', filePath, hit.snippet)),
340
394
  ];
341
395
 
342
396
  // ---------------------------------------------------------------------------
343
- // Style block extraction (Vue/Svelte <style> blocks)
397
+ // Structural CSS checks used by source files whose styles are not parsed by
398
+ // the static HTML engine.
399
+ // ---------------------------------------------------------------------------
400
+
401
+ const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
402
+
403
+ function insetStripeColorIsChromatic(rawColor) {
404
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
405
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
406
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
407
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
408
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
409
+ return !isNeutralAuthoredColor(color);
410
+ }
411
+
412
+ /**
413
+ * Blank out comment bodies while preserving every byte offset (and therefore
414
+ * every line number) so commented-out CSS is not scanned as live rules.
415
+ */
416
+ function blankCssComments(css) {
417
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
418
+ }
419
+
420
+ function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
421
+ const content = blankCssComments(rawContent);
422
+ const findings = [];
423
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
424
+ let match;
425
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
426
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
427
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
428
+ let scanOffset = 0;
429
+ let scanLine = 1;
430
+ const lineAtOffset = (offset) => {
431
+ while (scanOffset < offset) {
432
+ if (content[scanOffset] === '\n') scanLine++;
433
+ scanOffset++;
434
+ }
435
+ return scanLine;
436
+ };
437
+ while ((match = ruleRe.exec(content)) !== null) {
438
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
439
+ // newlines trailing the previous rule. Advance past that run before deriving
440
+ // the line, or every rule after the first reports the preceding line.
441
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
442
+ const selector = match[1].trim().replace(/\s+/g, ' ');
443
+ if (!selector) continue;
444
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
445
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
446
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
447
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
448
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
449
+
450
+ // Read the last of a repeated declaration, not the first: that is what the
451
+ // cascade paints. Taking the first both flagged stripes that a later
452
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
453
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
454
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
455
+ if (width && Number(width[1]) <= 40) continue;
456
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
457
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
458
+ // `!important` qualifies the declaration, not the shadow value, so strip it
459
+ // before the layers are read. Tokenizing split it into its own token, which
460
+ // made the color count wrong and silently stopped flagging stripes declared
461
+ // with it — a shape the previous regex handled.
462
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
463
+
464
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
465
+ const layer = rawLayer.trim();
466
+ // Parse the layer by its grammar rather than by one spelling of it.
467
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
468
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
469
+ // all paint the same stripe. Matching a fixed token order missed three
470
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
471
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
472
+ // whitespace would read its channels as lengths.
473
+ const tokens = tokenizeShadowLayer(layer);
474
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
475
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
476
+ const lengths = rest.filter(isShadowLength);
477
+ const colors = rest.filter((token) => !isShadowLength(token));
478
+ // Only the two offsets are required; omitted blur/spread default to 0,
479
+ // which is exactly the stripe shape. More than one non-length token is a
480
+ // layer shape we do not claim to understand, so leave it alone.
481
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
482
+ const values = lengths.map((token) => ({
483
+ n: Number(token.replace(/px$/i, '')),
484
+ hasPx: /px$/i.test(token),
485
+ }));
486
+ const x = values[0];
487
+ const y = values[1];
488
+ const blur = values[2] ? values[2].n : 0;
489
+ const spread = values[3] ? values[3].n : 0;
490
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
491
+ const ax = Math.abs(x.n);
492
+ const ay = Math.abs(y.n);
493
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
494
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
495
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
496
+ const line = lineOffset + lineAtOffset(selectorStart);
497
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
498
+ break;
499
+ }
500
+ }
501
+ return findings;
502
+ }
503
+
504
+ // ---------------------------------------------------------------------------
505
+ // Style block extraction (Astro/Vue/Svelte <style> blocks)
344
506
  // ---------------------------------------------------------------------------
345
507
 
346
508
  function extractStyleBlocks(content, ext) {
347
509
  ext = ext.toLowerCase();
348
- if (ext !== '.vue' && ext !== '.svelte') return [];
510
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
349
511
  const blocks = [];
350
512
  const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
351
513
  let m;
@@ -430,21 +592,20 @@ function runRegexMatchers(lines, filePath, lineOffset = 0, blockContext = null,
430
592
  }
431
593
 
432
594
  /** Page-level analyzers that scan rendered text content (em-dash use,
433
- * buzzword phrases, numbered section markers, aphoristic cadence).
595
+ * buzzword phrases, aphoristic cadence).
434
596
  * These are detector-agnostic — they work on any HTML/text source
435
597
  * and don't need a parsed DOM. Exported so detectHtml can call them
436
598
  * for `.html` files (which otherwise skip the regex engine). */
437
599
  const TEXT_CONTENT_ANALYZER_IDS = [
438
600
  'em-dash-overuse',
439
601
  'marketing-buzzword',
440
- 'numbered-section-markers',
441
602
  'aphoristic-cadence',
442
603
  ];
443
604
 
444
605
  function runTextContentAnalyzers(content, filePath, options = {}) {
445
606
  const profile = options?.profile;
446
607
  if (!shouldRunPageAnalyzers(content, filePath)) return [];
447
- // The 4 text-content analyzers are at indices 3-6 in REGEX_ANALYZERS.
608
+ // The 3 text-content analyzers are at indices 3-5 in REGEX_ANALYZERS.
448
609
  const findings = [];
449
610
  for (let i = 0; i < TEXT_CONTENT_ANALYZER_IDS.length; i++) {
450
611
  const analyzer = REGEX_ANALYZERS[3 + i];
@@ -472,8 +633,22 @@ function detectText(content, filePath, options = {}) {
472
633
  profile,
473
634
  phase: 'source',
474
635
  }));
636
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
637
+
638
+ // Block-level CSS checks that need multiple declarations must run over the
639
+ // complete source, not line-by-line. This covers standalone stylesheets,
640
+ // component style blocks, inline styles, and CSS-in-JS templates.
641
+ findings.push(...profileFindings(profile, {
642
+ engine: 'regex',
643
+ phase: 'source',
644
+ ruleId: 'codex-grid-background',
645
+ target: filePath,
646
+ }, () => scanCssTextForGridBackground(content).map(hit => {
647
+ const line = content.substring(0, hit.index).split('\n').length;
648
+ return finding('codex-grid-background', filePath, hit.snippet, line);
649
+ })));
475
650
 
476
- // Extract and scan <style> blocks from Vue/Svelte SFCs
651
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
477
652
  const styleBlocks = profile
478
653
  ? profileStep(profile, {
479
654
  engine: 'regex',
@@ -488,6 +663,13 @@ function detectText(content, filePath, options = {}) {
488
663
  profile,
489
664
  phase: 'style-block',
490
665
  }));
666
+ // block.startLine is the first line *after* the <style> tag, but block.content
667
+ // begins at the character right after that tag — so its own line 1 sits on the
668
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
669
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
670
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
671
+ // because it indexes its split lines from zero.
672
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
491
673
  }
492
674
 
493
675
  // Extract and scan CSS-in-JS template literals
@@ -505,6 +687,7 @@ function detectText(content, filePath, options = {}) {
505
687
  profile,
506
688
  phase: 'css-in-js',
507
689
  }));
690
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
508
691
  }
509
692
 
510
693
  if (options?.designSystem) {
@@ -535,7 +718,6 @@ function detectText(content, filePath, options = {}) {
535
718
  'monotonous-spacing',
536
719
  'em-dash-overuse',
537
720
  'marketing-buzzword',
538
- 'numbered-section-markers',
539
721
  'aphoristic-cadence',
540
722
  'dark-glow',
541
723
  ];
@@ -550,10 +732,9 @@ function detectText(content, filePath, options = {}) {
550
732
  }
551
733
  }
552
734
 
553
- const byProvider = filterByProviders(deduped, options?.providers);
554
735
  // Inline `impeccable-disable*` waivers travel with the file; honor them unless
555
736
  // explicitly bypassed (`--no-config` / `--no-inline-ignores`).
556
- return options?.inlineIgnores === false ? byProvider : applyInlineIgnores(byProvider, content);
737
+ return options?.inlineIgnores === false ? deduped : applyInlineIgnores(deduped, content);
557
738
  }
558
739
 
559
740
  export {