impeccable 3.6.0 → 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 +26 -21
- package/README.npm.md +26 -21
- package/README.repo.md +51 -17
- package/cli/bin/cli.js +77 -92
- package/package.json +16 -22
- package/cli/bin/commands/ignores.mjs +0 -351
- package/cli/bin/commands/skills.mjs +0 -2337
- package/cli/engine/browser/injected/index.mjs +0 -2073
- package/cli/engine/cli/main.mjs +0 -438
- package/cli/engine/design-system.mjs +0 -1121
- package/cli/engine/detect-antipatterns-browser.js +0 -8730
- package/cli/engine/detect-antipatterns.mjs +0 -51
- package/cli/engine/engines/browser/detect-url.mjs +0 -372
- package/cli/engine/engines/regex/detect-text.mjs +0 -1171
- package/cli/engine/engines/static-html/css-cascade.mjs +0 -1192
- package/cli/engine/engines/static-html/detect-html.mjs +0 -290
- 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 -617
- package/cli/engine/rules/checks.mjs +0 -5536
- package/cli/engine/shared/color.mjs +0 -588
- package/cli/engine/shared/constants.mjs +0 -112
- 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 -34
- package/cli/lib/impeccable-config.mjs +0 -640
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "impeccable",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"author": "Paul Bakaus",
|
|
5
5
|
"description": "Design skills, commands, and anti-pattern detection for AI coding agents",
|
|
6
6
|
"keywords": [
|
|
@@ -30,13 +30,8 @@
|
|
|
30
30
|
"bin": {
|
|
31
31
|
"impeccable": "cli/bin/cli.js"
|
|
32
32
|
},
|
|
33
|
-
"main": "./cli/engine/detect-antipatterns.mjs",
|
|
34
|
-
"exports": {
|
|
35
|
-
".": "./cli/engine/detect-antipatterns.mjs",
|
|
36
|
-
"./browser": "./cli/engine/detect-antipatterns-browser.js"
|
|
37
|
-
},
|
|
38
33
|
"files": [
|
|
39
|
-
"cli/",
|
|
34
|
+
"cli/bin/",
|
|
40
35
|
"LICENSE"
|
|
41
36
|
],
|
|
42
37
|
"scripts": {
|
|
@@ -44,17 +39,18 @@
|
|
|
44
39
|
"build:skills:release": "bun run scripts/build.js",
|
|
45
40
|
"build": "bun run build:skills && mkdir -p build/_data && rm -rf build/_data/dist && cp -R dist build/_data/dist",
|
|
46
41
|
"build:release": "bun run build:skills:release && mkdir -p build/_data && rm -rf build/_data/dist && cp -R dist build/_data/dist",
|
|
47
|
-
"build:browser": "node scripts/build-browser-detector.js",
|
|
48
42
|
"build:extension": "node scripts/build-extension.js",
|
|
43
|
+
"fetch:engine": "node scripts/fetch-engine.mjs",
|
|
49
44
|
"clean": "rm -rf dist build",
|
|
50
45
|
"rebuild": "bun run clean && bun run build",
|
|
51
46
|
"rebuild:release": "bun run clean && bun run build:release",
|
|
52
47
|
"test": "node scripts/run-tests.mjs default",
|
|
53
48
|
"test:core": "node scripts/run-tests.mjs core",
|
|
49
|
+
"test:oracle": "node scripts/run-tests.mjs oracle",
|
|
54
50
|
"test:detector": "node scripts/run-tests.mjs detector",
|
|
55
51
|
"test:framework": "node scripts/run-tests.mjs framework",
|
|
56
52
|
"test:live": "node scripts/run-tests.mjs live",
|
|
57
|
-
"test:
|
|
53
|
+
"test:cleanup": "node scripts/run-tests.mjs --cleanup",
|
|
58
54
|
"test:cli-remote-e2e": "node scripts/run-tests.mjs cli-remote-e2e",
|
|
59
55
|
"test:plugin-e2e": "node scripts/run-tests.mjs plugin-e2e",
|
|
60
56
|
"test:live-e2e": "node scripts/run-tests.mjs live-e2e",
|
|
@@ -64,36 +60,34 @@
|
|
|
64
60
|
"test:skill-behavior": "node scripts/run-tests.mjs skill-behavior",
|
|
65
61
|
"test:live-svelte-adapter-deepseek": "node scripts/run-tests.mjs live-svelte-adapter-deepseek",
|
|
66
62
|
"smoke:hooks": "node scripts/smoke-provider-hooks.mjs",
|
|
67
|
-
"bench:detector": "node scripts/benchmark-detector.mjs",
|
|
68
|
-
"bench:detector:browser": "node scripts/benchmark-detector.mjs --browser",
|
|
69
63
|
"audit": "bun audit --audit-level=moderate",
|
|
70
64
|
"prepack": "cp README.md README.repo.md && cp README.npm.md README.md",
|
|
71
65
|
"postpack": "cp README.repo.md README.md && rm README.repo.md",
|
|
72
66
|
"release:skill": "node scripts/release.mjs skill",
|
|
73
67
|
"release:cli": "node scripts/release.mjs cli",
|
|
74
|
-
"release:ext": "node scripts/release.mjs extension"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
"css-tree": "^3.2.1",
|
|
79
|
-
"domutils": "^4.0.2",
|
|
80
|
-
"fflate": "^0.8.3",
|
|
81
|
-
"htmlparser2": "^12.0.0",
|
|
82
|
-
"marked": "^18.0.5"
|
|
68
|
+
"release:ext": "node scripts/release.mjs extension",
|
|
69
|
+
"release:engine": "node scripts/release.mjs engine",
|
|
70
|
+
"release:platform-packages": "node scripts/publish-platform-packages.mjs",
|
|
71
|
+
"check:engine-release": "node scripts/check-engine-release.mjs"
|
|
83
72
|
},
|
|
84
73
|
"optionalDependencies": {
|
|
85
|
-
"
|
|
74
|
+
"@impeccable/cli-darwin-arm64": "0.1.0",
|
|
75
|
+
"@impeccable/cli-darwin-x64": "0.1.0",
|
|
76
|
+
"@impeccable/cli-linux-x64": "0.1.0",
|
|
77
|
+
"@impeccable/cli-linux-arm64": "0.1.0",
|
|
78
|
+
"@impeccable/cli-windows-x64": "0.1.0"
|
|
86
79
|
},
|
|
87
80
|
"devDependencies": {
|
|
88
81
|
"@ai-sdk/anthropic": "^4.0.7",
|
|
89
82
|
"@ai-sdk/google": "^4.0.8",
|
|
90
83
|
"@ai-sdk/openai": "^4.0.7",
|
|
91
84
|
"@anthropic-ai/claude-agent-sdk": "^0.3.165",
|
|
92
|
-
"@anthropic-ai/sdk": "^0.
|
|
85
|
+
"@anthropic-ai/sdk": "^0.122.0",
|
|
93
86
|
"@babel/parser": "^8.0.4",
|
|
94
87
|
"ai": "^7.0.14",
|
|
95
88
|
"archiver": "^8.0.0",
|
|
96
89
|
"playwright": "^1.59.1",
|
|
90
|
+
"puppeteer": "^25.1.0",
|
|
97
91
|
"svelte": "^5",
|
|
98
92
|
"zod": "^4.3.6"
|
|
99
93
|
}
|
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
getConfigPath,
|
|
5
|
-
getLocalConfigPath,
|
|
6
|
-
normalizeIgnoreValue,
|
|
7
|
-
readDetectionConfig,
|
|
8
|
-
readRawDetectionConfig,
|
|
9
|
-
writeDetectionConfig,
|
|
10
|
-
} from '../../lib/impeccable-config.mjs';
|
|
11
|
-
|
|
12
|
-
const ACTION_ALIASES = new Map([
|
|
13
|
-
['status', 'list'],
|
|
14
|
-
['ls', 'list'],
|
|
15
|
-
['list', 'list'],
|
|
16
|
-
['add-rule', 'add-rule'],
|
|
17
|
-
['ignore-rule', 'add-rule'],
|
|
18
|
-
['add-file', 'add-file'],
|
|
19
|
-
['ignore-file', 'add-file'],
|
|
20
|
-
['add-value', 'add-value'],
|
|
21
|
-
['ignore-value', 'add-value'],
|
|
22
|
-
['update-value', 'add-value'],
|
|
23
|
-
['remove-rule', 'remove-rule'],
|
|
24
|
-
['rm-rule', 'remove-rule'],
|
|
25
|
-
['remove-file', 'remove-file'],
|
|
26
|
-
['rm-file', 'remove-file'],
|
|
27
|
-
['remove-value', 'remove-value'],
|
|
28
|
-
['rm-value', 'remove-value'],
|
|
29
|
-
['clear', 'clear'],
|
|
30
|
-
]);
|
|
31
|
-
|
|
32
|
-
function printUsage() {
|
|
33
|
-
console.log(`Usage: impeccable ignores <action> [options]
|
|
34
|
-
|
|
35
|
-
Manage detector ignores in .impeccable config.
|
|
36
|
-
|
|
37
|
-
Actions:
|
|
38
|
-
list Show merged, shared, and local ignores
|
|
39
|
-
add-rule <rule> [--all-values] Ignore a rule
|
|
40
|
-
add-file <glob> Ignore files by glob
|
|
41
|
-
add-value <rule> <value> Ignore one rule/value pair
|
|
42
|
-
remove-rule <rule> Remove a rule ignore
|
|
43
|
-
remove-file <glob> Remove a file ignore
|
|
44
|
-
remove-value <rule> <value> Remove a rule/value ignore
|
|
45
|
-
clear Clear detector ignores in the selected scope
|
|
46
|
-
|
|
47
|
-
Scope:
|
|
48
|
-
--shared Write .impeccable/config.json (default)
|
|
49
|
-
--local Write .impeccable/config.local.json
|
|
50
|
-
--all For remove/clear, apply to shared and local
|
|
51
|
-
|
|
52
|
-
Value options:
|
|
53
|
-
--file <glob> Scope add-value/remove-value to a file glob
|
|
54
|
-
--reason <text> Store or update a reason on add-value
|
|
55
|
-
|
|
56
|
-
Examples:
|
|
57
|
-
impeccable ignores add-file "src/legacy/**"
|
|
58
|
-
impeccable ignores add-value overused-font Inter --reason "Brand font"
|
|
59
|
-
impeccable ignores add-value design-system-color "*" --file "src/demo.css"
|
|
60
|
-
impeccable ignores remove-value overused-font Inter`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function parseScope(args, { allowAll = false } = {}) {
|
|
64
|
-
const rest = [];
|
|
65
|
-
let local = false;
|
|
66
|
-
let shared = false;
|
|
67
|
-
let all = false;
|
|
68
|
-
for (const arg of args) {
|
|
69
|
-
if (arg === '--local') local = true;
|
|
70
|
-
else if (arg === '--shared') shared = true;
|
|
71
|
-
else if (arg === '--all') all = true;
|
|
72
|
-
else rest.push(arg);
|
|
73
|
-
}
|
|
74
|
-
if ([local, shared, all].filter(Boolean).length > 1) {
|
|
75
|
-
throw new Error(`Pass only one scope flag: --shared${allowAll ? ', --local, or --all' : ' or --local'}`);
|
|
76
|
-
}
|
|
77
|
-
if (all && !allowAll) throw new Error('--all is only supported for remove and clear actions');
|
|
78
|
-
return { local, all, rest };
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
|
|
82
|
-
// success and wrote an entry with no files: the user asked to scope a rule to one
|
|
83
|
-
// file and silently got the project-wide suppression instead. Refuse it.
|
|
84
|
-
function requireGlob(raw, flag) {
|
|
85
|
-
const glob = String(raw ?? '').trim();
|
|
86
|
-
if (!glob) throw new Error(`${flag} requires a non-empty glob`);
|
|
87
|
-
// A following flag is not a glob. `--file --reason "why"` consumed `--reason`
|
|
88
|
-
// as the scope and left the reason text to fold into the value, storing
|
|
89
|
-
// value="* why" files=["--reason"] and reporting success. Same silent-no-op
|
|
90
|
-
// class as an unknown flag folding into the value; refuse it the same way.
|
|
91
|
-
if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
|
|
92
|
-
return glob;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function parseValueArgs(args, { allowUnscopedWildcard = false } = {}) {
|
|
96
|
-
const positionals = [];
|
|
97
|
-
const files = [];
|
|
98
|
-
let reason = '';
|
|
99
|
-
|
|
100
|
-
for (let i = 0; i < args.length; i++) {
|
|
101
|
-
const arg = String(args[i] || '');
|
|
102
|
-
if (arg === '--reason') {
|
|
103
|
-
const chunks = [];
|
|
104
|
-
while (i + 1 < args.length && !String(args[i + 1]).startsWith('--')) chunks.push(args[++i]);
|
|
105
|
-
reason = chunks.join(' ').trim();
|
|
106
|
-
} else if (arg.startsWith('--reason=')) {
|
|
107
|
-
reason = arg.slice('--reason='.length).trim();
|
|
108
|
-
} else if (arg === '--file' || arg === '--files') {
|
|
109
|
-
if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
|
|
110
|
-
files.push(requireGlob(args[++i], arg));
|
|
111
|
-
} else if (arg.startsWith('--file=')) {
|
|
112
|
-
files.push(requireGlob(arg.slice('--file='.length), '--file'));
|
|
113
|
-
} else if (arg.startsWith('--files=')) {
|
|
114
|
-
files.push(requireGlob(arg.slice('--files='.length), '--files'));
|
|
115
|
-
} else if (arg.startsWith('--')) {
|
|
116
|
-
throw new Error(`Unknown add-value flag: ${arg}`);
|
|
117
|
-
} else {
|
|
118
|
-
positionals.push(arg);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const [rule, ...valueParts] = positionals;
|
|
123
|
-
const value = normalizeIgnoreValue(valueParts.join(' '));
|
|
124
|
-
if (!rule || !value) throw new Error('Pass a rule id and value, e.g. impeccable ignores add-value overused-font Inter');
|
|
125
|
-
// Sorted: the dedup key compares the files array, so an unsorted scope made
|
|
126
|
-
// `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
|
|
127
|
-
const scopedFiles = Array.from(new Set(files.filter(Boolean))).sort();
|
|
128
|
-
if (value === '*' && scopedFiles.length === 0 && !allowUnscopedWildcard) {
|
|
129
|
-
throw new Error('Wildcard value ignores must be scoped with --file <glob>.');
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
rule: String(rule).trim().toLowerCase(),
|
|
133
|
-
value,
|
|
134
|
-
files: scopedFiles,
|
|
135
|
-
reason,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function formatValues(values) {
|
|
140
|
-
if (!values.length) return '(none)';
|
|
141
|
-
return values
|
|
142
|
-
.map((entry) => {
|
|
143
|
-
const fileSuffix = Array.isArray(entry.files) && entry.files.length
|
|
144
|
-
? ` [${entry.files.join(', ')}]`
|
|
145
|
-
: '';
|
|
146
|
-
const reasonSuffix = entry.reason ? ` - ${entry.reason}` : '';
|
|
147
|
-
return `${entry.rule}=${entry.value}${fileSuffix}${reasonSuffix}`;
|
|
148
|
-
})
|
|
149
|
-
.join(', ');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function formatConfig(label, config) {
|
|
153
|
-
return [
|
|
154
|
-
`${label}:`,
|
|
155
|
-
` ignoreRules: ${config.ignoreRules.length ? config.ignoreRules.join(', ') : '(none)'}`,
|
|
156
|
-
` ignoreFiles: ${config.ignoreFiles.length ? config.ignoreFiles.join(', ') : '(none)'}`,
|
|
157
|
-
` ignoreValues: ${formatValues(config.ignoreValues)}`,
|
|
158
|
-
` designSystem: ${config.designSystem?.enabled === false ? 'disabled' : 'enabled'}`,
|
|
159
|
-
].join('\n');
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function list(cwd) {
|
|
163
|
-
const merged = readDetectionConfig(cwd);
|
|
164
|
-
const shared = readRawDetectionConfig(cwd);
|
|
165
|
-
const local = readRawDetectionConfig(cwd, { local: true });
|
|
166
|
-
return [
|
|
167
|
-
'Impeccable detector ignores',
|
|
168
|
-
` shared file: ${path.relative(cwd, getConfigPath(cwd)) || getConfigPath(cwd)}`,
|
|
169
|
-
` local file: ${path.relative(cwd, getLocalConfigPath(cwd)) || getLocalConfigPath(cwd)}`,
|
|
170
|
-
'',
|
|
171
|
-
formatConfig('Merged', merged),
|
|
172
|
-
'',
|
|
173
|
-
formatConfig('Shared', shared),
|
|
174
|
-
'',
|
|
175
|
-
formatConfig('Local', local),
|
|
176
|
-
].join('\n');
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function readScopeConfig(cwd, local) {
|
|
180
|
-
return readRawDetectionConfig(cwd, { local });
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function writeScopeConfig(cwd, config, local) {
|
|
184
|
-
return writeDetectionConfig(cwd, config, { local });
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function parseRuleArgs(args) {
|
|
188
|
-
const positionals = [];
|
|
189
|
-
let allValues = false;
|
|
190
|
-
|
|
191
|
-
for (let i = 0; i < args.length; i++) {
|
|
192
|
-
const arg = String(args[i] || '');
|
|
193
|
-
if (arg === '--all-values') {
|
|
194
|
-
allValues = true;
|
|
195
|
-
} else if (arg === '--reason') {
|
|
196
|
-
while (i + 1 < args.length && !String(args[i + 1]).startsWith('--')) i++;
|
|
197
|
-
} else if (arg.startsWith('--reason=')) {
|
|
198
|
-
// Accepted for symmetry with add-value; ignoreRules stores ids only.
|
|
199
|
-
} else if (arg.startsWith('--')) {
|
|
200
|
-
throw new Error(`Unknown add-rule flag: ${arg}`);
|
|
201
|
-
} else {
|
|
202
|
-
positionals.push(arg);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return {
|
|
207
|
-
rule: String(positionals[0] || '').trim().toLowerCase(),
|
|
208
|
-
allValues,
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function addRule(cwd, args) {
|
|
213
|
-
const { local, rest } = parseScope(args);
|
|
214
|
-
const { rule, allValues } = parseRuleArgs(rest);
|
|
215
|
-
if (!rule) throw new Error('Pass a rule id, e.g. impeccable ignores add-rule side-tab');
|
|
216
|
-
if (rule === 'overused-font' && !allValues) {
|
|
217
|
-
throw new Error('overused-font is value-specific by default. Use add-value overused-font <font>, or add-rule overused-font --all-values for broad suppression.');
|
|
218
|
-
}
|
|
219
|
-
const config = readScopeConfig(cwd, local);
|
|
220
|
-
if (!config.ignoreRules.includes(rule)) config.ignoreRules.push(rule);
|
|
221
|
-
const target = writeScopeConfig(cwd, config, local);
|
|
222
|
-
return `Added ${rule} to ${local ? 'local' : 'shared'} detector ignoreRules (${path.relative(cwd, target) || target}).`;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function addFile(cwd, args) {
|
|
226
|
-
const { local, rest } = parseScope(args);
|
|
227
|
-
const glob = String(rest[0] || '').trim();
|
|
228
|
-
if (!glob) throw new Error('Pass a glob, e.g. impeccable ignores add-file "src/legacy/**"');
|
|
229
|
-
const config = readScopeConfig(cwd, local);
|
|
230
|
-
if (!config.ignoreFiles.includes(glob)) config.ignoreFiles.push(glob);
|
|
231
|
-
const target = writeScopeConfig(cwd, config, local);
|
|
232
|
-
return `Added ${glob} to ${local ? 'local' : 'shared'} detector ignoreFiles (${path.relative(cwd, target) || target}).`;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function addValue(cwd, args) {
|
|
236
|
-
const { local, rest } = parseScope(args);
|
|
237
|
-
const parsed = parseValueArgs(rest);
|
|
238
|
-
const config = readScopeConfig(cwd, local);
|
|
239
|
-
const key = ignoreValueKey(parsed);
|
|
240
|
-
const existing = config.ignoreValues.find((entry) => ignoreValueKey(entry) === key);
|
|
241
|
-
if (existing) {
|
|
242
|
-
if (parsed.reason) existing.reason = parsed.reason;
|
|
243
|
-
if (parsed.files.length) existing.files = parsed.files;
|
|
244
|
-
} else {
|
|
245
|
-
// rule, value, files, createdAt, reason — the same order the normalizers emit,
|
|
246
|
-
// so a fresh entry survives the next write untouched.
|
|
247
|
-
const entry = {
|
|
248
|
-
rule: parsed.rule,
|
|
249
|
-
value: parsed.value,
|
|
250
|
-
};
|
|
251
|
-
if (parsed.files.length) entry.files = parsed.files;
|
|
252
|
-
entry.createdAt = new Date().toISOString();
|
|
253
|
-
if (parsed.reason) entry.reason = parsed.reason;
|
|
254
|
-
config.ignoreValues.push(entry);
|
|
255
|
-
}
|
|
256
|
-
const target = writeScopeConfig(cwd, config, local);
|
|
257
|
-
return `Added ${parsed.rule}=${parsed.value} to ${local ? 'local' : 'shared'} detector ignoreValues (${path.relative(cwd, target) || target}).`;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function removeFromScopes(cwd, args, remover) {
|
|
261
|
-
const { local, all, rest } = parseScope(args, { allowAll: true });
|
|
262
|
-
const scopes = all ? [false, true] : [local];
|
|
263
|
-
const removed = [];
|
|
264
|
-
for (const isLocal of scopes) {
|
|
265
|
-
const config = readScopeConfig(cwd, isLocal);
|
|
266
|
-
const count = remover(config, rest);
|
|
267
|
-
if (count > 0) {
|
|
268
|
-
const target = writeScopeConfig(cwd, config, isLocal);
|
|
269
|
-
removed.push(`${count} from ${isLocal ? 'local' : 'shared'} (${path.relative(cwd, target) || target})`);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return removed.length ? `Removed ${removed.join(', ')}.` : 'No matching detector ignore found.';
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function removeRule(cwd, args) {
|
|
276
|
-
return removeFromScopes(cwd, args, (config, rest) => {
|
|
277
|
-
const rule = String(rest[0] || '').trim().toLowerCase();
|
|
278
|
-
if (!rule) throw new Error('Pass a rule id, e.g. impeccable ignores remove-rule side-tab');
|
|
279
|
-
const before = config.ignoreRules.length;
|
|
280
|
-
config.ignoreRules = config.ignoreRules.filter((entry) => entry !== rule);
|
|
281
|
-
return before - config.ignoreRules.length;
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
function removeFile(cwd, args) {
|
|
286
|
-
return removeFromScopes(cwd, args, (config, rest) => {
|
|
287
|
-
const glob = String(rest[0] || '').trim();
|
|
288
|
-
if (!glob) throw new Error('Pass a glob, e.g. impeccable ignores remove-file "src/legacy/**"');
|
|
289
|
-
const before = config.ignoreFiles.length;
|
|
290
|
-
config.ignoreFiles = config.ignoreFiles.filter((entry) => entry !== glob);
|
|
291
|
-
return before - config.ignoreFiles.length;
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function removeValue(cwd, args) {
|
|
296
|
-
return removeFromScopes(cwd, args, (config, rest) => {
|
|
297
|
-
const parsed = parseValueArgs(rest, { allowUnscopedWildcard: true });
|
|
298
|
-
const key = ignoreValueKey(parsed);
|
|
299
|
-
const before = config.ignoreValues.length;
|
|
300
|
-
config.ignoreValues = config.ignoreValues.filter((entry) => ignoreValueKey(entry) !== key);
|
|
301
|
-
return before - config.ignoreValues.length;
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function clear(cwd, args) {
|
|
306
|
-
const { local, all, rest } = parseScope(args, { allowAll: true });
|
|
307
|
-
if (rest.length > 0) throw new Error('clear does not take positional arguments');
|
|
308
|
-
const scopes = all ? [false, true] : [local];
|
|
309
|
-
for (const isLocal of scopes) {
|
|
310
|
-
const config = readScopeConfig(cwd, isLocal);
|
|
311
|
-
config.ignoreRules = [];
|
|
312
|
-
config.ignoreFiles = [];
|
|
313
|
-
config.ignoreValues = [];
|
|
314
|
-
writeScopeConfig(cwd, config, isLocal);
|
|
315
|
-
}
|
|
316
|
-
return `Cleared detector ignores in ${all ? 'shared and local config' : local ? 'local config' : 'shared config'}.`;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
function ignoreValueKey(entry) {
|
|
320
|
-
// Sorted: a file scope is a set. Comparing stored order made an on-disk scope
|
|
321
|
-
// miss the sorted argv form, so a re-add duplicated the entry and a remove
|
|
322
|
-
// silently failed. Every key that hashes `files` must sort — there are four.
|
|
323
|
-
const files = Array.isArray(entry.files) && entry.files.length ? [...entry.files].sort().join('\x1f') : '';
|
|
324
|
-
return `${String(entry.rule || '').trim().toLowerCase()}\0${normalizeIgnoreValue(entry.value)}\0${files}`;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
export async function run(args = [], opts = {}) {
|
|
328
|
-
const cwd = opts.cwd || process.cwd();
|
|
329
|
-
const actionArg = args[0] || 'list';
|
|
330
|
-
if (actionArg === '--help' || actionArg === '-h') {
|
|
331
|
-
printUsage();
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
const action = ACTION_ALIASES.get(String(actionArg).toLowerCase());
|
|
335
|
-
if (!action) {
|
|
336
|
-
throw new Error(`Unknown ignores action: ${actionArg}. Run "impeccable ignores --help".`);
|
|
337
|
-
}
|
|
338
|
-
const rest = args.slice(1);
|
|
339
|
-
let out;
|
|
340
|
-
switch (action) {
|
|
341
|
-
case 'list': out = list(cwd); break;
|
|
342
|
-
case 'add-rule': out = addRule(cwd, rest); break;
|
|
343
|
-
case 'add-file': out = addFile(cwd, rest); break;
|
|
344
|
-
case 'add-value': out = addValue(cwd, rest); break;
|
|
345
|
-
case 'remove-rule': out = removeRule(cwd, rest); break;
|
|
346
|
-
case 'remove-file': out = removeFile(cwd, rest); break;
|
|
347
|
-
case 'remove-value': out = removeValue(cwd, rest); break;
|
|
348
|
-
case 'clear': out = clear(cwd, rest); break;
|
|
349
|
-
}
|
|
350
|
-
if (out) console.log(out);
|
|
351
|
-
}
|