@sushichan044/eslint-todo 0.0.6 → 0.0.7
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 +48 -27
- package/config-schema.json +73 -0
- package/dist/cli/index.mjs +125 -96
- package/dist/config/index.d.mts +7 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.mjs +8 -0
- package/dist/eslint/index.d.mts +6 -3
- package/dist/eslint/index.d.ts +6 -3
- package/dist/eslint/index.mjs +28 -6
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +2 -1
- package/dist/remote/client.d.mts +2 -2
- package/dist/remote/client.d.ts +2 -2
- package/dist/remote/core.d.mts +3 -3
- package/dist/remote/core.d.ts +3 -3
- package/dist/remote/core.mjs +4 -3
- package/dist/shared/eslint-todo.BA_lf5p3.mjs +191 -0
- package/dist/shared/{eslint-todo.COiTIKtF.d.ts → eslint-todo.BpdH45rQ.d.ts} +2 -7
- package/dist/shared/{eslint-todo.Bj71T6ke.d.mts → eslint-todo.CG2sIIb6.d.mts} +2 -7
- package/dist/shared/eslint-todo.DWzJhKY8.d.mts +72 -0
- package/dist/shared/eslint-todo.DWzJhKY8.d.ts +72 -0
- package/dist/shared/{eslint-todo.CfTCWctB.mjs → eslint-todo.EOEYtLpc.mjs} +40 -28
- package/package.json +22 -10
- package/dist/shared/eslint-todo.BijUMnSZ.d.mts +0 -16
- package/dist/shared/eslint-todo.BijUMnSZ.d.ts +0 -16
package/README.md
CHANGED
|
@@ -49,57 +49,78 @@ Requires:
|
|
|
49
49
|
### Generate ESLint Todo file
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
|
-
eslint-todo
|
|
52
|
+
npx eslint-todo
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
###
|
|
55
|
+
### Correct ignored errors
|
|
56
56
|
|
|
57
|
-
Add `--correct` flag to launch eslint-todo with
|
|
57
|
+
Add `--correct` flag to launch eslint-todo with correct mode.
|
|
58
|
+
|
|
59
|
+
In this mode, eslint-todo searches the todo file with the limit from config file or CLI.
|
|
60
|
+
And it removes one matching rule from the todo file.
|
|
58
61
|
|
|
59
|
-
In this mode, eslint-todo searches the todo file with the limit from CLI and removes one matching rule from the todo file.
|
|
60
62
|
This allows ESLint to detect that rule as a violation again. For safety, only auto-fixable rules are searched by default.
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
By default, it searches for rules that can be automatically fixed and have less than or equal to 100 violations.
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
Select one rule that has a total of 100 or fewer violations from **auto-fixable** rules.
|
|
66
|
+
## Configuration
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
eslint-todo --correct --limit 100 --limit-type violation
|
|
69
|
-
```
|
|
68
|
+
### Configuration File (recommended)
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
Just create `eslint-todo.config.{js,ts}`:
|
|
72
71
|
|
|
73
|
-
```
|
|
74
|
-
eslint-todo
|
|
72
|
+
```typescript
|
|
73
|
+
// example: eslint-todo.config.ts
|
|
74
|
+
import { defineConfig } from '@sushichan044/eslint-todo/config';
|
|
75
|
+
|
|
76
|
+
export default defineConfig({
|
|
77
|
+
correct: {
|
|
78
|
+
limit: {
|
|
79
|
+
count: 30,
|
|
80
|
+
type: "violation",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
});
|
|
75
84
|
```
|
|
76
85
|
|
|
77
|
-
|
|
86
|
+
You can check all available options at [here](./src/config/config.ts).
|
|
78
87
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
```
|
|
88
|
+
<details>
|
|
89
|
+
<summary>Want to use JSON?</summary>
|
|
82
90
|
|
|
83
|
-
|
|
91
|
+
Sure!
|
|
84
92
|
|
|
85
|
-
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"$schema": "node_modules/@sushichan044/eslint-todo/config-schema.json",
|
|
96
|
+
"correct": {
|
|
97
|
+
"limit": {
|
|
98
|
+
"count": 30,
|
|
99
|
+
"type": "violation"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
86
104
|
|
|
87
|
-
|
|
105
|
+
</details>
|
|
88
106
|
|
|
89
|
-
|
|
107
|
+
### Configuration via CLI flags
|
|
90
108
|
|
|
91
|
-
|
|
92
|
-
|
|
109
|
+
You can also set eslint-todo by passing a flag to the CLI.
|
|
110
|
+
Use `npx eslint-todo --help` to see all available options.
|
|
93
111
|
|
|
94
|
-
|
|
112
|
+
> [!CAUTION]
|
|
113
|
+
> The cli flag will be destructively renamed to the same name as the property on config file in v0.1.0.
|
|
95
114
|
|
|
96
|
-
|
|
115
|
+
> [!WARNING]
|
|
116
|
+
> Config from CLI flag overwrites the one in the configuration file.
|
|
117
|
+
> See the [unjs/defu documentation](https://github.com/unjs/defu) for the actual overwriting behavior.
|
|
97
118
|
|
|
98
|
-
|
|
119
|
+
## Misc
|
|
99
120
|
|
|
100
121
|
### logging mode
|
|
101
122
|
|
|
102
123
|
> [!CAUTION]
|
|
103
|
-
> This feature is not
|
|
124
|
+
> This feature is not implemented yet.
|
|
104
125
|
|
|
105
126
|
You can pass `--debug`, `--trace`, `--verbose` to see the debug logs.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"root": {
|
|
5
|
+
"title": "Project root",
|
|
6
|
+
"description": "Project root.\n\n**This directory must contain the ESLint configuration file.**\n\nThis also affects the default location of the ESLint todo file.",
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"todoFile": {
|
|
10
|
+
"title": "The file path to read and write the ESLint todo list",
|
|
11
|
+
"description": "The file path to read and write the ESLint todo list.",
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
"correct": {
|
|
15
|
+
"title": "Options for correct mode",
|
|
16
|
+
"description": "Options for correct mode.",
|
|
17
|
+
"type": "object",
|
|
18
|
+
"properties": {
|
|
19
|
+
"exclude": {
|
|
20
|
+
"title": "Options for excluding todo items",
|
|
21
|
+
"description": "Options for excluding todo items.",
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"rules": {
|
|
25
|
+
"title": "List of rules to exclude from the operation. Comma-separated string",
|
|
26
|
+
"description": "List of rules to exclude from the operation. Comma-separated string.",
|
|
27
|
+
"type": "array",
|
|
28
|
+
"items": {
|
|
29
|
+
"type": "string"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"required": []
|
|
34
|
+
},
|
|
35
|
+
"limit": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"properties": {
|
|
38
|
+
"count": {
|
|
39
|
+
"title": "Limit the number of violations or files to fix",
|
|
40
|
+
"description": "Limit the number of violations or files to fix.",
|
|
41
|
+
"type": "number"
|
|
42
|
+
},
|
|
43
|
+
"type": {
|
|
44
|
+
"title": "Type of limit to apply",
|
|
45
|
+
"description": "Type of limit to apply.",
|
|
46
|
+
"oneOf": [
|
|
47
|
+
{
|
|
48
|
+
"const": "file"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"const": "violation"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"required": []
|
|
57
|
+
},
|
|
58
|
+
"partialSelection": {
|
|
59
|
+
"title": "Allow partial selection of violations",
|
|
60
|
+
"description": "Allow partial selection of violations.",
|
|
61
|
+
"type": "boolean"
|
|
62
|
+
},
|
|
63
|
+
"autoFixableOnly": {
|
|
64
|
+
"title": "Allow to select non auto-fixable rules",
|
|
65
|
+
"description": "Allow to select non auto-fixable rules.",
|
|
66
|
+
"type": "boolean"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"required": []
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"required": []
|
|
73
|
+
}
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,41 +1,38 @@
|
|
|
1
1
|
import { defineCommand, runMain } from 'citty';
|
|
2
2
|
import { createConsola } from 'consola';
|
|
3
3
|
import { colorize } from 'consola/utils';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import { relative } from 'pathe';
|
|
5
|
+
import { mergeUserConfig } from '../config/index.mjs';
|
|
6
|
+
import { L as LATEST_TODO_MODULE_HANDLER, i as isNonEmptyString, T as TodoModuleV1Handler, c as configWithDefault, E as ESLintTodoCore } from '../shared/eslint-todo.EOEYtLpc.mjs';
|
|
7
|
+
import { r as readConfigFile } from '../shared/eslint-todo.BA_lf5p3.mjs';
|
|
6
8
|
import { launchRemoteESLintTodoCore } from '../remote/client.mjs';
|
|
7
9
|
import { klona } from 'klona/json';
|
|
8
|
-
import
|
|
9
|
-
import * as v from 'valibot';
|
|
10
|
+
import 'defu';
|
|
10
11
|
import 'eslint';
|
|
11
12
|
import 'node:fs';
|
|
12
13
|
import 'node:fs/promises';
|
|
13
14
|
import 'magicast';
|
|
15
|
+
import 'klona';
|
|
14
16
|
import 'node:process';
|
|
17
|
+
import 'valibot';
|
|
15
18
|
import 'jiti';
|
|
19
|
+
import 'typia/lib/internal/_accessExpressionAsString.js';
|
|
20
|
+
import 'typia/lib/internal/_validateReport.js';
|
|
16
21
|
import 'comlink';
|
|
17
22
|
import 'comlink/dist/esm/node-adapter.mjs';
|
|
18
23
|
import 'node:url';
|
|
19
24
|
import 'node:worker_threads';
|
|
20
25
|
|
|
21
|
-
const version = "0.0.
|
|
22
|
-
|
|
23
|
-
const operationOptionsWithDefault = (options = {}) => {
|
|
24
|
-
return defu(options, getDefaultOperationOptions());
|
|
25
|
-
};
|
|
26
|
-
const getDefaultOperationOptions = () => ({ ...DEFAULT_OPERATION_OPTIONS });
|
|
27
|
-
const DEFAULT_OPERATION_OPTIONS = {
|
|
28
|
-
allowPartialSelection: false,
|
|
29
|
-
autoFixableOnly: true
|
|
30
|
-
};
|
|
26
|
+
const version = "0.0.6";
|
|
31
27
|
|
|
32
28
|
const defineAction = (action) => action;
|
|
33
29
|
const NO_INPUT = Symbol("NO_INPUT");
|
|
34
30
|
async function runAction(action, options, input = NO_INPUT) {
|
|
35
|
-
const {
|
|
31
|
+
const { config, consola } = options;
|
|
36
32
|
const remoteService = launchRemoteESLintTodoCore();
|
|
37
|
-
const remoteCore = await new remoteService.RemoteESLintTodoCore(
|
|
33
|
+
const remoteCore = await new remoteService.RemoteESLintTodoCore(config);
|
|
38
34
|
const actionApi = {
|
|
35
|
+
config,
|
|
39
36
|
core: remoteCore,
|
|
40
37
|
logger: consola
|
|
41
38
|
};
|
|
@@ -102,28 +99,27 @@ const genAction = defineAction(async ({ core, logger }) => {
|
|
|
102
99
|
await core.writeTodoModule(todo);
|
|
103
100
|
});
|
|
104
101
|
|
|
105
|
-
const selectRuleBasedOnLimit = (todoModule,
|
|
106
|
-
|
|
107
|
-
switch (limit.type) {
|
|
102
|
+
const selectRuleBasedOnLimit = (todoModule, correctConfig) => {
|
|
103
|
+
switch (correctConfig.limit.type) {
|
|
108
104
|
case "file": {
|
|
109
|
-
return selectRuleBasedOnFilesLimit(todoModule,
|
|
105
|
+
return selectRuleBasedOnFilesLimit(todoModule, correctConfig);
|
|
110
106
|
}
|
|
111
107
|
case "violation": {
|
|
112
|
-
return selectRuleBasedOnViolationsLimit(
|
|
113
|
-
todoModule,
|
|
114
|
-
limit,
|
|
115
|
-
resolvedOptions
|
|
116
|
-
);
|
|
108
|
+
return selectRuleBasedOnViolationsLimit(todoModule, correctConfig);
|
|
117
109
|
}
|
|
118
110
|
default: {
|
|
119
|
-
const l = limit;
|
|
120
|
-
throw new Error(`Got unknown limit: ${JSON.stringify(l)}`);
|
|
111
|
+
const l = correctConfig.limit.type;
|
|
112
|
+
throw new Error(`Got unknown limit type: ${JSON.stringify(l)}`);
|
|
121
113
|
}
|
|
122
114
|
}
|
|
123
115
|
};
|
|
124
|
-
const selectRuleBasedOnFilesLimit = (todoModule,
|
|
125
|
-
const {
|
|
126
|
-
|
|
116
|
+
const selectRuleBasedOnFilesLimit = (todoModule, config) => {
|
|
117
|
+
const {
|
|
118
|
+
autoFixableOnly,
|
|
119
|
+
exclude: { rules: excludedRules },
|
|
120
|
+
limit: { count: limitCount },
|
|
121
|
+
partialSelection: allowPartialSelection
|
|
122
|
+
} = config;
|
|
127
123
|
if (limitCount <= 0) {
|
|
128
124
|
throw new Error("The file limit must be greater than 0.");
|
|
129
125
|
}
|
|
@@ -134,6 +130,9 @@ const selectRuleBasedOnFilesLimit = (todoModule, limit, options) => {
|
|
|
134
130
|
if (autoFixableOnly && !entry.autoFix) {
|
|
135
131
|
continue;
|
|
136
132
|
}
|
|
133
|
+
if (excludedRules.includes(ruleId)) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
137
136
|
const violatedFiles = Object.keys(entry.violations).length;
|
|
138
137
|
if (violatedFiles > limitCount) {
|
|
139
138
|
if (allowPartialSelection && partialSelectableRule == null) {
|
|
@@ -173,9 +172,13 @@ const selectRuleBasedOnFilesLimit = (todoModule, limit, options) => {
|
|
|
173
172
|
}
|
|
174
173
|
return { success: false };
|
|
175
174
|
};
|
|
176
|
-
const selectRuleBasedOnViolationsLimit = (todoModule,
|
|
177
|
-
const {
|
|
178
|
-
|
|
175
|
+
const selectRuleBasedOnViolationsLimit = (todoModule, config) => {
|
|
176
|
+
const {
|
|
177
|
+
autoFixableOnly,
|
|
178
|
+
exclude: { rules: excludedRules },
|
|
179
|
+
limit: { count: limitCount },
|
|
180
|
+
partialSelection: allowPartialSelection
|
|
181
|
+
} = config;
|
|
179
182
|
if (limitCount <= 0) {
|
|
180
183
|
throw new Error("The violation limit must be greater than 0.");
|
|
181
184
|
}
|
|
@@ -186,6 +189,9 @@ const selectRuleBasedOnViolationsLimit = (todoModule, limit, options) => {
|
|
|
186
189
|
if (autoFixableOnly && !entry.autoFix) {
|
|
187
190
|
continue;
|
|
188
191
|
}
|
|
192
|
+
if (excludedRules.includes(ruleId)) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
189
195
|
const totalViolationCount = Object.values(entry.violations).reduce(
|
|
190
196
|
(sum, count) => sum + count,
|
|
191
197
|
0
|
|
@@ -240,8 +246,7 @@ const isKeyOfTodoModuleV2 = (todoModule, ruleId) => {
|
|
|
240
246
|
};
|
|
241
247
|
|
|
242
248
|
const selectRulesToFixAction = defineAction(
|
|
243
|
-
async ({ core, logger }
|
|
244
|
-
const { limit, options } = input;
|
|
249
|
+
async ({ config, core, logger }) => {
|
|
245
250
|
const currentModule = await core.readTodoModule();
|
|
246
251
|
if (!LATEST_TODO_MODULE_HANDLER.isVersion(currentModule)) {
|
|
247
252
|
throw new Error(
|
|
@@ -249,7 +254,7 @@ const selectRulesToFixAction = defineAction(
|
|
|
249
254
|
);
|
|
250
255
|
}
|
|
251
256
|
logger.start("Refining ESLint todo file ...");
|
|
252
|
-
return selectRuleBasedOnLimit(currentModule,
|
|
257
|
+
return selectRuleBasedOnLimit(currentModule, config.correct);
|
|
253
258
|
}
|
|
254
259
|
);
|
|
255
260
|
|
|
@@ -270,39 +275,48 @@ const updateAction = defineAction(async ({ core, logger }) => {
|
|
|
270
275
|
logger.success("Upgrade finished!");
|
|
271
276
|
});
|
|
272
277
|
|
|
273
|
-
const
|
|
274
|
-
const parsed = Number(value);
|
|
275
|
-
return Number.isNaN(parsed) ? null : parsed;
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
const structureCLIInput = (input) => {
|
|
279
|
-
const todoFilePath = relative(input.cwd, input.todoFileAbsolutePath);
|
|
278
|
+
const parseArguments = (input) => {
|
|
280
279
|
return {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
280
|
+
context: {
|
|
281
|
+
mode: input.mode.correct ? "correct" : "generate"
|
|
282
|
+
},
|
|
283
|
+
userConfig: {
|
|
284
|
+
correct: parseCorrectMode(input.correct),
|
|
285
|
+
root: input.root,
|
|
286
|
+
todoFile: input.todoFile
|
|
287
|
+
}
|
|
284
288
|
};
|
|
285
289
|
};
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
290
|
+
const isValidLimitType = (input) => {
|
|
291
|
+
return ["file", "violation"].includes(input);
|
|
292
|
+
};
|
|
293
|
+
const parseCorrectMode = (input) => {
|
|
294
|
+
const limitCount = isNonEmptyString(input.limit) ? Number.parseInt(input.limit) : void 0;
|
|
295
|
+
if (limitCount != void 0 && Number.isNaN(limitCount)) {
|
|
296
|
+
throw new TypeError("limit must be a number");
|
|
291
297
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
298
|
+
if (isNonEmptyString(input.limitType) && !isValidLimitType(input.limitType)) {
|
|
299
|
+
throw new Error(
|
|
300
|
+
`limit-type must be either 'violation' or 'file', got ${input.limitType}`
|
|
301
|
+
);
|
|
295
302
|
}
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return {
|
|
301
|
-
limit,
|
|
302
|
-
options: {
|
|
303
|
-
allowPartialSelection: input.allowPartialSelection,
|
|
304
|
-
autoFixableOnly: input.autoFixableOnly
|
|
303
|
+
const excludedRules = isNonEmptyString(input?.["exclude.rules"]) ? input["exclude.rules"].split(",").flatMap((element) => {
|
|
304
|
+
const trimmedElement = element.trim();
|
|
305
|
+
if (isNonEmptyString(trimmedElement)) {
|
|
306
|
+
return trimmedElement;
|
|
305
307
|
}
|
|
308
|
+
return [];
|
|
309
|
+
}) : void 0;
|
|
310
|
+
return {
|
|
311
|
+
autoFixableOnly: input.autoFixableOnly,
|
|
312
|
+
exclude: {
|
|
313
|
+
rules: excludedRules
|
|
314
|
+
},
|
|
315
|
+
limit: {
|
|
316
|
+
count: limitCount,
|
|
317
|
+
type: input.limitType
|
|
318
|
+
},
|
|
319
|
+
partialSelection: input.allowPartialSelection
|
|
306
320
|
};
|
|
307
321
|
};
|
|
308
322
|
|
|
@@ -325,7 +339,7 @@ const cli = defineCommand({
|
|
|
325
339
|
},
|
|
326
340
|
"todo-file": {
|
|
327
341
|
alias: "f",
|
|
328
|
-
description: `ESLint todo file name
|
|
342
|
+
description: `ESLint todo file name.`,
|
|
329
343
|
required: false,
|
|
330
344
|
type: "string",
|
|
331
345
|
valueHint: "filename"
|
|
@@ -339,27 +353,31 @@ const cli = defineCommand({
|
|
|
339
353
|
},
|
|
340
354
|
// operation options
|
|
341
355
|
"allow-partial-selection": {
|
|
342
|
-
description: `Allow partial selection of violations. Only works with --correct
|
|
356
|
+
description: `Allow partial selection of violations. Only works with --correct.`,
|
|
343
357
|
required: false,
|
|
344
358
|
type: "boolean",
|
|
345
359
|
valueHint: "boolean"
|
|
346
360
|
},
|
|
347
361
|
"auto-fixable-only": {
|
|
348
|
-
description: `Only handle auto-fixable violations
|
|
362
|
+
description: `Only handle auto-fixable violations.`,
|
|
349
363
|
required: false,
|
|
350
364
|
type: "boolean",
|
|
351
365
|
valueHint: "boolean"
|
|
352
366
|
},
|
|
367
|
+
"exclude.rules": {
|
|
368
|
+
description: "List of rules to exclude from the operation. Comma-separated.",
|
|
369
|
+
required: false,
|
|
370
|
+
type: "string",
|
|
371
|
+
valueHint: "rule-id,rule-id"
|
|
372
|
+
},
|
|
353
373
|
"limit": {
|
|
354
|
-
|
|
355
|
-
description: "Limit the number of violations or files to fix. Only works with --correct. (default: 100)",
|
|
374
|
+
description: "Limit the number of violations or files to fix. Only works with --correct.",
|
|
356
375
|
required: false,
|
|
357
376
|
type: "string",
|
|
358
377
|
valueHint: "number"
|
|
359
378
|
},
|
|
360
379
|
"limit-type": {
|
|
361
|
-
|
|
362
|
-
description: "Type of limit to apply. Only works with --correct. (default: violation)",
|
|
380
|
+
description: "Type of limit to apply. Only works with --correct.",
|
|
363
381
|
required: false,
|
|
364
382
|
type: "string",
|
|
365
383
|
valueHint: "violation | file"
|
|
@@ -388,43 +406,54 @@ const cli = defineCommand({
|
|
|
388
406
|
},
|
|
389
407
|
async run({ args }) {
|
|
390
408
|
const cliCwd = process.cwd();
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
409
|
+
const { context, userConfig } = parseArguments({
|
|
410
|
+
// args from citty are always not nullable even if default is not set
|
|
411
|
+
correct: {
|
|
412
|
+
"allowPartialSelection": args["allow-partial-selection"],
|
|
413
|
+
"autoFixableOnly": args["auto-fixable-only"],
|
|
414
|
+
"exclude.rules": args["exclude.rules"],
|
|
415
|
+
"limit": args.limit,
|
|
416
|
+
"limitType": args["limit-type"]
|
|
417
|
+
},
|
|
398
418
|
mode: {
|
|
399
419
|
correct: args.correct
|
|
400
420
|
},
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
autoFixableOnly: args["auto-fixable-only"],
|
|
404
|
-
limit: args.limit,
|
|
405
|
-
limitType: args["limit-type"]
|
|
406
|
-
},
|
|
407
|
-
todoFileAbsolutePath: eslintTodoCore.getTodoModulePath().absolute
|
|
421
|
+
root: args.cwd,
|
|
422
|
+
todoFile: args["todo-file"]
|
|
408
423
|
});
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
424
|
+
const configReadResult = await readConfigFile(cliCwd);
|
|
425
|
+
const configFromFile = (() => {
|
|
426
|
+
if (configReadResult.success) {
|
|
427
|
+
return configReadResult.data;
|
|
428
|
+
}
|
|
429
|
+
consola.warn("Invalid config file detected. Ignoring the config file.");
|
|
430
|
+
return {};
|
|
431
|
+
})();
|
|
432
|
+
const resolvedUserConfig = mergeUserConfig(configFromFile, userConfig);
|
|
433
|
+
const config = configWithDefault(resolvedUserConfig);
|
|
434
|
+
const eslintTodoCore = new ESLintTodoCore(config);
|
|
435
|
+
const todoFilePathFromCLI = relative(
|
|
436
|
+
cliCwd,
|
|
437
|
+
eslintTodoCore.getTodoModulePath().absolute
|
|
438
|
+
);
|
|
439
|
+
await runAction(updateAction, { config, consola });
|
|
440
|
+
if (context.mode === "generate") {
|
|
441
|
+
await runAction(genAction, { config, consola });
|
|
442
|
+
consola.success(`ESLint todo file generated at ${todoFilePathFromCLI}!`);
|
|
413
443
|
return;
|
|
414
444
|
}
|
|
415
|
-
if (
|
|
416
|
-
const result = await runAction(
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
);
|
|
445
|
+
if (context.mode === "correct") {
|
|
446
|
+
const result = await runAction(selectRulesToFixAction, {
|
|
447
|
+
config,
|
|
448
|
+
consola
|
|
449
|
+
});
|
|
421
450
|
if (!result.success) {
|
|
422
451
|
consola.warn(
|
|
423
452
|
"Couldn't find any rule to fix. Increase the limit and retry."
|
|
424
453
|
);
|
|
425
454
|
return;
|
|
426
455
|
}
|
|
427
|
-
await runAction(deleteRuleAction, {
|
|
456
|
+
await runAction(deleteRuleAction, { config, consola }, result.selection);
|
|
428
457
|
if (result.selection.type === "full") {
|
|
429
458
|
consola.success(
|
|
430
459
|
`All violations of rule ${colorize(
|
|
@@ -451,7 +480,7 @@ const cli = defineCommand({
|
|
|
451
480
|
`Unknown selection type: ${JSON.stringify(_exhaustiveCheck)}`
|
|
452
481
|
);
|
|
453
482
|
}
|
|
454
|
-
throw new Error(`Unknown mode: ${JSON.stringify(
|
|
483
|
+
throw new Error(`Unknown mode: ${JSON.stringify(context.mode)}`);
|
|
455
484
|
},
|
|
456
485
|
setup({ args }) {
|
|
457
486
|
consola.info(`eslint-todo CLI ${version}`);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { U as UserConfig } from '../shared/eslint-todo.DWzJhKY8.mjs';
|
|
2
|
+
export { C as Config } from '../shared/eslint-todo.DWzJhKY8.mjs';
|
|
3
|
+
|
|
4
|
+
declare const defineConfig: (config: UserConfig) => UserConfig;
|
|
5
|
+
declare const mergeUserConfig: (base: UserConfig, override: UserConfig) => UserConfig;
|
|
6
|
+
|
|
7
|
+
export { UserConfig, defineConfig, mergeUserConfig };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { U as UserConfig } from '../shared/eslint-todo.DWzJhKY8.js';
|
|
2
|
+
export { C as Config } from '../shared/eslint-todo.DWzJhKY8.js';
|
|
3
|
+
|
|
4
|
+
declare const defineConfig: (config: UserConfig) => UserConfig;
|
|
5
|
+
declare const mergeUserConfig: (base: UserConfig, override: UserConfig) => UserConfig;
|
|
6
|
+
|
|
7
|
+
export { UserConfig, defineConfig, mergeUserConfig };
|
package/dist/eslint/index.d.mts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Linter } from 'eslint';
|
|
2
|
-
import {
|
|
2
|
+
import { D as DeepPartial, C as Config } from '../shared/eslint-todo.DWzJhKY8.mjs';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type ESLintConfigTodoInput = DeepPartial<Pick<Config, "todoFile"> & {
|
|
5
|
+
cwd: Config["root"];
|
|
6
|
+
}>;
|
|
7
|
+
declare const eslintConfigTodo: (config?: ESLintConfigTodoInput) => Promise<Linter.Config[]>;
|
|
5
8
|
/**
|
|
6
9
|
* @deprecated
|
|
7
10
|
* You should import this from default export.
|
|
8
11
|
*/
|
|
9
|
-
declare const _old_eslintConfigTodo: (
|
|
12
|
+
declare const _old_eslintConfigTodo: (config?: ESLintConfigTodoInput) => Promise<Linter.Config[]>;
|
|
10
13
|
|
|
11
14
|
export { eslintConfigTodo as default, _old_eslintConfigTodo as eslintConfigTodo };
|
package/dist/eslint/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Linter } from 'eslint';
|
|
2
|
-
import {
|
|
2
|
+
import { D as DeepPartial, C as Config } from '../shared/eslint-todo.DWzJhKY8.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type ESLintConfigTodoInput = DeepPartial<Pick<Config, "todoFile"> & {
|
|
5
|
+
cwd: Config["root"];
|
|
6
|
+
}>;
|
|
7
|
+
declare const eslintConfigTodo: (config?: ESLintConfigTodoInput) => Promise<Linter.Config[]>;
|
|
5
8
|
/**
|
|
6
9
|
* @deprecated
|
|
7
10
|
* You should import this from default export.
|
|
8
11
|
*/
|
|
9
|
-
declare const _old_eslintConfigTodo: (
|
|
12
|
+
declare const _old_eslintConfigTodo: (config?: ESLintConfigTodoInput) => Promise<Linter.Config[]>;
|
|
10
13
|
|
|
11
14
|
export { eslintConfigTodo as default, _old_eslintConfigTodo as eslintConfigTodo };
|
package/dist/eslint/index.mjs
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cwd } from 'node:process';
|
|
2
|
+
import { mergeUserConfig } from '../config/index.mjs';
|
|
3
|
+
import { r as readConfigFile } from '../shared/eslint-todo.BA_lf5p3.mjs';
|
|
4
|
+
import { E as ESLintTodoCore, T as TodoModuleV1Handler, a as TodoModuleV2Handler } from '../shared/eslint-todo.EOEYtLpc.mjs';
|
|
5
|
+
import 'defu';
|
|
6
|
+
import 'pathe';
|
|
7
|
+
import 'typia/lib/internal/_accessExpressionAsString.js';
|
|
8
|
+
import 'typia/lib/internal/_validateReport.js';
|
|
2
9
|
import 'eslint';
|
|
3
10
|
import 'node:fs';
|
|
4
11
|
import 'node:fs/promises';
|
|
5
|
-
import 'pathe';
|
|
6
12
|
import 'magicast';
|
|
7
|
-
import '
|
|
8
|
-
import 'node:process';
|
|
13
|
+
import 'klona';
|
|
9
14
|
import 'valibot';
|
|
10
15
|
import 'jiti';
|
|
11
16
|
|
|
12
|
-
const eslintConfigTodo = async (
|
|
13
|
-
const
|
|
17
|
+
const eslintConfigTodo = async (config) => {
|
|
18
|
+
const root = config?.cwd;
|
|
19
|
+
const todoFile = config?.todoFile;
|
|
20
|
+
const cwdString = cwd();
|
|
21
|
+
const configReadResult = await readConfigFile(cwdString);
|
|
22
|
+
const configFromFile = (() => {
|
|
23
|
+
if (configReadResult.success) {
|
|
24
|
+
return configReadResult.data;
|
|
25
|
+
}
|
|
26
|
+
console.warn(
|
|
27
|
+
"[WARN] @sushichan044/eslint-todo: Invalid config file detected. Ignoring the config file."
|
|
28
|
+
);
|
|
29
|
+
return {};
|
|
30
|
+
})();
|
|
31
|
+
const resolvedUserConfig = mergeUserConfig(configFromFile, {
|
|
32
|
+
root,
|
|
33
|
+
todoFile
|
|
34
|
+
});
|
|
35
|
+
const core = new ESLintTodoCore(resolvedUserConfig);
|
|
14
36
|
const todoModulePath = core.getTodoModulePath();
|
|
15
37
|
const module = await (async () => {
|
|
16
38
|
try {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'eslint';
|
|
2
|
-
import './shared/eslint-todo.
|
|
3
|
-
export { E as ESLintTodoCore } from './shared/eslint-todo.
|
|
2
|
+
import './shared/eslint-todo.DWzJhKY8.mjs';
|
|
3
|
+
export { E as ESLintTodoCore } from './shared/eslint-todo.CG2sIIb6.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'eslint';
|
|
2
|
-
import './shared/eslint-todo.
|
|
3
|
-
export { E as ESLintTodoCore } from './shared/eslint-todo.
|
|
2
|
+
import './shared/eslint-todo.DWzJhKY8.js';
|
|
3
|
+
export { E as ESLintTodoCore } from './shared/eslint-todo.BpdH45rQ.js';
|