impeccable 3.3.1 → 3.5.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.
- package/README.md +2 -2
- package/README.npm.md +2 -2
- package/README.repo.md +3 -3
- package/cli/bin/commands/skills.mjs +145 -13
- package/cli/engine/browser/injected/index.mjs +12 -4
- package/cli/engine/detect-antipatterns-browser.js +410 -111
- package/cli/engine/engines/browser/detect-url.mjs +35 -3
- package/cli/engine/engines/regex/detect-text.mjs +23 -24
- package/cli/engine/engines/static-html/css-cascade.mjs +27 -12
- package/cli/engine/engines/static-html/detect-html.mjs +23 -6
- package/cli/engine/node/file-system.mjs +16 -2
- package/cli/engine/registry/antipatterns.mjs +13 -15
- package/cli/engine/rules/checks.mjs +395 -97
- package/cli/lib/impeccable-config.mjs +3 -0
- package/package.json +3 -2
|
@@ -139,16 +139,6 @@ const ANTIPATTERNS = [
|
|
|
139
139
|
skillSection: 'Typography',
|
|
140
140
|
skillGuideline: 'overused fonts like Inter',
|
|
141
141
|
},
|
|
142
|
-
{
|
|
143
|
-
id: 'single-font',
|
|
144
|
-
category: 'slop',
|
|
145
|
-
scopes: ['type'],
|
|
146
|
-
name: 'Single font without hierarchy',
|
|
147
|
-
description:
|
|
148
|
-
'Only one font family is used for the entire page. A single family can work when weight and size contrast carry the hierarchy; otherwise pair a distinctive display font with a refined body font.',
|
|
149
|
-
skillSection: 'Typography',
|
|
150
|
-
skillGuideline: 'only one font family for the entire page',
|
|
151
|
-
},
|
|
152
142
|
{
|
|
153
143
|
id: 'flat-type-hierarchy',
|
|
154
144
|
category: 'slop',
|
|
@@ -260,6 +250,15 @@ const ANTIPATTERNS = [
|
|
|
260
250
|
skillSection: 'Color & Contrast',
|
|
261
251
|
skillGuideline: 'dark mode with glowing accents',
|
|
262
252
|
},
|
|
253
|
+
{
|
|
254
|
+
id: 'radial-spotlight-glow',
|
|
255
|
+
category: 'slop',
|
|
256
|
+
name: 'Decorative radial spotlight glow',
|
|
257
|
+
description:
|
|
258
|
+
'A soft, low-opacity accent-colored radial gradient fading to transparent, dropped behind a hero or section as a "spotlight." It is a reflex AI decoration — the translucent cousin of the saturated radial halo. Let the surface stand on its own, or light the composition with a deliberate material accent rather than a floating colored haze.',
|
|
259
|
+
skillSection: 'Color & Contrast',
|
|
260
|
+
skillGuideline: 'dark mode with glowing accents',
|
|
261
|
+
},
|
|
263
262
|
{
|
|
264
263
|
id: 'marquee',
|
|
265
264
|
category: 'slop',
|
|
@@ -300,15 +299,14 @@ const ANTIPATTERNS = [
|
|
|
300
299
|
skillGuideline: 'tiny uppercase tracked label above the hero headline',
|
|
301
300
|
},
|
|
302
301
|
{
|
|
303
|
-
id: '
|
|
302
|
+
id: 'kicker-above-heading',
|
|
304
303
|
category: 'slop',
|
|
305
304
|
scopes: ['type'],
|
|
306
|
-
|
|
307
|
-
name: 'Repeated section kicker labels',
|
|
305
|
+
name: 'Kicker / eyebrow label above heading',
|
|
308
306
|
description:
|
|
309
|
-
'
|
|
307
|
+
'A tiny tracked uppercase or small-caps label sitting as its own block directly above a heading is banned outright, repeated or not. Generated kickers never earn their place: the heading carries its own weight. Delete the label and let the heading speak; if the words matter, work them into the heading or the body.',
|
|
310
308
|
skillSection: 'Typography',
|
|
311
|
-
skillGuideline: '
|
|
309
|
+
skillGuideline: 'kicker or eyebrow labels above headings',
|
|
312
310
|
},
|
|
313
311
|
{
|
|
314
312
|
id: 'numbered-section-labels',
|
|
@@ -902,9 +900,21 @@ function checkColors(opts) {
|
|
|
902
900
|
const findings = [];
|
|
903
901
|
|
|
904
902
|
if (hasDirectText && textColor && !isEmojiOnly) {
|
|
903
|
+
// Gradient-clipped text (`background-clip: text`, typically with a
|
|
904
|
+
// transparent text-fill) paints its glyphs *with* the element's own
|
|
905
|
+
// gradient. The `color` value the cascade still reports is never painted,
|
|
906
|
+
// and the gradient is the fill, not a backdrop — so measuring `color`
|
|
907
|
+
// against that gradient (which resolveGradientStops picks up as the
|
|
908
|
+
// element's own background-image) is a guaranteed false positive
|
|
909
|
+
// (issue #409 Case A). Skip the backdrop-contrast checks; the gradient-text
|
|
910
|
+
// rule below still flags the pattern itself. Skipping a rule beats a false
|
|
911
|
+
// positive here — the true painted contrast can't be measured from `color`.
|
|
912
|
+
const isGradientClippedText = bgClip === 'text';
|
|
905
913
|
// Run background-dependent checks against either a solid bg or, if the
|
|
906
914
|
// ancestor is a gradient, against every gradient stop (use the worst case).
|
|
907
|
-
const bgs =
|
|
915
|
+
const bgs = isGradientClippedText
|
|
916
|
+
? null
|
|
917
|
+
: (effectiveBg ? [effectiveBg] : (effectiveBgStops && effectiveBgStops.length ? effectiveBgStops : null));
|
|
908
918
|
if (bgs) {
|
|
909
919
|
// Gray on colored background — flag if every stop is chromatic
|
|
910
920
|
const textLum = relativeLuminance(textColor);
|
|
@@ -1237,12 +1247,15 @@ function checkHeroEyebrow(opts) {
|
|
|
1237
1247
|
}];
|
|
1238
1248
|
}
|
|
1239
1249
|
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1250
|
+
// Outright ban: one kicker is one too many, so every collected candidate is
|
|
1251
|
+
// a finding. The judgment lives in the candidate gate (isKickerCandidate) and
|
|
1252
|
+
// the collector's context skips, not in a repetition count.
|
|
1253
|
+
function checkKickerAboveHeading(opts) {
|
|
1254
|
+
const { candidates } = opts;
|
|
1255
|
+
if (!Array.isArray(candidates)) return [];
|
|
1243
1256
|
return candidates.map(candidate => ({
|
|
1244
|
-
id: '
|
|
1245
|
-
snippet: `
|
|
1257
|
+
id: 'kicker-above-heading',
|
|
1258
|
+
snippet: `kicker "${candidate.kickerText}" above ${candidate.headingTag} "${candidate.headingText}"`,
|
|
1246
1259
|
}));
|
|
1247
1260
|
}
|
|
1248
1261
|
|
|
@@ -1604,7 +1617,13 @@ function isZeroOffset(value) {
|
|
|
1604
1617
|
// never see it — pseudo-elements aren't part of the DOM the cascade walks —
|
|
1605
1618
|
// so this scans stylesheet text directly, mirroring the border rule's
|
|
1606
1619
|
// gates: >= 3px thick, chromatic fill, full height against a side edge.
|
|
1607
|
-
function scanCssTextForPseudoStripe(
|
|
1620
|
+
function scanCssTextForPseudoStripe(rawContent) {
|
|
1621
|
+
// Blank comment bodies byte-for-byte so commented-out rules are not
|
|
1622
|
+
// scanned as live CSS and every rule keeps its source offset (each
|
|
1623
|
+
// finding carries `index` so line-based callers can attribute it and
|
|
1624
|
+
// line-scoped inline ignores can match).
|
|
1625
|
+
const content = String(rawContent || '').replace(/\/\*[\s\S]*?\*\//g,
|
|
1626
|
+
(block) => block.replace(/[^\n]/g, ' '));
|
|
1608
1627
|
const customProps = collectCssCustomProps(content);
|
|
1609
1628
|
const findings = [];
|
|
1610
1629
|
const seen = new Set();
|
|
@@ -1713,9 +1732,13 @@ function scanCssTextForPseudoStripe(content) {
|
|
|
1713
1732
|
|
|
1714
1733
|
if (seen.has(selector)) continue;
|
|
1715
1734
|
seen.add(selector);
|
|
1735
|
+
// The selector group absorbs whitespace trailing the previous rule;
|
|
1736
|
+
// advance past it so `index` points at the selector itself.
|
|
1737
|
+
const selectorStart = m.index + (m[1].length - m[1].trimStart().length);
|
|
1716
1738
|
findings.push({
|
|
1717
1739
|
id: 'side-tab',
|
|
1718
1740
|
snippet: `${selector} — absolute ${thicknessPx}px pseudo-element stripe (${edge}: 0)`,
|
|
1741
|
+
index: selectorStart,
|
|
1719
1742
|
});
|
|
1720
1743
|
}
|
|
1721
1744
|
return findings;
|
|
@@ -1830,9 +1853,11 @@ function collectMarqueeKeyframes(content) {
|
|
|
1830
1853
|
// bound to a keyframe loop that travels a large horizontal distance.
|
|
1831
1854
|
// Rotation/opacity animations never qualify (no X travel); JS-driven
|
|
1832
1855
|
// carousels with user controls have no infinite CSS X-loop to match.
|
|
1833
|
-
|
|
1856
|
+
// `content` is CSS-bearing text; `markup` (defaulting to the same string
|
|
1857
|
+
// for single-corpus callers) is where the <marquee> tag itself lives.
|
|
1858
|
+
function scanCssTextForMarquee(content, markup = content) {
|
|
1834
1859
|
const findings = [];
|
|
1835
|
-
if (/<marquee\b/i.test(
|
|
1860
|
+
if (/<marquee\b/i.test(markup)) {
|
|
1836
1861
|
findings.push({ id: 'marquee', snippet: '<marquee> element' });
|
|
1837
1862
|
}
|
|
1838
1863
|
const marqueeKeyframes = collectMarqueeKeyframes(content);
|
|
@@ -2011,10 +2036,14 @@ function selectorHitsLandmark(content, selector, ranges) {
|
|
|
2011
2036
|
// element sits inside a header/nav landmark is the hero liveness cliché
|
|
2012
2037
|
// and is promoted to error severity; occurrences elsewhere keep the
|
|
2013
2038
|
// registry default severity.
|
|
2014
|
-
|
|
2039
|
+
//
|
|
2040
|
+
// `content` is CSS-bearing text (rules and keyframes); `markup` — defaulting
|
|
2041
|
+
// to the same string for single-corpus callers like the regex source
|
|
2042
|
+
// engine — is where landmark ranges and Tailwind class attributes live.
|
|
2043
|
+
function scanCssTextForPulsingDot(content, markup = content) {
|
|
2015
2044
|
const customProps = collectCssCustomProps(content);
|
|
2016
2045
|
const keyframes = collectPulseKeyframes(content);
|
|
2017
|
-
const heroRanges = landmarkSourceRanges(
|
|
2046
|
+
const heroRanges = landmarkSourceRanges(markup);
|
|
2018
2047
|
const findings = [];
|
|
2019
2048
|
const seen = new Set();
|
|
2020
2049
|
|
|
@@ -2063,7 +2092,7 @@ function scanCssTextForPulsingDot(content) {
|
|
|
2063
2092
|
|
|
2064
2093
|
if (seen.has(selector)) continue;
|
|
2065
2094
|
seen.add(selector);
|
|
2066
|
-
const inLandmark = selectorHitsLandmark(
|
|
2095
|
+
const inLandmark = selectorHitsLandmark(markup, selector, heroRanges);
|
|
2067
2096
|
findings.push({
|
|
2068
2097
|
id: 'pulsing-dot',
|
|
2069
2098
|
snippet: `${selector} — ${w}x${h}px dot with infinite "${pulseName}" animation${inLandmark ? ' in header/nav' : ''}`,
|
|
@@ -2073,10 +2102,11 @@ function scanCssTextForPulsingDot(content) {
|
|
|
2073
2102
|
}
|
|
2074
2103
|
|
|
2075
2104
|
// Tailwind utilities: animate-ping / animate-pulse on a tiny rounded-full
|
|
2076
|
-
// element declared entirely in the class attribute.
|
|
2105
|
+
// element declared entirely in the class attribute. Scanned in the markup
|
|
2106
|
+
// corpus so the match index lines up with the landmark ranges.
|
|
2077
2107
|
const classRe = /class\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;
|
|
2078
2108
|
let cm;
|
|
2079
|
-
while ((cm = classRe.exec(
|
|
2109
|
+
while ((cm = classRe.exec(markup)) !== null) {
|
|
2080
2110
|
const cls = cm[1] || cm[2] || '';
|
|
2081
2111
|
const anim = cls.match(/\banimate-(ping|pulse)\b/);
|
|
2082
2112
|
if (!anim) continue;
|
|
@@ -2157,20 +2187,64 @@ function scanHtmlForShapeAssembledIllustration(html) {
|
|
|
2157
2187
|
return findings;
|
|
2158
2188
|
}
|
|
2159
2189
|
|
|
2190
|
+
// Scoped scan corpora for the page-level pattern checks. CSS-property
|
|
2191
|
+
// regexes run over the whole source string fire on documentation ABOUT
|
|
2192
|
+
// css — `<code>background-clip: text</code>` prose, <pre> samples, HTML
|
|
2193
|
+
// comments — so the checks scan only the strings that actually style the
|
|
2194
|
+
// page:
|
|
2195
|
+
// styleText — <style> block contents plus style="…" attribute values.
|
|
2196
|
+
// Attribute values keep their `style="…"` form so block-scoped
|
|
2197
|
+
// scanners (grid background) keep treating each attribute as one
|
|
2198
|
+
// declaration block, exactly as they did against raw source. Engines
|
|
2199
|
+
// that already read more CSS (linked stylesheets) prepend it.
|
|
2200
|
+
// classText — class attribute values, for utility-class scans.
|
|
2201
|
+
// Markup-shaped checks (inline <svg> scenes, <img> tags, <marquee>,
|
|
2202
|
+
// landmark ranges) and rendered-text checks (theater phrases) keep the
|
|
2203
|
+
// full source. This extraction serves callers without a parsed document
|
|
2204
|
+
// (the browser bundle scanning outerHTML); attribute reads are tag-scoped
|
|
2205
|
+
// so escaped code samples (<div style="…">) never contribute. The
|
|
2206
|
+
// static engine passes richer corpora built from its parsed document.
|
|
2207
|
+
// Bare CSS input (no markup at all) is its own style text, which keeps
|
|
2208
|
+
// direct checkHtmlPatterns(css) callers behaving as before.
|
|
2209
|
+
function buildHtmlPatternCorpora(html) {
|
|
2210
|
+
const source = String(html || '');
|
|
2211
|
+
if (!/<[a-zA-Z!/]/.test(source)) {
|
|
2212
|
+
return { styleText: source, classText: source };
|
|
2213
|
+
}
|
|
2214
|
+
const styleParts = [];
|
|
2215
|
+
const classParts = [];
|
|
2216
|
+
const styleBlockRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
2217
|
+
let m;
|
|
2218
|
+
while ((m = styleBlockRe.exec(source)) !== null) styleParts.push(m[1]);
|
|
2219
|
+
const tagRe = /<[a-zA-Z][^>]*>/g;
|
|
2220
|
+
while ((m = tagRe.exec(source)) !== null) {
|
|
2221
|
+
const tag = m[0];
|
|
2222
|
+
const sm = tag.match(/\bstyle\s*=\s*("[^"]*"|'[^']*')/i);
|
|
2223
|
+
if (sm) styleParts.push(`style=${sm[1]}`);
|
|
2224
|
+
const cm = tag.match(/\bclass\s*=\s*(?:"([^"]*)"|'([^']*)')/i);
|
|
2225
|
+
if (cm) classParts.push(cm[1] ?? cm[2] ?? '');
|
|
2226
|
+
}
|
|
2227
|
+
return { styleText: styleParts.join('\n'), classText: classParts.join('\n') };
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2160
2230
|
/**
|
|
2161
2231
|
* Regex-on-HTML checks shared between browser and Node page-level detection.
|
|
2162
|
-
* These don't need DOM access, just the raw HTML string.
|
|
2232
|
+
* These don't need DOM access, just the raw HTML string. CSS-property and
|
|
2233
|
+
* utility-class patterns scan the scoped corpora (styleText / classText —
|
|
2234
|
+
* see buildHtmlPatternCorpora) so prose about css never flags; only the
|
|
2235
|
+
* markup-shaped and rendered-text checks read the full source.
|
|
2163
2236
|
*/
|
|
2164
|
-
function checkHtmlPatterns(html) {
|
|
2237
|
+
function checkHtmlPatterns(html, corpora) {
|
|
2238
|
+
const { styleText, classText } = corpora || buildHtmlPatternCorpora(html);
|
|
2165
2239
|
const findings = [];
|
|
2166
2240
|
|
|
2167
2241
|
// --- Color ---
|
|
2168
2242
|
|
|
2169
2243
|
// AI color palette: purple/violet
|
|
2170
2244
|
const purpleHexRe = /#(?:7c3aed|8b5cf6|a855f7|9333ea|7e22ce|6d28d9|6366f1|764ba2|667eea)\b/gi;
|
|
2171
|
-
if (purpleHexRe.test(
|
|
2245
|
+
if (purpleHexRe.test(styleText)) {
|
|
2172
2246
|
const purpleTextRe = /(?:(?:^|;)\s*color\s*:\s*(?:.*?)(?:#(?:7c3aed|8b5cf6|a855f7|9333ea|7e22ce|6d28d9))|gradient.*?#(?:7c3aed|8b5cf6|a855f7|764ba2|667eea))/gi;
|
|
2173
|
-
if (purpleTextRe.test(
|
|
2247
|
+
if (purpleTextRe.test(styleText)) {
|
|
2174
2248
|
findings.push({ id: 'ai-color-palette', snippet: 'Purple/violet accent colors detected' });
|
|
2175
2249
|
}
|
|
2176
2250
|
}
|
|
@@ -2178,15 +2252,15 @@ function checkHtmlPatterns(html) {
|
|
|
2178
2252
|
// Gradient text (background-clip: text + gradient)
|
|
2179
2253
|
const gradientRe = /(?:-webkit-)?background-clip\s*:\s*text/gi;
|
|
2180
2254
|
let gm;
|
|
2181
|
-
while ((gm = gradientRe.exec(
|
|
2255
|
+
while ((gm = gradientRe.exec(styleText)) !== null) {
|
|
2182
2256
|
const start = Math.max(0, gm.index - 200);
|
|
2183
|
-
const context =
|
|
2257
|
+
const context = styleText.substring(start, gm.index + gm[0].length + 200);
|
|
2184
2258
|
if (/gradient/i.test(context)) {
|
|
2185
2259
|
findings.push({ id: 'gradient-text', snippet: 'background-clip: text + gradient' });
|
|
2186
2260
|
break;
|
|
2187
2261
|
}
|
|
2188
2262
|
}
|
|
2189
|
-
if (/\bbg-clip-text\b/.test(
|
|
2263
|
+
if (/\bbg-clip-text\b/.test(classText) && /\bbg-gradient-to-/.test(classText)) {
|
|
2190
2264
|
findings.push({ id: 'gradient-text', snippet: 'bg-clip-text + bg-gradient (Tailwind)' });
|
|
2191
2265
|
}
|
|
2192
2266
|
|
|
@@ -2195,10 +2269,10 @@ function checkHtmlPatterns(html) {
|
|
|
2195
2269
|
// Side-tab accent stripe drawn as an absolutely-positioned pseudo-element
|
|
2196
2270
|
// (no border property involved, so the element-level border checks and
|
|
2197
2271
|
// the border-left regexes never see it).
|
|
2198
|
-
findings.push(...scanCssTextForPseudoStripe(
|
|
2272
|
+
findings.push(...scanCssTextForPseudoStripe(styleText));
|
|
2199
2273
|
|
|
2200
2274
|
// Side-tab accent stripe drawn as a single-edge inset box-shadow.
|
|
2201
|
-
findings.push(...scanCssTextForInsetStripe(
|
|
2275
|
+
findings.push(...scanCssTextForInsetStripe(styleText));
|
|
2202
2276
|
|
|
2203
2277
|
// --- Layout ---
|
|
2204
2278
|
|
|
@@ -2206,20 +2280,20 @@ function checkHtmlPatterns(html) {
|
|
|
2206
2280
|
const spacingValues = [];
|
|
2207
2281
|
const spacingRe = /(?:padding|margin)(?:-(?:top|right|bottom|left))?\s*:\s*(\d+)px/gi;
|
|
2208
2282
|
let sm;
|
|
2209
|
-
while ((sm = spacingRe.exec(
|
|
2283
|
+
while ((sm = spacingRe.exec(styleText)) !== null) {
|
|
2210
2284
|
const v = parseInt(sm[1], 10);
|
|
2211
2285
|
if (v > 0 && v < 200) spacingValues.push(v);
|
|
2212
2286
|
}
|
|
2213
2287
|
const gapRe = /gap\s*:\s*(\d+)px/gi;
|
|
2214
|
-
while ((sm = gapRe.exec(
|
|
2288
|
+
while ((sm = gapRe.exec(styleText)) !== null) {
|
|
2215
2289
|
spacingValues.push(parseInt(sm[1], 10));
|
|
2216
2290
|
}
|
|
2217
2291
|
const twSpaceRe = /\b(?:p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|gap)-(\d+)\b/g;
|
|
2218
|
-
while ((sm = twSpaceRe.exec(
|
|
2292
|
+
while ((sm = twSpaceRe.exec(classText)) !== null) {
|
|
2219
2293
|
spacingValues.push(parseInt(sm[1], 10) * 4);
|
|
2220
2294
|
}
|
|
2221
2295
|
const remSpacingRe = /(?:padding|margin)(?:-(?:top|right|bottom|left))?\s*:\s*([\d.]+)rem/gi;
|
|
2222
|
-
while ((sm = remSpacingRe.exec(
|
|
2296
|
+
while ((sm = remSpacingRe.exec(styleText)) !== null) {
|
|
2223
2297
|
const v = Math.round(parseFloat(sm[1]) * 16);
|
|
2224
2298
|
if (v > 0 && v < 200) spacingValues.push(v);
|
|
2225
2299
|
}
|
|
@@ -2243,7 +2317,7 @@ function checkHtmlPatterns(html) {
|
|
|
2243
2317
|
|
|
2244
2318
|
// Bounce/elastic animation names
|
|
2245
2319
|
const bounceRe = /animation(?:-name)?\s*:\s*([^;{}]*(?:bounce|elastic|wobble|jiggle|spring)[^;{}]*)/gi;
|
|
2246
|
-
const bounceMatch = bounceRe.exec(
|
|
2320
|
+
const bounceMatch = bounceRe.exec(styleText);
|
|
2247
2321
|
if (bounceMatch) {
|
|
2248
2322
|
const animationToken = bounceMatch[1]
|
|
2249
2323
|
.split(/[,\s]+/)
|
|
@@ -2254,7 +2328,7 @@ function checkHtmlPatterns(html) {
|
|
|
2254
2328
|
// Overshoot cubic-bezier
|
|
2255
2329
|
const bezierRe = /cubic-bezier\(\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*\)/g;
|
|
2256
2330
|
let bm;
|
|
2257
|
-
while ((bm = bezierRe.exec(
|
|
2331
|
+
while ((bm = bezierRe.exec(styleText)) !== null) {
|
|
2258
2332
|
const y1 = parseFloat(bm[2]), y2 = parseFloat(bm[4]);
|
|
2259
2333
|
if (y1 < -0.1 || y1 > 1.1 || y2 < -0.1 || y2 > 1.1) {
|
|
2260
2334
|
findings.push({ id: 'bounce-easing', snippet: `cubic-bezier(${bm[1]}, ${bm[2]}, ${bm[3]}, ${bm[4]})` });
|
|
@@ -2265,7 +2339,7 @@ function checkHtmlPatterns(html) {
|
|
|
2265
2339
|
// Layout property transitions
|
|
2266
2340
|
const transRe = /transition(?:-property)?\s*:\s*([^;{}]+)/gi;
|
|
2267
2341
|
let tm;
|
|
2268
|
-
while ((tm = transRe.exec(
|
|
2342
|
+
while ((tm = transRe.exec(styleText)) !== null) {
|
|
2269
2343
|
const val = tm[1].toLowerCase();
|
|
2270
2344
|
if (/\ball\b/.test(val)) continue;
|
|
2271
2345
|
const found = val.match(/\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding(?:-(?:top|right|bottom|left))?\b|\bmargin(?:-(?:top|right|bottom|left))?\b/gi);
|
|
@@ -2275,30 +2349,32 @@ function checkHtmlPatterns(html) {
|
|
|
2275
2349
|
}
|
|
2276
2350
|
}
|
|
2277
2351
|
|
|
2278
|
-
// Pulsing status dots (tiny circular elements on infinite pulse animations)
|
|
2279
|
-
|
|
2352
|
+
// Pulsing status dots (tiny circular elements on infinite pulse animations).
|
|
2353
|
+
// The CSS rules come from styleText; the markup carries the landmark
|
|
2354
|
+
// ranges and Tailwind class attributes.
|
|
2355
|
+
findings.push(...scanCssTextForPulsingDot(styleText, html));
|
|
2280
2356
|
|
|
2281
2357
|
// Shape-assembled illustrations (large pictorial SVGs built from primitives)
|
|
2282
2358
|
findings.push(...scanHtmlForShapeAssembledIllustration(html));
|
|
2283
2359
|
|
|
2284
2360
|
// Auto-scrolling marquees (<marquee> or infinite horizontal loop animations)
|
|
2285
|
-
findings.push(...scanCssTextForMarquee(html));
|
|
2361
|
+
findings.push(...scanCssTextForMarquee(styleText, html));
|
|
2286
2362
|
|
|
2287
2363
|
// --- Dark glow / chromatic halo shadows ---
|
|
2288
2364
|
|
|
2289
|
-
const glowHits = scanCssTextForGlow(
|
|
2365
|
+
const glowHits = scanCssTextForGlow(styleText);
|
|
2290
2366
|
if (glowHits.length > 0) {
|
|
2291
2367
|
findings.push({ id: 'dark-glow', snippet: glowHits[0].snippet });
|
|
2292
2368
|
}
|
|
2293
2369
|
|
|
2294
2370
|
// Radial-gradient background halo (gradient-drawn sibling of dark-glow)
|
|
2295
|
-
const haloHits = scanCssTextForRadialHalo(
|
|
2371
|
+
const haloHits = scanCssTextForRadialHalo(styleText);
|
|
2296
2372
|
if (haloHits.length > 0) {
|
|
2297
2373
|
findings.push({ id: 'radial-halo', snippet: haloHits[0].snippet });
|
|
2298
2374
|
}
|
|
2299
2375
|
|
|
2300
2376
|
// --- Generated-UI tells: repeating-gradient stripes ---
|
|
2301
|
-
if (/repeating-(?:linear|radial|conic)-gradient\s*\(/i.test(
|
|
2377
|
+
if (/repeating-(?:linear|radial|conic)-gradient\s*\(/i.test(styleText)) {
|
|
2302
2378
|
findings.push({ id: 'repeating-stripes-gradient', snippet: 'repeating-gradient decorative stripes' });
|
|
2303
2379
|
}
|
|
2304
2380
|
|
|
@@ -2315,7 +2391,7 @@ function checkHtmlPatterns(html) {
|
|
|
2315
2391
|
// in for the second axis. Colors like `oklch(96% 0.012 82 / 0.055)` carry
|
|
2316
2392
|
// nested parens, so match the hairline stop directly rather than parsing
|
|
2317
2393
|
// whole gradient layers.
|
|
2318
|
-
const gridHits = scanCssTextForGridBackground(
|
|
2394
|
+
const gridHits = scanCssTextForGridBackground(styleText);
|
|
2319
2395
|
if (gridHits.length > 0) {
|
|
2320
2396
|
findings.push({ id: 'codex-grid-background', snippet: gridHits[0].snippet });
|
|
2321
2397
|
}
|
|
@@ -2337,7 +2413,7 @@ function checkHtmlPatterns(html) {
|
|
|
2337
2413
|
// hover:rotate / hover:translate utility on an <img>. Each distinct
|
|
2338
2414
|
// mechanism is its own finding.
|
|
2339
2415
|
const imgHoverCss = /\bimg\b[^,{}]*:hover\b[^{}]*\{[^}]*\btransform\s*:\s*(?:scale|rotate|translate|matrix|skew)/i;
|
|
2340
|
-
if (imgHoverCss.test(
|
|
2416
|
+
if (imgHoverCss.test(styleText)) {
|
|
2341
2417
|
findings.push({ id: 'image-hover-transform', snippet: 'img:hover { transform } rule' });
|
|
2342
2418
|
}
|
|
2343
2419
|
const imgTagRe = /<img\b[^>]*\bclass\s*=\s*"([^"]*)"/gi;
|
|
@@ -2462,29 +2538,54 @@ function resolveBackground(el, win, customPropMap) {
|
|
|
2462
2538
|
// Walk parents looking for a gradient background and return its color stops.
|
|
2463
2539
|
// Used as a fallback when resolveBackground() returns null because the
|
|
2464
2540
|
// effective background is a gradient (no single solid color to compare against).
|
|
2465
|
-
function resolveGradientStops(el, win) {
|
|
2541
|
+
function resolveGradientStops(el, win, customPropMap) {
|
|
2466
2542
|
let current = el;
|
|
2467
2543
|
while (current && current.nodeType === 1) {
|
|
2468
2544
|
const style = DETECTOR_IS_BROWSER ? getComputedStyle(current) : win.getComputedStyle(current);
|
|
2469
2545
|
const bgImage = style.backgroundImage || '';
|
|
2546
|
+
let stops = null;
|
|
2470
2547
|
if (bgImage && bgImage !== 'none' && /gradient/i.test(bgImage)) {
|
|
2471
|
-
const
|
|
2472
|
-
if (
|
|
2548
|
+
const parsed = parseGradientColors(bgImage);
|
|
2549
|
+
if (parsed.length > 0) stops = parsed;
|
|
2473
2550
|
}
|
|
2474
|
-
if (!DETECTOR_IS_BROWSER) {
|
|
2551
|
+
if (!stops && !DETECTOR_IS_BROWSER) {
|
|
2475
2552
|
// jsdom doesn't decompose `background:` shorthand — peek at the raw inline style
|
|
2476
2553
|
const rawStyle = current.getAttribute?.('style') || '';
|
|
2477
2554
|
const bgMatch = rawStyle.match(/background(?:-image)?\s*:\s*([^;]+)/i);
|
|
2478
2555
|
if (bgMatch && /gradient/i.test(bgMatch[1])) {
|
|
2479
|
-
const
|
|
2480
|
-
if (
|
|
2556
|
+
const parsed = parseGradientColors(bgMatch[1]);
|
|
2557
|
+
if (parsed.length > 0) stops = parsed;
|
|
2481
2558
|
}
|
|
2482
2559
|
}
|
|
2560
|
+
if (stops) return compositeGradientStops(stops, current, win, customPropMap);
|
|
2483
2561
|
current = current.parentElement;
|
|
2484
2562
|
}
|
|
2485
2563
|
return null;
|
|
2486
2564
|
}
|
|
2487
2565
|
|
|
2566
|
+
// A translucent gradient stop (e.g. a faint `rgba(52,192,168,0.09)` accent
|
|
2567
|
+
// glow) paints over whatever surface sits beneath the gradient — the browser
|
|
2568
|
+
// composites it, so its effective color is far closer to the base than to the
|
|
2569
|
+
// full-opacity accent. Treating the stop as opaque flags every text child of a
|
|
2570
|
+
// softly-glowing section as low-contrast (issue #409 Case B). Composite each
|
|
2571
|
+
// alpha stop over the resolved surface beneath the gradient element. When that
|
|
2572
|
+
// surface isn't resolvable (another gradient above, no opaque ancestor), drop
|
|
2573
|
+
// the translucent stop rather than guess: a dropped stop can't manufacture a
|
|
2574
|
+
// false finding, and skipping beats a wrong ratio.
|
|
2575
|
+
function compositeGradientStops(stops, gradientEl, win, customPropMap) {
|
|
2576
|
+
const hasAlpha = stops.some(s => (s.a ?? 1) < 0.99);
|
|
2577
|
+
if (!hasAlpha) return stops;
|
|
2578
|
+
const base = resolveBackground(gradientEl.parentElement || gradientEl, win, customPropMap);
|
|
2579
|
+
const out = [];
|
|
2580
|
+
for (const s of stops) {
|
|
2581
|
+
const a = s.a ?? 1;
|
|
2582
|
+
if (a >= 0.99) { out.push(s); continue; }
|
|
2583
|
+
if (base) out.push(compositeColorOver(s, base));
|
|
2584
|
+
// else: unresolvable base — drop the translucent stop (skip, don't guess).
|
|
2585
|
+
}
|
|
2586
|
+
return out.length ? out : null;
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2488
2589
|
// Parse a single CSS length token to pixels. Accepts "12px", "50%", a
|
|
2489
2590
|
// shorthand like "12px 4px" (uses the first value), or empty / null.
|
|
2490
2591
|
// Returns the pixel value, or null when the input is unparseable.
|
|
@@ -3134,7 +3235,7 @@ function parseColorResolved(str, customPropMap) {
|
|
|
3134
3235
|
return parseAnyColor(resolved);
|
|
3135
3236
|
}
|
|
3136
3237
|
|
|
3137
|
-
const
|
|
3238
|
+
const KICKER_SKIP_SELECTOR = [
|
|
3138
3239
|
'nav',
|
|
3139
3240
|
'form',
|
|
3140
3241
|
'table',
|
|
@@ -3153,7 +3254,7 @@ const REPEATED_KICKER_SKIP_SELECTOR = [
|
|
|
3153
3254
|
'[data-impeccable-allow-kickers]',
|
|
3154
3255
|
].join(',');
|
|
3155
3256
|
|
|
3156
|
-
const
|
|
3257
|
+
const KICKER_CARD_CONTEXT_SELECTOR = [
|
|
3157
3258
|
'article',
|
|
3158
3259
|
'button',
|
|
3159
3260
|
'a',
|
|
@@ -3171,23 +3272,32 @@ function cleanInlineText(el) {
|
|
|
3171
3272
|
.trim();
|
|
3172
3273
|
}
|
|
3173
3274
|
|
|
3174
|
-
function
|
|
3175
|
-
const item = heading.closest?.(
|
|
3275
|
+
function isKickerCardContext(heading, kicker) {
|
|
3276
|
+
const item = heading.closest?.(KICKER_CARD_CONTEXT_SELECTOR);
|
|
3176
3277
|
return Boolean(item && (!item.contains || item.contains(kicker)));
|
|
3177
3278
|
}
|
|
3178
3279
|
|
|
3179
|
-
|
|
3280
|
+
// Meta lines above headlines join category and date (or path crumbs) with
|
|
3281
|
+
// separator glyphs, or carry a year. A kicker is one short phrase; metadata
|
|
3282
|
+
// keeps its markers.
|
|
3283
|
+
const KICKER_META_TEXT_RE = /[·•|]|\s[\/›»>]\s|\b(19|20)\d{2}\b/;
|
|
3284
|
+
// Legal and document numbering: "Section 4.2", "Article IX", "§ 12.3",
|
|
3285
|
+
// dotted decimal outlines. The label identifies the clause, so it stays.
|
|
3286
|
+
const KICKER_DOC_NUMBERING_RE = /^(§|\d+(\.\d+)+\b|(section|article|clause|appendix|exhibit|schedule|chapter|part|rule|title)\s+([\divxlc]+\b|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b)/i;
|
|
3287
|
+
|
|
3288
|
+
function isKickerCandidate(opts) {
|
|
3180
3289
|
const {
|
|
3181
|
-
|
|
3290
|
+
headingLevel,
|
|
3182
3291
|
headingText,
|
|
3183
3292
|
headingFontSize,
|
|
3184
3293
|
kickerTag,
|
|
3185
3294
|
kickerText,
|
|
3186
3295
|
kickerTextTransform,
|
|
3296
|
+
kickerFontVariant,
|
|
3187
3297
|
kickerFontSize,
|
|
3188
3298
|
kickerLetterSpacing,
|
|
3189
3299
|
} = opts;
|
|
3190
|
-
if (!
|
|
3300
|
+
if (!headingLevel || headingLevel > 4) return false;
|
|
3191
3301
|
if (!headingText || headingText.length < 3) return false;
|
|
3192
3302
|
if (/^\/[\w-]+/i.test(headingText.replace(/^"|"$/g, '').trim())) return false;
|
|
3193
3303
|
if (!(headingFontSize >= 20)) return false;
|
|
@@ -3195,47 +3305,82 @@ function isRepeatedKickerCandidate(opts) {
|
|
|
3195
3305
|
if (!['p', 'span', 'div', 'small'].includes(kickerTag)) return false;
|
|
3196
3306
|
if (!kickerText || kickerText.length < 2 || kickerText.length > 34) return false;
|
|
3197
3307
|
if (/^step\s*\d+/i.test(kickerText) || /^\d{1,2}$/.test(kickerText)) return false;
|
|
3308
|
+
if (KICKER_META_TEXT_RE.test(kickerText)) return false;
|
|
3309
|
+
if (KICKER_DOC_NUMBERING_RE.test(kickerText)) return false;
|
|
3198
3310
|
|
|
3311
|
+
const isSmallCaps = /small-caps/.test(kickerFontVariant || '');
|
|
3199
3312
|
const isUppercased = kickerTextTransform === 'uppercase'
|
|
3200
|
-
|| (/[A-Z]/.test(kickerText) && !/[a-z]/.test(kickerText))
|
|
3313
|
+
|| (/[A-Z]/.test(kickerText) && !/[a-z]/.test(kickerText))
|
|
3314
|
+
|| isSmallCaps;
|
|
3201
3315
|
if (!isUppercased) return false;
|
|
3202
3316
|
if (!(kickerFontSize > 0 && kickerFontSize <= 14)) return false;
|
|
3203
|
-
|
|
3317
|
+
// Proportional only, no absolute floor: the wild's most common recipe is
|
|
3318
|
+
// 0.08em at a sub-13px size, which computes to under 1px and sailed past
|
|
3319
|
+
// the old Math.max(1, ...) floor (observed live: a page whose kickers were
|
|
3320
|
+
// literally class="kicker" produced zero findings).
|
|
3321
|
+
const minTrackedSpacing = kickerFontSize * 0.06;
|
|
3204
3322
|
if (!(kickerLetterSpacing >= minTrackedSpacing)) return false;
|
|
3205
3323
|
return true;
|
|
3206
3324
|
}
|
|
3207
3325
|
|
|
3208
|
-
|
|
3326
|
+
// Resolve a heading level for the anchor element: 1-4 for h1-h4, aria-level
|
|
3327
|
+
// (default 2) for role="heading" elements, 0 otherwise.
|
|
3328
|
+
function kickerHeadingLevel(heading) {
|
|
3329
|
+
const tag = heading.tagName.toLowerCase();
|
|
3330
|
+
const byTag = /^h([1-6])$/.exec(tag);
|
|
3331
|
+
if (byTag) return parseInt(byTag[1], 10);
|
|
3332
|
+
const role = heading.getAttribute?.('role') || '';
|
|
3333
|
+
if (role.toLowerCase() !== 'heading') return 0;
|
|
3334
|
+
const ariaLevel = parseInt(heading.getAttribute?.('aria-level') || '', 10);
|
|
3335
|
+
return Number.isFinite(ariaLevel) && ariaLevel >= 1 ? ariaLevel : 2;
|
|
3336
|
+
}
|
|
3337
|
+
|
|
3338
|
+
function collectKickerCandidates(doc, getStyle, resolveLetterSpacing) {
|
|
3209
3339
|
const candidates = [];
|
|
3210
|
-
for (const heading of doc.querySelectorAll('h2, h3, h4')) {
|
|
3211
|
-
|
|
3340
|
+
for (const heading of doc.querySelectorAll('h1, h2, h3, h4, [role="heading"]')) {
|
|
3341
|
+
const headingLevel = kickerHeadingLevel(heading);
|
|
3342
|
+
if (!headingLevel || headingLevel > 4) continue;
|
|
3343
|
+
if (heading.closest?.(KICKER_SKIP_SELECTOR)) continue;
|
|
3344
|
+
// Application contexts (tab panels, dialogs) use compact context labels
|
|
3345
|
+
// above headings to describe state, not to decorate. Same carve-out the
|
|
3346
|
+
// hero-eyebrow rule makes.
|
|
3347
|
+
if (heading.closest?.('[role="tabpanel"], [role="dialog"], [role="application"], dialog')) continue;
|
|
3212
3348
|
const kicker = heading.previousElementSibling;
|
|
3213
|
-
if (!kicker || kicker.closest?.(
|
|
3214
|
-
if (
|
|
3349
|
+
if (!kicker || kicker.closest?.(KICKER_SKIP_SELECTOR)) continue;
|
|
3350
|
+
if (isKickerCardContext(heading, kicker)) continue;
|
|
3215
3351
|
|
|
3216
3352
|
const headingStyle = getStyle(heading);
|
|
3217
3353
|
const kickerStyle = getStyle(kicker);
|
|
3354
|
+
const headingTag = heading.tagName.toLowerCase();
|
|
3218
3355
|
const headingText = (heading.textContent || '').replace(/\s+/g, ' ').trim();
|
|
3219
3356
|
const kickerText = cleanInlineText(kicker) || (kicker.textContent || '').replace(/\s+/g, ' ').trim();
|
|
3220
3357
|
const headingFontSize = resolveLetterSpacing(headingStyle.fontSize || '', 16) || parseFloat(headingStyle.fontSize) || 0;
|
|
3221
3358
|
const kickerFontSize = resolveLetterSpacing(kickerStyle.fontSize || '', 16) || parseFloat(kickerStyle.fontSize) || 0;
|
|
3222
3359
|
const kickerLetterSpacing = resolveLetterSpacing(kickerStyle.letterSpacing || '', kickerFontSize);
|
|
3223
3360
|
|
|
3224
|
-
if (!
|
|
3225
|
-
|
|
3361
|
+
if (!isKickerCandidate({
|
|
3362
|
+
headingLevel,
|
|
3226
3363
|
headingText,
|
|
3227
3364
|
headingFontSize,
|
|
3228
3365
|
kickerTag: kicker.tagName.toLowerCase(),
|
|
3229
3366
|
kickerText,
|
|
3230
3367
|
kickerTextTransform: kickerStyle.textTransform || '',
|
|
3368
|
+
kickerFontVariant: `${kickerStyle.fontVariant || ''} ${kickerStyle.fontVariantCaps || ''}`,
|
|
3231
3369
|
kickerFontSize,
|
|
3232
3370
|
kickerLetterSpacing,
|
|
3233
3371
|
})) {
|
|
3234
3372
|
continue;
|
|
3235
3373
|
}
|
|
3236
3374
|
|
|
3375
|
+
// A tracked-caps eyebrow above a hero-scale h1 belongs to
|
|
3376
|
+
// hero-eyebrow-chip (which also covers the accent-bold and dash-prefix
|
|
3377
|
+
// stylings there). Stand down so one element gets one finding.
|
|
3378
|
+
if (headingTag === 'h1' && headingFontSize >= 48 && kickerLetterSpacing >= 1.6) {
|
|
3379
|
+
continue;
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3237
3382
|
candidates.push({
|
|
3238
|
-
headingTag
|
|
3383
|
+
headingTag,
|
|
3239
3384
|
headingText: headingText.replace(/^"|"$/g, '').slice(0, 60),
|
|
3240
3385
|
kickerText: kickerText.slice(0, 40),
|
|
3241
3386
|
});
|
|
@@ -3243,17 +3388,17 @@ function collectRepeatedSectionKickerCandidates(doc, getStyle, resolveLetterSpac
|
|
|
3243
3388
|
return candidates;
|
|
3244
3389
|
}
|
|
3245
3390
|
|
|
3246
|
-
function
|
|
3247
|
-
const candidates =
|
|
3391
|
+
function checkKickerAboveHeadingDOM() {
|
|
3392
|
+
const candidates = collectKickerCandidates(
|
|
3248
3393
|
document,
|
|
3249
3394
|
(el) => getComputedStyle(el),
|
|
3250
3395
|
(value, fontSize) => resolveLengthPx(value, fontSize) || 0,
|
|
3251
3396
|
);
|
|
3252
|
-
return
|
|
3397
|
+
return checkKickerAboveHeading({ candidates });
|
|
3253
3398
|
}
|
|
3254
3399
|
|
|
3255
3400
|
// ── Numbered section labels ─────────────────────────────────────────────────
|
|
3256
|
-
// Sibling of the
|
|
3401
|
+
// Sibling of the kicker-above-heading rule: instead of a tracked uppercase word,
|
|
3257
3402
|
// the section scaffold is a tiny numeric index riding beside each section
|
|
3258
3403
|
// heading — bare and zero-padded, or an index joined to a short micro-label
|
|
3259
3404
|
// by a separator glyph. The kicker rule deliberately excludes bare 1-2 digit
|
|
@@ -3307,7 +3452,7 @@ function collectNumberedSectionLabelCandidates(doc, getStyle, resolveLetterSpaci
|
|
|
3307
3452
|
const candidates = [];
|
|
3308
3453
|
const seenLabels = new Set();
|
|
3309
3454
|
for (const heading of doc.querySelectorAll('h2, h3, h4')) {
|
|
3310
|
-
if (heading.closest?.(
|
|
3455
|
+
if (heading.closest?.(KICKER_SKIP_SELECTOR)) continue;
|
|
3311
3456
|
// The index sits either directly before the heading, or before the
|
|
3312
3457
|
// wrapper the heading leads (label | <div><h2>…</h2>…</div>).
|
|
3313
3458
|
let label = heading.previousElementSibling;
|
|
@@ -3317,9 +3462,9 @@ function collectNumberedSectionLabelCandidates(doc, getStyle, resolveLetterSpaci
|
|
|
3317
3462
|
if (firstChild === heading) label = parent.previousElementSibling;
|
|
3318
3463
|
}
|
|
3319
3464
|
if (!label || seenLabels.has(label)) continue;
|
|
3320
|
-
if (label.closest?.(
|
|
3465
|
+
if (label.closest?.(KICKER_SKIP_SELECTOR)) continue;
|
|
3321
3466
|
if (HEADING_TAGS.has(label.tagName.toLowerCase())) continue;
|
|
3322
|
-
if (
|
|
3467
|
+
if (isKickerCardContext(heading, label)) continue;
|
|
3323
3468
|
|
|
3324
3469
|
const labelText = cleanInlineText(label) || (label.textContent || '').replace(/\s+/g, ' ').trim();
|
|
3325
3470
|
const parsed = parseNumberedLabelText(labelText);
|
|
@@ -3522,6 +3667,131 @@ function checkElementAIPaletteDOM(el) {
|
|
|
3522
3667
|
return findings;
|
|
3523
3668
|
}
|
|
3524
3669
|
|
|
3670
|
+
// ─── Decorative radial spotlight glow ───────────────────────────────────────
|
|
3671
|
+
// A soft, low-opacity chromatic radial-gradient fading to transparent, painted
|
|
3672
|
+
// as a decorative wash behind a hero or section. The translucent sibling of the
|
|
3673
|
+
// `radial-halo` tell: `radial-halo` requires a saturated, near-opaque center on
|
|
3674
|
+
// a dark page; this catches the low-alpha "spotlight" the halo gate lets slip
|
|
3675
|
+
// (e.g. `radial-gradient(circle at 52% 38%, rgba(80,111,255,0.26),
|
|
3676
|
+
// transparent 44%)`). The two alpha bands are disjoint, so they never
|
|
3677
|
+
// double-report the same declaration.
|
|
3678
|
+
const SPOTLIGHT_COLOR_TOKEN_RE = /(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color-mix)\([^)]*(?:\([^)]*\))?[^)]*\)|#[0-9a-f]{3,8}\b|\btransparent\b/i;
|
|
3679
|
+
|
|
3680
|
+
// Parse the FIRST non-repeating radial-gradient in a background value into its
|
|
3681
|
+
// ordered color stops. Each stop is { color: {r,g,b,a} | null, transparent }.
|
|
3682
|
+
// Returns null when there is no plain radial-gradient to read.
|
|
3683
|
+
function parseRadialGradientStops(value) {
|
|
3684
|
+
if (!value || !/radial-gradient/i.test(value)) return null;
|
|
3685
|
+
const gradRe = /(repeating-)?radial-gradient\(/gi;
|
|
3686
|
+
let g;
|
|
3687
|
+
while ((g = gradRe.exec(value)) !== null) {
|
|
3688
|
+
if (g[1]) continue; // repeating-* is a pattern, not a spotlight
|
|
3689
|
+
let depth = 0, end = -1;
|
|
3690
|
+
const open = value.indexOf('(', g.index);
|
|
3691
|
+
for (let i = open; i < value.length; i++) {
|
|
3692
|
+
if (value[i] === '(') depth++;
|
|
3693
|
+
else if (value[i] === ')') { depth--; if (depth === 0) { end = i; break; } }
|
|
3694
|
+
}
|
|
3695
|
+
if (end < 0) return null;
|
|
3696
|
+
const args = splitTopLevelCommas(value.slice(open + 1, end));
|
|
3697
|
+
// The optional prelude (shape / size / `at <pos>`) carries no color token.
|
|
3698
|
+
const stopArgs = args.filter(a => SPOTLIGHT_COLOR_TOKEN_RE.test(a));
|
|
3699
|
+
if (stopArgs.length < 2) return null;
|
|
3700
|
+
return stopArgs.map(a => {
|
|
3701
|
+
const tok = a.match(SPOTLIGHT_COLOR_TOKEN_RE);
|
|
3702
|
+
if (!tok) return { color: null, transparent: false };
|
|
3703
|
+
if (/^transparent$/i.test(tok[0])) return { color: null, transparent: true };
|
|
3704
|
+
const color = parseAnyColor(tok[0]);
|
|
3705
|
+
return { color, transparent: !!color && (color.a ?? 1) <= 0.05 };
|
|
3706
|
+
});
|
|
3707
|
+
}
|
|
3708
|
+
return null;
|
|
3709
|
+
}
|
|
3710
|
+
|
|
3711
|
+
// Pure gate. `label` is a stable identifier the fixture test keys on.
|
|
3712
|
+
function checkRadialSpotlight({ gradientValue, width, height, label }) {
|
|
3713
|
+
const stops = parseRadialGradientStops(gradientValue);
|
|
3714
|
+
if (!stops || stops.length < 2) return [];
|
|
3715
|
+
|
|
3716
|
+
// Must fade OUT: the last stop is transparent / near-zero alpha. A gradient
|
|
3717
|
+
// between two visible surfaces is a real background, not a floating glow.
|
|
3718
|
+
const last = stops[stops.length - 1];
|
|
3719
|
+
const lastAlpha = last.transparent ? 0 : (last.color ? (last.color.a ?? 1) : 1);
|
|
3720
|
+
if (lastAlpha > 0.05) return [];
|
|
3721
|
+
|
|
3722
|
+
// The visible (non-transparent, parseable) color stops.
|
|
3723
|
+
const colored = stops.filter(s => !s.transparent && s.color && (s.color.a ?? 1) > 0.05);
|
|
3724
|
+
if (colored.length === 0) return [];
|
|
3725
|
+
// One soft glow, not a multi-color composition: at most two visible stops.
|
|
3726
|
+
if (colored.length > 2) return [];
|
|
3727
|
+
// Every visible stop must be LOW opacity. Any opaque stop means a real fill
|
|
3728
|
+
// or a saturated halo (`radial-halo`'s job), not this translucent spotlight.
|
|
3729
|
+
if (colored.some(s => (s.color.a ?? 1) >= 0.45)) return [];
|
|
3730
|
+
// At least one visible stop must be chromatic. A neutral (grayscale)
|
|
3731
|
+
// near-black / near-white vignette is a legitimate lighting move, exempt.
|
|
3732
|
+
const chromatic = colored.find(s => hasChroma(s.color, 24));
|
|
3733
|
+
if (!chromatic) return [];
|
|
3734
|
+
|
|
3735
|
+
// Decorative-scale gate. Badges, avatars, and actual small "lights" are
|
|
3736
|
+
// exempt; a spotlight glow only reads as slop when it washes a large surface.
|
|
3737
|
+
if (!(width >= 240 && height >= 160)) return [];
|
|
3738
|
+
|
|
3739
|
+
const alpha = (chromatic.color.a ?? 1).toFixed(2);
|
|
3740
|
+
const name = label || 'section';
|
|
3741
|
+
return [{
|
|
3742
|
+
id: 'radial-spotlight-glow',
|
|
3743
|
+
snippet: `radial-gradient spotlight glow "${name}" (${colorToHex(chromatic.color)} a${alpha} → transparent) on ${Math.round(width)}x${Math.round(height)} surface`,
|
|
3744
|
+
}];
|
|
3745
|
+
}
|
|
3746
|
+
|
|
3747
|
+
// Read the raw radial-gradient source off an element's computed style, with a
|
|
3748
|
+
// fallback to the `background` shorthand and the inline style attribute for
|
|
3749
|
+
// engines that don't decompose the shorthand into backgroundImage.
|
|
3750
|
+
function elementGradientValue(style, el) {
|
|
3751
|
+
const bgImage = style.backgroundImage && style.backgroundImage !== 'none' ? style.backgroundImage : '';
|
|
3752
|
+
if (/radial-gradient/i.test(bgImage)) return bgImage;
|
|
3753
|
+
const bg = style.background || '';
|
|
3754
|
+
if (/radial-gradient/i.test(bg)) return bg;
|
|
3755
|
+
const rawStyle = el?.getAttribute?.('style') || '';
|
|
3756
|
+
const m = rawStyle.match(/background(?:-image)?\s*:\s*([^;]+)/i);
|
|
3757
|
+
if (m && /radial-gradient/i.test(m[1])) return m[1];
|
|
3758
|
+
return '';
|
|
3759
|
+
}
|
|
3760
|
+
|
|
3761
|
+
function spotlightLabel(el) {
|
|
3762
|
+
const dataName = el.getAttribute?.('data-name');
|
|
3763
|
+
if (dataName) return dataName;
|
|
3764
|
+
if (typeof el.id === 'string' && el.id) return el.id;
|
|
3765
|
+
const cls = typeof el.className === 'string' ? el.className.trim().split(/\s+/)[0] : '';
|
|
3766
|
+
if (cls) return cls;
|
|
3767
|
+
return el.tagName ? el.tagName.toLowerCase() : 'section';
|
|
3768
|
+
}
|
|
3769
|
+
|
|
3770
|
+
function checkElementRadialSpotlightDOM(el) {
|
|
3771
|
+
const style = getComputedStyle(el);
|
|
3772
|
+
const gradientValue = elementGradientValue(style, el);
|
|
3773
|
+
if (!gradientValue) return [];
|
|
3774
|
+
const rect = el.getBoundingClientRect();
|
|
3775
|
+
return checkRadialSpotlight({
|
|
3776
|
+
gradientValue,
|
|
3777
|
+
width: rect.width,
|
|
3778
|
+
height: rect.height,
|
|
3779
|
+
label: spotlightLabel(el),
|
|
3780
|
+
});
|
|
3781
|
+
}
|
|
3782
|
+
|
|
3783
|
+
function checkElementRadialSpotlight(el, style, tag, window) {
|
|
3784
|
+
const gradientValue = elementGradientValue(style, el);
|
|
3785
|
+
if (!gradientValue) return [];
|
|
3786
|
+
// Static engine does no layout — read explicit pixel dimensions from CSS.
|
|
3787
|
+
return checkRadialSpotlight({
|
|
3788
|
+
gradientValue,
|
|
3789
|
+
width: parseFloat(style.width) || 0,
|
|
3790
|
+
height: parseFloat(style.height) || 0,
|
|
3791
|
+
label: spotlightLabel(el),
|
|
3792
|
+
});
|
|
3793
|
+
}
|
|
3794
|
+
|
|
3525
3795
|
const QUALITY_TEXT_TAGS = new Set(['p', 'li', 'td', 'th', 'dd', 'blockquote', 'figcaption']);
|
|
3526
3796
|
|
|
3527
3797
|
// Resolve a CSS font-size value to pixels by walking up the parent chain.
|
|
@@ -3664,6 +3934,34 @@ function isVisuallyHidden(el, style) {
|
|
|
3664
3934
|
return false;
|
|
3665
3935
|
}
|
|
3666
3936
|
|
|
3937
|
+
// Elements whose text is never painted: document metadata and script/style
|
|
3938
|
+
// payloads. Their JS / CSS / JSON-LD text satisfies `hasDirectText`, and on
|
|
3939
|
+
// sites that set `html { font-size: 62.5% }` their inherited computed size is
|
|
3940
|
+
// 10px — so the text-size floors flag them as tiny body copy even though
|
|
3941
|
+
// nothing renders (issue #408: dozens of phantom "10px body text" findings on
|
|
3942
|
+
// every Shopify page). Exclude them, plus anything the cascade resolves to
|
|
3943
|
+
// display:none / visibility:hidden. The jsdom path can't lay out, so the
|
|
3944
|
+
// tag/attribute-based exclusions carry the weight there; the display checks are
|
|
3945
|
+
// computed-style reads that resolve without layout in both adapters.
|
|
3946
|
+
const NON_RENDERED_TAGS = new Set([
|
|
3947
|
+
'script', 'style', 'title', 'noscript', 'template', 'head',
|
|
3948
|
+
'meta', 'link', 'base', 'param', 'source', 'track', 'datalist',
|
|
3949
|
+
'col', 'colgroup', 'map', 'area',
|
|
3950
|
+
]);
|
|
3951
|
+
function isNonRenderedText(el, tag, style) {
|
|
3952
|
+
const t = (tag || '').toLowerCase();
|
|
3953
|
+
if (NON_RENDERED_TAGS.has(t)) return true;
|
|
3954
|
+
// Descendants of <head> never render even when the tag itself would
|
|
3955
|
+
// (some sites nest <noscript>/<template> content there).
|
|
3956
|
+
if (el && el.closest && el.closest('head')) return true;
|
|
3957
|
+
if (style) {
|
|
3958
|
+
if (style.display === 'none') return true;
|
|
3959
|
+
const vis = style.visibility;
|
|
3960
|
+
if (vis === 'hidden' || vis === 'collapse') return true;
|
|
3961
|
+
}
|
|
3962
|
+
return false;
|
|
3963
|
+
}
|
|
3964
|
+
|
|
3667
3965
|
// Pure quality checks. Most run on computed CSS and DOM-only inputs (work in
|
|
3668
3966
|
// jsdom and the browser). Two checks (line-length, cramped-padding) gate on
|
|
3669
3967
|
// element rect dimensions, which jsdom can't compute — pass `rect: null` from
|
|
@@ -3674,8 +3972,13 @@ function isVisuallyHidden(el, style) {
|
|
|
3674
3972
|
function checkQuality(opts) {
|
|
3675
3973
|
const { el, tag, style, hasDirectText, textLen, fontSize, lineHeightPx, letterSpacingPx, rect, lineMax = 80, viewportWidth = 0, win = null } = opts;
|
|
3676
3974
|
const findings = [];
|
|
3677
|
-
// Skip browser extension injected elements
|
|
3678
|
-
|
|
3975
|
+
// Skip browser extension injected elements. Read the id via getAttribute
|
|
3976
|
+
// whenever `el.id` is not a string: on a <form> (and other
|
|
3977
|
+
// [LegacyOverrideBuiltIns] hosts) a named control like <input name="id">
|
|
3978
|
+
// shadows the builtin `id` getter and returns the control element, whose
|
|
3979
|
+
// `.startsWith` is undefined and throws (issue #407 — every Shopify product
|
|
3980
|
+
// form ships an <input name="id">).
|
|
3981
|
+
const elId = typeof el.id === 'string' ? el.id : (el.getAttribute?.('id') || '');
|
|
3679
3982
|
if (elId.startsWith('claude-') || elId.startsWith('cic-')) return findings;
|
|
3680
3983
|
|
|
3681
3984
|
// --- Line length too long --- (browser-only: needs rect.width)
|
|
@@ -3943,7 +4246,7 @@ function checkQuality(opts) {
|
|
|
3943
4246
|
const skipTags = ['sub', 'sup', 'code', 'kbd', 'samp', 'var', 'caption', 'figcaption'];
|
|
3944
4247
|
const inUIContext = el.closest && el.closest('button, a, label, summary, pre, [role="button"], [role="link"], [role="tab"], [role="menuitem"], [role="option"], nav, footer, [aria-hidden="true"], [class*="badge" i], [class*="caption" i], [class*="chip" i], [class*="code" i], [class*="console" i], [class*="diff" i], [class*="label" i], [class*="meta" i], [class*="mock" i], [class*="pill" i], [class*="preview" i], [class*="tag" i], [class*="terminal" i], [class*="writes" i]');
|
|
3945
4248
|
const isUppercase = style.textTransform === 'uppercase';
|
|
3946
|
-
if (!skipTags.includes(tag) && !inUIContext && !isUppercase) {
|
|
4249
|
+
if (!skipTags.includes(tag) && !inUIContext && !isUppercase && !isNonRenderedText(el, tag, style)) {
|
|
3947
4250
|
findings.push({ id: 'tiny-text', snippet: `${fontSize}px body text` });
|
|
3948
4251
|
}
|
|
3949
4252
|
}
|
|
@@ -3973,13 +4276,15 @@ function checkQuality(opts) {
|
|
|
3973
4276
|
.replace(/\s+/g, ' ')
|
|
3974
4277
|
.trim();
|
|
3975
4278
|
const dtLen = directText.length;
|
|
3976
|
-
|
|
3977
|
-
|
|
4279
|
+
// `option` renders (in native select popups) so it stays a local skip;
|
|
4280
|
+
// script/style/title/noscript/head-descendants and display:none /
|
|
4281
|
+
// visibility:hidden are handled by isNonRenderedText (shared with tiny-text).
|
|
4282
|
+
const UI_SKIP_TAGS = new Set(['sub', 'sup', 'option']);
|
|
3978
4283
|
// jsdom resolves the parent chain in resolveFontSizePx, so em/rem/%-sized
|
|
3979
4284
|
// text that computes at or above the floor never reaches here. The browser
|
|
3980
4285
|
// adapter additionally catches values only resolvable with real layout
|
|
3981
4286
|
// (e.g. viewport-relative units, cascade winners set in linked sheets).
|
|
3982
|
-
if (fontSize > 0 && fontSize < 11 && dtLen >= 2 && !UI_SKIP_TAGS.has(tag) && !
|
|
4287
|
+
if (fontSize > 0 && fontSize < 11 && dtLen >= 2 && !UI_SKIP_TAGS.has(tag) && !isNonRenderedText(el, tag, style)) {
|
|
3983
4288
|
const EXEMPT_CONTEXT = 'pre, code, kbd, samp, var, svg, [aria-hidden="true"], [class*="terminal" i], [class*="console" i], [class*="code" i], [class*="mock" i], [class*="editor" i], [class*="syntax" i], [class*="diff" i]';
|
|
3984
4289
|
const isExemptContext = (el.matches && el.matches(EXEMPT_CONTEXT)) || (el.closest && el.closest(EXEMPT_CONTEXT));
|
|
3985
4290
|
if (!isExemptContext && !isVisuallyHidden(el, style)) {
|
|
@@ -4192,7 +4497,7 @@ function checkElementColors(el, style, tag, window, customPropMap, hasAnchorInhe
|
|
|
4192
4497
|
textColor,
|
|
4193
4498
|
bgColor: ownBg,
|
|
4194
4499
|
effectiveBg: finalEffectiveBg,
|
|
4195
|
-
effectiveBgStops: finalEffectiveBg ? null : resolveGradientStops(el, window),
|
|
4500
|
+
effectiveBgStops: finalEffectiveBg ? null : resolveGradientStops(el, window, customPropMap),
|
|
4196
4501
|
fontSize: parseFloat(style.fontSize) || 16,
|
|
4197
4502
|
fontWeight: parseInt(style.fontWeight) || 400,
|
|
4198
4503
|
hasDirectText,
|
|
@@ -4332,13 +4637,13 @@ function checkElementHeroEyebrow(el, style, tag, window, customPropMap) {
|
|
|
4332
4637
|
});
|
|
4333
4638
|
}
|
|
4334
4639
|
|
|
4335
|
-
function
|
|
4336
|
-
const candidates =
|
|
4640
|
+
function checkKickerAboveHeadingFromDoc(doc, win) {
|
|
4641
|
+
const candidates = collectKickerCandidates(
|
|
4337
4642
|
doc,
|
|
4338
4643
|
(el) => win.getComputedStyle(el),
|
|
4339
4644
|
(value, fontSize) => resolveLengthPx(value, fontSize) || 0,
|
|
4340
4645
|
);
|
|
4341
|
-
return
|
|
4646
|
+
return checkKickerAboveHeading({ candidates });
|
|
4342
4647
|
}
|
|
4343
4648
|
|
|
4344
4649
|
function checkElementMotion(tag, style) {
|
|
@@ -4397,12 +4702,6 @@ function checkTypography() {
|
|
|
4397
4702
|
if (isBrandFontOnOwnDomain(font)) continue;
|
|
4398
4703
|
findings.push({ type: 'overused-font', detail: `Primary font: ${font} (${Math.round(share * 100)}% of text)` });
|
|
4399
4704
|
}
|
|
4400
|
-
|
|
4401
|
-
// Single-font check: only one distinct primary font across all text
|
|
4402
|
-
if (fontUsage.size === 1) {
|
|
4403
|
-
const only = [...fontUsage.keys()][0];
|
|
4404
|
-
findings.push({ type: 'single-font', detail: `only font used is ${only}` });
|
|
4405
|
-
}
|
|
4406
4705
|
}
|
|
4407
4706
|
|
|
4408
4707
|
const sizes = new Set();
|
|
@@ -4664,14 +4963,6 @@ function checkPageTypography(doc, win) {
|
|
|
4664
4963
|
findings.push({ id: 'overused-font', snippet: `Primary font: ${font}` });
|
|
4665
4964
|
}
|
|
4666
4965
|
|
|
4667
|
-
// Single font
|
|
4668
|
-
if (fonts.size === 1) {
|
|
4669
|
-
const els = doc.querySelectorAll('*');
|
|
4670
|
-
if (els.length >= 20) {
|
|
4671
|
-
findings.push({ id: 'single-font', snippet: `only font used is ${[...fonts][0]}` });
|
|
4672
|
-
}
|
|
4673
|
-
}
|
|
4674
|
-
|
|
4675
4966
|
// Flat type hierarchy
|
|
4676
4967
|
const sizes = new Set();
|
|
4677
4968
|
const textEls = doc.querySelectorAll('h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, button, div');
|
|
@@ -6497,7 +6788,11 @@ if (IS_BROWSER) {
|
|
|
6497
6788
|
function generateSelector(el) {
|
|
6498
6789
|
if (el === document.body) return 'body';
|
|
6499
6790
|
if (el === document.documentElement) return 'html';
|
|
6500
|
-
|
|
6791
|
+
// Read via getAttribute when `el.id` is not a string — a <form> with a
|
|
6792
|
+
// named control (e.g. <input name="id">) shadows the builtin getter and
|
|
6793
|
+
// returns the element, producing a garbage `#[object …]` selector (#407).
|
|
6794
|
+
const elId = typeof el.id === 'string' ? el.id : (el.getAttribute('id') || '');
|
|
6795
|
+
if (elId) return '#' + CSS.escape(elId);
|
|
6501
6796
|
|
|
6502
6797
|
const parts = [];
|
|
6503
6798
|
let current = el;
|
|
@@ -7434,8 +7729,11 @@ if (IS_BROWSER) {
|
|
|
7434
7729
|
for (const el of document.querySelectorAll('*')) {
|
|
7435
7730
|
// Skip impeccable's own elements and any descendants (overlays, labels, banner, nav buttons)
|
|
7436
7731
|
if (el.closest('.impeccable-overlay, .impeccable-label, .impeccable-banner, .impeccable-tooltip')) continue;
|
|
7437
|
-
// Skip browser extension elements (Claude, etc.)
|
|
7438
|
-
|
|
7732
|
+
// Skip browser extension elements (Claude, etc.). Use getAttribute when
|
|
7733
|
+
// `el.id` is not a string: a <form> with a named control like
|
|
7734
|
+
// <input name="id"> shadows the builtin `id` getter and returns the
|
|
7735
|
+
// element, whose `.startsWith` throws (issue #407).
|
|
7736
|
+
const elId = typeof el.id === 'string' ? el.id : (el.getAttribute('id') || '');
|
|
7439
7737
|
if (elId.startsWith('claude-') || elId.startsWith('cic-')) continue;
|
|
7440
7738
|
// Skip the impeccable live-mode overlay (highlight, tooltip, bar, picker, toast).
|
|
7441
7739
|
// These are inspector chrome, not part of the user's design.
|
|
@@ -7450,6 +7748,7 @@ if (IS_BROWSER) {
|
|
|
7450
7748
|
...checkElementMotionDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
|
|
7451
7749
|
...checkElementGlowDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
|
|
7452
7750
|
...checkElementAIPaletteDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
|
|
7751
|
+
...checkElementRadialSpotlightDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
|
|
7453
7752
|
...checkElementIconTileDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
|
|
7454
7753
|
...checkElementItalicSerifDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
|
|
7455
7754
|
...checkElementQualityDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
|
|
@@ -7488,7 +7787,7 @@ if (IS_BROWSER) {
|
|
|
7488
7787
|
addBrowserFindings(groupMap, document.body, typoFindings);
|
|
7489
7788
|
}
|
|
7490
7789
|
|
|
7491
|
-
const sectionKickerFindings =
|
|
7790
|
+
const sectionKickerFindings = checkKickerAboveHeadingDOM()
|
|
7492
7791
|
.map(f => ({ type: f.id, detail: f.snippet }))
|
|
7493
7792
|
.filter(f => _ruleOk(f.type));
|
|
7494
7793
|
if (sectionKickerFindings.length > 0) {
|