waypoint-skills 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +348 -0
- package/README.npm.md +56 -0
- package/cli/bin/cli.js +127 -0
- package/cli/bin/lib/paths.mjs +31 -0
- package/cli/bin/postinstall.mjs +25 -0
- package/manifest.json +107 -0
- package/package.json +44 -0
- package/packages/agents/inspiration-scout.md +105 -0
- package/packages/agents/orchestrator.md +186 -0
- package/packages/agents/scrutiny-validator.md +136 -0
- package/packages/agents/user-testing-validator.md +171 -0
- package/packages/agents/validator.md +102 -0
- package/packages/agents/worker.md +116 -0
- package/packages/agents/wp-router.md +69 -0
- package/packages/hooks/hooks.json.example +12 -0
- package/packages/hooks/templates/mission-worktree-bootstrap.sh +88 -0
- package/packages/hooks/templates/run-assertions.sh +48 -0
- package/packages/rules/adversarial-context-isolation.mdc +57 -0
- package/packages/rules/serial-git-enforcement.mdc +77 -0
- package/packages/skills/caveman/SKILL.md +78 -0
- package/packages/skills/design-taste-frontend/SKILL.md +1206 -0
- package/packages/skills/gpt-taste/SKILL.md +74 -0
- package/packages/skills/impeccable/SKILL.md +164 -0
- package/packages/skills/impeccable/reference/adapt.md +311 -0
- package/packages/skills/impeccable/reference/animate.md +201 -0
- package/packages/skills/impeccable/reference/audit.md +133 -0
- package/packages/skills/impeccable/reference/bolder.md +120 -0
- package/packages/skills/impeccable/reference/brand.md +108 -0
- package/packages/skills/impeccable/reference/clarify.md +288 -0
- package/packages/skills/impeccable/reference/codex.md +105 -0
- package/packages/skills/impeccable/reference/colorize.md +257 -0
- package/packages/skills/impeccable/reference/craft.md +123 -0
- package/packages/skills/impeccable/reference/critique.md +780 -0
- package/packages/skills/impeccable/reference/delight.md +302 -0
- package/packages/skills/impeccable/reference/distill.md +111 -0
- package/packages/skills/impeccable/reference/document.md +429 -0
- package/packages/skills/impeccable/reference/extract.md +69 -0
- package/packages/skills/impeccable/reference/harden.md +347 -0
- package/packages/skills/impeccable/reference/hooks.md +90 -0
- package/packages/skills/impeccable/reference/init.md +172 -0
- package/packages/skills/impeccable/reference/interaction-design.md +189 -0
- package/packages/skills/impeccable/reference/layout.md +161 -0
- package/packages/skills/impeccable/reference/live.md +718 -0
- package/packages/skills/impeccable/reference/onboard.md +234 -0
- package/packages/skills/impeccable/reference/optimize.md +258 -0
- package/packages/skills/impeccable/reference/overdrive.md +130 -0
- package/packages/skills/impeccable/reference/polish.md +241 -0
- package/packages/skills/impeccable/reference/product.md +60 -0
- package/packages/skills/impeccable/reference/quieter.md +99 -0
- package/packages/skills/impeccable/reference/shape.md +165 -0
- package/packages/skills/impeccable/reference/typeset.md +279 -0
- package/packages/skills/impeccable/scripts/command-metadata.json +94 -0
- package/packages/skills/impeccable/scripts/context-signals.mjs +225 -0
- package/packages/skills/impeccable/scripts/context.mjs +961 -0
- package/packages/skills/impeccable/scripts/critique-storage.mjs +242 -0
- package/packages/skills/impeccable/scripts/detect-csp.mjs +198 -0
- package/packages/skills/impeccable/scripts/detect.mjs +21 -0
- package/packages/skills/impeccable/scripts/detector/browser/injected/index.mjs +1937 -0
- package/packages/skills/impeccable/scripts/detector/cli/main.mjs +290 -0
- package/packages/skills/impeccable/scripts/detector/design-system.mjs +750 -0
- package/packages/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +5185 -0
- package/packages/skills/impeccable/scripts/detector/detect-antipatterns.mjs +50 -0
- package/packages/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +277 -0
- package/packages/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +568 -0
- package/packages/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +1015 -0
- package/packages/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +234 -0
- package/packages/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
- package/packages/skills/impeccable/scripts/detector/findings.mjs +12 -0
- package/packages/skills/impeccable/scripts/detector/node/file-system.mjs +198 -0
- package/packages/skills/impeccable/scripts/detector/profile/profiler.mjs +166 -0
- package/packages/skills/impeccable/scripts/detector/registry/antipatterns.mjs +459 -0
- package/packages/skills/impeccable/scripts/detector/rules/checks.mjs +2707 -0
- package/packages/skills/impeccable/scripts/detector/shared/color.mjs +124 -0
- package/packages/skills/impeccable/scripts/detector/shared/constants.mjs +101 -0
- package/packages/skills/impeccable/scripts/detector/shared/inline-ignores.mjs +148 -0
- package/packages/skills/impeccable/scripts/detector/shared/page.mjs +7 -0
- package/packages/skills/impeccable/scripts/hook-admin.mjs +660 -0
- package/packages/skills/impeccable/scripts/hook-before-edit.mjs +476 -0
- package/packages/skills/impeccable/scripts/hook-lib.mjs +1632 -0
- package/packages/skills/impeccable/scripts/hook.mjs +61 -0
- package/packages/skills/impeccable/scripts/lib/design-parser.mjs +842 -0
- package/packages/skills/impeccable/scripts/lib/impeccable-config.mjs +638 -0
- package/packages/skills/impeccable/scripts/lib/impeccable-paths.mjs +128 -0
- package/packages/skills/impeccable/scripts/lib/is-generated.mjs +69 -0
- package/packages/skills/impeccable/scripts/lib/target-args.mjs +42 -0
- package/packages/skills/impeccable/scripts/live/browser-script-parts.mjs +49 -0
- package/packages/skills/impeccable/scripts/live/completion.mjs +19 -0
- package/packages/skills/impeccable/scripts/live/event-validation.mjs +137 -0
- package/packages/skills/impeccable/scripts/live/insert-ui.mjs +458 -0
- package/packages/skills/impeccable/scripts/live/manual-apply.mjs +939 -0
- package/packages/skills/impeccable/scripts/live/manual-edit-routes.mjs +357 -0
- package/packages/skills/impeccable/scripts/live/manual-edits-buffer.mjs +152 -0
- package/packages/skills/impeccable/scripts/live/session-store.mjs +289 -0
- package/packages/skills/impeccable/scripts/live/svelte-component.mjs +826 -0
- package/packages/skills/impeccable/scripts/live/sveltekit-adapter.mjs +274 -0
- package/packages/skills/impeccable/scripts/live/ui-core.mjs +180 -0
- package/packages/skills/impeccable/scripts/live/vocabulary.mjs +36 -0
- package/packages/skills/impeccable/scripts/live-accept.mjs +812 -0
- package/packages/skills/impeccable/scripts/live-browser-dom.js +146 -0
- package/packages/skills/impeccable/scripts/live-browser-session.js +123 -0
- package/packages/skills/impeccable/scripts/live-browser.js +11173 -0
- package/packages/skills/impeccable/scripts/live-commit-manual-edits.mjs +1241 -0
- package/packages/skills/impeccable/scripts/live-complete.mjs +75 -0
- package/packages/skills/impeccable/scripts/live-copy-edit-agent.mjs +683 -0
- package/packages/skills/impeccable/scripts/live-discard-manual-edits.mjs +51 -0
- package/packages/skills/impeccable/scripts/live-inject.mjs +583 -0
- package/packages/skills/impeccable/scripts/live-insert.mjs +272 -0
- package/packages/skills/impeccable/scripts/live-manual-edit-evidence.mjs +363 -0
- package/packages/skills/impeccable/scripts/live-poll.mjs +384 -0
- package/packages/skills/impeccable/scripts/live-resume.mjs +94 -0
- package/packages/skills/impeccable/scripts/live-server.mjs +1135 -0
- package/packages/skills/impeccable/scripts/live-status.mjs +61 -0
- package/packages/skills/impeccable/scripts/live-target.mjs +30 -0
- package/packages/skills/impeccable/scripts/live-wrap.mjs +894 -0
- package/packages/skills/impeccable/scripts/live.mjs +297 -0
- package/packages/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/packages/skills/impeccable/scripts/palette.mjs +633 -0
- package/packages/skills/impeccable/scripts/pin.mjs +214 -0
- package/packages/skills/ponytail/SKILL.md +117 -0
- package/packages/skills/stitch-design-taste/DESIGN.md +121 -0
- package/packages/skills/stitch-design-taste/SKILL.md +184 -0
- package/packages/skills/waypoint/SKILL.md +67 -0
- package/packages/skills/wp/SKILL.md +330 -0
- package/packages/skills/wp/caveman-wire.md +148 -0
- package/packages/skills/wp/reference.md +411 -0
- package/scripts/detect-platform.sh +32 -0
- package/scripts/install.sh +123 -0
- package/scripts/lib/common.sh +215 -0
- package/scripts/sync-skills.sh +21 -0
- package/scripts/uninstall.sh +38 -0
- package/scripts/waypoint +281 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// ─── Section 2: Color Utilities ─────────────────────────────────────────────
|
|
2
|
+
|
|
3
|
+
function isNeutralColor(color) {
|
|
4
|
+
if (!color || color === 'transparent') return true;
|
|
5
|
+
|
|
6
|
+
// rgb/rgba — use channel spread. Threshold 30 ≈ 11.7% of the 0–255 range.
|
|
7
|
+
const rgb = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
8
|
+
if (rgb) {
|
|
9
|
+
return (Math.max(+rgb[1], +rgb[2], +rgb[3]) - Math.min(+rgb[1], +rgb[2], +rgb[3])) < 30;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// oklch()/lch() — chroma is the second numeric component.
|
|
13
|
+
// oklch chroma is ~0–0.4 in sRGB gamut; >= 0.02 reads as tinted, not gray.
|
|
14
|
+
// lch chroma is ~0–150; >= 3 reads as tinted. jsdom emits both formats
|
|
15
|
+
// literally (it does NOT convert them to rgb).
|
|
16
|
+
const oklch = color.match(/oklch\(\s*[\d.]+%?\s*([\d.-]+)/i);
|
|
17
|
+
if (oklch) return parseFloat(oklch[1]) < 0.02;
|
|
18
|
+
const lch = color.match(/lch\(\s*[\d.]+%?\s*([\d.-]+)/i);
|
|
19
|
+
if (lch) return parseFloat(lch[1]) < 3;
|
|
20
|
+
|
|
21
|
+
// oklab()/lab() — a and b are signed axes; chroma = sqrt(a² + b²).
|
|
22
|
+
// oklab a/b are ~-0.4..0.4, threshold 0.02. lab a/b are ~-128..127, threshold 3.
|
|
23
|
+
const oklab = color.match(/oklab\(\s*[\d.]+%?\s*([\d.-]+)\s+([\d.-]+)/i);
|
|
24
|
+
if (oklab) {
|
|
25
|
+
const a = parseFloat(oklab[1]), b = parseFloat(oklab[2]);
|
|
26
|
+
return Math.hypot(a, b) < 0.02;
|
|
27
|
+
}
|
|
28
|
+
const lab = color.match(/lab\(\s*[\d.]+%?\s*([\d.-]+)\s+([\d.-]+)/i);
|
|
29
|
+
if (lab) {
|
|
30
|
+
const a = parseFloat(lab[1]), b = parseFloat(lab[2]);
|
|
31
|
+
return Math.hypot(a, b) < 3;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// hsl/hsla — saturation is the second numeric component (percent).
|
|
35
|
+
// Modern jsdom usually converts hsl() to rgb, but handle it directly for
|
|
36
|
+
// safety across versions and for any engine that preserves the format.
|
|
37
|
+
const hsl = color.match(/hsla?\(\s*[\d.-]+\s*,?\s*([\d.]+)%/i);
|
|
38
|
+
if (hsl) return parseFloat(hsl[1]) < 10;
|
|
39
|
+
|
|
40
|
+
// hwb(hue whiteness% blackness%) — a pixel is fully gray when
|
|
41
|
+
// whiteness + blackness >= 100; chroma-like saturation = 1 - (w+b)/100.
|
|
42
|
+
const hwb = color.match(/hwb\(\s*[\d.-]+\s+([\d.]+)%\s+([\d.]+)%/i);
|
|
43
|
+
if (hwb) {
|
|
44
|
+
const w = parseFloat(hwb[1]), b = parseFloat(hwb[2]);
|
|
45
|
+
return (1 - Math.min(100, w + b) / 100) < 0.1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Unknown / unrecognized format — err on the side of DETECTING rather
|
|
49
|
+
// than silently skipping. This is the opposite of the previous default,
|
|
50
|
+
// which was the root cause of the oklch bug.
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function parseRgb(color) {
|
|
55
|
+
if (!color || color === 'transparent') return null;
|
|
56
|
+
const m = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
|
|
57
|
+
if (!m) return null;
|
|
58
|
+
return { r: +m[1], g: +m[2], b: +m[3], a: m[4] !== undefined ? +m[4] : 1 };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function relativeLuminance({ r, g, b }) {
|
|
62
|
+
const [rs, gs, bs] = [r / 255, g / 255, b / 255].map(c =>
|
|
63
|
+
c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4
|
|
64
|
+
);
|
|
65
|
+
return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function contrastRatio(c1, c2) {
|
|
69
|
+
const l1 = relativeLuminance(c1);
|
|
70
|
+
const l2 = relativeLuminance(c2);
|
|
71
|
+
return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function parseGradientColors(bgImage) {
|
|
75
|
+
if (!bgImage || !bgImage.includes('gradient')) return [];
|
|
76
|
+
const colors = [];
|
|
77
|
+
for (const m of bgImage.matchAll(/rgba?\([^)]+\)/g)) {
|
|
78
|
+
const c = parseRgb(m[0]);
|
|
79
|
+
if (c) colors.push(c);
|
|
80
|
+
}
|
|
81
|
+
for (const m of bgImage.matchAll(/#([0-9a-f]{6}|[0-9a-f]{3})\b/gi)) {
|
|
82
|
+
const h = m[1];
|
|
83
|
+
if (h.length === 6) {
|
|
84
|
+
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 });
|
|
85
|
+
} else {
|
|
86
|
+
colors.push({ r: parseInt(h[0]+h[0],16), g: parseInt(h[1]+h[1],16), b: parseInt(h[2]+h[2],16), a: 1 });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return colors;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function hasChroma(c, threshold = 30) {
|
|
93
|
+
if (!c) return false;
|
|
94
|
+
return (Math.max(c.r, c.g, c.b) - Math.min(c.r, c.g, c.b)) >= threshold;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getHue(c) {
|
|
98
|
+
if (!c) return 0;
|
|
99
|
+
const r = c.r / 255, g = c.g / 255, b = c.b / 255;
|
|
100
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
101
|
+
if (max === min) return 0;
|
|
102
|
+
const d = max - min;
|
|
103
|
+
let h;
|
|
104
|
+
if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
105
|
+
else if (max === g) h = ((b - r) / d + 2) / 6;
|
|
106
|
+
else h = ((r - g) / d + 4) / 6;
|
|
107
|
+
return Math.round(h * 360);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function colorToHex(c) {
|
|
111
|
+
if (!c) return '?';
|
|
112
|
+
return '#' + [c.r, c.g, c.b].map(v => v.toString(16).padStart(2, '0')).join('');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
isNeutralColor,
|
|
117
|
+
parseRgb,
|
|
118
|
+
relativeLuminance,
|
|
119
|
+
contrastRatio,
|
|
120
|
+
parseGradientColors,
|
|
121
|
+
hasChroma,
|
|
122
|
+
getHue,
|
|
123
|
+
colorToHex,
|
|
124
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
const GENERIC_FONTS = new Set([
|
|
60
|
+
'serif', 'sans-serif', 'monospace', 'cursive', 'fantasy',
|
|
61
|
+
'system-ui', 'ui-serif', 'ui-sans-serif', 'ui-monospace', 'ui-rounded',
|
|
62
|
+
'-apple-system', 'blinkmacsystemfont', 'segoe ui',
|
|
63
|
+
'inherit', 'initial', 'unset', 'revert',
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
// WCAG large text thresholds are defined in points: 18pt normal text and
|
|
67
|
+
// 14pt bold text. Browsers expose font-size in CSS pixels at 96px per inch.
|
|
68
|
+
const WCAG_LARGE_TEXT_PX = 18 * (96 / 72);
|
|
69
|
+
const WCAG_LARGE_BOLD_TEXT_PX = 14 * (96 / 72);
|
|
70
|
+
|
|
71
|
+
// Serif faces that show up in italic-display heroes. The rule also fires when
|
|
72
|
+
// the primary face is unknown but the stack ends in the generic `serif` token,
|
|
73
|
+
// which catches custom/private faces with a serif fallback.
|
|
74
|
+
const KNOWN_SERIF_FONTS = new Set([
|
|
75
|
+
'fraunces', 'recoleta', 'newsreader', 'playfair display', 'playfair',
|
|
76
|
+
'cormorant', 'cormorant garamond', 'garamond', 'eb garamond',
|
|
77
|
+
'tiempos', 'tiempos headline', 'tiempos text',
|
|
78
|
+
'lora', 'vollkorn', 'spectral',
|
|
79
|
+
'source serif pro', 'source serif 4', 'source serif',
|
|
80
|
+
'ibm plex serif', 'merriweather',
|
|
81
|
+
'libre caslon', 'libre baskerville', 'baskerville',
|
|
82
|
+
'georgia', 'times new roman', 'times',
|
|
83
|
+
'dm serif display', 'dm serif text',
|
|
84
|
+
'instrument serif', 'gt sectra', 'ogg', 'canela',
|
|
85
|
+
'freight display', 'freight text',
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
SAFE_TAGS,
|
|
90
|
+
BORDER_SAFE_TAGS,
|
|
91
|
+
OVERUSED_FONTS,
|
|
92
|
+
GOOGLE_DOMAINS,
|
|
93
|
+
VERCEL_DOMAINS,
|
|
94
|
+
GITHUB_DOMAINS,
|
|
95
|
+
BRAND_FONT_DOMAINS,
|
|
96
|
+
isBrandFontOnOwnDomain,
|
|
97
|
+
GENERIC_FONTS,
|
|
98
|
+
WCAG_LARGE_TEXT_PX,
|
|
99
|
+
WCAG_LARGE_BOLD_TEXT_PX,
|
|
100
|
+
KNOWN_SERIF_FONTS,
|
|
101
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
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 };
|