impeccable 3.6.0 → 3.6.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.
@@ -70,13 +70,27 @@ function isBrandFontOnOwnDomain(font) {
70
70
  return allowed.some(suffix => host === suffix || host.endsWith('.' + suffix));
71
71
  }
72
72
 
73
- const GENERIC_FONTS = new Set([
73
+ // Overused-font primary selection skips only CSS generics so a system stack
74
+ // keeps the system face as primary; GENERIC_FONTS still includes platform
75
+ // faces for design-system/serif resolution.
76
+ const CSS_GENERIC_FONTS = new Set([
74
77
  'serif', 'sans-serif', 'monospace', 'cursive', 'fantasy',
78
+ 'inherit', 'initial', 'unset', 'revert',
79
+ ]);
80
+
81
+ const GENERIC_FONTS = new Set([
82
+ ...CSS_GENERIC_FONTS,
75
83
  'system-ui', 'ui-serif', 'ui-sans-serif', 'ui-monospace', 'ui-rounded',
76
84
  '-apple-system', 'blinkmacsystemfont', 'segoe ui',
77
- 'inherit', 'initial', 'unset', 'revert',
78
85
  ]);
79
86
 
87
+ function primaryFontFace(fontFamily, skip = CSS_GENERIC_FONTS) {
88
+ return String(fontFamily || '')
89
+ .split(',')
90
+ .map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase())
91
+ .find(f => f && !skip.has(f)) || null;
92
+ }
93
+
80
94
  // WCAG large text thresholds are defined in points: 18pt normal text and
81
95
  // 14pt bold text. Browsers expose font-size in CSS pixels at 96px per inch.
82
96
  const WCAG_LARGE_TEXT_PX = 18 * (96 / 72);
@@ -232,6 +246,24 @@ const ANTIPATTERNS = [
232
246
  'A large inline SVG that builds a pictorial scene from a pile of primitive shapes reads as placeholder clip art, not illustration. Icons, logos, and data graphics are fine at their scale; a hero-sized visual deserves real artwork, a photograph, or a deliberately drawn graphic.',
233
247
  skillSection: 'Imagery',
234
248
  },
249
+ {
250
+ id: 'organic-clip-path',
251
+ category: 'quality',
252
+ name: 'Organic contour drawn as clip-path',
253
+ description:
254
+ 'A clip-path polygon with many arbitrary vertices, or a curved clip-path path(), is CSS approximating a torn edge, blob, or silhouette. It reads as the cheap version of the effect and is usually a produced or photographic material replaced with code. Derive an alpha matte from the real image, or ship the shape as a cut-out raster; keep clip-path for geometry (cut corners, diagonals, hexagons).',
255
+ skillSection: 'Imagery',
256
+ skillGuideline: 'geometric masks standing in for organic contours',
257
+ },
258
+ {
259
+ id: 'buried-raster',
260
+ category: 'quality',
261
+ name: 'Raster buried under a wash or opacity',
262
+ description:
263
+ 'A background image under a near-opaque gradient wash, or a raster on an element at near-zero opacity, never reaches the screen: the page shows the wash, and the produced texture or photo ships as a compliance token. Let the material show (a tint under 0.9 alpha, a blend mode, an opacity you can see) or remove the file.',
264
+ skillSection: 'Imagery',
265
+ skillGuideline: 'a produced material must survive to the screen',
266
+ },
235
267
  {
236
268
  id: 'dark-glow',
237
269
  category: 'slop',
@@ -773,14 +805,22 @@ function extractColorFunctionTokens(value) {
773
805
  function parseGradientColors(bgImage) {
774
806
  if (!bgImage || !bgImage.includes('gradient')) return [];
775
807
  const colors = [];
808
+ const tokenSpans = [];
809
+ let from = 0;
776
810
  // Stops arrive in whatever syntax the author wrote and the browser kept.
777
811
  // A dark ground painted as `linear-gradient(oklch(...), oklch(...))` used
778
812
  // to read as a gradient with no stops at all.
779
813
  for (const token of extractColorFunctionTokens(bgImage)) {
814
+ const start = bgImage.indexOf(token, from);
815
+ if (start < 0) break;
816
+ tokenSpans.push({ start, end: start + token.length });
817
+ from = start + token.length;
780
818
  const c = parseAnyColor(token);
781
819
  if (c) colors.push(c);
782
820
  }
783
821
  for (const m of bgImage.matchAll(/#([0-9a-f]{6}|[0-9a-f]{3})\b/gi)) {
822
+ // Nested hex inside color-mix is an ingredient, not a stop (issue #578).
823
+ if (tokenSpans.some(s => m.index >= s.start && m.index < s.end)) continue;
784
824
  const h = m[1];
785
825
  if (h.length === 6) {
786
826
  colors.push({ r: parseInt(h.slice(0,2),16), g: parseInt(h.slice(2,4),16), b: parseInt(h.slice(4,6),16), a: 1 });
@@ -1565,7 +1605,7 @@ function checkIconTile(opts) {
1565
1605
  function resolveSerif(fontFamily) {
1566
1606
  if (!fontFamily) return { primary: null, isSerif: false };
1567
1607
  const tokens = fontFamily.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase());
1568
- const primary = tokens.find(f => f && !GENERIC_FONTS.has(f)) || null;
1608
+ const primary = primaryFontFace(fontFamily, GENERIC_FONTS);
1569
1609
  if (!primary) return { primary: null, isSerif: false };
1570
1610
  if (KNOWN_SERIF_FONTS.has(primary)) return { primary, isSerif: true };
1571
1611
  if (tokens.includes('serif')) return { primary, isSerif: true };
@@ -1916,8 +1956,13 @@ function enclosingCssSelector(cssText, index) {
1916
1956
  if (!cssText || !Number.isFinite(index)) return null;
1917
1957
  const open = cssText.lastIndexOf('{', index);
1918
1958
  if (open === -1) return null;
1959
+ // A match inside an inline style fragment (`style="…"` appended to the
1960
+ // corpus by buildHtmlPatternCorpora) has no enclosing rule; the previous
1961
+ // `{` belongs to some other selector.
1962
+ const closeBeforeIndex = cssText.lastIndexOf('}', index);
1963
+ if (closeBeforeIndex > open) return null;
1919
1964
  const prevClose = Math.max(cssText.lastIndexOf('}', open - 1), cssText.lastIndexOf(';', open - 1));
1920
- const raw = cssText.slice(prevClose + 1, open).trim().replace(/\s+/g, ' ');
1965
+ const raw = cssText.slice(prevClose + 1, open).replace(/\/\*[\s\S]*?\*\//g, '').trim().replace(/\s+/g, ' ');
1921
1966
  if (!raw || raw.startsWith('@') || /^\d/.test(raw) || /[{}<]/.test(raw)) return null;
1922
1967
  // Keyframe steps: percentage steps fail the digit test above, but `from`
1923
1968
  // and `to` would read as (never-matching) type selectors and get a valid
@@ -1955,20 +2000,19 @@ function scanCssTextForGlow(content) {
1955
2000
  return results;
1956
2001
  }
1957
2002
 
1958
- // Decorative grid or line-field backgrounds drawn with hairline
2003
+ // Decorative two-axis grid backgrounds drawn with hairline
1959
2004
  // linear-gradient layers tiled by a fixed pixel cell. Shared by the HTML
1960
2005
  // pattern pass and the regex source engine so standalone CSS, component
1961
2006
  // styles, and inline styles receive the same coverage. Both signals must
1962
2007
  // co-occur in one declaration block; unrelated rules must not add up across
1963
- // the file. Returns [{ index, snippet }], capped at one finding per source to
1964
- // match the page-level HTML check's existing behavior.
2008
+ // the file. A single hairline is a line, divider, or rail, not a grid, even
2009
+ // when tiled by a 2D px cell. Returns [{ index, snippet }], capped at one
2010
+ // finding per source to match the page-level HTML check's existing behavior.
1965
2011
  function scanCssTextForGridBackground(content) {
1966
2012
  const hairlineRe = /\b\d{1,3}px\s*,\s*transparent\s+\d{1,3}px/gi;
1967
2013
  const invertedHairlineRe = /transparent\s+calc\(100%\s*-\s*\d{1,3}px\)/gi;
1968
2014
  const sizeDeclPxRe = /background-size\s*:[^;{}"']*\b\d{1,3}px\b/i;
1969
- const sizeDeclPxPairRe = /background-size\s*:[^;{}"']*\b\d{1,3}px\s+\d{1,3}px/i;
1970
2015
  const shorthandPxAnyRe = /\/\s*\d{1,3}px\b/;
1971
- const shorthandPxPairRe = /\/\s*\d{1,3}px\s+\d{1,3}px/;
1972
2016
  const bgDeclRe = /\bbackground(?:-image)?\s*:\s*([^;{}"']*)/gi;
1973
2017
  const blockRe = /\{([^{}]*)\}|style\s*=\s*"([^"]*)"|style\s*=\s*'([^']*)'/gi;
1974
2018
  let blk;
@@ -1985,13 +2029,10 @@ function scanCssTextForGridBackground(content) {
1985
2029
  }
1986
2030
  if (hairlineCount === 0) continue;
1987
2031
  const hasPxCell = sizeDeclPxRe.test(block) || shorthandPxAnyRe.test(bgJoined);
1988
- const hasPxPairCell = sizeDeclPxPairRe.test(block) || shorthandPxPairRe.test(bgJoined);
1989
- if ((hairlineCount >= 2 && hasPxCell) || hasPxPairCell) {
2032
+ if (hairlineCount >= 2 && hasPxCell) {
1990
2033
  return [{
1991
2034
  index: blk.index,
1992
- snippet: hairlineCount >= 2
1993
- ? 'two-axis grid-line gradient background'
1994
- : 'px-tiled hairline line-field background',
2035
+ snippet: 'two-axis grid-line gradient background',
1995
2036
  }];
1996
2037
  }
1997
2038
  }
@@ -2687,6 +2728,95 @@ function scanHtmlForShapeAssembledIllustration(html) {
2687
2728
  return findings;
2688
2729
  }
2689
2730
 
2731
+
2732
+ // --- Organic clip-path polygons ----------------------------------------------
2733
+ // A `clip-path: polygon(...)` with many vertices, or `clip-path: path(...)`
2734
+ // with curves, is CSS approximating an organic contour: a torn edge, a blob,
2735
+ // a silhouette. The approximation reads as the cheap version of the effect
2736
+ // (the craft floor's geometric-occlusion-mask ban), and it is the signature
2737
+ // of a comp's produced material being replaced with code. Geometric clips
2738
+ // (cut corners, diagonals, hexagons, arrows: few vertices, or vertices on
2739
+ // the 0/50/100 grid) pass; circle()/inset()/ellipse() pass; a mask-image
2740
+ // from an alpha matte passes.
2741
+ const ORGANIC_POLYGON_MIN_VERTICES = 10;
2742
+ function scanCssTextForOrganicClipPath(styleText) {
2743
+ const findings = [];
2744
+ const re = /clip-path\s*:\s*(polygon|path)\s*\(([^)]*(?:\)[^;}]*)?)/gi;
2745
+ let m;
2746
+ while ((m = re.exec(styleText)) !== null) {
2747
+ const kind = m[1].toLowerCase();
2748
+ const body = m[2];
2749
+ if (kind === 'path') {
2750
+ // curves (C, S, Q, T, A, absolute or relative) drawing a contour, not a
2751
+ // rectilinear M/L/Z outline; letters in path data are only commands
2752
+ const curves = (body.match(/[CSQTA]/gi) || []).length;
2753
+ if (curves < 3) continue;
2754
+ findings.push({ id: 'organic-clip-path', snippet: `clip-path: path() with ${curves} curve segments`, selector: enclosingCssSelector(styleText, m.index) || undefined });
2755
+ continue;
2756
+ }
2757
+ const points = body.split(',').map((p) => p.trim()).filter(Boolean);
2758
+ if (points.length < ORGANIC_POLYGON_MIN_VERTICES) continue;
2759
+ // Vertices sitting on a coarse grid (multiples of 25%) are geometric; a
2760
+ // contour has arbitrary values.
2761
+ let offGrid = 0;
2762
+ for (const p of points) {
2763
+ const nums = p.match(/-?[\d.]+/g) || [];
2764
+ for (const n of nums) { const v = parseFloat(n); if (Math.abs(v - Math.round(v / 25) * 25) > 0.5) offGrid++; }
2765
+ }
2766
+ if (offGrid < points.length) continue;
2767
+ findings.push({ id: 'organic-clip-path', snippet: `clip-path: polygon() with ${points.length} vertices approximating an organic contour`, selector: enclosingCssSelector(styleText, m.index) || undefined });
2768
+ }
2769
+ return findings;
2770
+ }
2771
+
2772
+ // --- Buried raster ------------------------------------------------------------
2773
+ // A raster (background-image url or <img>) that never reaches the screen:
2774
+ // under a near-opaque gradient wash in the same background stack, or on an
2775
+ // element at near-zero opacity. It is how a produced texture "ships" while
2776
+ // the page shows flat color, and the finish reviewer cannot see it either.
2777
+ // A tint under 0.9 alpha passes (hero darkening); a blend mode passes
2778
+ // (multiply/overlay keep the material visible); opacity >= 0.15 passes.
2779
+ function scanCssTextForBuriedRaster(styleText) {
2780
+ const findings = [];
2781
+ // background stacks: split declarations, look for url() + a gradient whose
2782
+ // stops all carry alpha >= 0.9 (or opaque hex/named colors)
2783
+ const declRe = /background(?:-image)?\s*:\s*([^;}]+)/gi;
2784
+ let m;
2785
+ while ((m = declRe.exec(styleText)) !== null) {
2786
+ const value = m[1];
2787
+ if (!/url\(/i.test(value) || !/gradient\(/i.test(value)) continue;
2788
+ // a blend mode declared in the same rule keeps the raster visible
2789
+ const ruleStart = styleText.lastIndexOf('{', m.index);
2790
+ const ruleEnd = styleText.indexOf('}', m.index);
2791
+ const rule = styleText.slice(ruleStart < 0 ? 0 : ruleStart, ruleEnd < 0 ? styleText.length : ruleEnd);
2792
+ if (/background-blend-mode\s*:\s*(?!normal)/i.test(rule) || /mix-blend-mode\s*:\s*(?!normal)/i.test(rule)) continue;
2793
+ // Layers are painted first-on-top: only a wash listed BEFORE the url()
2794
+ // covers it. An image on top of a gradient is not buried.
2795
+ const firstUrl = value.search(/url\(/i);
2796
+ const gradients = [...value.matchAll(/(?:linear|radial|conic)-gradient\([^()]*(?:\([^()]*\)[^()]*)*\)/gi)].filter((gm) => gm.index < firstUrl).map((gm) => gm[0]);
2797
+ let opaqueWash = false;
2798
+ // an alpha token normalized to 0..1: '0.8' -> 0.8, '80%' -> 0.8
2799
+ const alphaOf = (a) => { if (a == null) return 1; const v = parseFloat(a); return String(a).trim().endsWith('%') ? v / 100 : v; };
2800
+ for (const g of gradients) {
2801
+ const alphas = [...g.matchAll(/rgba?\(\s*[\d.]+%?\s*,?\s*[\d.]+%?\s*,?\s*[\d.]+%?\s*(?:[,/]\s*([\d.]+%?))?\s*\)|hsla?\([^)]*?(?:[,/]\s*([\d.]+%?))?\s*\)/gi)].map((a) => alphaOf(a[1] ?? a[2]));
2802
+ const stripped = g.replace(/rgba?\([^)]*\)|hsla?\([^)]*\)/gi, '');
2803
+ // hex stops: 4- and 8-digit forms carry their own alpha
2804
+ for (const h of stripped.matchAll(/#([0-9a-f]{3,8})\b/gi)) {
2805
+ const hex = h[1];
2806
+ if (hex.length === 4) alphas.push(parseInt(hex[3] + hex[3], 16) / 255);
2807
+ else if (hex.length === 8) alphas.push(parseInt(hex.slice(6), 16) / 255);
2808
+ else alphas.push(1);
2809
+ }
2810
+ const named = /\b(?:white|black|ivory|beige|linen|snow|cream)\b/i.test(stripped);
2811
+ if (named) alphas.push(1);
2812
+ if (alphas.length && alphas.every((a) => !Number.isFinite(a) || a >= 0.9)) { opaqueWash = true; break; }
2813
+ }
2814
+ if (!opaqueWash) continue;
2815
+ findings.push({ id: 'buried-raster', snippet: `raster under a near-opaque gradient wash: ${value.trim().slice(0, 90)}`, selector: enclosingCssSelector(styleText, m.index) || undefined });
2816
+ }
2817
+ return findings;
2818
+ }
2819
+
2690
2820
  // Scoped scan corpora for the page-level pattern checks. CSS-property
2691
2821
  // regexes run over the whole source string fire on documentation ABOUT
2692
2822
  // css — `<code>background-clip: text</code>` prose, <pre> samples, HTML
@@ -2859,6 +2989,10 @@ function checkHtmlPatterns(html, corpora) {
2859
2989
  // Shape-assembled illustrations (large pictorial SVGs built from primitives)
2860
2990
  findings.push(...scanHtmlForShapeAssembledIllustration(html));
2861
2991
 
2992
+ // Organic clip-path contours and rasters buried under washes or opacity
2993
+ findings.push(...scanCssTextForOrganicClipPath(styleText));
2994
+ findings.push(...scanCssTextForBuriedRaster(styleText));
2995
+
2862
2996
  // Auto-scrolling marquees (<marquee> or infinite horizontal loop animations)
2863
2997
  findings.push(...scanCssTextForMarquee(styleText, html));
2864
2998
 
@@ -3986,7 +4120,7 @@ function checkElementAIPaletteDOM(el) {
3986
4120
  }
3987
4121
 
3988
4122
  // Check for neon text (vivid cyan/purple color on dark background)
3989
- const textColor = parseRgb(style.color);
4123
+ const textColor = parseRgb(style.color) || parseAnyColor(style.color);
3990
4124
  if (textColor && hasChroma(textColor, 80)) {
3991
4125
  const hue = getHue(textColor);
3992
4126
  const isAIPalette = (hue >= 160 && hue <= 200) || (hue >= 260 && hue <= 310);
@@ -4329,14 +4463,30 @@ function isNonRenderedText(el, tag, style) {
4329
4463
  function checkQuality(opts) {
4330
4464
  const { el, tag, style, hasDirectText, textLen, fontSize, lineHeightPx, letterSpacingPx, rect, lineMax = 80, viewportWidth = 0, win = null } = opts;
4331
4465
  const findings = [];
4332
- // Skip browser extension injected elements. Read the id via getAttribute
4333
- // whenever `el.id` is not a string: on a <form> (and other
4334
- // [LegacyOverrideBuiltIns] hosts) a named control like <input name="id">
4335
- // shadows the builtin `id` getter and returns the control element, whose
4336
- // `.startsWith` is undefined and throws (issue #407 — every Shopify product
4337
- // form ships an <input name="id">).
4466
+ // A raster (<img>, or an element with a background url) at near-zero
4467
+ // opacity never reaches the screen: the produced material ships as a
4468
+ // compliance token. The CSS-text scan catches the stylesheet form; this
4469
+ // catches computed opacity on the element itself (both engines).
4470
+ // Skip browser extension injected elements BEFORE any finding is pushed
4471
+ // (a low-opacity raster those hosts inject used to be recorded and then
4472
+ // returned by this very skip). Read the id via getAttribute whenever
4473
+ // `el.id` is not a string: on a <form> (and other [LegacyOverrideBuiltIns]
4474
+ // hosts) a named control like <input name="id"> shadows the builtin `id`
4475
+ // getter and returns the control element, whose `.startsWith` is undefined
4476
+ // and throws (issue #407 — every Shopify product form ships an
4477
+ // <input name="id">).
4338
4478
  const elId = typeof el.id === 'string' ? el.id : (el.getAttribute?.('id') || '');
4339
4479
  if (elId.startsWith('claude-') || elId.startsWith('cic-')) return findings;
4480
+ {
4481
+ const op = parseFloat(style.opacity);
4482
+ if (Number.isFinite(op) && op < 0.15 && op >= 0) {
4483
+ const bg = String(style.backgroundImage || '');
4484
+ if (tag === 'img' || /url\(/i.test(bg)) {
4485
+ const label = tag === 'img' ? (el.getAttribute && el.getAttribute('alt')) || '' : (el.textContent || '').trim().slice(0, 40);
4486
+ findings.push({ id: 'buried-raster', snippet: `${tag === 'img' ? '<img>' : 'raster background'} at opacity ${op}${label ? ` "${label}"` : ''}` });
4487
+ }
4488
+ }
4489
+ }
4340
4490
 
4341
4491
  // --- Line length too long --- (browser-only: needs rect.width)
4342
4492
  if (rect && hasDirectText && QUALITY_TEXT_TAGS.has(tag) && rect.width > 0 && textLen > lineMax) {
@@ -5054,8 +5204,7 @@ function checkTypography() {
5054
5204
  const style = getComputedStyle(el);
5055
5205
  const ff = style.fontFamily;
5056
5206
  if (!ff) continue;
5057
- const stack = ff.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase());
5058
- const primary = stack.find(f => f && !GENERIC_FONTS.has(f));
5207
+ const primary = primaryFontFace(ff);
5059
5208
  if (!primary) continue;
5060
5209
  fontUsage.set(primary, (fontUsage.get(primary) || 0) + 1);
5061
5210
  totalTextElements++;
@@ -5300,8 +5449,7 @@ function checkPageTypography(doc, win) {
5300
5449
  if (rule.type !== 1) continue;
5301
5450
  const ff = rule.style?.fontFamily;
5302
5451
  if (!ff) continue;
5303
- const stack = ff.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase());
5304
- const primary = stack.find(f => f && !GENERIC_FONTS.has(f));
5452
+ const primary = primaryFontFace(ff);
5305
5453
  if (primary) {
5306
5454
  fonts.add(primary);
5307
5455
  if (OVERUSED_FONTS.has(primary)) overusedFound.add(primary);
@@ -5320,11 +5468,10 @@ function checkPageTypography(doc, win) {
5320
5468
  const ffRe = /font-family\s*:\s*([^;}]+)/gi;
5321
5469
  let fm;
5322
5470
  while ((fm = ffRe.exec(html)) !== null) {
5323
- for (const f of fm[1].split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase())) {
5324
- if (f && !GENERIC_FONTS.has(f)) {
5325
- fonts.add(f);
5326
- if (OVERUSED_FONTS.has(f)) overusedFound.add(f);
5327
- }
5471
+ const primary = primaryFontFace(fm[1]);
5472
+ if (primary) {
5473
+ fonts.add(primary);
5474
+ if (OVERUSED_FONTS.has(primary)) overusedFound.add(primary);
5328
5475
  }
5329
5476
  }
5330
5477
 
@@ -6400,6 +6547,36 @@ function checkTextOcclusionDOM() {
6400
6547
  // reads as an opaque box.
6401
6548
  const effectiveOpacity = effectiveOpacityDOM;
6402
6549
 
6550
+ // The part of an element that is actually painted, after every scrolling or
6551
+ // clipping ancestor has had its say.
6552
+ //
6553
+ // getBoundingClientRect reports where a box would be if nothing cut it off,
6554
+ // so a paragraph half scrolled out of a panel still reports its full height,
6555
+ // and the half that is clipped away lands wherever the page continues below
6556
+ // the panel. The elementFromPoint probe then samples coordinates the text is
6557
+ // not painted at, finds whatever genuinely is painted there, and reports the
6558
+ // text as buried under it. Any sticky footer or toolbar beneath a scroll
6559
+ // region produces this, and it is the shape most likely to be waved off as
6560
+ // noise, which costs the rule its credibility on the findings that are real.
6561
+ //
6562
+ // Border box rather than padding box on purpose: it errs toward probing, and
6563
+ // giving up a scrollbar gutter's width would drop true findings at the right
6564
+ // edge of a scroller.
6565
+ const paintedRect = (el, rect) => {
6566
+ let left = rect.left, top = rect.top, right = rect.right, bottom = rect.bottom;
6567
+ for (let cur = el.parentElement; cur && cur !== document.documentElement; cur = cur.parentElement) {
6568
+ let cs; try { cs = getComputedStyle(cur); } catch { continue; }
6569
+ const clipsX = String(cs.overflowX || 'visible') !== 'visible';
6570
+ const clipsY = String(cs.overflowY || 'visible') !== 'visible';
6571
+ if (!clipsX && !clipsY) continue;
6572
+ let b; try { b = cur.getBoundingClientRect(); } catch { continue; }
6573
+ if (clipsX) { left = Math.max(left, b.left); right = Math.min(right, b.right); }
6574
+ if (clipsY) { top = Math.max(top, b.top); bottom = Math.min(bottom, b.bottom); }
6575
+ if (right - left < 1 || bottom - top < 1) return null;
6576
+ }
6577
+ return { left, top, right, bottom, width: right - left, height: bottom - top };
6578
+ };
6579
+
6403
6580
  // Collect renderable text owners in / near the first viewport for the
6404
6581
  // elementFromPoint probe. SVG <text> counts too.
6405
6582
  const textEls = [];
@@ -6412,8 +6589,13 @@ function checkTextOcclusionDOM() {
6412
6589
  if (text.length < 2) continue;
6413
6590
  if (!isPaintedForOcclusion(el)) continue;
6414
6591
  if (effectiveOpacity(el) <= 0.02) continue;
6415
- let rect; try { rect = el.getBoundingClientRect(); } catch { continue; }
6416
- if (rect.width < 6 || rect.height < 6) continue;
6592
+ let full; try { full = el.getBoundingClientRect(); } catch { continue; }
6593
+ if (full.width < 6 || full.height < 6) continue;
6594
+ // Probe only where the text is on screen. A run clipped down to a sliver is
6595
+ // dropped rather than sampled: a few pixels of visible text cannot support
6596
+ // a coverage fraction worth reporting either way.
6597
+ const rect = paintedRect(el, full);
6598
+ if (!rect || rect.width < 6 || rect.height < 6) continue;
6417
6599
  // Viewport-bound probe: keep text whose box overlaps the live viewport.
6418
6600
  if (rect.bottom <= 0 || rect.top >= vh) continue;
6419
6601
  textEls.push({ el, rect, text, inSvg });
@@ -7281,7 +7463,7 @@ if (IS_BROWSER) {
7281
7463
  if (currentStyle.filter && currentStyle.filter !== 'none') reasons.add('filter');
7282
7464
  if (currentStyle.backdropFilter && currentStyle.backdropFilter !== 'none') reasons.add('backdrop filter');
7283
7465
 
7284
- const solidBg = parseRgb(currentStyle.backgroundColor);
7466
+ const solidBg = parseRgb(currentStyle.backgroundColor) || parseAnyColor(currentStyle.backgroundColor);
7285
7467
  if (solidBg && solidBg.a >= 0.95 && (!bgImage || bgImage === 'none')) break;
7286
7468
  current = current.parentElement;
7287
7469
  }
@@ -7343,7 +7525,7 @@ if (IS_BROWSER) {
7343
7525
  // starve the url()-backed texts this mode exists to sample.
7344
7526
  if (options.imageOnly && !reasons.includes('image background')) continue;
7345
7527
 
7346
- const textColor = parseRgb(style.color);
7528
+ const textColor = parseRgb(style.color) || parseAnyColor(style.color);
7347
7529
  const fontSize = parseFloat(style.fontSize) || 16;
7348
7530
  const fontWeight = parseInt(style.fontWeight) || 400;
7349
7531
  const isLargeText = fontSize >= WCAG_LARGE_TEXT_PX || (fontSize >= WCAG_LARGE_BOLD_TEXT_PX && fontWeight >= 700);
@@ -7640,7 +7822,7 @@ if (IS_BROWSER) {
7640
7822
  return sample;
7641
7823
  }
7642
7824
  }
7643
- const bg = parseRgb(style.backgroundColor);
7825
+ const bg = parseRgb(style.backgroundColor) || parseAnyColor(style.backgroundColor);
7644
7826
  if (bg && bg.a > 0.05) return { status: 'sampled', color: bg, method: 'solid-background' };
7645
7827
  return { status: 'unresolved', reason: 'no readable background' };
7646
7828
  }
@@ -7770,7 +7952,7 @@ if (IS_BROWSER) {
7770
7952
  }
7771
7953
 
7772
7954
  const style = getComputedStyle(el);
7773
- const textColor = parseRgb(style.color) || candidate.textColor;
7955
+ const textColor = parseRgb(style.color) || parseAnyColor(style.color) || candidate.textColor;
7774
7956
  if (!textColor) return { ...candidate, status: 'unresolved', confidence: 'none', reason: 'unreadable text color' };
7775
7957
 
7776
7958
  const rect = getDirectTextRect(el) || el.getBoundingClientRect();
@@ -8127,7 +8309,19 @@ if (IS_BROWSER) {
8127
8309
  return findings;
8128
8310
  }
8129
8311
 
8312
+ // A page matched by detector.ignoreFiles is waived wholesale: every scan
8313
+ // stage answers empty so the badge and toast read zero. Mirrors
8314
+ // shouldIgnoreDetectionFile in cli/lib/impeccable-config.mjs; the live
8315
+ // overlay resolves the globs per page (live-browser-ignores.js) and
8316
+ // forwards the verdict as config.skipScan.
8317
+ function skipScanActive() {
8318
+ return EXTENSION_MODE && window.__IMPECCABLE_CONFIG__?.skipScan === true;
8319
+ }
8320
+
8130
8321
  function collectBrowserFindings() {
8322
+ if (skipScanActive()) {
8323
+ return { groupMap: new Map(), allFindings: [], pageLevelFindings: [] };
8324
+ }
8131
8325
  const groupMap = new Map();
8132
8326
  const _disabled = EXTENSION_MODE ? (window.__IMPECCABLE_CONFIG__?.disabledRules || []) : [];
8133
8327
  const _ruleOk = (id) => !_disabled.length || !_disabled.includes(id);
@@ -8330,6 +8524,119 @@ if (IS_BROWSER) {
8330
8524
  addBrowserFindings(groupMap, document.body, mapped);
8331
8525
  }
8332
8526
 
8527
+ // Value-level suppression (issue #639). `disabledRules` above handles
8528
+ // whole rules; this applies the config's remaining ignoreValues entries,
8529
+ // which the CLI filters through isIgnoredFindingValue in
8530
+ // cli/lib/impeccable-config.mjs, so a project waiver like
8531
+ // overused-font = "geist mono" reaches the overlay and extension too.
8532
+ const _normValue = (v) => String(v || '').trim().replace(/^["']|["']$/g, '')
8533
+ .replace(/\+/g, ' ').replace(/\s+/g, ' ').toLowerCase();
8534
+ const _disabledValues = EXTENSION_MODE
8535
+ ? (Array.isArray(window.__IMPECCABLE_CONFIG__?.disabledValues) ? window.__IMPECCABLE_CONFIG__.disabledValues : [])
8536
+ .filter(e => e && typeof e === 'object' && e.rule && e.value)
8537
+ .map(e => ({ rule: String(e.rule).trim().toLowerCase(), value: _normValue(e.value) }))
8538
+ : [];
8539
+ if (_disabledValues.length > 0) {
8540
+ // The six rules whose findings carry a matchable value; keep in step
8541
+ // with extractFindingIgnoreValue in cli/lib/impeccable-config.mjs.
8542
+ // Everything else is suppressed by rule or by file scope, both already
8543
+ // resolved into disabledRules before the scan message was sent.
8544
+ const _directValueRules = new Set([
8545
+ 'overused-font',
8546
+ 'bounce-easing',
8547
+ 'design-system-font',
8548
+ 'design-system-color',
8549
+ 'design-system-radius',
8550
+ 'design-system-font-size',
8551
+ ]);
8552
+ // The design-system checks set `ignoreValue` on their findings; the
8553
+ // detail fallbacks catch overused-font, whose value lives in its
8554
+ // sentence. One CLI matcher is not mirrored here: the motion extractor
8555
+ // (a value-scoped bounce-easing waiver only matches when the finding
8556
+ // carries ignoreValue directly). The CLI's [?&]family= URL fallback is
8557
+ // also omitted on purpose: browser findings for these rules always
8558
+ // carry ignoreValue or a "Primary font:" / "Google Fonts:" /
8559
+ // font-family sentence, so it is unreachable here.
8560
+ const _findingValue = (f) => {
8561
+ if (!f || !_directValueRules.has(f.type || f.id)) return '';
8562
+ const direct = f.ignoreValue || f.value;
8563
+ if (direct) return _normValue(direct);
8564
+ // The CLI routes bounce-easing through extractMotionIgnoreValue and
8565
+ // never the font regexes; without a direct ignoreValue there is no
8566
+ // value to match, so do not invent one from unrelated CSS text.
8567
+ if ((f.type || f.id) === 'bounce-easing') return '';
8568
+ for (const text of [f.detail, f.snippet]) {
8569
+ if (typeof text !== 'string' || !text) continue;
8570
+ const primary = text.match(/Primary font:\s*([^()\n;]+)/i);
8571
+ if (primary) return _normValue(primary[1]);
8572
+ const google = text.match(/Google Fonts:\s*([^()\n;]+)/i);
8573
+ if (google) return _normValue(google[1]);
8574
+ const family = text.match(/font-family\s*:\s*["']?([^'",;\n]+)/i);
8575
+ if (family) return _normValue(family[1]);
8576
+ }
8577
+ return '';
8578
+ };
8579
+ // design-system-color compares by color value, not by spelling: the
8580
+ // browser reports computed rgb(...) strings while waivers are usually
8581
+ // written as hex. Mirrors ignoreValueMatches -> colorIgnoreKey in
8582
+ // cli/lib/impeccable-config.mjs for the hex and rgb()/rgba() forms;
8583
+ // hsl stays CLI-only.
8584
+ const _colorKey = (value) => {
8585
+ const text = String(value || '').trim().toLowerCase();
8586
+ const hex = text.match(/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/);
8587
+ if (hex) {
8588
+ const expanded = hex[1].length <= 4 ? [...hex[1]].map(d => d + d).join('') : hex[1];
8589
+ const [r, g, b, a = 255] = expanded.match(/../g).map(ch => parseInt(ch, 16));
8590
+ return `${r},${g},${b},${a}`;
8591
+ }
8592
+ const rgb = text.match(/^rgba?\((.*)\)$/);
8593
+ if (!rgb) return '';
8594
+ const body = rgb[1].trim().replace(/\s*\/\s*/g, ' / ');
8595
+ let parts;
8596
+ if (body.includes(',')) {
8597
+ parts = body.split(',').map(p => p.trim()).filter(Boolean);
8598
+ const last = parts[parts.length - 1];
8599
+ if (last && last.includes('/')) {
8600
+ parts = [...parts.slice(0, -1), ...last.split('/').map(p => p.trim()).filter(Boolean)];
8601
+ }
8602
+ } else {
8603
+ parts = body.split(/\s+/).filter(p => p && p !== '/');
8604
+ }
8605
+ if (parts.length < 3 || parts.length > 4) return '';
8606
+ const channel = (raw, isAlpha) => {
8607
+ const m = String(raw).trim().match(/^(-?\d*\.?\d+)(%)?$/);
8608
+ if (!m) return null;
8609
+ let v = parseFloat(m[1]);
8610
+ if (m[2]) v = isAlpha ? v / 100 : v * 2.55;
8611
+ const max = isAlpha ? 1 : 255;
8612
+ if (!Number.isFinite(v) || v < 0 || v > max) return null;
8613
+ return isAlpha ? v : Math.round(v);
8614
+ };
8615
+ const r = channel(parts[0], false);
8616
+ const g = channel(parts[1], false);
8617
+ const b = channel(parts[2], false);
8618
+ const a = parts[3] === undefined ? 1 : channel(parts[3], true);
8619
+ if ([r, g, b, a].some(v => v === null)) return '';
8620
+ return `${r},${g},${b},${Math.round(a * 255)}`;
8621
+ };
8622
+ const _valueIgnored = (f) => {
8623
+ const value = _findingValue(f);
8624
+ if (!value) return false;
8625
+ const rule = f.type || f.id;
8626
+ return _disabledValues.some(e => e.rule === rule && (e.value === value
8627
+ || (rule === 'design-system-color'
8628
+ && _colorKey(e.value) !== '' && _colorKey(e.value) === _colorKey(value))));
8629
+ };
8630
+ for (const [el, list] of [...groupMap.entries()]) {
8631
+ const kept = list.filter(f => !_valueIgnored(f));
8632
+ if (kept.length > 0) groupMap.set(el, kept);
8633
+ else groupMap.delete(el);
8634
+ }
8635
+ for (let i = pageLevelFindings.length - 1; i >= 0; i--) {
8636
+ if (_valueIgnored(pageLevelFindings[i])) pageLevelFindings.splice(i, 1);
8637
+ }
8638
+ }
8639
+
8333
8640
  return {
8334
8641
  groupMap,
8335
8642
  allFindings: browserFindingsFromMap(groupMap),
@@ -8547,6 +8854,12 @@ if (IS_BROWSER) {
8547
8854
 
8548
8855
  async function collectBrowserFindingsAsync(options = {}, runtime = {}) {
8549
8856
  const collected = collectBrowserFindings();
8857
+ // The visual pass walks the DOM on its own; on a skipScan page it would
8858
+ // repopulate the emptied scan, so it is skipped with everything else.
8859
+ if (skipScanActive()) {
8860
+ lastVisualContrastAnalyses = [];
8861
+ return { ...collected, allFindings: [], visualContrastAnalyses: [] };
8862
+ }
8550
8863
  await addVisualContrastFindings(collected.groupMap, options, runtime);
8551
8864
  return {
8552
8865
  ...collected,
@@ -8600,7 +8913,7 @@ if (IS_BROWSER) {
8600
8913
  const generation = scanGeneration;
8601
8914
  const collected = collectBrowserFindings();
8602
8915
  const allFindings = renderBrowserFindings(collected, options);
8603
- if (shouldRunVisualContrast(options)) {
8916
+ if (!skipScanActive() && shouldRunVisualContrast(options)) {
8604
8917
  addVisualContrastFindings(collected.groupMap, options, { decorate: true, generation })
8605
8918
  .then(() => {
8606
8919
  if (generation === scanGeneration) postSerializedFindings(collected.groupMap, options);
@@ -162,7 +162,68 @@ async function runVisualContrastFallback(page, serializedGroups, options, profil
162
162
  // Puppeteer detection (for URLs)
163
163
  // ---------------------------------------------------------------------------
164
164
 
165
- async function detectUrl(url, options = {}) {
165
+ function decodeUrlComponent(value) {
166
+ try {
167
+ return decodeURIComponent(value);
168
+ } catch {
169
+ return value;
170
+ }
171
+ }
172
+
173
+ function splitScanUrl(url) {
174
+ let parsed;
175
+ try {
176
+ parsed = new URL(url);
177
+ } catch {
178
+ return { href: url, credentials: null };
179
+ }
180
+ if (!parsed.username && !parsed.password) {
181
+ return { href: url, credentials: null };
182
+ }
183
+ const credentials =
184
+ parsed.protocol === 'http:' || parsed.protocol === 'https:'
185
+ ? {
186
+ username: decodeUrlComponent(parsed.username),
187
+ password: decodeUrlComponent(parsed.password),
188
+ }
189
+ : null;
190
+ parsed.username = '';
191
+ parsed.password = '';
192
+ return { href: parsed.href, credentials };
193
+ }
194
+
195
+ function basicAuthHeader(credentials) {
196
+ return `Basic ${Buffer.from(`${credentials.username}:${credentials.password}`).toString('base64')}`;
197
+ }
198
+
199
+ // page.authenticate is page-wide: a cross-origin redirect that then 401s
200
+ // would receive these credentials. Attach Authorization only to the scan origin.
201
+ async function applyOriginScopedAuth(page, href, credentials) {
202
+ if (!credentials) return;
203
+ let origin = '';
204
+ try {
205
+ origin = new URL(href).origin;
206
+ } catch {
207
+ return;
208
+ }
209
+ if (!origin) return;
210
+ const header = basicAuthHeader(credentials);
211
+ await page.setRequestInterception(true);
212
+ page.on('request', (request) => {
213
+ let headers;
214
+ try {
215
+ if (new URL(request.url()).origin === origin) {
216
+ headers = { ...request.headers(), authorization: header };
217
+ }
218
+ } catch {
219
+ // invalid request URL: continue without auth
220
+ }
221
+ void request.continue(headers ? { headers } : undefined).catch(() => {});
222
+ });
223
+ }
224
+
225
+ async function detectUrl(rawUrl, options = {}) {
226
+ const { href: url, credentials } = splitScanUrl(rawUrl);
166
227
  const profile = options?.profile;
167
228
  const waitUntil = options?.waitUntil || 'networkidle0';
168
229
  const settleMs = Number.isFinite(options?.settleMs) ? options.settleMs : 0;
@@ -238,6 +299,7 @@ async function detectUrl(url, options = {}) {
238
299
  ruleId: 'set-viewport',
239
300
  target: url,
240
301
  }, () => page.setViewport(viewport));
302
+ await applyOriginScopedAuth(page, url, credentials);
241
303
  await profileStepAsync(profile, {
242
304
  engine: 'browser',
243
305
  phase: 'load',
@@ -369,4 +431,4 @@ async function createBrowserDetector(options = {}) {
369
431
  };
370
432
  }
371
433
 
372
- export { runVisualContrastFallback, detectUrl, createBrowserDetector, launchBrowser };
434
+ export { runVisualContrastFallback, detectUrl, createBrowserDetector, launchBrowser, splitScanUrl };