impeccable 3.6.1 → 4.0.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 +24 -19
- package/README.npm.md +24 -19
- package/README.repo.md +13 -7
- package/cli/bin/cli.js +77 -92
- package/package.json +15 -21
- package/cli/bin/commands/ignores.mjs +0 -355
- package/cli/bin/commands/skills.mjs +0 -2415
- package/cli/engine/browser/injected/index.mjs +0 -2204
- package/cli/engine/cli/main.mjs +0 -432
- package/cli/engine/design-system.mjs +0 -1311
- package/cli/engine/detect-antipatterns-browser.js +0 -9043
- package/cli/engine/detect-antipatterns.mjs +0 -51
- package/cli/engine/engines/browser/detect-url.mjs +0 -434
- package/cli/engine/engines/regex/detect-text.mjs +0 -1319
- package/cli/engine/engines/static-html/css-cascade.mjs +0 -1241
- package/cli/engine/engines/static-html/detect-html.mjs +0 -288
- package/cli/engine/engines/visual/screenshot-contrast.mjs +0 -189
- package/cli/engine/findings.mjs +0 -18
- package/cli/engine/node/file-system.mjs +0 -213
- package/cli/engine/profile/profiler.mjs +0 -166
- package/cli/engine/registry/antipatterns.mjs +0 -635
- package/cli/engine/rules/checks.mjs +0 -5681
- package/cli/engine/shared/color.mjs +0 -596
- package/cli/engine/shared/constants.mjs +0 -127
- package/cli/engine/shared/fonts.mjs +0 -30
- package/cli/engine/shared/inline-ignores.mjs +0 -148
- package/cli/engine/shared/page.mjs +0 -7
- package/cli/lib/download-providers.js +0 -35
- package/cli/lib/impeccable-config.mjs +0 -640
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
// ─── Section 1: Constants ───────────────────────────────────────────────────
|
|
2
|
-
|
|
3
|
-
const SAFE_TAGS = new Set([
|
|
4
|
-
'blockquote', 'nav', 'a', 'input', 'textarea', 'select',
|
|
5
|
-
'pre', 'code', 'span', 'th', 'td', 'tr', 'li', 'label',
|
|
6
|
-
'button', 'hr', 'html', 'head', 'body', 'script', 'style',
|
|
7
|
-
'link', 'meta', 'title', 'br', 'img', 'svg', 'path', 'circle',
|
|
8
|
-
'rect', 'line', 'polyline', 'polygon', 'g', 'defs', 'use',
|
|
9
|
-
]);
|
|
10
|
-
|
|
11
|
-
// Per-check safe-tags override for the border (side-tab / border-accent)
|
|
12
|
-
// rule. We intentionally re-allow <label> here because card-shaped clickable
|
|
13
|
-
// labels (e.g. .checklist-item wrapping a checkbox + content) are one of the
|
|
14
|
-
// canonical side-tab anti-pattern shapes and must be detected. The rule's
|
|
15
|
-
// other preconditions (non-neutral color, width >= 2px on a single side,
|
|
16
|
-
// radius > 0 or width >= 3, element size >= 20x20 in the browser path)
|
|
17
|
-
// already filter out plain inline form labels so this does not introduce
|
|
18
|
-
// false positives. See modern-color-borders.html for the test matrix.
|
|
19
|
-
const BORDER_SAFE_TAGS = new Set(
|
|
20
|
-
[...SAFE_TAGS].filter(t => t !== 'label')
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const OVERUSED_FONTS = new Set([
|
|
24
|
-
// Older monoculture (still ubiquitous):
|
|
25
|
-
'inter', 'roboto', 'open sans', 'lato', 'montserrat', 'arial', 'helvetica',
|
|
26
|
-
// Newer monoculture (the Anthropic-skill / Vercel / GitHub default wave):
|
|
27
|
-
'fraunces', 'instrument sans', 'instrument serif',
|
|
28
|
-
'geist', 'geist sans', 'geist mono',
|
|
29
|
-
'mona sans',
|
|
30
|
-
'plus jakarta sans', 'space grotesk', 'recoleta',
|
|
31
|
-
]);
|
|
32
|
-
|
|
33
|
-
// Brand-associated fonts: don't flag these as "overused" on the brand's own domains.
|
|
34
|
-
// Keys are font names, values are arrays of hostname suffixes where the font is allowed.
|
|
35
|
-
const GOOGLE_DOMAINS = [
|
|
36
|
-
'google.com', 'youtube.com', 'android.com', 'chromium.org',
|
|
37
|
-
'chrome.com', 'web.dev', 'gstatic.com', 'firebase.google.com',
|
|
38
|
-
];
|
|
39
|
-
const VERCEL_DOMAINS = ['vercel.com', 'nextjs.org', 'v0.app'];
|
|
40
|
-
const GITHUB_DOMAINS = ['github.com', 'githubnext.com'];
|
|
41
|
-
const BRAND_FONT_DOMAINS = {
|
|
42
|
-
'roboto': GOOGLE_DOMAINS,
|
|
43
|
-
'google sans': GOOGLE_DOMAINS,
|
|
44
|
-
'product sans': GOOGLE_DOMAINS,
|
|
45
|
-
'geist': VERCEL_DOMAINS,
|
|
46
|
-
'geist sans': VERCEL_DOMAINS,
|
|
47
|
-
'geist mono': VERCEL_DOMAINS,
|
|
48
|
-
'mona sans': GITHUB_DOMAINS,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
function isBrandFontOnOwnDomain(font) {
|
|
52
|
-
if (typeof location === 'undefined') return false;
|
|
53
|
-
const allowed = BRAND_FONT_DOMAINS[font];
|
|
54
|
-
if (!allowed) return false;
|
|
55
|
-
const host = location.hostname.toLowerCase();
|
|
56
|
-
return allowed.some(suffix => host === suffix || host.endsWith('.' + suffix));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Overused-font primary selection skips only CSS generics so a system stack
|
|
60
|
-
// keeps the system face as primary; GENERIC_FONTS still includes platform
|
|
61
|
-
// faces for design-system/serif resolution.
|
|
62
|
-
const CSS_GENERIC_FONTS = new Set([
|
|
63
|
-
'serif', 'sans-serif', 'monospace', 'cursive', 'fantasy',
|
|
64
|
-
'inherit', 'initial', 'unset', 'revert',
|
|
65
|
-
]);
|
|
66
|
-
|
|
67
|
-
const GENERIC_FONTS = new Set([
|
|
68
|
-
...CSS_GENERIC_FONTS,
|
|
69
|
-
'system-ui', 'ui-serif', 'ui-sans-serif', 'ui-monospace', 'ui-rounded',
|
|
70
|
-
'-apple-system', 'blinkmacsystemfont', 'segoe ui',
|
|
71
|
-
]);
|
|
72
|
-
|
|
73
|
-
function primaryFontFace(fontFamily, skip = CSS_GENERIC_FONTS) {
|
|
74
|
-
return String(fontFamily || '')
|
|
75
|
-
.split(',')
|
|
76
|
-
.map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase())
|
|
77
|
-
.find(f => f && !skip.has(f)) || null;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// WCAG large text thresholds are defined in points: 18pt normal text and
|
|
81
|
-
// 14pt bold text. Browsers expose font-size in CSS pixels at 96px per inch.
|
|
82
|
-
const WCAG_LARGE_TEXT_PX = 18 * (96 / 72);
|
|
83
|
-
const WCAG_LARGE_BOLD_TEXT_PX = 14 * (96 / 72);
|
|
84
|
-
|
|
85
|
-
// Em-dash overuse (advisory) thresholds, shared by the regex/static-HTML
|
|
86
|
-
// analyzer and the browser DOM check so both fire on the same saturation
|
|
87
|
-
// pattern. Two gates must hold: an absolute floor of EM_DASH_FLOOR dashes, and
|
|
88
|
-
// a density of at least one dash per EM_DASH_CHARS_PER_DASH characters of body
|
|
89
|
-
// text. A long article that uses a few em-dashes is left alone; a short,
|
|
90
|
-
// dash-per-clause page is not.
|
|
91
|
-
const EM_DASH_FLOOR = 8;
|
|
92
|
-
const EM_DASH_CHARS_PER_DASH = 500;
|
|
93
|
-
|
|
94
|
-
// Serif faces that show up in italic-display heroes. The rule also fires when
|
|
95
|
-
// the primary face is unknown but the stack ends in the generic `serif` token,
|
|
96
|
-
// which catches custom/private faces with a serif fallback.
|
|
97
|
-
const KNOWN_SERIF_FONTS = new Set([
|
|
98
|
-
'fraunces', 'recoleta', 'newsreader', 'playfair display', 'playfair',
|
|
99
|
-
'cormorant', 'cormorant garamond', 'garamond', 'eb garamond',
|
|
100
|
-
'tiempos', 'tiempos headline', 'tiempos text',
|
|
101
|
-
'lora', 'vollkorn', 'spectral',
|
|
102
|
-
'source serif pro', 'source serif 4', 'source serif',
|
|
103
|
-
'ibm plex serif', 'merriweather',
|
|
104
|
-
'libre caslon', 'libre baskerville', 'baskerville',
|
|
105
|
-
'georgia', 'times new roman', 'times',
|
|
106
|
-
'dm serif display', 'dm serif text',
|
|
107
|
-
'instrument serif', 'gt sectra', 'ogg', 'canela',
|
|
108
|
-
'freight display', 'freight text',
|
|
109
|
-
]);
|
|
110
|
-
|
|
111
|
-
export {
|
|
112
|
-
SAFE_TAGS,
|
|
113
|
-
BORDER_SAFE_TAGS,
|
|
114
|
-
OVERUSED_FONTS,
|
|
115
|
-
GOOGLE_DOMAINS,
|
|
116
|
-
VERCEL_DOMAINS,
|
|
117
|
-
GITHUB_DOMAINS,
|
|
118
|
-
BRAND_FONT_DOMAINS,
|
|
119
|
-
isBrandFontOnOwnDomain,
|
|
120
|
-
GENERIC_FONTS,
|
|
121
|
-
primaryFontFace,
|
|
122
|
-
WCAG_LARGE_TEXT_PX,
|
|
123
|
-
WCAG_LARGE_BOLD_TEXT_PX,
|
|
124
|
-
EM_DASH_FLOOR,
|
|
125
|
-
EM_DASH_CHARS_PER_DASH,
|
|
126
|
-
KNOWN_SERIF_FONTS,
|
|
127
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const GOOGLE_FONTS_URL_RE = /fonts\.googleapis\.com\/css2?\?[^"'\s)<>]*/gi;
|
|
2
|
-
|
|
3
|
-
function normalizeGoogleFontFamilyParam(value) {
|
|
4
|
-
return String(value || '')
|
|
5
|
-
.split('|')
|
|
6
|
-
.map(part => part.split(':')[0].trim().toLowerCase())
|
|
7
|
-
.filter(Boolean);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function extractGoogleFontFamilies(text) {
|
|
11
|
-
const families = [];
|
|
12
|
-
if (!text) return families;
|
|
13
|
-
|
|
14
|
-
GOOGLE_FONTS_URL_RE.lastIndex = 0;
|
|
15
|
-
let urlMatch;
|
|
16
|
-
while ((urlMatch = GOOGLE_FONTS_URL_RE.exec(text)) !== null) {
|
|
17
|
-
const url = urlMatch[0];
|
|
18
|
-
const queryStart = url.indexOf('?');
|
|
19
|
-
if (queryStart === -1) continue;
|
|
20
|
-
|
|
21
|
-
const params = new URLSearchParams(url.slice(queryStart + 1).replace(/&/g, '&'));
|
|
22
|
-
for (const value of params.getAll('family')) {
|
|
23
|
-
families.push(...normalizeGoogleFontFamilyParam(value));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return families;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { extractGoogleFontFamilies };
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inline, in-file ignore directives — eslint-disable-style waivers that live at
|
|
3
|
-
* the point they apply and travel with the artifact instead of (or alongside)
|
|
4
|
-
* an ignore in `.impeccable/config.json`.
|
|
5
|
-
*
|
|
6
|
-
* A config ignore is the right default for repo-wide policy. This complements it
|
|
7
|
-
* for the one case config can't cover: a waiver that belongs to a single file and
|
|
8
|
-
* needs to follow that file when it leaves the repo — a generated/exported
|
|
9
|
-
* standalone document, an emailed HTML file, a snippet scanned out of context.
|
|
10
|
-
*
|
|
11
|
-
* Comment-syntax-agnostic: the directive is a raw token matched anywhere on a
|
|
12
|
-
* line, so the same marker works across every comment style impeccable scans —
|
|
13
|
-
* `//`, `/* *\/`, `<!-- -->`, `#`, `{/* *\/}`, `{# #}`. Trailing comment closers
|
|
14
|
-
* are stripped before the rule list is parsed.
|
|
15
|
-
*
|
|
16
|
-
* Syntax (reason optional; eslint `--` or biome `:` separator):
|
|
17
|
-
*
|
|
18
|
-
* impeccable-disable <rule>[, <rule>...] [-- reason] whole file
|
|
19
|
-
* impeccable-disable-line <rule>... [-- reason] the same line
|
|
20
|
-
* impeccable-disable-next-line <rule>... [-- reason] the following line
|
|
21
|
-
* impeccable-disable bare / `*` = every rule
|
|
22
|
-
*
|
|
23
|
-
* Examples:
|
|
24
|
-
*
|
|
25
|
-
* <!-- impeccable-disable overused-font -- exported brand doc, font is first-party -->
|
|
26
|
-
* .brand { font-family: Inter; } /* impeccable-disable-line overused-font *\/
|
|
27
|
-
* // impeccable-disable-next-line bounce-easing: intentional playful affordance
|
|
28
|
-
*
|
|
29
|
-
* Behavior is suppression, for parity with config ignores: a matched directive
|
|
30
|
-
* drops the finding. The inline reason is self-documenting in the diff; it is not
|
|
31
|
-
* required and is discarded at scan time (only used here to keep reason words out
|
|
32
|
-
* of the parsed rule list).
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
const DIRECTIVE_RE = /impeccable-(disable-next-line|disable-line|disable)\b[ \t]*([^\n\r]*)/gi;
|
|
36
|
-
|
|
37
|
-
// Trailing comment closers, so `*/`, `*/}`, `-->`, `*}`, `#}`, `%>`, `}}` don't
|
|
38
|
-
// leak into the rule list. Anchored to end-of-line; the leading `\s*` mops up the
|
|
39
|
-
// space before the closer. `--+>` covers `-->` and any longer dash run.
|
|
40
|
-
const TRAILING_CLOSER_RE = /\s*(?:\*\/\}?|--+>|\*\}|#\}|%>|\}\})\s*$/;
|
|
41
|
-
|
|
42
|
-
function normalizeRule(token) {
|
|
43
|
-
return String(token || '').trim().toLowerCase();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Split the directive remainder into rule tokens, dropping any human reason that
|
|
47
|
-
// follows an eslint-style `--` or biome-style `:` separator. Rule ids only ever
|
|
48
|
-
// contain single hyphens (`overused-font`, `bounce-easing`), so `--` and `:`
|
|
49
|
-
// are unambiguous separators.
|
|
50
|
-
function parseRuleList(remainder) {
|
|
51
|
-
let text = String(remainder || '').replace(TRAILING_CLOSER_RE, '').trim();
|
|
52
|
-
// Cut off a human reason at the first `--` (eslint) or `:` (biome) separator.
|
|
53
|
-
const reasonSep = text.match(/\s*(?:--+|:)\s*/);
|
|
54
|
-
if (reasonSep) text = text.slice(0, reasonSep.index);
|
|
55
|
-
const tokens = text.split(/[\s,]+/).map(normalizeRule).filter(Boolean);
|
|
56
|
-
if (tokens.length === 0 || tokens.includes('*')) return ['*'];
|
|
57
|
-
return tokens;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function addRules(set, rules) {
|
|
61
|
-
for (const rule of rules) set.add(rule);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function getSet(map, key) {
|
|
65
|
-
let set = map.get(key);
|
|
66
|
-
if (!set) {
|
|
67
|
-
set = new Set();
|
|
68
|
-
map.set(key, set);
|
|
69
|
-
}
|
|
70
|
-
return set;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Parse every inline ignore directive in a file's raw text.
|
|
75
|
-
*
|
|
76
|
-
* Returns sets keyed by the 1-based line the directive *targets* so matching is a
|
|
77
|
-
* direct lookup:
|
|
78
|
-
* - file: rules disabled for the whole file
|
|
79
|
-
* - line: line -> rules disabled on that exact line (disable-line)
|
|
80
|
-
* - nextLine: line -> rules disabled on that line (disable-next-line on line-1)
|
|
81
|
-
*
|
|
82
|
-
* `*` in any set means "every rule".
|
|
83
|
-
*/
|
|
84
|
-
function parseInlineIgnores(content) {
|
|
85
|
-
const result = { file: new Set(), line: new Map(), nextLine: new Map() };
|
|
86
|
-
const text = typeof content === 'string' ? content : '';
|
|
87
|
-
// Cheap bail-out: the substring must be present for any directive to exist.
|
|
88
|
-
// Case-insensitive to match DIRECTIVE_RE's `i` flag (e.g. `Impeccable-Disable`).
|
|
89
|
-
if (!/impeccable-disable/i.test(text)) return result;
|
|
90
|
-
|
|
91
|
-
// Split on `\n` only, exactly as detectText numbers lines, so directive line
|
|
92
|
-
// keys line up with finding `line` values (incl. on `\r`-only line endings).
|
|
93
|
-
// The directive regex excludes `\r`, so a trailing `\r` on `\r\n` files is
|
|
94
|
-
// never captured into the rule list.
|
|
95
|
-
const lines = text.split('\n');
|
|
96
|
-
for (let i = 0; i < lines.length; i++) {
|
|
97
|
-
DIRECTIVE_RE.lastIndex = 0;
|
|
98
|
-
let m;
|
|
99
|
-
while ((m = DIRECTIVE_RE.exec(lines[i])) !== null) {
|
|
100
|
-
const variant = m[1].toLowerCase();
|
|
101
|
-
const rules = parseRuleList(m[2]);
|
|
102
|
-
if (variant === 'disable') {
|
|
103
|
-
addRules(result.file, rules);
|
|
104
|
-
} else if (variant === 'disable-line') {
|
|
105
|
-
addRules(getSet(result.line, i + 1), rules);
|
|
106
|
-
} else {
|
|
107
|
-
// disable-next-line on line i+1 targets line i+2.
|
|
108
|
-
addRules(getSet(result.nextLine, i + 2), rules);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function setMatches(set, rule) {
|
|
116
|
-
return Boolean(set) && (set.has('*') || set.has(rule));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function isInlineIgnored(finding, directives) {
|
|
120
|
-
const rule = normalizeRule(finding && finding.antipattern);
|
|
121
|
-
if (!rule) return false;
|
|
122
|
-
if (setMatches(directives.file, rule)) return true;
|
|
123
|
-
const line = Number(finding && finding.line) || 0;
|
|
124
|
-
if (line > 0) {
|
|
125
|
-
if (setMatches(directives.line.get(line), rule)) return true;
|
|
126
|
-
if (setMatches(directives.nextLine.get(line), rule)) return true;
|
|
127
|
-
}
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function hasDirectives(directives) {
|
|
132
|
-
return directives.file.size > 0 || directives.line.size > 0 || directives.nextLine.size > 0;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Drop findings waived by an inline directive in the same file's source text.
|
|
137
|
-
* Findings without a usable line number (e.g. static-HTML page-level findings)
|
|
138
|
-
* are only matched by whole-file directives — which is the standalone-document
|
|
139
|
-
* case this primitive exists for.
|
|
140
|
-
*/
|
|
141
|
-
function applyInlineIgnores(findings, content) {
|
|
142
|
-
if (!Array.isArray(findings) || findings.length === 0) return findings;
|
|
143
|
-
const directives = parseInlineIgnores(content);
|
|
144
|
-
if (!hasDirectives(directives)) return findings;
|
|
145
|
-
return findings.filter((finding) => !isInlineIgnored(finding, directives));
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export { parseInlineIgnores, applyInlineIgnores, isInlineIgnored };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Nothing in this repo imports this module. Its consumers are the Cloudflare
|
|
2
|
-
// Pages Functions in the private impeccable-site repo (functions/api/download/
|
|
3
|
-
// bundle/[provider].js and [type]/[provider]/[id].js), which share cli/lib/.
|
|
4
|
-
// Do not remove it as dead code; keep the provider list in sync with the
|
|
5
|
-
// harness dirs the build emits.
|
|
6
|
-
export const FILE_DOWNLOAD_PROVIDER_CONFIG_DIRS = Object.freeze({
|
|
7
|
-
cursor: '.cursor',
|
|
8
|
-
'claude-code': '.claude',
|
|
9
|
-
gemini: '.gemini',
|
|
10
|
-
codex: '.codex',
|
|
11
|
-
agents: '.agents',
|
|
12
|
-
antigravity: '.agent',
|
|
13
|
-
github: '.github',
|
|
14
|
-
grok: '.grok',
|
|
15
|
-
hermes: '.hermes',
|
|
16
|
-
kiro: '.kiro',
|
|
17
|
-
opencode: '.opencode',
|
|
18
|
-
pi: '.pi',
|
|
19
|
-
qoder: '.qoder',
|
|
20
|
-
vibe: '.vibe',
|
|
21
|
-
veto: '.veto',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export const FILE_DOWNLOAD_PROVIDERS = Object.freeze(
|
|
25
|
-
Object.keys(FILE_DOWNLOAD_PROVIDER_CONFIG_DIRS)
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
export const BUNDLE_DOWNLOAD_PROVIDERS = Object.freeze([
|
|
29
|
-
'universal',
|
|
30
|
-
]);
|
|
31
|
-
|
|
32
|
-
export const DOWNLOAD_PROVIDERS = Object.freeze([
|
|
33
|
-
...FILE_DOWNLOAD_PROVIDERS,
|
|
34
|
-
...BUNDLE_DOWNLOAD_PROVIDERS,
|
|
35
|
-
]);
|