impeccable 3.2.1 → 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 = {}) {
@@ -2,10 +2,10 @@ import { GENERIC_FONTS, OVERUSED_FONTS } from '../../shared/constants.mjs';
2
2
  import { isNeutralColor } from '../../shared/color.mjs';
3
3
  import { extractGoogleFontFamilies } from '../../shared/fonts.mjs';
4
4
  import { checkSourceDesignSystem } from '../../design-system.mjs';
5
+ import { scanCssTextForGlow, scanCssTextForGridBackground, scanCssTextForMarquee, scanCssTextForRadialHalo } from '../../rules/checks.mjs';
5
6
  import { isFullPage } from '../../shared/page.mjs';
6
7
  import { applyInlineIgnores } from '../../shared/inline-ignores.mjs';
7
8
  import { finding } from '../../findings.mjs';
8
- import { filterByProviders } from '../../registry/antipatterns.mjs';
9
9
  import { profileFindings, profileStep } from '../../profile/profiler.mjs';
10
10
 
11
11
  // ---------------------------------------------------------------------------
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
43
43
  return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
44
44
  }
45
45
 
46
- function isNeutralBorderColor(str) {
47
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
48
- if (!m) return false;
49
- const c = m[1].toLowerCase();
50
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
51
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
52
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
53
- if (hex) {
54
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
55
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
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;
56
84
  }
57
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
58
- if (shex) {
59
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
60
- 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);
61
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;
62
127
  return false;
63
128
  }
64
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
+
65
136
  const REGEX_MATCHERS = [
66
137
  // --- Side-tab ---
67
138
  { id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -279,22 +350,6 @@ const REGEX_ANALYZERS = [
279
350
  if (count === 0) return [];
280
351
  return [finding('marketing-buzzword', filePath, `${count} buzzword phrase${count === 1 ? '' : 's'}: "${firstSample}"`)];
281
352
  },
282
- // Numbered section markers (01 / 02 / 03 ...)
283
- (content, filePath) => {
284
- const text = stripHtmlToText(content);
285
- const re = /\b(0[1-9]|1[0-2])\b/g;
286
- const seen = new Set();
287
- let m;
288
- while ((m = re.exec(text)) !== null) seen.add(m[1]);
289
- if (seen.size < 3) return [];
290
- const sorted = [...seen].sort();
291
- let sequential = 0;
292
- for (let i = 1; i < sorted.length; i++) {
293
- if (parseInt(sorted[i], 10) === parseInt(sorted[i - 1], 10) + 1) sequential++;
294
- }
295
- if (sequential < 2) return [];
296
- return [finding('numbered-section-markers', filePath, `Sequence: ${sorted.slice(0, 6).join(', ')}`)];
297
- },
298
353
  // Aphoristic cadence: manufactured-contrast + short-rebuttal
299
354
  (content, filePath) => {
300
355
  const text = stripHtmlToText(content);
@@ -316,41 +371,143 @@ const REGEX_ANALYZERS = [
316
371
  if (count < 3) return [];
317
372
  return [finding('aphoristic-cadence', filePath, `${count} aphoristic constructions: "${firstSample}"`)];
318
373
  },
319
- // 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.
320
377
  (content, filePath) => {
321
- // Check if page has a dark background
322
- 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;
323
- const twDarkBg = /\bbg-(?:gray|slate|zinc|neutral|stone)-(?:9\d{2}|800)\b/;
324
- const hasDarkBg = darkBgRe.test(content) || twDarkBg.test(content);
325
- if (!hasDarkBg) return [];
326
-
327
- // Check for colored box-shadow with blur > 4px
328
- const shadowRe = /box-shadow\s*:\s*([^;{}]+)/gi;
329
- let m;
330
- while ((m = shadowRe.exec(content)) !== null) {
331
- const val = m[1];
332
- const colorMatch = val.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
333
- if (!colorMatch) continue;
334
- const [r, g, b] = [+colorMatch[1], +colorMatch[2], +colorMatch[3]];
335
- if ((Math.max(r, g, b) - Math.min(r, g, b)) < 30) continue; // skip gray
336
- // Check blur: look for pattern like "0 0 20px" (third number > 4)
337
- const pxVals = [...val.matchAll(/(\d+)px|(?<![.\d])\b(0)\b(?![.\d])/g)].map(p => +(p[1] || p[2]));
338
- if (pxVals.length >= 3 && pxVals[2] > 4) {
339
- const lines = content.substring(0, m.index).split('\n');
340
- return [finding('dark-glow', filePath, `Colored glow (rgb(${r},${g},${b})) on dark page`, lines.length)];
341
- }
342
- }
343
- 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)];
344
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)];
390
+ },
391
+ // Auto-scrolling marquees (<marquee> or infinite horizontal loop
392
+ // animations).
393
+ (content, filePath) => scanCssTextForMarquee(content).map(hit => finding('marquee', filePath, hit.snippet)),
345
394
  ];
