impeccable 3.3.1 → 3.4.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 +73 -12
- package/cli/engine/browser/injected/index.mjs +12 -4
- package/cli/engine/detect-antipatterns-browser.js +321 -55
- package/cli/engine/engines/regex/detect-text.mjs +18 -2
- package/cli/engine/engines/static-html/css-cascade.mjs +23 -11
- package/cli/engine/engines/static-html/detect-html.mjs +4 -2
- package/cli/engine/node/file-system.mjs +16 -2
- package/cli/engine/registry/antipatterns.mjs +13 -5
- package/cli/engine/rules/checks.mjs +305 -51
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@ import { GENERIC_FONTS, OVERUSED_FONTS, EM_DASH_FLOOR, EM_DASH_CHARS_PER_DASH }
|
|
|
2
2
|
import { isNeutralColor } from '../../shared/color.mjs';
|
|
3
3
|
import { extractGoogleFontFamilies } from '../../shared/fonts.mjs';
|
|
4
4
|
import { checkSourceDesignSystem } from '../../design-system.mjs';
|
|
5
|
-
import { scanCssTextForGlow, scanCssTextForGridBackground, scanCssTextForMarquee, scanCssTextForRadialHalo } from '../../rules/checks.mjs';
|
|
5
|
+
import { scanCssTextForGlow, scanCssTextForGridBackground, scanCssTextForMarquee, scanCssTextForPseudoStripe, scanCssTextForRadialHalo } from '../../rules/checks.mjs';
|
|
6
6
|
import { isFullPage } from '../../shared/page.mjs';
|
|
7
7
|
import { applyInlineIgnores } from '../../shared/inline-ignores.mjs';
|
|
8
8
|
import { finding } from '../../findings.mjs';
|
|
@@ -653,7 +653,21 @@ function detectText(content, filePath, options = {}) {
|
|
|
653
653
|
profile,
|
|
654
654
|
phase: 'source',
|
|
655
655
|
}));
|
|
656
|
-
|
|
656
|
+
// Pseudo-element stripes (::before/::after absolute bars) carry the same
|
|
657
|
+
// side-tab silhouette without any border token, so the line matchers can't
|
|
658
|
+
// see them (issue #394). The shared scanner already runs on full HTML pages
|
|
659
|
+
// via checkHtmlPatterns; give standalone stylesheets, component style
|
|
660
|
+
// blocks, and CSS-in-JS templates the same coverage. Each hit carries the
|
|
661
|
+
// rule's source offset, so the finding gets a real line and line-scoped
|
|
662
|
+
// inline ignores keep working.
|
|
663
|
+
const pseudoStripeFindings = (text, lineOffset) =>
|
|
664
|
+
scanCssTextForPseudoStripe(text).map(hit =>
|
|
665
|
+
finding(hit.id, filePath, hit.snippet, lineOffset + text.slice(0, hit.index).split('\n').length));
|
|
666
|
+
|
|
667
|
+
if (cssLike.has(ext)) {
|
|
668
|
+
findings.push(...scanInsetStripeCss(content, filePath));
|
|
669
|
+
findings.push(...pseudoStripeFindings(content, 0));
|
|
670
|
+
}
|
|
657
671
|
|
|
658
672
|
// Block-level CSS checks that need multiple declarations must run over the
|
|
659
673
|
// complete source, not line-by-line. This covers standalone stylesheets,
|
|
@@ -690,6 +704,7 @@ function detectText(content, filePath, options = {}) {
|
|
|
690
704
|
// reported every selector one line low. runRegexMatchers keeps startLine - 1
|
|
691
705
|
// because it indexes its split lines from zero.
|
|
692
706
|
findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
|
|
707
|
+
findings.push(...pseudoStripeFindings(block.content, block.startLine - 2));
|
|
693
708
|
}
|
|
694
709
|
|
|
695
710
|
// Extract and scan CSS-in-JS template literals
|
|
@@ -708,6 +723,7 @@ function detectText(content, filePath, options = {}) {
|
|
|
708
723
|
phase: 'css-in-js',
|
|
709
724
|
}));
|
|
710
725
|
findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
|
|
726
|
+
findings.push(...pseudoStripeFindings(block.content, block.startLine - 1));
|
|
711
727
|
}
|
|
712
728
|
|
|
713
729
|
if (options?.designSystem) {
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
4
|
import { profileStep, recordProfileEvent } from '../../profile/profiler.mjs';
|
|
5
|
-
import { collectCssCustomProps, cssLengthToPx, parseAnyColor, resolveLengthPx, resolveVarRefs } from '../../rules/checks.mjs';
|
|
5
|
+
import { CSS_NAMED_COLORS, collectCssCustomProps, cssLengthToPx, parseAnyColor, resolveLengthPx, resolveVarRefs } from '../../rules/checks.mjs';
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
// jsdom CSS-variable border override map
|
|
@@ -223,7 +223,7 @@ function unwrapCssAtLayer(source) {
|
|
|
223
223
|
// ---------------------------------------------------------------------------
|
|
224
224
|
|
|
225
225
|
const STATIC_INHERITED_PROPS = new Set([
|
|
226
|
-
'color', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight',
|
|
226
|
+
'color', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'fontVariant',
|
|
227
227
|
'lineHeight', 'letterSpacing', 'textTransform', 'textAlign', 'hyphens',
|
|
228
228
|
'webkitHyphens',
|
|
229
229
|
]);
|
|
@@ -252,6 +252,7 @@ const STATIC_DEFAULT_STYLE = {
|
|
|
252
252
|
fontFamily: '',
|
|
253
253
|
fontSize: '16px',
|
|
254
254
|
fontStyle: 'normal',
|
|
255
|
+
fontVariant: 'normal',
|
|
255
256
|
fontWeight: '400',
|
|
256
257
|
lineHeight: 'normal',
|
|
257
258
|
letterSpacing: 'normal',
|
|
@@ -344,18 +345,29 @@ const STATIC_PROP_MAP = {
|
|
|
344
345
|
'overflow-y': 'overflowY',
|
|
345
346
|
};
|
|
346
347
|
|
|
348
|
+
// parseStaticColor tries parseAnyColor first, which already resolves every
|
|
349
|
+
// name in the shared CSS_NAMED_COLORS table. This fallback only carries the
|
|
350
|
+
// keywords parseAnyColor deliberately returns null for: the cascade needs
|
|
351
|
+
// `transparent` to read as an actual zero-alpha color.
|
|
347
352
|
const STATIC_NAMED_COLORS = {
|
|
348
|
-
black: { r: 0, g: 0, b: 0, a: 1 },
|
|
349
|
-
white: { r: 255, g: 255, b: 255, a: 1 },
|
|
350
353
|
transparent: { r: 0, g: 0, b: 0, a: 0 },
|
|
351
|
-
gray: { r: 128, g: 128, b: 128, a: 1 },
|
|
352
|
-
grey: { r: 128, g: 128, b: 128, a: 1 },
|
|
353
|
-
silver: { r: 192, g: 192, b: 192, a: 1 },
|
|
354
|
-
red: { r: 255, g: 0, b: 0, a: 1 },
|
|
355
|
-
green: { r: 0, g: 128, b: 0, a: 1 },
|
|
356
|
-
blue: { r: 0, g: 0, b: 255, a: 1 },
|
|
357
354
|
};
|
|
358
355
|
|
|
356
|
+
// Named-color alternation for plucking a color token out of shorthand values
|
|
357
|
+
// (issue #359: a hardcoded 9-name list here silently dropped `purple`,
|
|
358
|
+
// `crimson`, `teal`, ... from border shorthands, so the side defaulted to
|
|
359
|
+
// neutral black and side-tab never fired on .html files). Derived from the
|
|
360
|
+
// same table parseAnyColor resolves against, so extraction and parsing can't
|
|
361
|
+
// drift apart. Longest-first so names containing other names as substrings
|
|
362
|
+
// (rebeccapurple) are matched whole.
|
|
363
|
+
const NAMED_COLOR_TOKENS = [...Object.keys(CSS_NAMED_COLORS), ...Object.keys(STATIC_NAMED_COLORS)]
|
|
364
|
+
.sort((a, b) => b.length - a.length)
|
|
365
|
+
.join('|');
|
|
366
|
+
const STATIC_COLOR_TOKEN_RE = new RegExp(
|
|
367
|
+
`(?:rgba?\\([^)]+\\)|oklch\\([^)]+\\)|oklab\\([^)]+\\)|lch\\([^)]+\\)|lab\\([^)]+\\)|hsla?\\([^)]+\\)|hwb\\([^)]+\\)|#[0-9a-f]{3,8}\\b|\\b(?:${NAMED_COLOR_TOKENS})\\b)`,
|
|
368
|
+
'i'
|
|
369
|
+
);
|
|
370
|
+
|
|
359
371
|
function splitCssList(value) {
|
|
360
372
|
const parts = [];
|
|
361
373
|
let depth = 0, quote = '', start = 0;
|
|
@@ -441,7 +453,7 @@ function extractStaticColor(value) {
|
|
|
441
453
|
}
|
|
442
454
|
return '';
|
|
443
455
|
}
|
|
444
|
-
const colorLike = raw.match(
|
|
456
|
+
const colorLike = raw.match(STATIC_COLOR_TOKEN_RE);
|
|
445
457
|
if (!colorLike) return '';
|
|
446
458
|
return colorLike[0];
|
|
447
459
|
}
|
|
@@ -24,13 +24,14 @@ import {
|
|
|
24
24
|
checkElementMotion,
|
|
25
25
|
checkElementOversizedH1,
|
|
26
26
|
checkElementQuality,
|
|
27
|
+
checkElementRadialSpotlight,
|
|
27
28
|
checkCreamPalette,
|
|
28
29
|
checkHtmlPatterns,
|
|
30
|
+
checkKickerAboveHeadingFromDoc,
|
|
29
31
|
checkNumberedSectionLabelsFromDoc,
|
|
30
32
|
checkPageLayout,
|
|
31
33
|
checkPageQualityFromDoc,
|
|
32
34
|
checkRepeatedContainerTextFromDoc,
|
|
33
|
-
checkRepeatedSectionKickersFromDoc,
|
|
34
35
|
resolveBackground,
|
|
35
36
|
resolveBorderRadiusPx,
|
|
36
37
|
} from '../../rules/checks.mjs';
|
|
@@ -105,6 +106,7 @@ const STATIC_ELEMENT_RULES = [
|
|
|
105
106
|
{ id: 'oversized-h1', selector: 'h1', run: (el, tag, style, window) => checkElementOversizedH1(el, style, tag, window) },
|
|
106
107
|
{ id: 'clipped-overflow-container', selector: '*', run: (el, tag, style, window) => checkElementClippedOverflow(el, style, tag, window) },
|
|
107
108
|
{ id: 'gpt-thin-border-wide-shadow', selector: '*', run: (el, tag, style) => checkElementGptBorderShadow(el, style) },
|
|
109
|
+
{ id: 'radial-spotlight-glow', selector: '*', run: (el, tag, style, window) => checkElementRadialSpotlight(el, style, tag, window) },
|
|
108
110
|
];
|
|
109
111
|
|
|
110
112
|
async function detectHtml(filePath, options = {}) {
|
|
@@ -200,7 +202,7 @@ async function detectHtml(filePath, options = {}) {
|
|
|
200
202
|
for (const f of runPageCheck('typography-rules', () => checkStaticPageTypography(document, window))) {
|
|
201
203
|
findings.push(finding(f.id, filePath, f.snippet));
|
|
202
204
|
}
|
|
203
|
-
for (const f of runPageCheck('
|
|
205
|
+
for (const f of runPageCheck('kicker-above-heading', () => checkKickerAboveHeadingFromDoc(document, window))) {
|
|
204
206
|
findings.push(finding(f.id, filePath, f.snippet));
|
|
205
207
|
}
|
|
206
208
|
for (const f of runPageCheck('numbered-section-labels', () => checkNumberedSectionLabelsFromDoc(document, window))) {
|
|
@@ -5,11 +5,24 @@ import path from 'node:path';
|
|
|
5
5
|
// File walker
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
// Hidden directories are skipped wholesale during recursion (below), which
|
|
9
|
+
// covers .git / .next / .nuxt / .svelte-kit / .turbo / .vercel and — the
|
|
10
|
+
// issue #303 class — every vendored AI-harness install (.claude, .cursor,
|
|
11
|
+
// .codex, .agents, .impeccable, ...) whose bundled detector source would
|
|
12
|
+
// otherwise be reported as findings on a root scan. Only the non-hidden
|
|
13
|
+
// build/dependency dirs need naming. An explicitly passed hidden target
|
|
14
|
+
// still scans: walkDir name-checks children, never the root it's given.
|
|
8
15
|
const SKIP_DIRS = new Set([
|
|
9
|
-
'node_modules', '
|
|
10
|
-
'.svelte-kit', '__pycache__', '.turbo', '.vercel',
|
|
16
|
+
'node_modules', 'dist', 'build', '__pycache__',
|
|
11
17
|
]);
|
|
12
18
|
|
|
19
|
+
// The exceptions to the hidden-dir rule: hidden directories that
|
|
20
|
+
// conventionally hold real UI source rather than tooling or vendored code.
|
|
21
|
+
// VitePress and VuePress keep custom theme components in
|
|
22
|
+
// .vitepress/theme/*.vue / .vuepress/theme/, and Storybook keeps preview
|
|
23
|
+
// decorators/styles in .storybook/.
|
|
24
|
+
const HIDDEN_SOURCE_DIRS = new Set(['.vitepress', '.vuepress', '.storybook']);
|
|
25
|
+
|
|
13
26
|
const SCANNABLE_EXTENSIONS = new Set([
|
|
14
27
|
'.html', '.htm', '.css', '.scss', '.sass', '.less',
|
|
15
28
|
'.jsx', '.tsx', '.js', '.ts',
|
|
@@ -24,6 +37,7 @@ function walkDir(dir) {
|
|
|
24
37
|
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return files; }
|
|
25
38
|
for (const entry of entries) {
|
|
26
39
|
if (SKIP_DIRS.has(entry.name)) continue;
|
|
40
|
+
if (entry.isDirectory() && entry.name.startsWith('.') && !HIDDEN_SOURCE_DIRS.has(entry.name)) continue;
|
|
27
41
|
const full = path.join(dir, entry.name);
|
|
28
42
|
if (entry.isDirectory()) files.push(...walkDir(full));
|
|
29
43
|
else if (SCANNABLE_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) files.push(full);
|
|
@@ -149,6 +149,15 @@ const ANTIPATTERNS = [
|
|
|
149
149
|
skillSection: 'Color & Contrast',
|
|
150
150
|
skillGuideline: 'dark mode with glowing accents',
|
|
151
151
|
},
|
|
152
|
+
{
|
|
153
|
+
id: 'radial-spotlight-glow',
|
|
154
|
+
category: 'slop',
|
|
155
|
+
name: 'Decorative radial spotlight glow',
|
|
156
|
+
description:
|
|
157
|
+
'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.',
|
|
158
|
+
skillSection: 'Color & Contrast',
|
|
159
|
+
skillGuideline: 'dark mode with glowing accents',
|
|
160
|
+
},
|
|
152
161
|
{
|
|
153
162
|
id: 'marquee',
|
|
154
163
|
category: 'slop',
|
|
@@ -189,15 +198,14 @@ const ANTIPATTERNS = [
|
|
|
189
198
|
skillGuideline: 'tiny uppercase tracked label above the hero headline',
|
|
190
199
|
},
|
|
191
200
|
{
|
|
192
|
-
id: '
|
|
201
|
+
id: 'kicker-above-heading',
|
|
193
202
|
category: 'slop',
|
|
194
203
|
scopes: ['type'],
|
|
195
|
-
|
|
196
|
-
name: 'Repeated section kicker labels',
|
|
204
|
+
name: 'Kicker / eyebrow label above heading',
|
|
197
205
|
description:
|
|
198
|
-
'
|
|
206
|
+
'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.',
|
|
199
207
|
skillSection: 'Typography',
|
|
200
|
-
skillGuideline: '
|
|
208
|
+
skillGuideline: 'kicker or eyebrow labels above headings',
|
|
201
209
|
},
|
|
202
210
|
{
|
|
203
211
|
id: 'numbered-section-labels',
|