impeccable 3.0.3 → 3.2.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 +3 -3
- package/README.npm.md +3 -3
- package/README.repo.md +50 -7
- package/cli/bin/cli.js +19 -3
- package/cli/bin/commands/skills.mjs +51 -4
- package/cli/engine/cli/main.mjs +28 -6
- package/cli/engine/detect-antipatterns-browser.js +47 -0
- package/cli/engine/engines/regex/detect-text.mjs +10 -4
- package/cli/engine/engines/static-html/detect-html.mjs +6 -1
- package/cli/engine/registry/antipatterns.mjs +11 -0
- package/cli/engine/rules/checks.mjs +36 -0
- package/cli/engine/shared/inline-ignores.mjs +148 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Impeccable CLI
|
|
2
2
|
|
|
3
|
-
Detect UI anti-patterns and design quality issues from the command line. Scans HTML, CSS, JSX, TSX, Vue, and Svelte files for
|
|
3
|
+
Detect UI anti-patterns and design quality issues from the command line. Scans HTML, CSS, JSX, TSX, Vue, and Svelte files for 45 deterministic rules, including AI-generated UI tells, accessibility violations, and general design quality problems.
|
|
4
4
|
|
|
5
5
|
## Quick Start
|
|
6
6
|
|
|
@@ -56,7 +56,7 @@ npx impeccable detect --fast src/
|
|
|
56
56
|
|
|
57
57
|
**Quality**: tiny body text, cramped padding, long line lengths, small touch targets
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
45 deterministic detector rules in total. See the full catalog at [impeccable.style/slop](https://impeccable.style/slop).
|
|
60
60
|
|
|
61
61
|
## Exit Codes
|
|
62
62
|
|
|
@@ -81,7 +81,7 @@ impeccable detect [options] [file-or-dir-or-url...]
|
|
|
81
81
|
|
|
82
82
|
## Part of Impeccable
|
|
83
83
|
|
|
84
|
-
This CLI is part of [Impeccable](https://impeccable.style), a cross-provider design skill pack for AI-powered development tools. The full suite includes 23 commands for Claude, Cursor, Gemini, Codex, and more.
|
|
84
|
+
This CLI is part of [Impeccable](https://impeccable.style), a cross-provider design skill pack for AI-powered development tools. The full suite includes 23 commands for Claude, Cursor, GitHub Copilot, Gemini, Codex, and more.
|
|
85
85
|
|
|
86
86
|
## License
|
|
87
87
|
|
package/README.npm.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Impeccable CLI
|
|
2
2
|
|
|
3
|
-
Detect UI anti-patterns and design quality issues from the command line. Scans HTML, CSS, JSX, TSX, Vue, and Svelte files for
|
|
3
|
+
Detect UI anti-patterns and design quality issues from the command line. Scans HTML, CSS, JSX, TSX, Vue, and Svelte files for 45 deterministic rules, including AI-generated UI tells, accessibility violations, and general design quality problems.
|
|
4
4
|
|
|
5
5
|
## Quick Start
|
|
6
6
|
|
|
@@ -56,7 +56,7 @@ npx impeccable detect --fast src/
|
|
|
56
56
|
|
|
57
57
|
**Quality**: tiny body text, cramped padding, long line lengths, small touch targets
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
45 deterministic detector rules in total. See the full catalog at [impeccable.style/slop](https://impeccable.style/slop).
|
|
60
60
|
|
|
61
61
|
## Exit Codes
|
|
62
62
|
|
|
@@ -81,7 +81,7 @@ impeccable detect [options] [file-or-dir-or-url...]
|
|
|
81
81
|
|
|
82
82
|
## Part of Impeccable
|
|
83
83
|
|
|
84
|
-
This CLI is part of [Impeccable](https://impeccable.style), a cross-provider design skill pack for AI-powered development tools. The full suite includes 23 commands for Claude, Cursor, Gemini, Codex, and more.
|
|
84
|
+
This CLI is part of [Impeccable](https://impeccable.style), a cross-provider design skill pack for AI-powered development tools. The full suite includes 23 commands for Claude, Cursor, GitHub Copilot, Gemini, Codex, and more.
|
|
85
85
|
|
|
86
86
|
## License
|
|
87
87
|
|
package/README.repo.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Impeccable
|
|
2
2
|
|
|
3
|
-
Design guidance for AI coding agents. 1 skill, 23 commands, live browser iteration, and
|
|
3
|
+
Design guidance for AI coding agents. 1 skill, 23 commands, live browser iteration, and 45 deterministic detector rules for AI-generated frontend design.
|
|
4
4
|
|
|
5
5
|
> **Quick start:** From your project root, run `npx impeccable install`, then run `/impeccable init` inside your AI coding tool. Full docs: [impeccable.style](https://impeccable.style).
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ Every model trained on the same SaaS templates. Skip the guidance and you get th
|
|
|
13
13
|
Impeccable adds:
|
|
14
14
|
- **One setup flow.** `/impeccable init` writes `PRODUCT.md` and offers `DESIGN.md`, so later commands know the audience, brand/product lane, voice, anti-references, colors, type, and components.
|
|
15
15
|
- **23 commands.** A shared design vocabulary with your AI: `polish`, `audit`, `critique`, `distill`, `animate`, `bolder`, `quieter`, and more.
|
|
16
|
-
- **
|
|
16
|
+
- **45 deterministic detector rules** plus LLM-only critique checks. The CLI and browser extension run the deterministic rules with no LLM and no API key.
|
|
17
17
|
|
|
18
18
|
## What's Included
|
|
19
19
|
|
|
@@ -258,13 +258,54 @@ If you reach for one command often, pin it with `/impeccable pin audit` to get `
|
|
|
258
258
|
|
|
259
259
|
**Note:** Codex uses skills here, not `/prompts:` commands. Open `/skills` or type `$impeccable`. Repo-local installs live in `.agents/skills/`; user-wide installs live in `~/.agents/skills/`. GitHub Copilot uses `.github/skills/`. Restart the tool if a newly installed skill does not appear.
|
|
260
260
|
|
|
261
|
+
## Keeping `.impeccable` out of git
|
|
262
|
+
|
|
263
|
+
As you run commands, Impeccable writes working files under `.impeccable/`: critique and polish screenshots, live-mode session and preview state, runtime caches, and per-developer config. Most of it is ephemeral and should not be committed, while a few files are shared project artifacts that belong in the repo. Add this block to your project's `.gitignore`:
|
|
264
|
+
|
|
265
|
+
```gitignore
|
|
266
|
+
# impeccable-ignore-start
|
|
267
|
+
# Ephemeral output, runtime state, and per-dev overrides.
|
|
268
|
+
# Unanchored: .impeccable may sit at the repo root or under a nested
|
|
269
|
+
# workspace (apps/web/.impeccable/...); anchored patterns would miss it.
|
|
270
|
+
# Shared artifacts stay tracked: config.json, live/config.json,
|
|
271
|
+
# design.json, critique/*.md.
|
|
272
|
+
.impeccable/config.local.json
|
|
273
|
+
.impeccable/hook.cache.json
|
|
274
|
+
.impeccable/hook.pending.json
|
|
275
|
+
.impeccable/*.png
|
|
276
|
+
.impeccable/live/server.json
|
|
277
|
+
.impeccable/live/sessions/
|
|
278
|
+
.impeccable/live/previews/
|
|
279
|
+
.impeccable/live/annotations/
|
|
280
|
+
.impeccable/live/cache/
|
|
281
|
+
.impeccable/live/manual-edit-apply-transaction.json
|
|
282
|
+
.impeccable/live/manual-edit-events.jsonl
|
|
283
|
+
.impeccable/live/manual-edit-evidence/
|
|
284
|
+
.impeccable/live/pending-manual-edits.json
|
|
285
|
+
.impeccable/live/deferred-svelte-component-accepts.json
|
|
286
|
+
.impeccable/live/*.png
|
|
287
|
+
# impeccable-ignore-end
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
The block is wrapped in `# impeccable-ignore-start` / `# impeccable-ignore-end` markers so you can recognize and refresh it later. Patterns are unanchored on purpose: in a monorepo the active project (and its `.impeccable/` directory) often lives under a nested workspace path like `apps/web/`, and a root-anchored pattern would miss it.
|
|
291
|
+
|
|
292
|
+
**Keep these tracked** (they are shared project artifacts, do not add them to `.gitignore`):
|
|
293
|
+
|
|
294
|
+
- `.impeccable/config.json` (unified shared config)
|
|
295
|
+
- `.impeccable/live/config.json` (live-mode framework wiring)
|
|
296
|
+
- `.impeccable/design.json` (shared design spec)
|
|
297
|
+
- `.impeccable/critique/*.md` (review reports)
|
|
298
|
+
|
|
299
|
+
If an ephemeral file (a screenshot, `config.local.json`) was committed before you added the block, `.gitignore` will not untrack it automatically. Run `git rm --cached <path>` to stop tracking it without deleting your local copy.
|
|
300
|
+
|
|
261
301
|
## Design hook
|
|
262
302
|
|
|
263
|
-
On Claude Code, Codex, and Cursor, `npx impeccable install` and `npx impeccable update` install a provider-native hook manifest along with the skill payload. The hook runs the Impeccable design detector on direct UI file edits and surfaces findings back into the agent flow. Claude Code and Codex surface findings after the edit. Cursor blocks bad proposed writes before they land.
|
|
303
|
+
On Claude Code, GitHub Copilot, Codex, and Cursor, `npx impeccable install` and `npx impeccable update` install a provider-native hook manifest along with the skill payload. The hook runs the Impeccable design detector on direct UI file edits and surfaces findings back into the agent flow. Claude Code, GitHub Copilot, and Codex surface findings after the edit. Cursor blocks bad proposed writes before they land.
|
|
264
304
|
|
|
265
305
|
Installed hook surfaces:
|
|
266
306
|
|
|
267
307
|
- Claude Code: `.claude/settings.local.json` (gitignored, machine-local) runs `${CLAUDE_PROJECT_DIR}/.claude/skills/impeccable/scripts/hook.mjs`. A hook moved into the shared `settings.json` is honored in place.
|
|
308
|
+
- GitHub Copilot: `.github/hooks/impeccable.json` (committed, shared by the Copilot CLI and the cloud agent) runs `.github/skills/impeccable/scripts/hook.mjs`. The Copilot CLI activates it once the file is on the repository's default branch and the folder is trusted.
|
|
268
309
|
- Cursor: `.cursor/hooks.json` runs `.cursor/skills/impeccable/scripts/hook-before-edit.mjs`.
|
|
269
310
|
- Codex: `.codex/hooks.json` runs `.agents/skills/impeccable/scripts/hook.mjs`.
|
|
270
311
|
|
|
@@ -300,21 +341,23 @@ npx impeccable ignores add-file "src/legacy/**"
|
|
|
300
341
|
npx impeccable ignores add-value overused-font Inter --reason "Brand font"
|
|
301
342
|
```
|
|
302
343
|
|
|
303
|
-
The detector catches
|
|
344
|
+
The detector catches 45 deterministic issues across AI slop (side-tab borders, purple gradients, bounce easing, dark glows) and general design quality (line length, cramped padding, small touch targets, skipped headings, and more).
|
|
304
345
|
|
|
305
346
|
By default, `detect` respects the same `.impeccable/config.json` and `.impeccable/config.local.json` detector config as the design hook: `detector.ignoreRules`, `detector.ignoreFiles`, `detector.ignoreValues`, and `detector.designSystem.enabled`. Hook lifecycle settings such as `hook.enabled` only affect automatic hook execution.
|
|
306
347
|
|
|
348
|
+
For a waiver that should travel with one file instead of the repo config, add an inline comment in the file: `<!-- impeccable-disable overused-font: exported brand doc -->`. The marker works in any comment syntax, scopes to the whole file (or one line with `impeccable-disable-line` / `impeccable-disable-next-line`), and is bypassed by `--no-inline-ignores` or `--no-config`.
|
|
349
|
+
|
|
307
350
|
Full detector docs: [impeccable.style/docs/detector](https://impeccable.style/docs/detector).
|
|
308
351
|
|
|
309
352
|
## Supported Tools
|
|
310
353
|
|
|
311
354
|
- [Cursor](https://cursor.com)
|
|
312
355
|
- [Claude Code](https://claude.ai/code)
|
|
313
|
-
- [
|
|
314
|
-
- [Pi](https://pi.dev)
|
|
356
|
+
- [GitHub Copilot](https://github.com/features/copilot)
|
|
315
357
|
- [Gemini CLI](https://github.com/google-gemini/gemini-cli)
|
|
316
358
|
- [Codex CLI](https://github.com/openai/codex)
|
|
317
|
-
- [
|
|
359
|
+
- [OpenCode](https://opencode.ai)
|
|
360
|
+
- [Pi](https://pi.dev)
|
|
318
361
|
- [Kiro](https://kiro.dev)
|
|
319
362
|
- [Trae](https://trae.ai)
|
|
320
363
|
- [Rovo Dev](https://www.atlassian.com/software/rovo)
|
package/cli/bin/cli.js
CHANGED
|
@@ -10,13 +10,24 @@
|
|
|
10
10
|
* npx impeccable --help
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { readFileSync } from 'node:fs';
|
|
14
|
-
import { join, dirname } from 'node:path';
|
|
13
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
14
|
+
import { join, dirname, resolve } from 'node:path';
|
|
15
15
|
import { fileURLToPath } from 'node:url';
|
|
16
16
|
|
|
17
17
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
18
18
|
const SKILL_COMMANDS = new Set(['help', 'install', 'link', 'update', 'check']);
|
|
19
19
|
|
|
20
|
+
// Is this a detect target (the `npx impeccable src/` shorthand) or a mistyped
|
|
21
|
+
// command? Flags, URLs, path-shaped args, and real files/dirs (e.g. an
|
|
22
|
+
// extension-less `Dockerfile`) are targets; anything else is an unknown command.
|
|
23
|
+
function looksLikeDetectTarget(arg) {
|
|
24
|
+
const isFlag = arg.startsWith('-');
|
|
25
|
+
const isUrl = /^https?:\/\//i.test(arg);
|
|
26
|
+
const isPathShaped = arg.includes('/') || arg.includes('\\') || arg.includes('.');
|
|
27
|
+
const isExistingPath = existsSync(resolve(arg));
|
|
28
|
+
return isFlag || isUrl || isPathShaped || isExistingPath;
|
|
29
|
+
}
|
|
30
|
+
|
|
20
31
|
async function main() {
|
|
21
32
|
const args = process.argv.slice(2);
|
|
22
33
|
const command = args[0];
|
|
@@ -61,11 +72,16 @@ Compatibility:
|
|
|
61
72
|
} else if (SKILL_COMMANDS.has(command)) {
|
|
62
73
|
const { run } = await import('./commands/skills.mjs');
|
|
63
74
|
await run(args);
|
|
64
|
-
} else {
|
|
75
|
+
} else if (looksLikeDetectTarget(command)) {
|
|
65
76
|
// Default: treat as detect arguments (allow `npx impeccable src/` shorthand)
|
|
66
77
|
process.argv = [process.argv[0], process.argv[1], ...args];
|
|
67
78
|
const { detectCli } = await import('../engine/detect-antipatterns.mjs');
|
|
68
79
|
await detectCli();
|
|
80
|
+
} else {
|
|
81
|
+
// An unknown bareword: a mistyped command (or an old cached version run
|
|
82
|
+
// against newer docs). Fail loudly instead of silently statting it as a path.
|
|
83
|
+
console.error(`Unknown command: "${command}"\n\nTo see a list of supported commands, run:\n impeccable --help`);
|
|
84
|
+
process.exit(1);
|
|
69
85
|
}
|
|
70
86
|
}
|
|
71
87
|
|
|
@@ -103,6 +103,12 @@ const PROVIDER_HOOK_ARTIFACTS = {
|
|
|
103
103
|
'.agents': [
|
|
104
104
|
{ sourceProvider: '.codex', rel: 'hooks.json', destProvider: '.codex' },
|
|
105
105
|
],
|
|
106
|
+
// GitHub Copilot reads repo-level hooks from `.github/hooks/*.json`. Unlike
|
|
107
|
+
// Claude, this is a team-shared, committed file (not a machine-local override),
|
|
108
|
+
// so source and dest are the same path.
|
|
109
|
+
'.github': [
|
|
110
|
+
{ sourceProvider: '.github', rel: 'hooks/impeccable.json', destProvider: '.github' },
|
|
111
|
+
],
|
|
106
112
|
};
|
|
107
113
|
|
|
108
114
|
let pipedAnswers = null;
|
|
@@ -1004,6 +1010,36 @@ async function chooseInstallPlan(projectRoot, flags, { yes } = {}) {
|
|
|
1004
1010
|
return { targets, scope, installRoot, hookRoot: projectRoot, detections };
|
|
1005
1011
|
}
|
|
1006
1012
|
|
|
1013
|
+
/**
|
|
1014
|
+
* Whether `localSkillsDir` is a symlink that points at ANOTHER in-project
|
|
1015
|
+
* provider's skills dir (e.g. `.claude/skills -> ../.agents/skills`, the shape a
|
|
1016
|
+
* prior `npx skills` install can leave behind). Only these get dropped so each
|
|
1017
|
+
* provider can receive its own compiled variant. A symlink to anywhere else -
|
|
1018
|
+
* notably a user's external shared skills dir (`~/.claude/skills ->
|
|
1019
|
+
* ~/.config/agents/skills`) - is preserved and written through. See issue #295.
|
|
1020
|
+
*/
|
|
1021
|
+
function isInProjectProviderLink(localSkillsDir, root, provider) {
|
|
1022
|
+
let target;
|
|
1023
|
+
try {
|
|
1024
|
+
if (!lstatSync(localSkillsDir).isSymbolicLink()) return false;
|
|
1025
|
+
target = readlinkSync(localSkillsDir);
|
|
1026
|
+
} catch {
|
|
1027
|
+
return false; // not a symlink, or unreadable
|
|
1028
|
+
}
|
|
1029
|
+
// Resolve the link's TARGET lexically against the link's own directory. We
|
|
1030
|
+
// deliberately do NOT realpathSync the target:
|
|
1031
|
+
// * it lets a not-yet-created in-project target still match, so a dangling
|
|
1032
|
+
// `.claude/skills -> ../.agents/skills` is still dropped;
|
|
1033
|
+
// * it compares the ACTUAL target, not a shared realpath, so two providers
|
|
1034
|
+
// pointing at the SAME external dir are never misread as in-project.
|
|
1035
|
+
const resolvedTarget = resolve(dirname(localSkillsDir), target);
|
|
1036
|
+
for (const other of PROVIDER_DIRS) {
|
|
1037
|
+
if (other === provider) continue;
|
|
1038
|
+
if (resolvedTarget === join(root, other, 'skills')) return true;
|
|
1039
|
+
}
|
|
1040
|
+
return false;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1007
1043
|
/**
|
|
1008
1044
|
* Copy each target provider's compiled skill variant from an extracted bundle
|
|
1009
1045
|
* into the project. Writes real directories (copy, never symlink) so every
|
|
@@ -1016,10 +1052,12 @@ function copyProviderSkills(bundleDir, root, targets) {
|
|
|
1016
1052
|
if (existsSync(srcDir)) {
|
|
1017
1053
|
const localSkillsDir = join(root, provider, 'skills');
|
|
1018
1054
|
// A previous `npx skills` install may have left this provider's skills dir
|
|
1019
|
-
// as a symlink to
|
|
1020
|
-
// write a real, provider-specific directory
|
|
1055
|
+
// as a symlink to ANOTHER in-project provider's canonical copy. Drop only
|
|
1056
|
+
// that link so we write a real, provider-specific directory. A user's
|
|
1057
|
+
// external shared-skills symlink (e.g. ~/.claude/skills ->
|
|
1058
|
+
// ~/.config/agents/skills) is preserved and written through. See #295.
|
|
1021
1059
|
try {
|
|
1022
|
-
if (
|
|
1060
|
+
if (isInProjectProviderLink(localSkillsDir, root, provider)) unlinkSync(localSkillsDir);
|
|
1023
1061
|
} catch {}
|
|
1024
1062
|
for (const skill of readdirSync(srcDir, { withFileTypes: true })) {
|
|
1025
1063
|
if (!skill.isDirectory()) continue;
|
|
@@ -1072,6 +1110,12 @@ function hookArtifactsForProvider(bundleDir, root, provider) {
|
|
|
1072
1110
|
}
|
|
1073
1111
|
|
|
1074
1112
|
function hookScriptPathForProvider(skillRoot, provider) {
|
|
1113
|
+
// `.github` is intentionally absent: its hook manifest (`.github/hooks/
|
|
1114
|
+
// impeccable.json`) is a committed, team-shared file that the Copilot cloud
|
|
1115
|
+
// agent and every teammate read, so the command must stay portable
|
|
1116
|
+
// (`$(git rev-parse --show-toplevel)/.github/skills/...`). Rewriting it to a
|
|
1117
|
+
// machine-local absolute skillRoot path would break those. GitHub skills are
|
|
1118
|
+
// project-scoped (not a home-provider), so the project-relative path resolves.
|
|
1075
1119
|
if (provider === '.cursor') {
|
|
1076
1120
|
return join(skillRoot, provider, 'skills', 'impeccable', 'scripts', 'hook-before-edit.mjs');
|
|
1077
1121
|
}
|
|
@@ -1160,7 +1204,10 @@ function valueHasImpeccableHookMarker(value) {
|
|
|
1160
1204
|
|
|
1161
1205
|
function stripImpeccableHookEntry(entry) {
|
|
1162
1206
|
if (!entry || typeof entry !== 'object') return entry;
|
|
1163
|
-
|
|
1207
|
+
// `command`/`args`: Claude/Codex/Cursor. `bash`/`powershell`: GitHub Copilot's
|
|
1208
|
+
// flat entry shape, where the marker lives under the shell-command keys.
|
|
1209
|
+
if (valueHasImpeccableHookMarker(entry.command) || valueHasImpeccableHookMarker(entry.args)
|
|
1210
|
+
|| valueHasImpeccableHookMarker(entry.bash) || valueHasImpeccableHookMarker(entry.powershell)) {
|
|
1164
1211
|
return null;
|
|
1165
1212
|
}
|
|
1166
1213
|
if (!Array.isArray(entry.hooks)) return entry;
|
package/cli/engine/cli/main.mjs
CHANGED
|
@@ -22,6 +22,10 @@ import {
|
|
|
22
22
|
// Output formatting
|
|
23
23
|
// ---------------------------------------------------------------------------
|
|
24
24
|
|
|
25
|
+
function formatFindingSummary(count) {
|
|
26
|
+
return `${count} anti-pattern${count === 1 ? '' : 's'} found.`;
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
function formatFindings(findings, jsonMode) {
|
|
26
30
|
if (jsonMode) return JSON.stringify(findings, null, 2);
|
|
27
31
|
|
|
@@ -39,7 +43,7 @@ function formatFindings(findings, jsonMode) {
|
|
|
39
43
|
out.push(` → ${item.description}`);
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
|
-
out.push(`\n${findings.length}
|
|
46
|
+
out.push(`\n${formatFindingSummary(findings.length)}`);
|
|
43
47
|
return out.join('\n');
|
|
44
48
|
}
|
|
45
49
|
|
|
@@ -86,9 +90,12 @@ Scan files or URLs for UI anti-patterns and design quality issues.
|
|
|
86
90
|
|
|
87
91
|
Options:
|
|
88
92
|
--json Output results as JSON
|
|
93
|
+
--quiet In text mode, only print the final findings count
|
|
89
94
|
--gpt Also report GPT-specific provider tells (off by default)
|
|
90
95
|
--gemini Also report Gemini-specific provider tells (off by default)
|
|
91
|
-
--no-config Do not apply project config, detector ignores,
|
|
96
|
+
--no-config Do not apply project config, detector ignores, inline
|
|
97
|
+
ignore comments, or DESIGN.md
|
|
98
|
+
--no-inline-ignores Do not honor in-file impeccable-disable* ignore comments
|
|
92
99
|
--no-design-system Do not load local DESIGN.md / .impeccable/design.json context
|
|
93
100
|
--help Show this help message
|
|
94
101
|
|
|
@@ -97,6 +104,14 @@ Project config:
|
|
|
97
104
|
settings: detector.ignoreRules, detector.ignoreFiles, detector.ignoreValues,
|
|
98
105
|
and detector.designSystem.enabled.
|
|
99
106
|
|
|
107
|
+
Inline ignores:
|
|
108
|
+
In-file comments waive a finding where it lives and travel with the file:
|
|
109
|
+
<!-- impeccable-disable overused-font -- exported brand doc -->
|
|
110
|
+
.brand { font-family: Inter } /* impeccable-disable-line overused-font */
|
|
111
|
+
// impeccable-disable-next-line bounce-easing: intentional bounce
|
|
112
|
+
impeccable-disable applies to the whole file; -line / -next-line are scoped.
|
|
113
|
+
List one or more rule ids (comma-separated), or omit them / use * for all.
|
|
114
|
+
|
|
100
115
|
Detection modes:
|
|
101
116
|
HTML files Static HTML/CSS analysis (default, catches linked CSS)
|
|
102
117
|
Non-HTML files Regex pattern matching (CSS, JSX, TSX, etc.)
|
|
@@ -118,6 +133,7 @@ async function detectCli() {
|
|
|
118
133
|
});
|
|
119
134
|
if (args[0] === 'detect') args = args.slice(1);
|
|
120
135
|
const jsonMode = args.includes('--json');
|
|
136
|
+
const quietMode = args.includes('--quiet');
|
|
121
137
|
const helpMode = args.includes('--help');
|
|
122
138
|
// --fast (regex-only) is deprecated: since the jsdom removal, the static
|
|
123
139
|
// HTML/CSS analysis is fast and covers every rule, so the regex-only path
|
|
@@ -137,7 +153,12 @@ async function detectCli() {
|
|
|
137
153
|
if (args.includes('--gemini')) providers.push('gemini');
|
|
138
154
|
const designSystemEnabled = configEnabled && !args.includes('--no-design-system') && detectionConfig.designSystem?.enabled !== false;
|
|
139
155
|
const designSystem = designSystemEnabled ? loadDesignSystemForCwd(process.cwd()) : null;
|
|
140
|
-
|
|
156
|
+
// Inline `impeccable-disable*` waivers are part of the scanned file, so they
|
|
157
|
+
// apply by default. `--no-config` (raw scan) and the dedicated
|
|
158
|
+
// `--no-inline-ignores` both turn them off.
|
|
159
|
+
const inlineIgnoresEnabled = configEnabled && !args.includes('--no-inline-ignores');
|
|
160
|
+
const scanOptions = { providers, inlineIgnores: inlineIgnoresEnabled };
|
|
161
|
+
if (designSystem) scanOptions.designSystem = designSystem;
|
|
141
162
|
const targets = args.filter(a => !a.startsWith('--'));
|
|
142
163
|
|
|
143
164
|
if (helpMode) { printUsage(); process.exit(0); }
|
|
@@ -169,8 +190,8 @@ async function detectCli() {
|
|
|
169
190
|
catch { process.stderr.write(`Warning: cannot access ${target}\n`); continue; }
|
|
170
191
|
|
|
171
192
|
if (stat.isDirectory()) {
|
|
172
|
-
// Check for framework dev server config (skip in JSON
|
|
173
|
-
if (!jsonMode) {
|
|
193
|
+
// Check for framework dev server config (skip in JSON/quiet modes to avoid polluting output)
|
|
194
|
+
if (!jsonMode && !quietMode) {
|
|
174
195
|
const fwConfig = detectFrameworkConfig(resolved);
|
|
175
196
|
if (fwConfig) {
|
|
176
197
|
const probe = await isPortListening(fwConfig.port, fwConfig.fingerprint);
|
|
@@ -200,7 +221,7 @@ async function detectCli() {
|
|
|
200
221
|
const htmlCount = files.filter(f => HTML_EXTENSIONS.has(path.extname(f).toLowerCase())).length;
|
|
201
222
|
|
|
202
223
|
// Warn and confirm if scanning many files (static HTML/CSS processes each HTML file)
|
|
203
|
-
if (files.length > 50 && process.stdin.isTTY && !jsonMode) {
|
|
224
|
+
if (files.length > 50 && process.stdin.isTTY && !jsonMode && !quietMode) {
|
|
204
225
|
process.stderr.write(
|
|
205
226
|
`\nFound ${files.length} files (${htmlCount} HTML) in ${target}.\n` +
|
|
206
227
|
`Scanning may take a while${htmlCount > 10 ? ' (static HTML/CSS processes each HTML file individually)' : ''}.\n` +
|
|
@@ -258,6 +279,7 @@ async function detectCli() {
|
|
|
258
279
|
|
|
259
280
|
if (allFindings.length > 0) {
|
|
260
281
|
if (jsonMode) process.stdout.write(formatFindings(allFindings, true) + '\n');
|
|
282
|
+
else if (quietMode) process.stderr.write(formatFindingSummary(allFindings.length) + '\n');
|
|
261
283
|
else process.stderr.write(formatFindings(allFindings, false) + '\n');
|
|
262
284
|
process.exit(2);
|
|
263
285
|
}
|
|
@@ -478,6 +478,17 @@ const ANTIPATTERNS = [
|
|
|
478
478
|
skillSection: 'Visual Details',
|
|
479
479
|
skillGuideline: 'repeating-gradient decorative stripes',
|
|
480
480
|
},
|
|
481
|
+
{
|
|
482
|
+
id: 'codex-grid-background',
|
|
483
|
+
category: 'slop',
|
|
484
|
+
severity: 'advisory',
|
|
485
|
+
gated: 'gpt',
|
|
486
|
+
name: 'Decorative grid-line background',
|
|
487
|
+
description:
|
|
488
|
+
'A two-axis grid drawn with hairline linear-gradient layers ("1px, transparent 1px" on both axes) is a recurring generated-UI signature. Reserve grid overlays for actual canvas, map, blueprint, or measurement surfaces; elsewhere use product structure or a plain surface.',
|
|
489
|
+
skillSection: 'Visual Details',
|
|
490
|
+
skillGuideline: 'two-axis grid-line gradient background',
|
|
491
|
+
},
|
|
481
492
|
{
|
|
482
493
|
id: 'theater-slop-phrase',
|
|
483
494
|
category: 'slop',
|
|
@@ -1172,6 +1183,42 @@ function checkHtmlPatterns(html) {
|
|
|
1172
1183
|
findings.push({ id: 'repeating-stripes-gradient', snippet: 'repeating-gradient decorative stripes' });
|
|
1173
1184
|
}
|
|
1174
1185
|
|
|
1186
|
+
// --- Provider tells (gated): two-axis grid-line background (Codex/GPT) ---
|
|
1187
|
+
// The Codex grid tell is two hairline `linear-gradient(... <color> 1px,
|
|
1188
|
+
// transparent 1px)` layers (one per axis) tiled by a repeating
|
|
1189
|
+
// `background-size` cell. Both signals must co-occur in the SAME style block
|
|
1190
|
+
// (a CSS rule body or one inline `style="..."`): two hairline stops WITHOUT a
|
|
1191
|
+
// tiling background-size is a fixed crosshair, not a grid, and a single
|
|
1192
|
+
// hairline is a legitimate ruled line. Scoping to one block also stops
|
|
1193
|
+
// unrelated single-axis rules on separate elements from adding up across the
|
|
1194
|
+
// page. Count hairlines only inside `background`/`background-image` values so
|
|
1195
|
+
// a hairline in an unrelated property (mask-image, border-image) can't stand
|
|
1196
|
+
// in for the second axis. Colors like `oklch(96% 0.012 82 / 0.055)` carry
|
|
1197
|
+
// nested parens, so match the hairline stop directly rather than parsing
|
|
1198
|
+
// whole gradient layers.
|
|
1199
|
+
{
|
|
1200
|
+
const hairlineRe = /\b\d{1,3}px\s*,\s*transparent\s+\d{1,3}px/gi;
|
|
1201
|
+
const gridSizeRe = /background-size\s*:[^;{}"']*\b\d{1,3}px\b/i;
|
|
1202
|
+
const bgDeclRe = /\bbackground(?:-image)?\s*:\s*([^;{}"']*)/gi;
|
|
1203
|
+
const blockRe = /\{([^{}]*)\}|style\s*=\s*"([^"]*)"|style\s*=\s*'([^']*)'/gi;
|
|
1204
|
+
let blk;
|
|
1205
|
+
while ((blk = blockRe.exec(html)) !== null) {
|
|
1206
|
+
const block = blk[1] || blk[2] || blk[3] || '';
|
|
1207
|
+
if (!gridSizeRe.test(block)) continue;
|
|
1208
|
+
let hairlineCount = 0;
|
|
1209
|
+
let bm;
|
|
1210
|
+
bgDeclRe.lastIndex = 0;
|
|
1211
|
+
while ((bm = bgDeclRe.exec(block)) !== null) {
|
|
1212
|
+
const stops = bm[1].match(hairlineRe);
|
|
1213
|
+
if (stops) hairlineCount += stops.length;
|
|
1214
|
+
}
|
|
1215
|
+
if (hairlineCount >= 2) {
|
|
1216
|
+
findings.push({ id: 'codex-grid-background', snippet: 'two-axis grid-line gradient background' });
|
|
1217
|
+
break;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1175
1222
|
// --- Provider tells (gated): "X theater" framing copy (GPT) ---
|
|
1176
1223
|
// Lives here (regex-on-HTML) rather than in the text-content analyzers so it
|
|
1177
1224
|
// runs in the bundled browser path too, not just the CLI/static path.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { GENERIC_FONTS } from '../../shared/constants.mjs';
|
|
2
|
+
import { isNeutralColor } from '../../shared/color.mjs';
|
|
2
3
|
import { checkSourceDesignSystem } from '../../design-system.mjs';
|
|
3
4
|
import { isFullPage } from '../../shared/page.mjs';
|
|
5
|
+
import { applyInlineIgnores } from '../../shared/inline-ignores.mjs';
|
|
4
6
|
import { finding } from '../../findings.mjs';
|
|
5
7
|
import { filterByProviders } from '../../registry/antipatterns.mjs';
|
|
6
8
|
import { profileFindings, profileStep } from '../../profile/profiler.mjs';
|
|
@@ -37,10 +39,11 @@ function shouldRunPageAnalyzers(content, filePath) {
|
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
function isNeutralBorderColor(str) {
|
|
40
|
-
const m = str.match(/solid\s+(
|
|
42
|
+
const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
|
|
41
43
|
if (!m) return false;
|
|
42
44
|
const c = m[1].toLowerCase();
|
|
43
45
|
if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
|
|
46
|
+
if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
|
|
44
47
|
const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
|
|
45
48
|
if (hex) {
|
|
46
49
|
const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
|
|
@@ -57,10 +60,10 @@ function isNeutralBorderColor(str) {
|
|
|
57
60
|
const REGEX_MATCHERS = [
|
|
58
61
|
// --- Side-tab ---
|
|
59
62
|
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
|
|
60
|
-
test: (m, line) => { const n = +m[1]; return hasRounded(line) ? n >=
|
|
63
|
+
test: (m, line) => { const n = +m[1]; return hasRounded(line) ? n >= 2 : n >= 4; },
|
|
61
64
|
fmt: (m) => m[0] },
|
|
62
65
|
{ id: 'side-tab', regex: /border-(?:left|right)\s*:\s*(\d+)px\s+solid[^;]*/gi,
|
|
63
|
-
test: (m, line) => { if (isSafeElement(line)) return false; if (isNeutralBorderColor(m[0])) return false; const n = +m[1]; return hasBorderRadius(line) ? n >=
|
|
66
|
+
test: (m, line) => { if (isSafeElement(line)) return false; if (isNeutralBorderColor(m[0])) return false; const n = +m[1]; return hasBorderRadius(line) ? n >= 2 : n >= 3; },
|
|
64
67
|
fmt: (m) => m[0].replace(/\s*;?\s*$/, '') },
|
|
65
68
|
{ id: 'side-tab', regex: /border-(?:left|right)-width\s*:\s*(\d+)px/gi,
|
|
66
69
|
test: (m, line) => !isSafeElement(line) && +m[1] >= 3,
|
|
@@ -547,7 +550,10 @@ function detectText(content, filePath, options = {}) {
|
|
|
547
550
|
}
|
|
548
551
|
}
|
|
549
552
|
|
|
550
|
-
|
|
553
|
+
const byProvider = filterByProviders(deduped, options?.providers);
|
|
554
|
+
// Inline `impeccable-disable*` waivers travel with the file; honor them unless
|
|
555
|
+
// explicitly bypassed (`--no-config` / `--no-inline-ignores`).
|
|
556
|
+
return options?.inlineIgnores === false ? byProvider : applyInlineIgnores(byProvider, content);
|
|
551
557
|
}
|
|
552
558
|
|
|
553
559
|
export {
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
mergeDesignSystemFindings,
|
|
9
9
|
} from '../../design-system.mjs';
|
|
10
10
|
import { isFullPage } from '../../shared/page.mjs';
|
|
11
|
+
import { applyInlineIgnores } from '../../shared/inline-ignores.mjs';
|
|
11
12
|
import { finding } from '../../findings.mjs';
|
|
12
13
|
import { profileFindings, profileStep, profileStepAsync } from '../../profile/profiler.mjs';
|
|
13
14
|
import {
|
|
@@ -223,7 +224,11 @@ async function detectHtml(filePath, options = {}) {
|
|
|
223
224
|
}
|
|
224
225
|
}
|
|
225
226
|
|
|
226
|
-
|
|
227
|
+
const byProvider = filterByProviders(findings, options.providers);
|
|
228
|
+
// Static-HTML findings carry no line number, so only whole-file
|
|
229
|
+
// `impeccable-disable` directives apply here — exactly the standalone-document
|
|
230
|
+
// waiver this primitive targets. Bypassed by `--no-config` / `--no-inline-ignores`.
|
|
231
|
+
return options?.inlineIgnores === false ? byProvider : applyInlineIgnores(byProvider, html);
|
|
227
232
|
}
|
|
228
233
|
|
|
229
234
|
export { checkStaticPageTypography, STATIC_ELEMENT_RULES, detectHtml };
|
|
@@ -376,6 +376,17 @@ const ANTIPATTERNS = [
|
|
|
376
376
|
skillSection: 'Visual Details',
|
|
377
377
|
skillGuideline: 'repeating-gradient decorative stripes',
|
|
378
378
|
},
|
|
379
|
+
{
|
|
380
|
+
id: 'codex-grid-background',
|
|
381
|
+
category: 'slop',
|
|
382
|
+
severity: 'advisory',
|
|
383
|
+
gated: 'gpt',
|
|
384
|
+
name: 'Decorative grid-line background',
|
|
385
|
+
description:
|
|
386
|
+
'A two-axis grid drawn with hairline linear-gradient layers ("1px, transparent 1px" on both axes) is a recurring generated-UI signature. Reserve grid overlays for actual canvas, map, blueprint, or measurement surfaces; elsewhere use product structure or a plain surface.',
|
|
387
|
+
skillSection: 'Visual Details',
|
|
388
|
+
skillGuideline: 'two-axis grid-line gradient background',
|
|
389
|
+
},
|
|
379
390
|
{
|
|
380
391
|
id: 'theater-slop-phrase',
|
|
381
392
|
category: 'slop',
|
|
@@ -573,6 +573,42 @@ function checkHtmlPatterns(html) {
|
|
|
573
573
|
findings.push({ id: 'repeating-stripes-gradient', snippet: 'repeating-gradient decorative stripes' });
|
|
574
574
|
}
|
|
575
575
|
|
|
576
|
+
// --- Provider tells (gated): two-axis grid-line background (Codex/GPT) ---
|
|
577
|
+
// The Codex grid tell is two hairline `linear-gradient(... <color> 1px,
|
|
578
|
+
// transparent 1px)` layers (one per axis) tiled by a repeating
|
|
579
|
+
// `background-size` cell. Both signals must co-occur in the SAME style block
|
|
580
|
+
// (a CSS rule body or one inline `style="..."`): two hairline stops WITHOUT a
|
|
581
|
+
// tiling background-size is a fixed crosshair, not a grid, and a single
|
|
582
|
+
// hairline is a legitimate ruled line. Scoping to one block also stops
|
|
583
|
+
// unrelated single-axis rules on separate elements from adding up across the
|
|
584
|
+
// page. Count hairlines only inside `background`/`background-image` values so
|
|
585
|
+
// a hairline in an unrelated property (mask-image, border-image) can't stand
|
|
586
|
+
// in for the second axis. Colors like `oklch(96% 0.012 82 / 0.055)` carry
|
|
587
|
+
// nested parens, so match the hairline stop directly rather than parsing
|
|
588
|
+
// whole gradient layers.
|
|
589
|
+
{
|
|
590
|
+
const hairlineRe = /\b\d{1,3}px\s*,\s*transparent\s+\d{1,3}px/gi;
|
|
591
|
+
const gridSizeRe = /background-size\s*:[^;{}"']*\b\d{1,3}px\b/i;
|
|
592
|
+
const bgDeclRe = /\bbackground(?:-image)?\s*:\s*([^;{}"']*)/gi;
|
|
593
|
+
const blockRe = /\{([^{}]*)\}|style\s*=\s*"([^"]*)"|style\s*=\s*'([^']*)'/gi;
|
|
594
|
+
let blk;
|
|
595
|
+
while ((blk = blockRe.exec(html)) !== null) {
|
|
596
|
+
const block = blk[1] || blk[2] || blk[3] || '';
|
|
597
|
+
if (!gridSizeRe.test(block)) continue;
|
|
598
|
+
let hairlineCount = 0;
|
|
599
|
+
let bm;
|
|
600
|
+
bgDeclRe.lastIndex = 0;
|
|
601
|
+
while ((bm = bgDeclRe.exec(block)) !== null) {
|
|
602
|
+
const stops = bm[1].match(hairlineRe);
|
|
603
|
+
if (stops) hairlineCount += stops.length;
|
|
604
|
+
}
|
|
605
|
+
if (hairlineCount >= 2) {
|
|
606
|
+
findings.push({ id: 'codex-grid-background', snippet: 'two-axis grid-line gradient background' });
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
576
612
|
// --- Provider tells (gated): "X theater" framing copy (GPT) ---
|
|
577
613
|
// Lives here (regex-on-HTML) rather than in the text-content analyzers so it
|
|
578
614
|
// runs in the bundled browser path too, not just the CLI/static path.
|
|
@@ -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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "impeccable",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"author": "Paul Bakaus",
|
|
5
5
|
"description": "Design skills, commands, and anti-pattern detection for AI coding agents",
|
|
6
6
|
"keywords": [
|
|
@@ -93,12 +93,12 @@
|
|
|
93
93
|
"@ai-sdk/google": "^3.0.75",
|
|
94
94
|
"@ai-sdk/openai": "^3.0.53",
|
|
95
95
|
"@anthropic-ai/claude-agent-sdk": "^0.3.165",
|
|
96
|
-
"@anthropic-ai/sdk": "^0.
|
|
96
|
+
"@anthropic-ai/sdk": "^0.105.0",
|
|
97
97
|
"@google/genai": "^2.8.0",
|
|
98
98
|
"@paper-design/shaders": "^0.0.76",
|
|
99
99
|
"ai": "^6.0.168",
|
|
100
100
|
"archiver": "^8.0.0",
|
|
101
|
-
"astro": "^
|
|
101
|
+
"astro": "^7.0.0",
|
|
102
102
|
"fontkit": "^2.0.4",
|
|
103
103
|
"modern-screenshot": "^4.7.0",
|
|
104
104
|
"motion": "^12.38.0",
|