@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 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
- ### Reduce ignored errors
55
+ ### Correct ignored errors
56
56
 
57
- Add `--correct` flag to launch eslint-todo with error reduction mode.
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
- You can use `--limit`, `--limit-type`, `--auto-fixable-only` options to control the behavior.
64
+ By default, it searches for rules that can be automatically fixed and have less than or equal to 100 violations.
63
65
 
64
- Default options are: <br>
65
- Select one rule that has a total of 100 or fewer violations from **auto-fixable** rules.
66
+ ## Configuration
66
67
 
67
- ```bash
68
- eslint-todo --correct --limit 100 --limit-type violation
69
- ```
68
+ ### Configuration File (recommended)
70
69
 
71
- Select one rule that has a total of 10 or fewer files with violations from auto-fixable rules:
70
+ Just create `eslint-todo.config.{js,ts}`:
72
71
 
73
- ```bash
74
- eslint-todo --correct --limit 10 --limit-type file
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
- Select one rule that has a total of 100 or fewer violations from **all rules including non-auto-fixable** rules:
86
+ You can check all available options at [here](./src/config/config.ts).
78
87
 
79
- ```bash
80
- eslint-todo --correct --limit 100 --limit-type violation --auto-fixable-only false
81
- ```
88
+ <details>
89
+ <summary>Want to use JSON?</summary>
82
90
 
83
- ## Configuration (CLI)
91
+ Sure!
84
92
 
85
- ### cwd
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
- default: `process.cwd()`
105
+ </details>
88
106
 
89
- You can pass `--cwd` to specify the directory where `.eslint-todo.js` will be generated.
107
+ ### Configuration via CLI flags
90
108
 
91
- > [!WARNING]
92
- > You should place `eslint.config.js` on the specified directory.
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
- ### todo-file
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
- default: `.eslint-todo.js`
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
- You can pass `--todo-file` to specify the name of the ESLint Todo file.
119
+ ## Misc
99
120
 
100
121
  ### logging mode
101
122
 
102
123
  > [!CAUTION]
103
- > This feature is not working properly yet.
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
+ }
@@ -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 { L as LATEST_TODO_MODULE_HANDLER, i as isNonEmptyString, T as TodoModuleV1Handler, D as DEFAULT_OPTIONS, E as ESLintTodoCore } from '../shared/eslint-todo.CfTCWctB.mjs';
5
- import defu from 'defu';
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 { relative } from 'pathe';
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.5";
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 { consola, options: coreOptions } = options;
31
+ const { config, consola } = options;
36
32
  const remoteService = launchRemoteESLintTodoCore();
37
- const remoteCore = await new remoteService.RemoteESLintTodoCore(coreOptions);
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, limit, options = {}) => {
106
- const resolvedOptions = operationOptionsWithDefault(options);
107
- switch (limit.type) {
102
+ const selectRuleBasedOnLimit = (todoModule, correctConfig) => {
103
+ switch (correctConfig.limit.type) {
108
104
  case "file": {
109
- return selectRuleBasedOnFilesLimit(todoModule, limit, resolvedOptions);
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, limit, options) => {
125
- const { count: limitCount } = limit;
126
- const { allowPartialSelection, autoFixableOnly } = options;
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, limit, options) => {
177
- const { count: limitCount } = limit;
178
- const { allowPartialSelection, autoFixableOnly } = options;
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 }, input) => {
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, limit, options);
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 safeTryNumber = (value) => {
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
- mode: input.mode.correct ? "correct" : "generate",
282
- operation: resolveCLIOperation(input.operation),
283
- todoFilePath
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 limitTypeSchema = v.union([v.literal("violation"), v.literal("file")]);
287
- const resolveCLIOperation = (input) => {
288
- const parsedLimitType = v.safeParse(limitTypeSchema, input.limitType);
289
- if (!parsedLimitType.success) {
290
- throw new Error("limit-type must be either 'violation' or 'file'");
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
- const limitCount = safeTryNumber(input.limit);
293
- if (limitCount === null) {
294
- throw new Error("limit must be a number");
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 limit = {
297
- count: limitCount,
298
- type: parsedLimitType.output
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 (default: ${DEFAULT_OPTIONS.todoFile})`,
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. (default: ${DEFAULT_OPERATION_OPTIONS.allowPartialSelection})`,
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. (default: ${DEFAULT_OPERATION_OPTIONS.autoFixableOnly})`,
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
- default: "100",
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
- default: "violation",
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 options = {
392
- cwd: args.cwd,
393
- todoFile: args["todo-file"]
394
- };
395
- const eslintTodoCore = new ESLintTodoCore(options);
396
- const input = structureCLIInput({
397
- cwd: cliCwd,
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
- operation: {
402
- allowPartialSelection: args["allow-partial-selection"],
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
- await runAction(updateAction, { consola, options });
410
- if (input.mode === "generate") {
411
- await runAction(genAction, { consola, options });
412
- consola.success(`ESLint todo file generated at ${input.todoFilePath}!`);
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 (input.mode === "correct") {
416
- const result = await runAction(
417
- selectRulesToFixAction,
418
- { consola, options },
419
- input.operation
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, { consola, options }, result.selection);
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(input.mode)}`);
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 };
@@ -0,0 +1,8 @@
1
+ import defu from 'defu';
2
+
3
+ const defineConfig = (config) => {
4
+ return config;
5
+ };
6
+ const mergeUserConfig = (base, override) => defu(override, base);
7
+
8
+ export { defineConfig, mergeUserConfig };
@@ -1,11 +1,14 @@
1
1
  import { Linter } from 'eslint';
2
- import { U as UserOptions } from '../shared/eslint-todo.BijUMnSZ.mjs';
2
+ import { D as DeepPartial, C as Config } from '../shared/eslint-todo.DWzJhKY8.mjs';
3
3
 
4
- declare const eslintConfigTodo: (userOptions?: UserOptions) => Promise<Linter.Config[]>;
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: (userOptions?: UserOptions) => Promise<Linter.Config[]>;
12
+ declare const _old_eslintConfigTodo: (config?: ESLintConfigTodoInput) => Promise<Linter.Config[]>;
10
13
 
11
14
  export { eslintConfigTodo as default, _old_eslintConfigTodo as eslintConfigTodo };
@@ -1,11 +1,14 @@
1
1
  import { Linter } from 'eslint';
2
- import { U as UserOptions } from '../shared/eslint-todo.BijUMnSZ.js';
2
+ import { D as DeepPartial, C as Config } from '../shared/eslint-todo.DWzJhKY8.js';
3
3
 
4
- declare const eslintConfigTodo: (userOptions?: UserOptions) => Promise<Linter.Config[]>;
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: (userOptions?: UserOptions) => Promise<Linter.Config[]>;
12
+ declare const _old_eslintConfigTodo: (config?: ESLintConfigTodoInput) => Promise<Linter.Config[]>;
10
13
 
11
14
  export { eslintConfigTodo as default, _old_eslintConfigTodo as eslintConfigTodo };
@@ -1,16 +1,38 @@
1
- import { E as ESLintTodoCore, T as TodoModuleV1Handler, a as TodoModuleV2Handler } from '../shared/eslint-todo.CfTCWctB.mjs';
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 'defu';
8
- import 'node:process';
13
+ import 'klona';
9
14
  import 'valibot';
10
15
  import 'jiti';
11
16
 
12
- const eslintConfigTodo = async (userOptions = {}) => {
13
- const core = new ESLintTodoCore(userOptions);
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.BijUMnSZ.mjs';
3
- export { E as ESLintTodoCore } from './shared/eslint-todo.Bj71T6ke.mjs';
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.BijUMnSZ.js';
3
- export { E as ESLintTodoCore } from './shared/eslint-todo.COiTIKtF.js';
2
+ import './shared/eslint-todo.DWzJhKY8.js';
3
+ export { E as ESLintTodoCore } from './shared/eslint-todo.BpdH45rQ.js';