@sushichan044/eslint-todo 0.0.2 → 0.0.4
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 +23 -24
- package/bin/eslint-todo.mjs +1 -4
- package/package.json +32 -23
- package/dist/cli/index.d.mts +0 -3
- package/dist/cli/index.d.ts +0 -3
- package/dist/cli/index.mjs +0 -332
- package/dist/eslint/index.d.mts +0 -11
- package/dist/eslint/index.d.ts +0 -11
- package/dist/eslint/index.mjs +0 -47
- package/dist/index.d.mts +0 -3
- package/dist/index.d.ts +0 -3
- package/dist/index.mjs +0 -11
- package/dist/remote/client.d.mts +0 -25
- package/dist/remote/client.d.ts +0 -25
- package/dist/remote/client.mjs +0 -25
- package/dist/remote/core.d.mts +0 -18
- package/dist/remote/core.d.ts +0 -18
- package/dist/remote/core.mjs +0 -54
- package/dist/shared/eslint-todo.BD1wUnwb.d.ts +0 -142
- package/dist/shared/eslint-todo.B_vRyhWL.d.mts +0 -142
- package/dist/shared/eslint-todo.BijUMnSZ.d.mts +0 -16
- package/dist/shared/eslint-todo.BijUMnSZ.d.ts +0 -16
- package/dist/shared/eslint-todo.BwJWAS7j.mjs +0 -246
package/README.md
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
# @sushichan044/eslint-todo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Simple tool to temporarily disable existing ESLint violations like `.rubocop_todo.yml` in RuboCop.
|
|
4
|
+
|
|
5
|
+
It also has a utility that helps reducing ignored violations at your pace.
|
|
6
|
+
|
|
7
|
+
> [!NOTE]
|
|
4
8
|
> This tool only supports ESLint Flat Config with ES Module.
|
|
5
9
|
>
|
|
6
10
|
> If you want to use this tool to supress ESLint errors when migrating to ESLint Flat Config,
|
|
7
11
|
> you first need to create Flat Config and then use this tool. Maybe utilities like [@eslint/compat](https://github.com/eslint/rewrite/tree/main/packages/compat) can help you.
|
|
8
12
|
|
|
9
|
-
Simple tool to temporarily disable existing ESLint violations like `.rubocop_todo.yml` in RuboCop.
|
|
10
|
-
|
|
11
|
-
This allows existing offending files to be excluded from scanning on a rule-by-rule basis, which is useful when making destructive changes to ESLint settings.
|
|
12
|
-
|
|
13
|
-
It also has a utility that reduces the number of ignored rules at a pace that works for your team.
|
|
14
|
-
|
|
15
|
-
## Features
|
|
16
|
-
|
|
17
|
-
- Temporarily disable ESLint rules for specific files having existing violations with one command.
|
|
18
|
-
- Assistive feature to gradually eliminate ignored errors.
|
|
19
|
-
|
|
20
13
|
## Installation
|
|
21
14
|
|
|
22
15
|
```bash
|
|
23
|
-
|
|
16
|
+
npm install --save-dev eslint @sushichan044/eslint-todo
|
|
24
17
|
```
|
|
25
18
|
|
|
19
|
+
Requires:
|
|
20
|
+
|
|
21
|
+
- **ES Module**
|
|
22
|
+
- ESLint: `^8.57.0 || ^9.0.0`
|
|
23
|
+
- **Flat Config**
|
|
24
|
+
- Node.js: `>= 20.0.0`
|
|
25
|
+
- May work in Deno, but not tested.
|
|
26
|
+
|
|
26
27
|
## Getting Started
|
|
27
28
|
|
|
28
|
-
1. Add `eslint-todo` config
|
|
29
|
+
1. Add `eslint-todo` config **at the bottom of your configs**. Do not forget `await`.
|
|
29
30
|
|
|
30
31
|
``` diff
|
|
32
|
+
// example: eslint.config.js
|
|
31
33
|
+ import { eslintConfigTodo } from '@sushichan044/eslint-todo/eslint';
|
|
32
34
|
|
|
33
35
|
export default [
|
|
@@ -36,16 +38,13 @@ pnpm install -D @sushichan044/eslint-todo
|
|
|
36
38
|
]
|
|
37
39
|
```
|
|
38
40
|
|
|
39
|
-
2. Run `eslint-todo` to generate ESLint Todo file
|
|
40
|
-
|
|
41
|
-
> [!NOTE]
|
|
42
|
-
> Run this command at the directory where your `eslint.config.js` is located.
|
|
41
|
+
2. Run `eslint-todo` to generate ESLint Todo file at the directory where `eslint.config.js` is placed.
|
|
43
42
|
|
|
44
43
|
```bash
|
|
45
|
-
|
|
44
|
+
npx eslint-todo
|
|
46
45
|
```
|
|
47
46
|
|
|
48
|
-
3. Ignore `.eslint-todo.js`
|
|
47
|
+
3. Ignore generated `.eslint-todo.js` in some tools if you needed.
|
|
49
48
|
|
|
50
49
|
```diff
|
|
51
50
|
// example: .prettierignore
|
|
@@ -67,10 +66,10 @@ Add `--correct` flag to launch eslint-todo with error reduction mode.
|
|
|
67
66
|
In this mode, eslint-todo searches the todo file with the limit from CLI and removes one matching rule from the todo file.
|
|
68
67
|
This allows ESLint to detect that rule as a violation again. For safety, only auto-fixable rules are searched by default.
|
|
69
68
|
|
|
70
|
-
You can use `--limit`, `--limit-type`, `--
|
|
69
|
+
You can use `--limit`, `--limit-type`, `--auto-fixable-only` options to control the behavior.
|
|
71
70
|
|
|
72
71
|
Default options are: <br>
|
|
73
|
-
Select one rule that has a total of 100 or fewer violations from auto-fixable rules.
|
|
72
|
+
Select one rule that has a total of 100 or fewer violations from **auto-fixable** rules.
|
|
74
73
|
|
|
75
74
|
```bash
|
|
76
75
|
eslint-todo --correct --limit 100 --limit-type violation
|
|
@@ -82,10 +81,10 @@ Select one rule that has a total of 10 or fewer files with violations from auto-
|
|
|
82
81
|
eslint-todo --correct --limit 10 --limit-type file
|
|
83
82
|
```
|
|
84
83
|
|
|
85
|
-
Select one rule that has a total of 100 or fewer violations from all rules including non-auto-fixable rules:
|
|
84
|
+
Select one rule that has a total of 100 or fewer violations from **all rules including non-auto-fixable** rules:
|
|
86
85
|
|
|
87
86
|
```bash
|
|
88
|
-
eslint-todo --correct --limit 100 --limit-type violation --
|
|
87
|
+
eslint-todo --correct --limit 100 --limit-type violation --auto-fixable-only false
|
|
89
88
|
```
|
|
90
89
|
|
|
91
90
|
## Configuration (CLI)
|
package/bin/eslint-todo.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sushichan044/eslint-todo",
|
|
3
|
-
"
|
|
4
|
-
"type": "git",
|
|
5
|
-
"url": "https://github.com/sushichan044/eslint-todo.git"
|
|
6
|
-
},
|
|
7
|
-
"version": "0.0.2",
|
|
3
|
+
"version": "0.0.4",
|
|
8
4
|
"type": "module",
|
|
9
|
-
"bin": {
|
|
10
|
-
"eslint-todo": "bin/eslint-todo.mjs"
|
|
11
|
-
},
|
|
12
5
|
"module": "./dist/index.mjs",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
13
9
|
"exports": {
|
|
14
10
|
".": {
|
|
15
11
|
"import": "./dist/index.mjs",
|
|
@@ -20,9 +16,17 @@
|
|
|
20
16
|
"types": "./dist/eslint/index.d.ts"
|
|
21
17
|
}
|
|
22
18
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
19
|
+
"bin": {
|
|
20
|
+
"eslint-todo": "bin/eslint-todo.mjs"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/sushichan044/eslint-todo.git"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public",
|
|
28
|
+
"registry": "https://registry.npmjs.org/"
|
|
29
|
+
},
|
|
26
30
|
"peerDependencies": {
|
|
27
31
|
"eslint": "^8.57.0 || ^9.0.0"
|
|
28
32
|
},
|
|
@@ -31,30 +35,35 @@
|
|
|
31
35
|
"comlink": "4.4.2",
|
|
32
36
|
"consola": "3.4.0",
|
|
33
37
|
"defu": "6.1.4",
|
|
34
|
-
"es-toolkit": "1.32.0",
|
|
35
38
|
"jiti": "2.4.2",
|
|
36
39
|
"klona": "2.0.6",
|
|
37
40
|
"magicast": "0.3.5",
|
|
38
41
|
"pathe": "2.0.3",
|
|
39
|
-
"valibot": "1.0.0-rc.
|
|
42
|
+
"valibot": "1.0.0-rc.3"
|
|
40
43
|
},
|
|
41
44
|
"devDependencies": {
|
|
42
|
-
"@eslint/config-inspector": "1.0.
|
|
43
|
-
"@types/node": "22.13.
|
|
45
|
+
"@eslint/config-inspector": "1.0.1",
|
|
46
|
+
"@types/node": "22.13.8",
|
|
44
47
|
"@virtual-live-lab/eslint-config": "2.2.17",
|
|
45
48
|
"@virtual-live-lab/prettier-config": "2.0.16",
|
|
46
49
|
"@virtual-live-lab/tsconfig": "2.1.17",
|
|
47
|
-
"@vitest/coverage-v8": "3.0.
|
|
48
|
-
"@vitest/eslint-plugin": "1.1.
|
|
49
|
-
"eslint": "9.
|
|
50
|
+
"@vitest/coverage-v8": "3.0.7",
|
|
51
|
+
"@vitest/eslint-plugin": "1.1.36",
|
|
52
|
+
"eslint": "9.21.0",
|
|
50
53
|
"eslint-flat-config-utils": "2.0.1",
|
|
54
|
+
"eslint-plugin-import-access": "2.2.2",
|
|
55
|
+
"eslint-plugin-unicorn": "57.0.0",
|
|
51
56
|
"eslint-typegen": "2.0.0",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
57
|
+
"globals": "16.0.0",
|
|
58
|
+
"pkg-pr-new": "0.0.40",
|
|
59
|
+
"pnpm": "10.5.2",
|
|
60
|
+
"prettier": "3.5.3",
|
|
61
|
+
"release-it": "18.1.2",
|
|
62
|
+
"release-it-pnpm": "4.6.4",
|
|
54
63
|
"typescript": "5.7.3",
|
|
55
|
-
"typescript-eslint": "8.
|
|
56
|
-
"unbuild": "3.
|
|
57
|
-
"vitest": "3.0.
|
|
64
|
+
"typescript-eslint": "8.25.0",
|
|
65
|
+
"unbuild": "3.5.0",
|
|
66
|
+
"vitest": "3.0.7"
|
|
58
67
|
},
|
|
59
68
|
"engines": {
|
|
60
69
|
"node": "^20.0.0 || ^22.0.0 || ^23.0.0"
|
package/dist/cli/index.d.mts
DELETED
package/dist/cli/index.d.ts
DELETED
package/dist/cli/index.mjs
DELETED
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import { defineCommand, runMain } from 'citty';
|
|
2
|
-
import { createConsola } from 'consola';
|
|
3
|
-
import { colorize } from 'consola/utils';
|
|
4
|
-
import { L as LATEST_MODULE_HANDLER, T as TodoModuleV1Handler, E as ESLintTodoCore } from '../shared/eslint-todo.BwJWAS7j.mjs';
|
|
5
|
-
import { launchRemoteESLintTodoCore } from '../remote/client.mjs';
|
|
6
|
-
import { klona } from 'klona/json';
|
|
7
|
-
import { relative } from 'pathe';
|
|
8
|
-
import * as v from 'valibot';
|
|
9
|
-
import 'eslint';
|
|
10
|
-
import 'node:fs';
|
|
11
|
-
import 'node:fs/promises';
|
|
12
|
-
import 'magicast';
|
|
13
|
-
import 'es-toolkit/compat';
|
|
14
|
-
import 'defu';
|
|
15
|
-
import 'node:process';
|
|
16
|
-
import 'jiti';
|
|
17
|
-
import 'comlink';
|
|
18
|
-
import 'comlink/dist/esm/node-adapter.mjs';
|
|
19
|
-
import 'node:url';
|
|
20
|
-
import 'node:worker_threads';
|
|
21
|
-
|
|
22
|
-
const version = "0.0.2";
|
|
23
|
-
|
|
24
|
-
const defineAction = (action) => action;
|
|
25
|
-
const NO_INPUT = Symbol("NO_INPUT");
|
|
26
|
-
async function runAction(action, options, input = NO_INPUT) {
|
|
27
|
-
const { consola, options: coreOptions } = options;
|
|
28
|
-
const remoteService = launchRemoteESLintTodoCore();
|
|
29
|
-
const remoteCore = await new remoteService.RemoteESLintTodoCore(coreOptions);
|
|
30
|
-
const actionApi = {
|
|
31
|
-
core: remoteCore,
|
|
32
|
-
logger: consola
|
|
33
|
-
};
|
|
34
|
-
try {
|
|
35
|
-
if (input === NO_INPUT) {
|
|
36
|
-
return await action(actionApi);
|
|
37
|
-
}
|
|
38
|
-
return await action(actionApi, input);
|
|
39
|
-
} catch (e) {
|
|
40
|
-
consola.error(e);
|
|
41
|
-
throw e;
|
|
42
|
-
} finally {
|
|
43
|
-
await remoteService.terminate();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const deleteRule = (currentModule, ruleId) => {
|
|
48
|
-
const newModule = klona(currentModule);
|
|
49
|
-
if (Object.hasOwn(newModule.todo, ruleId)) {
|
|
50
|
-
delete newModule.todo[ruleId];
|
|
51
|
-
}
|
|
52
|
-
return newModule;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const deleteRuleAction = defineAction(
|
|
56
|
-
async ({ core, logger }, input) => {
|
|
57
|
-
const { ruleId } = input;
|
|
58
|
-
const currentModule = await core.readTodoModule();
|
|
59
|
-
if (!LATEST_MODULE_HANDLER.isVersion(currentModule)) {
|
|
60
|
-
throw new Error(
|
|
61
|
-
"This action requires the latest version of the todo file."
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
logger.info(`Deleting rule ${ruleId} from the todo file ...`);
|
|
65
|
-
const newModule = deleteRule(currentModule, ruleId);
|
|
66
|
-
await core.writeTodoModule(newModule);
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const genAction = defineAction(async ({ core, logger }) => {
|
|
71
|
-
await core.resetTodoModule();
|
|
72
|
-
logger.start("Running ESLint ...");
|
|
73
|
-
const lintResults = await core.lint();
|
|
74
|
-
logger.success("ESLint finished!");
|
|
75
|
-
logger.start("Generating ESLint todo file ...");
|
|
76
|
-
const todo = await core.buildTodoFromLintResults(lintResults);
|
|
77
|
-
await core.writeTodoModule(todo);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const selectRuleBasedOnLimit = (todoModule, limit, options = {}) => {
|
|
81
|
-
switch (limit.type) {
|
|
82
|
-
case "file":
|
|
83
|
-
return selectRuleBasedOnFilesLimit(todoModule, limit, options);
|
|
84
|
-
case "violation":
|
|
85
|
-
return selectRuleBasedOnViolationsLimit(todoModule, limit, options);
|
|
86
|
-
default:
|
|
87
|
-
const l = limit;
|
|
88
|
-
throw new Error(`Got unknown limit: ${JSON.stringify(l)}`);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
const selectRuleBasedOnFilesLimit = (todoModule, limit, options = {}) => {
|
|
92
|
-
const { count: limitCount } = limit;
|
|
93
|
-
const { autoFixableOnly = true } = options;
|
|
94
|
-
let selectedRule = null;
|
|
95
|
-
let maxFiles = 0;
|
|
96
|
-
for (const [ruleId, entry] of Object.entries(todoModule.todo)) {
|
|
97
|
-
if (autoFixableOnly && !entry.autoFix) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const totalFiles = Object.keys(entry.violations).length;
|
|
101
|
-
if (totalFiles > maxFiles && totalFiles <= limitCount) {
|
|
102
|
-
maxFiles = totalFiles;
|
|
103
|
-
selectedRule = ruleId;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return selectedRule != null ? { ruleId: selectedRule, success: true } : { success: false };
|
|
107
|
-
};
|
|
108
|
-
const selectRuleBasedOnViolationsLimit = (todoModule, limit, options = {}) => {
|
|
109
|
-
const { count: limitCount } = limit;
|
|
110
|
-
const { autoFixableOnly = true } = options;
|
|
111
|
-
let selectedRule = null;
|
|
112
|
-
let maxViolations = 0;
|
|
113
|
-
for (const [ruleId, entry] of Object.entries(todoModule.todo)) {
|
|
114
|
-
if (autoFixableOnly && !entry.autoFix) {
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
const totalViolations = Object.values(entry.violations).reduce(
|
|
118
|
-
(sum, count) => sum + count,
|
|
119
|
-
0
|
|
120
|
-
);
|
|
121
|
-
if (totalViolations > maxViolations && totalViolations <= limitCount) {
|
|
122
|
-
maxViolations = totalViolations;
|
|
123
|
-
selectedRule = ruleId;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return selectedRule != null ? { ruleId: selectedRule, success: true } : { success: false };
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const selectRulesToFixAction = defineAction(
|
|
130
|
-
async ({ core, logger }, input) => {
|
|
131
|
-
const {
|
|
132
|
-
limit,
|
|
133
|
-
options = {
|
|
134
|
-
autoFixableOnly: true
|
|
135
|
-
}
|
|
136
|
-
} = input;
|
|
137
|
-
const currentModule = await core.readTodoModule();
|
|
138
|
-
if (!LATEST_MODULE_HANDLER.isVersion(currentModule)) {
|
|
139
|
-
throw new Error(
|
|
140
|
-
"This action requires the latest version of the todo file."
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
logger.start("Refining ESLint todo file ...");
|
|
144
|
-
return selectRuleBasedOnLimit(currentModule, limit, options);
|
|
145
|
-
}
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
const updateAction = defineAction(async ({ core, logger }) => {
|
|
149
|
-
const currentModule = await core.readTodoModule();
|
|
150
|
-
if (!TodoModuleV1Handler.isVersion(currentModule)) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
logger.start(
|
|
154
|
-
"Detected old version of todo file. Automatically upgrading ..."
|
|
155
|
-
);
|
|
156
|
-
const nextModule = TodoModuleV1Handler.upgradeToNextVersion(currentModule);
|
|
157
|
-
if (nextModule === false) {
|
|
158
|
-
logger.error("Upgrade failed!");
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
await core.writeTodoModule(nextModule);
|
|
162
|
-
logger.success("Upgrade finished!");
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
const safeTryNumber = (value) => {
|
|
166
|
-
const parsed = Number(value);
|
|
167
|
-
return Number.isNaN(parsed) ? null : parsed;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const resolveCLIContext = (input) => {
|
|
171
|
-
const todoFilePath = relative(input.cwd, input.todoFileAbsolutePath);
|
|
172
|
-
return {
|
|
173
|
-
mode: input.mode.correct ? "correct" : "generate",
|
|
174
|
-
operation: resolveCLIOperation(input.operation),
|
|
175
|
-
todoFilePath
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
const limitTypeSchema = v.union([v.literal("violation"), v.literal("file")]);
|
|
179
|
-
const resolveCLIOperation = (input) => {
|
|
180
|
-
const parsedLimitType = v.safeParse(limitTypeSchema, input.limitType);
|
|
181
|
-
if (!parsedLimitType.success) {
|
|
182
|
-
throw new Error("limit-type must be either 'violation' or 'file'");
|
|
183
|
-
}
|
|
184
|
-
const limitCount = safeTryNumber(input.limit);
|
|
185
|
-
if (limitCount === null) {
|
|
186
|
-
throw new Error("limit must be a number");
|
|
187
|
-
}
|
|
188
|
-
const limit = {
|
|
189
|
-
count: limitCount,
|
|
190
|
-
type: parsedLimitType.output
|
|
191
|
-
};
|
|
192
|
-
return {
|
|
193
|
-
limit,
|
|
194
|
-
options: {
|
|
195
|
-
autoFixableOnly: input.autoFixableOnly
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const consola = createConsola({ formatOptions: { date: false } });
|
|
201
|
-
const cli = defineCommand({
|
|
202
|
-
args: {
|
|
203
|
-
// general options
|
|
204
|
-
"cwd": {
|
|
205
|
-
description: "Current working directory (default: .)",
|
|
206
|
-
required: false,
|
|
207
|
-
type: "string",
|
|
208
|
-
valueHint: "path"
|
|
209
|
-
},
|
|
210
|
-
"todo-file": {
|
|
211
|
-
alias: "f",
|
|
212
|
-
description: "ESLint todo file name (default: .eslint-todo.js)",
|
|
213
|
-
required: false,
|
|
214
|
-
type: "string",
|
|
215
|
-
valueHint: "filename"
|
|
216
|
-
},
|
|
217
|
-
// mode toggle
|
|
218
|
-
"correct": {
|
|
219
|
-
default: false,
|
|
220
|
-
description: "Launch the correct mode (default: false)",
|
|
221
|
-
required: false,
|
|
222
|
-
type: "boolean"
|
|
223
|
-
},
|
|
224
|
-
// operation options
|
|
225
|
-
"auto-fixable-only": {
|
|
226
|
-
default: true,
|
|
227
|
-
description: "Only handle auto-fixable violations. (default: true)",
|
|
228
|
-
required: false,
|
|
229
|
-
type: "boolean",
|
|
230
|
-
valueHint: "boolean"
|
|
231
|
-
},
|
|
232
|
-
"limit": {
|
|
233
|
-
default: "100",
|
|
234
|
-
description: "Limit the number of violations or files to fix. Only works with --correct. (default: 100)",
|
|
235
|
-
required: false,
|
|
236
|
-
type: "string",
|
|
237
|
-
valueHint: "number"
|
|
238
|
-
},
|
|
239
|
-
"limit-type": {
|
|
240
|
-
default: "violation",
|
|
241
|
-
description: "Type of limit to apply. Only works with --correct. (default: violation)",
|
|
242
|
-
required: false,
|
|
243
|
-
type: "string",
|
|
244
|
-
valueHint: "violation | file"
|
|
245
|
-
},
|
|
246
|
-
// logging
|
|
247
|
-
"debug": {
|
|
248
|
-
description: "Enable debug mode",
|
|
249
|
-
required: false,
|
|
250
|
-
type: "boolean"
|
|
251
|
-
},
|
|
252
|
-
"trace": {
|
|
253
|
-
description: "Enable trace mode",
|
|
254
|
-
required: false,
|
|
255
|
-
type: "boolean"
|
|
256
|
-
},
|
|
257
|
-
"verbose": {
|
|
258
|
-
description: "Enable verbose mode",
|
|
259
|
-
required: false,
|
|
260
|
-
type: "boolean"
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
meta: {
|
|
264
|
-
description: "Generate ESLint todo file and temporally suppress ESLint errors!",
|
|
265
|
-
name: "@sushichan044/eslint-todo/cli",
|
|
266
|
-
version: version
|
|
267
|
-
},
|
|
268
|
-
async run({ args }) {
|
|
269
|
-
const cliCwd = process.cwd();
|
|
270
|
-
const options = {
|
|
271
|
-
cwd: args.cwd,
|
|
272
|
-
todoFile: args["todo-file"]
|
|
273
|
-
};
|
|
274
|
-
const eslintTodoCore = new ESLintTodoCore(options);
|
|
275
|
-
const ctx = resolveCLIContext({
|
|
276
|
-
cwd: cliCwd,
|
|
277
|
-
mode: {
|
|
278
|
-
correct: args.correct
|
|
279
|
-
},
|
|
280
|
-
operation: {
|
|
281
|
-
autoFixableOnly: args["auto-fixable-only"],
|
|
282
|
-
limit: args.limit,
|
|
283
|
-
limitType: args["limit-type"]
|
|
284
|
-
},
|
|
285
|
-
todoFileAbsolutePath: eslintTodoCore.getTodoModulePath().absolute
|
|
286
|
-
});
|
|
287
|
-
await runAction(updateAction, { consola, options });
|
|
288
|
-
if (ctx.mode === "generate") {
|
|
289
|
-
await runAction(genAction, { consola, options });
|
|
290
|
-
consola.success(`ESLint todo file generated at ${ctx.todoFilePath}!`);
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
if (ctx.mode === "correct") {
|
|
294
|
-
const selection = await runAction(
|
|
295
|
-
selectRulesToFixAction,
|
|
296
|
-
{ consola, options },
|
|
297
|
-
ctx.operation
|
|
298
|
-
);
|
|
299
|
-
if (!selection.success) {
|
|
300
|
-
consola.warn(
|
|
301
|
-
"Couldn't find any rule to fix. Increase the limit and retry."
|
|
302
|
-
);
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
await runAction(
|
|
306
|
-
deleteRuleAction,
|
|
307
|
-
{ consola, options },
|
|
308
|
-
{ ruleId: selection.ruleId }
|
|
309
|
-
);
|
|
310
|
-
consola.success(
|
|
311
|
-
`Rule ${colorize("magenta", selection.ruleId)} deleted from the todo file and now ESLint will detect the violations.`
|
|
312
|
-
);
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
throw new Error(`Unknown mode: ${JSON.stringify(ctx.mode)}`);
|
|
316
|
-
},
|
|
317
|
-
setup({ args }) {
|
|
318
|
-
consola.info(`eslint-todo CLI ${version}`);
|
|
319
|
-
if (args.debug === true) {
|
|
320
|
-
consola.level = 4;
|
|
321
|
-
} else if (args.trace === true) {
|
|
322
|
-
consola.level = 5;
|
|
323
|
-
} else if (args.verbose === true) {
|
|
324
|
-
consola.level = 999;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
const run = async (argv) => {
|
|
329
|
-
await runMain(cli, { rawArgs: argv });
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
export { run };
|
package/dist/eslint/index.d.mts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Linter } from 'eslint';
|
|
2
|
-
import { U as UserOptions } from '../shared/eslint-todo.BijUMnSZ.mjs';
|
|
3
|
-
|
|
4
|
-
declare const eslintConfigTodo: (userOptions?: UserOptions) => Promise<Linter.Config[]>;
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated
|
|
7
|
-
* You should import this from default export.
|
|
8
|
-
*/
|
|
9
|
-
declare const _old_eslintConfigTodo: (userOptions?: UserOptions) => Promise<Linter.Config[]>;
|
|
10
|
-
|
|
11
|
-
export { eslintConfigTodo as default, _old_eslintConfigTodo as eslintConfigTodo };
|
package/dist/eslint/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Linter } from 'eslint';
|
|
2
|
-
import { U as UserOptions } from '../shared/eslint-todo.BijUMnSZ.js';
|
|
3
|
-
|
|
4
|
-
declare const eslintConfigTodo: (userOptions?: UserOptions) => Promise<Linter.Config[]>;
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated
|
|
7
|
-
* You should import this from default export.
|
|
8
|
-
*/
|
|
9
|
-
declare const _old_eslintConfigTodo: (userOptions?: UserOptions) => Promise<Linter.Config[]>;
|
|
10
|
-
|
|
11
|
-
export { eslintConfigTodo as default, _old_eslintConfigTodo as eslintConfigTodo };
|
package/dist/eslint/index.mjs
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { E as ESLintTodoCore, T as TodoModuleV1Handler, a as TodoModuleV2Handler, b as buildESLintConfigForModule } from '../shared/eslint-todo.BwJWAS7j.mjs';
|
|
2
|
-
import 'eslint';
|
|
3
|
-
import 'node:fs';
|
|
4
|
-
import 'node:fs/promises';
|
|
5
|
-
import 'pathe';
|
|
6
|
-
import 'magicast';
|
|
7
|
-
import 'es-toolkit/compat';
|
|
8
|
-
import 'valibot';
|
|
9
|
-
import 'defu';
|
|
10
|
-
import 'node:process';
|
|
11
|
-
import 'jiti';
|
|
12
|
-
|
|
13
|
-
const eslintConfigTodo = async (userOptions = {}) => {
|
|
14
|
-
const core = new ESLintTodoCore(userOptions);
|
|
15
|
-
const todoModulePath = core.getTodoModulePath();
|
|
16
|
-
const module = await (async () => {
|
|
17
|
-
try {
|
|
18
|
-
return await core._DO_NOT_USE_DIRECTLY_unsafeReadTodoModule();
|
|
19
|
-
} catch {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
})();
|
|
23
|
-
const configs = [
|
|
24
|
-
{
|
|
25
|
-
files: [todoModulePath.relative],
|
|
26
|
-
linterOptions: {
|
|
27
|
-
reportUnusedDisableDirectives: false
|
|
28
|
-
},
|
|
29
|
-
name: "@sushichan044/eslint-todo/setup"
|
|
30
|
-
}
|
|
31
|
-
];
|
|
32
|
-
if (module == null || !TodoModuleV1Handler.isVersion(module) && !TodoModuleV2Handler.isVersion(module)) {
|
|
33
|
-
configs.push({
|
|
34
|
-
files: [todoModulePath.relative],
|
|
35
|
-
name: "@sushichan044/eslint-todo/warning/YOU_ARE_USING_INVALID_TODO_FILE"
|
|
36
|
-
});
|
|
37
|
-
return configs;
|
|
38
|
-
}
|
|
39
|
-
const builtConfigs = buildESLintConfigForModule(module, "off");
|
|
40
|
-
if (builtConfigs != null) {
|
|
41
|
-
configs.push(...builtConfigs);
|
|
42
|
-
}
|
|
43
|
-
return configs;
|
|
44
|
-
};
|
|
45
|
-
const _old_eslintConfigTodo = eslintConfigTodo;
|
|
46
|
-
|
|
47
|
-
export { eslintConfigTodo as default, _old_eslintConfigTodo as eslintConfigTodo };
|
package/dist/index.d.mts
DELETED
package/dist/index.d.ts
DELETED
package/dist/index.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import 'eslint';
|
|
2
|
-
import 'node:fs';
|
|
3
|
-
import 'node:fs/promises';
|
|
4
|
-
import 'pathe';
|
|
5
|
-
export { E as ESLintTodoCore } from './shared/eslint-todo.BwJWAS7j.mjs';
|
|
6
|
-
import 'magicast';
|
|
7
|
-
import 'es-toolkit/compat';
|
|
8
|
-
import 'valibot';
|
|
9
|
-
import 'defu';
|
|
10
|
-
import 'node:process';
|
|
11
|
-
import 'jiti';
|
package/dist/remote/client.d.mts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as Comlink from 'comlink';
|
|
2
|
-
import { RemoteESLintTodoCore } from './core.mjs';
|
|
3
|
-
import '../shared/eslint-todo.BijUMnSZ.mjs';
|
|
4
|
-
import '../shared/eslint-todo.B_vRyhWL.mjs';
|
|
5
|
-
import 'eslint';
|
|
6
|
-
|
|
7
|
-
type RemoteCore = {
|
|
8
|
-
RemoteESLintTodoCore: Comlink.Remote<typeof RemoteESLintTodoCore>;
|
|
9
|
-
terminate: () => Promise<number>;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Launch a remote ESLintTodoCore worker with new process.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* const remote = launchRemoteESLintTodoCore();
|
|
17
|
-
const remoteCore = await new remote.RemoteESLintTodoCore(options);
|
|
18
|
-
const currentModule = await remoteCore.safeReadTodoModule();
|
|
19
|
-
|
|
20
|
-
await remote.terminate();
|
|
21
|
-
```
|
|
22
|
-
*/
|
|
23
|
-
declare const launchRemoteESLintTodoCore: () => RemoteCore;
|
|
24
|
-
|
|
25
|
-
export { launchRemoteESLintTodoCore };
|
package/dist/remote/client.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as Comlink from 'comlink';
|
|
2
|
-
import { RemoteESLintTodoCore } from './core.js';
|
|
3
|
-
import '../shared/eslint-todo.BijUMnSZ.js';
|
|
4
|
-
import '../shared/eslint-todo.BD1wUnwb.js';
|
|
5
|
-
import 'eslint';
|
|
6
|
-
|
|
7
|
-
type RemoteCore = {
|
|
8
|
-
RemoteESLintTodoCore: Comlink.Remote<typeof RemoteESLintTodoCore>;
|
|
9
|
-
terminate: () => Promise<number>;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Launch a remote ESLintTodoCore worker with new process.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* const remote = launchRemoteESLintTodoCore();
|
|
17
|
-
const remoteCore = await new remote.RemoteESLintTodoCore(options);
|
|
18
|
-
const currentModule = await remoteCore.safeReadTodoModule();
|
|
19
|
-
|
|
20
|
-
await remote.terminate();
|
|
21
|
-
```
|
|
22
|
-
*/
|
|
23
|
-
declare const launchRemoteESLintTodoCore: () => RemoteCore;
|
|
24
|
-
|
|
25
|
-
export { launchRemoteESLintTodoCore };
|