346
395
 
347
396
  // ---------------------------------------------------------------------------
348
- // 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)
349
506
  // ---------------------------------------------------------------------------
350
507
 
351
508
  function extractStyleBlocks(content, ext) {
352
509
  ext = ext.toLowerCase();
353
- if (ext !== '.vue' && ext !== '.svelte') return [];
510
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
354
511
  const blocks = [];
355
512
  const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
356
513
  let m;
@@ -435,21 +592,20 @@ function runRegexMatchers(lines, filePath, lineOffset = 0, blockContext = null,
435
592
  }
436
593
 
437
594
  /** Page-level analyzers that scan rendered text content (em-dash use,
438
- * buzzword phrases, numbered section markers, aphoristic cadence).
595
+ * buzzword phrases, aphoristic cadence).
439
596
  * These are detector-agnostic — they work on any HTML/text source
440
597
  * and don't need a parsed DOM. Exported so detectHtml can call them
441
598
  * for `.html` files (which otherwise skip the regex engine). */
442
599
  const TEXT_CONTENT_ANALYZER_IDS = [
443
600
  'em-dash-overuse',
444
601
  'marketing-buzzword',
445
- 'numbered-section-markers',
446
602
  'aphoristic-cadence',
447
603
  ];
448
604
 
449
605
  function runTextContentAnalyzers(content, filePath, options = {}) {
450
606
  const profile = options?.profile;
451
607
  if (!shouldRunPageAnalyzers(content, filePath)) return [];
452
- // 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.
453
609
  const findings = [];
454
610
  for (let i = 0; i < TEXT_CONTENT_ANALYZER_IDS.length; i++) {
455
611
  const analyzer = REGEX_ANALYZERS[3 + i];
@@ -477,8 +633,22 @@ function detectText(content, filePath, options = {}) {
477
633
  profile,
478
634
  phase: 'source',
479
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
+ })));
480
650
 
481
- // Extract and scan <style> blocks from Vue/Svelte SFCs
651
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
482
652
  const styleBlocks = profile
483
653
  ? profileStep(profile, {
484
654
  engine: 'regex',
@@ -493,6 +663,13 @@ function detectText(content, filePath, options = {}) {
493
663
  profile,
494
664
  phase: 'style-block',
495
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));
496
673
  }
497
674
 
498
675
  // Extract and scan CSS-in-JS template literals
@@ -510,6 +687,7 @@ function detectText(content, filePath, options = {}) {
510
687
  profile,
511
688
  phase: 'css-in-js',
512
689
  }));
690
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
513
691
  }
514
692
 
515
693
  if (options?.designSystem) {
@@ -540,7 +718,6 @@ function detectText(content, filePath, options = {}) {
540
718
  'monotonous-spacing',
541
719
  'em-dash-overuse',
542
720
  'marketing-buzzword',
543
- 'numbered-section-markers',
544
721
  'aphoristic-cadence',
545
722
  'dark-glow',
546
723
  ];
@@ -555,10 +732,9 @@ function detectText(content, filePath, options = {}) {
555
732
  }
556
733
  }
557
734
 
558
- const byProvider = filterByProviders(deduped, options?.providers);
559
735
  // Inline `impeccable-disable*` waivers travel with the file; honor them unless
560
736
  // explicitly bypassed (`--no-config` / `--no-inline-ignores`).
561
- return options?.inlineIgnores === false ? byProvider : applyInlineIgnores(byProvider, content);
737
+ return options?.inlineIgnores === false ? deduped : applyInlineIgnores(deduped, content);
562
738
  }
563
739
 
564
740
  export {