eslint-interactive 12.0.0 → 13.0.1
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 +34 -58
- package/bin/eslint-interactive.js +8 -11
- package/dist/action/index.d.ts +0 -2
- package/dist/action/index.d.ts.map +1 -1
- package/dist/action/index.js +0 -2
- package/dist/action/index.js.map +1 -1
- package/dist/action/print-result-details.d.ts.map +1 -1
- package/dist/action/print-result-details.js +6 -1
- package/dist/action/print-result-details.js.map +1 -1
- package/dist/cli/log.d.ts +3 -3
- package/dist/cli/log.d.ts.map +1 -1
- package/dist/cli/log.js +5 -4
- package/dist/cli/log.js.map +1 -1
- package/dist/cli/parse-argv.d.ts +2 -22
- package/dist/cli/parse-argv.d.ts.map +1 -1
- package/dist/cli/parse-argv.js +37 -43
- package/dist/cli/parse-argv.js.map +1 -1
- package/dist/cli/prompt.d.ts +1 -11
- package/dist/cli/prompt.d.ts.map +1 -1
- package/dist/cli/prompt.js +3 -44
- package/dist/cli/prompt.js.map +1 -1
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +6 -20
- package/dist/cli/run.js.map +1 -1
- package/dist/core-worker.d.ts +2 -4
- package/dist/core-worker.d.ts.map +1 -1
- package/dist/core-worker.js +3 -10
- package/dist/core-worker.js.map +1 -1
- package/dist/core.d.ts +8 -5
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +61 -47
- package/dist/core.js.map +1 -1
- package/dist/eslint/linter.d.ts +2 -3
- package/dist/eslint/linter.d.ts.map +1 -1
- package/dist/eslint/linter.js.map +1 -1
- package/dist/eslint/source-code-fixer.d.ts +1 -5
- package/dist/eslint/source-code-fixer.d.ts.map +1 -1
- package/dist/fix/make-fixable-and-fix.d.ts +2 -3
- package/dist/fix/make-fixable-and-fix.d.ts.map +1 -1
- package/dist/fix/make-fixable-and-fix.js +14 -41
- package/dist/fix/make-fixable-and-fix.js.map +1 -1
- package/dist/formatter/format-by-files.d.ts.map +1 -1
- package/dist/formatter/format-by-files.js +1 -0
- package/dist/formatter/format-by-files.js.map +1 -1
- package/dist/formatter/format-by-rules.d.ts +6 -1
- package/dist/formatter/format-by-rules.d.ts.map +1 -1
- package/dist/formatter/format-by-rules.js +7 -2
- package/dist/formatter/format-by-rules.js.map +1 -1
- package/dist/formatter/index.d.ts +3 -1
- package/dist/formatter/index.d.ts.map +1 -1
- package/dist/formatter/index.js +3 -2
- package/dist/formatter/index.js.map +1 -1
- package/dist/formatter/sort-rule-statistics.d.ts +5 -0
- package/dist/formatter/sort-rule-statistics.d.ts.map +1 -0
- package/dist/formatter/sort-rule-statistics.js +34 -0
- package/dist/formatter/sort-rule-statistics.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +14 -0
- package/dist/plugin.js.map +1 -1
- package/dist/scene/lint.d.ts.map +1 -1
- package/dist/scene/lint.js +13 -14
- package/dist/scene/lint.js.map +1 -1
- package/dist/scene/select-action.d.ts.map +1 -1
- package/dist/scene/select-action.js +3 -9
- package/dist/scene/select-action.js.map +1 -1
- package/dist/type.d.ts +12 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +2 -0
- package/dist/type.js.map +1 -0
- package/dist/util/eslint.d.ts.map +1 -1
- package/dist/util/eslint.js +1 -1
- package/dist/util/eslint.js.map +1 -1
- package/dist/util/type-check.d.ts +0 -3
- package/dist/util/type-check.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/action/index.ts +0 -2
- package/src/action/print-result-details.ts +7 -1
- package/src/cli/log.ts +5 -4
- package/src/cli/parse-argv.ts +45 -61
- package/src/cli/prompt.ts +4 -48
- package/src/cli/run.ts +6 -22
- package/src/core-worker.ts +6 -21
- package/src/core.ts +52 -50
- package/src/eslint/linter.ts +2 -3
- package/src/fix/make-fixable-and-fix.ts +15 -47
- package/src/formatter/format-by-files.ts +1 -0
- package/src/formatter/format-by-rules.ts +18 -3
- package/src/formatter/index.ts +8 -3
- package/src/formatter/sort-rule-statistics.ts +35 -0
- package/src/index.ts +2 -2
- package/src/plugin.ts +14 -0
- package/src/scene/lint.ts +16 -18
- package/src/scene/select-action.ts +1 -8
- package/src/type.ts +13 -0
- package/src/util/eslint.ts +2 -2
- package/src/util/type-check.ts +0 -4
- package/bin/_eslint-interactive.js +0 -9
- package/dist/action/apply-suggestions.d.ts +0 -6
- package/dist/action/apply-suggestions.d.ts.map +0 -1
- package/dist/action/apply-suggestions.js +0 -27
- package/dist/action/apply-suggestions.js.map +0 -1
- package/dist/action/make-fixable-and-fix.d.ts +0 -6
- package/dist/action/make-fixable-and-fix.d.ts.map +0 -1
- package/dist/action/make-fixable-and-fix.js +0 -27
- package/dist/action/make-fixable-and-fix.js.map +0 -1
- package/dist/config.d.ts +0 -47
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -98
- package/dist/config.js.map +0 -1
- package/dist/eslint/use-at-your-own-risk.d.ts +0 -5
- package/dist/eslint/use-at-your-own-risk.d.ts.map +0 -1
- package/dist/eslint/use-at-your-own-risk.js +0 -6
- package/dist/eslint/use-at-your-own-risk.js.map +0 -1
- package/dist/util/file-system.d.ts +0 -5
- package/dist/util/file-system.d.ts.map +0 -1
- package/dist/util/file-system.js +0 -10
- package/dist/util/file-system.js.map +0 -1
- package/dist/util/filter-script.d.ts +0 -6
- package/dist/util/filter-script.d.ts.map +0 -1
- package/dist/util/filter-script.js +0 -38
- package/dist/util/filter-script.js.map +0 -1
- package/src/action/apply-suggestions.ts +0 -39
- package/src/action/make-fixable-and-fix.ts +0 -39
- package/src/config.ts +0 -142
- package/src/eslint/use-at-your-own-risk.js +0 -6
- package/src/util/file-system.ts +0 -10
- package/src/util/filter-script.ts +0 -45
- package/static/example-filter-script.js +0 -40
- package/static/example-fixable-maker-script.js +0 -38
package/src/formatter/index.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { ESLint } from 'eslint';
|
|
2
2
|
import { formatByFiles } from './format-by-files.js';
|
|
3
|
-
import { formatByRules } from './format-by-rules.js';
|
|
3
|
+
import { formatByRules, type FormatByRulesSortOptions } from './format-by-rules.js';
|
|
4
4
|
|
|
5
5
|
export { takeRuleStatistics, type RuleStatistic } from './take-rule-statistics.js';
|
|
6
|
+
export { sortRuleStatistics } from './sort-rule-statistics.js';
|
|
6
7
|
|
|
7
|
-
export function format(
|
|
8
|
-
|
|
8
|
+
export function format(
|
|
9
|
+
results: ESLint.LintResult[],
|
|
10
|
+
data?: ESLint.LintResultData,
|
|
11
|
+
sortOptions?: FormatByRulesSortOptions,
|
|
12
|
+
): string {
|
|
13
|
+
return `${formatByFiles(results)}\n${formatByRules(results, data, sortOptions)}`;
|
|
9
14
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { SortField, SortOrder } from '../type.js';
|
|
2
|
+
import { unreachable } from '../util/type-check.js';
|
|
3
|
+
import type { RuleStatistic } from './take-rule-statistics.js';
|
|
4
|
+
|
|
5
|
+
const SORT_FIELD_TO_KEY: Record<SortField, keyof RuleStatistic> = {
|
|
6
|
+
rule: 'ruleId',
|
|
7
|
+
error: 'errorCount',
|
|
8
|
+
warning: 'warningCount',
|
|
9
|
+
fixable: 'isFixableCount',
|
|
10
|
+
suggestions: 'hasSuggestionsCount',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** Get the default sort order for a given field */
|
|
14
|
+
function getDefaultSortOrder(field: SortField): SortOrder {
|
|
15
|
+
return field === 'rule' ? 'asc' : 'desc';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Sort rule statistics by the specified field and order */
|
|
19
|
+
export function sortRuleStatistics(statistics: RuleStatistic[], field: SortField, order?: SortOrder): RuleStatistic[] {
|
|
20
|
+
const resolvedOrder = order ?? getDefaultSortOrder(field);
|
|
21
|
+
const key = SORT_FIELD_TO_KEY[field];
|
|
22
|
+
const sorted = [...statistics].sort((a, b) => {
|
|
23
|
+
const aVal = a[key];
|
|
24
|
+
const bVal = b[key];
|
|
25
|
+
if (typeof aVal === 'string' && typeof bVal === 'string') {
|
|
26
|
+
return aVal.localeCompare(bVal);
|
|
27
|
+
} else if (typeof aVal === 'number' && typeof bVal === 'number') {
|
|
28
|
+
return aVal - bVal;
|
|
29
|
+
} else {
|
|
30
|
+
return unreachable('Invalid sort key type');
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (resolvedOrder === 'desc') sorted.reverse();
|
|
34
|
+
return sorted;
|
|
35
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { run, type Options } from './cli/run.js';
|
|
2
2
|
export { Core } from './core.js';
|
|
3
|
-
export { type
|
|
4
|
-
export { takeRuleStatistics, type RuleStatistic } from './formatter/index.js';
|
|
3
|
+
export { type SortField, type SortOrder, type Config } from './type.js';
|
|
4
|
+
export { takeRuleStatistics, type RuleStatistic, sortRuleStatistics } from './formatter/index.js';
|
|
5
5
|
export { type FixableMaker, type SuggestionFilter, type FixContext } from './fix/index.js';
|
package/src/plugin.ts
CHANGED
|
@@ -18,6 +18,20 @@ export const plugin: ESLint.Plugin = {
|
|
|
18
18
|
return {};
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
|
+
/** This is a rule for testing purposes. It reports without end location (endLine/endColumn). */
|
|
22
|
+
'report-without-end-location': {
|
|
23
|
+
create(context: Rule.RuleContext) {
|
|
24
|
+
return {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
26
|
+
Program(node) {
|
|
27
|
+
context.report({
|
|
28
|
+
loc: node.loc!.start,
|
|
29
|
+
message: 'Report without end location.',
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
},
|
|
21
35
|
/** This is a rule for testing purposes. */
|
|
22
36
|
'prefer-addition-shorthand': {
|
|
23
37
|
meta: {
|
package/src/scene/lint.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { Remote } from 'comlink';
|
|
2
|
-
import {
|
|
2
|
+
import { error } from '../cli/log.js';
|
|
3
3
|
import { lintingSpinner } from '../cli/spinner.js';
|
|
4
4
|
import type { SerializableCore } from '../core-worker.js';
|
|
5
|
-
import { unique } from '../util/array.js';
|
|
6
|
-
import { notEmpty } from '../util/type-check.js';
|
|
7
5
|
import type { NextScene } from './index.js';
|
|
8
6
|
|
|
9
7
|
/**
|
|
@@ -13,29 +11,29 @@ export async function lint(core: Remote<SerializableCore>): Promise<NextScene> {
|
|
|
13
11
|
const results = await lintingSpinner(async () => core.lint());
|
|
14
12
|
console.log();
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.flatMap((result) => result.messages)
|
|
19
|
-
.flatMap((message) => message.ruleId)
|
|
20
|
-
.filter(notEmpty),
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
if (ruleIdsInResults.length === 0) {
|
|
24
|
-
console.log('💚 No error found.');
|
|
25
|
-
return { name: 'exit' };
|
|
26
|
-
}
|
|
27
|
-
console.log(await core.formatResultSummary(results));
|
|
28
|
-
|
|
14
|
+
// Check for ESLint core problems (ruleId === null) first.
|
|
15
|
+
// These represent config errors, syntax errors, etc. that eslint-interactive cannot fix.
|
|
29
16
|
const hasESLintCoreProblems = results.flatMap((result) => result.messages).some((message) => message.ruleId === null);
|
|
30
17
|
if (hasESLintCoreProblems) {
|
|
31
|
-
|
|
18
|
+
error(
|
|
32
19
|
'ESLint Core Problems are found. ' +
|
|
33
20
|
'The problems cannot be fixed by eslint-interactive. ' +
|
|
34
21
|
'Check the details of the problem and fix it. ' +
|
|
35
|
-
'This is usually caused by the invalid
|
|
22
|
+
'This is usually caused by the invalid eslint config or the invalid syntax of the linted code.',
|
|
36
23
|
);
|
|
37
24
|
console.log(await core.formatResultDetails(results, [null]));
|
|
25
|
+
// eslint-disable-next-line n/no-process-exit
|
|
26
|
+
process.exit(1);
|
|
38
27
|
}
|
|
28
|
+
|
|
29
|
+
const ruleIdsInResults = await core.getSortedRuleIdsInResults(results);
|
|
30
|
+
|
|
31
|
+
if (ruleIdsInResults.length === 0) {
|
|
32
|
+
console.log('💚 No error found.');
|
|
33
|
+
return { name: 'exit' };
|
|
34
|
+
}
|
|
35
|
+
console.log(await core.formatResultSummary(results));
|
|
36
|
+
|
|
39
37
|
console.log();
|
|
40
38
|
return { name: 'selectRuleIds', args: { results, ruleIdsInResults } };
|
|
41
39
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { Remote } from 'comlink';
|
|
2
2
|
import type { ESLint } from 'eslint';
|
|
3
3
|
import {
|
|
4
|
-
doApplySuggestionsAction,
|
|
5
4
|
doConvertErrorToWarningPerFileAction,
|
|
6
5
|
doDisablePerFileAction,
|
|
7
6
|
doDisablePerLineAction,
|
|
8
7
|
doFixAction,
|
|
9
|
-
doMakeFixableAndFixAction,
|
|
10
8
|
doPrintResultDetailsAction,
|
|
11
9
|
} from '../action/index.js';
|
|
12
10
|
import type { Action } from '../cli/prompt.js';
|
|
@@ -47,6 +45,7 @@ export async function selectAction(
|
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
if (selectedAction === 'reselectRules') return selectRuleIdsScene;
|
|
48
|
+
if (selectedAction === 'relintAndReselectRules') return { name: 'lint' };
|
|
50
49
|
|
|
51
50
|
if (selectedAction === 'printResultDetails') {
|
|
52
51
|
await doPrintResultDetailsAction(core, results, selectedRuleIds);
|
|
@@ -63,12 +62,6 @@ export async function selectAction(
|
|
|
63
62
|
} else if (selectedAction === 'convertErrorToWarningPerFile') {
|
|
64
63
|
const undo = await doConvertErrorToWarningPerFileAction(core, results, selectedRuleIds);
|
|
65
64
|
return createCheckResultsScene(undo);
|
|
66
|
-
} else if (selectedAction === 'applySuggestions') {
|
|
67
|
-
const undo = await doApplySuggestionsAction(core, results, selectedRuleIds);
|
|
68
|
-
return createCheckResultsScene(undo);
|
|
69
|
-
} else if (selectedAction === 'makeFixableAndFix') {
|
|
70
|
-
const undo = await doMakeFixableAndFixAction(core, results, selectedRuleIds);
|
|
71
|
-
return createCheckResultsScene(undo);
|
|
72
65
|
}
|
|
73
66
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
74
67
|
return unreachable(`unknown action: ${selectedAction}`);
|
package/src/type.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ESLint } from 'eslint';
|
|
2
|
+
|
|
3
|
+
export type SortField = 'rule' | 'error' | 'warning' | 'fixable' | 'suggestions';
|
|
4
|
+
export type SortOrder = 'asc' | 'desc';
|
|
5
|
+
|
|
6
|
+
/** The config of eslint-interactive */
|
|
7
|
+
export type Config = ESLint.Options & {
|
|
8
|
+
patterns: string[];
|
|
9
|
+
formatterName?: string | undefined;
|
|
10
|
+
quiet?: boolean | undefined;
|
|
11
|
+
sort?: SortField | undefined;
|
|
12
|
+
sortOrder?: SortOrder | undefined;
|
|
13
|
+
};
|
package/src/util/eslint.ts
CHANGED
|
@@ -201,7 +201,7 @@ export function insertDisableCommentStatementBeforeLine(args: {
|
|
|
201
201
|
scope: 'file' | 'next-line';
|
|
202
202
|
ruleIds: string[];
|
|
203
203
|
description: string | undefined;
|
|
204
|
-
}) {
|
|
204
|
+
}): Rule.Fix {
|
|
205
205
|
const { fixer, sourceCode, line, column, scope, ruleIds, description } = args;
|
|
206
206
|
const indent = getIndentFromLine(sourceCode, line);
|
|
207
207
|
const headNodeIndex = sourceCode.getIndexFromLoc({ line, column });
|
|
@@ -232,7 +232,7 @@ export function toInlineConfigCommentText({ rulesRecord, description }: Omit<Inl
|
|
|
232
232
|
const header = 'eslint';
|
|
233
233
|
const rulesRecordText = Object.entries(rulesRecord)
|
|
234
234
|
.map(([ruleId, ruleEntry]) => {
|
|
235
|
-
// TODO: Inherit options of the rule set by the user in
|
|
235
|
+
// TODO: Inherit options of the rule set by the user in ESLint config if the option exists.
|
|
236
236
|
return `${ruleId}: ${JSON.stringify(ruleEntry)}`;
|
|
237
237
|
})
|
|
238
238
|
.join(', ');
|
package/src/util/type-check.ts
CHANGED
|
@@ -6,7 +6,3 @@ export function unreachable(message?: string): never {
|
|
|
6
6
|
export function notEmpty<TValue>(value: TValue | null | undefined): value is TValue {
|
|
7
7
|
return value !== null && value !== undefined;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
export type DeepPartial<T> = {
|
|
11
|
-
[P in keyof T]?: T[P] extends Record<string, unknown> ? DeepPartial<T[P]> : T[P];
|
|
12
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Remote } from 'comlink';
|
|
2
|
-
import type { ESLint } from 'eslint';
|
|
3
|
-
import type { Undo } from '../core.js';
|
|
4
|
-
import type { SerializableCore } from '../core-worker.js';
|
|
5
|
-
export declare function doApplySuggestionsAction(core: Remote<SerializableCore>, results: ESLint.LintResult[], selectedRuleIds: string[]): Promise<Undo>;
|
|
6
|
-
//# sourceMappingURL=apply-suggestions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apply-suggestions.d.ts","sourceRoot":"","sources":["../../src/action/apply-suggestions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAO1D,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAC9B,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAC5B,eAAe,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC,CAoBf"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { access, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { dirname } from 'node:path';
|
|
3
|
-
import { promptToInputReuseFilterScript } from '../cli/prompt.js';
|
|
4
|
-
import { fixingSpinner } from '../cli/spinner.js';
|
|
5
|
-
import { editFileWithEditor, generateExampleFilterScriptFilePath, generateFilterScriptFilePath, } from '../util/filter-script.js';
|
|
6
|
-
export async function doApplySuggestionsAction(core, results, selectedRuleIds) {
|
|
7
|
-
const exampleScript = await readFile(generateExampleFilterScriptFilePath(), 'utf8');
|
|
8
|
-
const filterScriptFilePath = generateFilterScriptFilePath(selectedRuleIds);
|
|
9
|
-
const isFilterScriptExist = await access(filterScriptFilePath)
|
|
10
|
-
.then(() => true)
|
|
11
|
-
.catch(() => false);
|
|
12
|
-
if (isFilterScriptExist) {
|
|
13
|
-
const reuseFilterScript = await promptToInputReuseFilterScript();
|
|
14
|
-
if (!reuseFilterScript) {
|
|
15
|
-
await writeFile(filterScriptFilePath, exampleScript);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
await mkdir(dirname(filterScriptFilePath), { recursive: true }); // Create the directory because it might not exist
|
|
20
|
-
await writeFile(filterScriptFilePath, exampleScript);
|
|
21
|
-
}
|
|
22
|
-
console.log('Opening editor...');
|
|
23
|
-
const filterScript = await editFileWithEditor(filterScriptFilePath);
|
|
24
|
-
const undo = await fixingSpinner(async () => core.applySuggestions(results, selectedRuleIds, filterScript));
|
|
25
|
-
return undo;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=apply-suggestions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apply-suggestions.js","sourceRoot":"","sources":["../../src/action/apply-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAA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0 @@
|
|
|
1
|
-
import type { Remote } from 'comlink';
|
|
2
|
-
import type { ESLint } from 'eslint';
|
|
3
|
-
import type { Undo } from '../core.js';
|
|
4
|
-
import type { SerializableCore } from '../core-worker.js';
|
|
5
|
-
export declare function doMakeFixableAndFixAction(core: Remote<SerializableCore>, results: ESLint.LintResult[], selectedRuleIds: string[]): Promise<Undo>;
|
|
6
|
-
//# sourceMappingURL=make-fixable-and-fix.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"make-fixable-and-fix.d.ts","sourceRoot":"","sources":["../../src/action/make-fixable-and-fix.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAO1D,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAC9B,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAC5B,eAAe,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC,CAoBf"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { access, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { dirname } from 'node:path';
|
|
3
|
-
import { promptToInputReuseScript } from '../cli/prompt.js';
|
|
4
|
-
import { fixingSpinner } from '../cli/spinner.js';
|
|
5
|
-
import { editFileWithEditor, generateExampleFixableMakerScriptFilePath, generateFixableMakerScriptFilePath, } from '../util/filter-script.js';
|
|
6
|
-
export async function doMakeFixableAndFixAction(core, results, selectedRuleIds) {
|
|
7
|
-
const exampleScript = await readFile(generateExampleFixableMakerScriptFilePath(), 'utf8');
|
|
8
|
-
const fixableMakerScriptFilePath = generateFixableMakerScriptFilePath(selectedRuleIds);
|
|
9
|
-
const isFixableMakerScriptExist = await access(fixableMakerScriptFilePath)
|
|
10
|
-
.then(() => true)
|
|
11
|
-
.catch(() => false);
|
|
12
|
-
if (isFixableMakerScriptExist) {
|
|
13
|
-
const reuseScript = await promptToInputReuseScript();
|
|
14
|
-
if (!reuseScript) {
|
|
15
|
-
await writeFile(fixableMakerScriptFilePath, exampleScript);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
await mkdir(dirname(fixableMakerScriptFilePath), { recursive: true }); // Create the directory because it might not exist
|
|
20
|
-
await writeFile(fixableMakerScriptFilePath, exampleScript);
|
|
21
|
-
}
|
|
22
|
-
console.log('Opening editor...');
|
|
23
|
-
const fixableMakerScript = await editFileWithEditor(fixableMakerScriptFilePath);
|
|
24
|
-
const undo = await fixingSpinner(async () => core.makeFixableAndFix(results, selectedRuleIds, fixableMakerScript));
|
|
25
|
-
return undo;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=make-fixable-and-fix.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"make-fixable-and-fix.js","sourceRoot":"","sources":["../../src/action/make-fixable-and-fix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EACL,kBAAkB,EAClB,yCAAyC,EACzC,kCAAkC,GACnC,MAAM,0BAA0B,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,IAA8B,EAC9B,OAA4B,EAC5B,eAAyB;IAEzB,MAAM,aAAa,GAAG,MAAM,QAAQ,CAAC,yCAAyC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC1F,MAAM,0BAA0B,GAAG,kCAAkC,CAAC,eAAe,CAAC,CAAC;IACvF,MAAM,yBAAyB,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC;SACvE,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;SAChB,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IACtB,IAAI,yBAAyB,EAAE,CAAC;QAC9B,MAAM,WAAW,GAAG,MAAM,wBAAwB,EAAE,CAAC;QACrD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,SAAS,CAAC,0BAA0B,EAAE,aAAa,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,CAAC,OAAO,CAAC,0BAA0B,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,kDAAkD;QACzH,MAAM,SAAS,CAAC,0BAA0B,EAAE,aAAa,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAEjC,MAAM,kBAAkB,GAAG,MAAM,kBAAkB,CAAC,0BAA0B,CAAC,CAAC;IAChF,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,eAAe,EAAE,kBAAkB,CAAC,CAAC,CAAC;IACnH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/config.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { ESLint } from 'eslint';
|
|
2
|
-
import type { ParsedCLIOptions } from './cli/parse-argv.js';
|
|
3
|
-
type LegacyESLintOptions = {
|
|
4
|
-
type: 'eslintrc';
|
|
5
|
-
} & Pick<ESLint.LegacyOptions, 'useEslintrc' | 'overrideConfigFile' | 'extensions' | 'rulePaths' | 'ignorePath' | 'cache' | 'cacheLocation' | 'overrideConfig' | 'cwd' | 'resolvePluginsRelativeTo' | 'plugins'>;
|
|
6
|
-
type FlatESLintOptions = {
|
|
7
|
-
type: 'flat';
|
|
8
|
-
} & Pick<ESLint.Options, 'overrideConfigFile' | 'cache' | 'cacheLocation' | 'overrideConfig' | 'cwd' | 'flags'>;
|
|
9
|
-
export type ESLintOptions = LegacyESLintOptions | FlatESLintOptions;
|
|
10
|
-
/** The config of eslint-interactive */
|
|
11
|
-
export type Config = {
|
|
12
|
-
patterns: string[];
|
|
13
|
-
formatterName?: string | undefined;
|
|
14
|
-
quiet?: boolean | undefined;
|
|
15
|
-
cwd?: string | undefined;
|
|
16
|
-
eslintOptions: ESLintOptions;
|
|
17
|
-
flags?: string[] | undefined;
|
|
18
|
-
};
|
|
19
|
-
type ESLintOptionsType = 'eslintrc' | 'flat';
|
|
20
|
-
export declare function translateCLIOptions(options: ParsedCLIOptions, eslintOptionsType: ESLintOptionsType): Config;
|
|
21
|
-
/** Default config of `Core` */
|
|
22
|
-
export declare const configDefaults: {
|
|
23
|
-
formatterName: string;
|
|
24
|
-
quiet: false;
|
|
25
|
-
cwd: string;
|
|
26
|
-
eslintOptions: {
|
|
27
|
-
useEslintrc: true;
|
|
28
|
-
overrideConfigFile: undefined;
|
|
29
|
-
extensions: undefined;
|
|
30
|
-
rulePaths: undefined;
|
|
31
|
-
ignorePath: undefined;
|
|
32
|
-
cache: false;
|
|
33
|
-
cacheLocation: undefined;
|
|
34
|
-
overrideConfig: undefined;
|
|
35
|
-
resolvePluginsRelativeTo: undefined;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export type NormalizedConfig = {
|
|
39
|
-
patterns: string[];
|
|
40
|
-
formatterName: string;
|
|
41
|
-
quiet: boolean;
|
|
42
|
-
cwd: string;
|
|
43
|
-
eslintOptions: ESLintOptions;
|
|
44
|
-
};
|
|
45
|
-
export declare function normalizeConfig(config: Config): NormalizedConfig;
|
|
46
|
-
export {};
|
|
47
|
-
//# sourceMappingURL=config.d.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O,MAAM,cAAc;;;;;;;;;;;;;;;CAeI,CAAC;AAEhC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAwChE"}
|
package/dist/config.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { cliOptionsDefaults } from './cli/parse-argv.js';
|
|
2
|
-
export function translateCLIOptions(options, eslintOptionsType) {
|
|
3
|
-
if (eslintOptionsType === 'eslintrc') {
|
|
4
|
-
return {
|
|
5
|
-
patterns: options.patterns,
|
|
6
|
-
formatterName: options.formatterName,
|
|
7
|
-
quiet: options.quiet,
|
|
8
|
-
eslintOptions: {
|
|
9
|
-
type: 'eslintrc',
|
|
10
|
-
useEslintrc: options.useEslintrc,
|
|
11
|
-
overrideConfigFile: options.overrideConfigFile,
|
|
12
|
-
extensions: options.extensions,
|
|
13
|
-
rulePaths: options.rulePaths,
|
|
14
|
-
ignorePath: options.ignorePath,
|
|
15
|
-
cache: options.cache,
|
|
16
|
-
cacheLocation: options.cacheLocation,
|
|
17
|
-
resolvePluginsRelativeTo: options.resolvePluginsRelativeTo,
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
else if (eslintOptionsType === 'flat') {
|
|
22
|
-
return {
|
|
23
|
-
patterns: options.patterns,
|
|
24
|
-
formatterName: options.formatterName,
|
|
25
|
-
quiet: options.quiet,
|
|
26
|
-
eslintOptions: {
|
|
27
|
-
type: 'flat',
|
|
28
|
-
overrideConfigFile: options.overrideConfigFile,
|
|
29
|
-
cache: options.cache,
|
|
30
|
-
cacheLocation: options.cacheLocation,
|
|
31
|
-
// Pass flags conditionally to avoid errors in ESLint v8
|
|
32
|
-
...(options.flags && options.flags.length > 0 ? { flags: options.flags } : {}),
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
throw new Error(`Unexpected configType: ${String(eslintOptionsType)}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/** Default config of `Core` */
|
|
41
|
-
export const configDefaults = {
|
|
42
|
-
formatterName: cliOptionsDefaults.formatterName,
|
|
43
|
-
quiet: cliOptionsDefaults.quiet,
|
|
44
|
-
cwd: process.cwd(),
|
|
45
|
-
eslintOptions: {
|
|
46
|
-
useEslintrc: cliOptionsDefaults.useEslintrc,
|
|
47
|
-
overrideConfigFile: undefined,
|
|
48
|
-
extensions: undefined,
|
|
49
|
-
rulePaths: undefined,
|
|
50
|
-
ignorePath: undefined,
|
|
51
|
-
cache: cliOptionsDefaults.cache,
|
|
52
|
-
cacheLocation: undefined,
|
|
53
|
-
overrideConfig: undefined,
|
|
54
|
-
resolvePluginsRelativeTo: undefined,
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
export function normalizeConfig(config) {
|
|
58
|
-
const cwd = config.cwd ?? configDefaults.cwd;
|
|
59
|
-
let eslintOptions;
|
|
60
|
-
if (config.eslintOptions.type === 'eslintrc') {
|
|
61
|
-
eslintOptions = {
|
|
62
|
-
type: 'eslintrc',
|
|
63
|
-
useEslintrc: config.eslintOptions.useEslintrc ?? configDefaults.eslintOptions.useEslintrc,
|
|
64
|
-
overrideConfigFile: config.eslintOptions.overrideConfigFile ?? configDefaults.eslintOptions.overrideConfigFile,
|
|
65
|
-
extensions: config.eslintOptions.extensions ?? configDefaults.eslintOptions.extensions,
|
|
66
|
-
rulePaths: config.eslintOptions.rulePaths ?? configDefaults.eslintOptions.rulePaths,
|
|
67
|
-
ignorePath: config.eslintOptions.ignorePath ?? configDefaults.eslintOptions.ignorePath,
|
|
68
|
-
cache: config.eslintOptions.cache ?? configDefaults.eslintOptions.cache,
|
|
69
|
-
cacheLocation: config.eslintOptions.cacheLocation ?? configDefaults.eslintOptions.cacheLocation,
|
|
70
|
-
overrideConfig: config.eslintOptions.overrideConfig ?? configDefaults.eslintOptions.overrideConfig,
|
|
71
|
-
cwd,
|
|
72
|
-
resolvePluginsRelativeTo: config.eslintOptions.resolvePluginsRelativeTo ?? configDefaults.eslintOptions.resolvePluginsRelativeTo,
|
|
73
|
-
plugins: config.eslintOptions.plugins,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
eslintOptions = {
|
|
78
|
-
type: 'flat',
|
|
79
|
-
overrideConfigFile: config.eslintOptions.overrideConfigFile ?? configDefaults.eslintOptions.overrideConfigFile,
|
|
80
|
-
cache: config.eslintOptions.cache ?? configDefaults.eslintOptions.cache,
|
|
81
|
-
cacheLocation: config.eslintOptions.cacheLocation ?? configDefaults.eslintOptions.cacheLocation,
|
|
82
|
-
overrideConfig: config.eslintOptions.overrideConfig ?? configDefaults.eslintOptions.overrideConfig,
|
|
83
|
-
cwd,
|
|
84
|
-
// Pass flags conditionally to avoid errors in ESLint v8
|
|
85
|
-
...(config.eslintOptions.flags && config.eslintOptions.flags.length > 0 ?
|
|
86
|
-
{ flags: config.eslintOptions.flags }
|
|
87
|
-
: {}),
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
patterns: config.patterns,
|
|
92
|
-
formatterName: config.formatterName ?? configDefaults.formatterName,
|
|
93
|
-
quiet: config.quiet ?? configDefaults.quiet,
|
|
94
|
-
cwd,
|
|
95
|
-
eslintOptions,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAoCzD,MAAM,UAAU,mBAAmB,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 -1,5 +0,0 @@
|
|
|
1
|
-
export const LegacyESLint: typeof eslintPkg.LegacyESLint;
|
|
2
|
-
export const FlatESLint: typeof eslintPkg.FlatESLint;
|
|
3
|
-
export const shouldUseFlatConfig: typeof eslintPkg.shouldUseFlatConfig;
|
|
4
|
-
import eslintPkg from 'eslint/use-at-your-own-risk';
|
|
5
|
-
//# sourceMappingURL=use-at-your-own-risk.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-at-your-own-risk.d.ts","sourceRoot":"","sources":["../../src/eslint/use-at-your-own-risk.js"],"names":[],"mappings":"AAGA,yDAAmD;AACnD,qDAA+C;AAC/C,uEAAiE;sBAJ3C,6BAA6B"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import eslintPkg from 'eslint/use-at-your-own-risk';
|
|
3
|
-
export const LegacyESLint = eslintPkg.LegacyESLint;
|
|
4
|
-
export const FlatESLint = eslintPkg.FlatESLint;
|
|
5
|
-
export const shouldUseFlatConfig = eslintPkg.shouldUseFlatConfig;
|
|
6
|
-
//# sourceMappingURL=use-at-your-own-risk.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-at-your-own-risk.js","sourceRoot":"","sources":["../../src/eslint/use-at-your-own-risk.js"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAEpD,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC;AACnD,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-system.d.ts","sourceRoot":"","sources":["../../src/util/file-system.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
|
package/dist/util/file-system.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { tmpdir } from 'node:os';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { VERSION } from '../cli/package.js';
|
|
4
|
-
/**
|
|
5
|
-
* Get the path of the temporary directory for eslint-interactive.
|
|
6
|
-
*/
|
|
7
|
-
export function getTempDir() {
|
|
8
|
-
return join(tmpdir(), 'eslint-interactive', VERSION);
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=file-system.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-system.js","sourceRoot":"","sources":["../../src/util/file-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare function editFileWithEditor(filepath: string): Promise<string>;
|
|
2
|
-
export declare function generateFilterScriptFilePath(ruleIds: string[]): string;
|
|
3
|
-
export declare function generateFixableMakerScriptFilePath(ruleIds: string[]): string;
|
|
4
|
-
export declare function generateExampleFilterScriptFilePath(): string;
|
|
5
|
-
export declare function generateExampleFixableMakerScriptFilePath(): string;
|
|
6
|
-
//# sourceMappingURL=filter-script.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter-script.d.ts","sourceRoot":"","sources":["../../src/util/filter-script.ts"],"names":[],"mappings":"AAeA,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS1E;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAItE;AAED,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAI5E;AAED,wBAAgB,mCAAmC,IAAI,MAAM,CAE5D;AAED,wBAAgB,yCAAyC,IAAI,MAAM,CAElE"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { exec as execOriginal } from 'node:child_process';
|
|
2
|
-
import { access, appendFile, mkdir, readFile } from 'node:fs/promises';
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { promisify } from 'node:util';
|
|
6
|
-
import { getTempDir } from './file-system.js';
|
|
7
|
-
const exec = promisify(execOriginal);
|
|
8
|
-
const DEFAULT_EDITOR_COMMAND = 'vi';
|
|
9
|
-
function getEditorCommand() {
|
|
10
|
-
return process.env['EDITOR'] ?? DEFAULT_EDITOR_COMMAND;
|
|
11
|
-
}
|
|
12
|
-
export async function editFileWithEditor(filepath) {
|
|
13
|
-
const command = getEditorCommand();
|
|
14
|
-
await mkdir(dirname(filepath), { recursive: true });
|
|
15
|
-
await access(filepath).catch(async () => {
|
|
16
|
-
await appendFile(filepath, '', 'utf8');
|
|
17
|
-
});
|
|
18
|
-
await exec(`${command} ${filepath}`);
|
|
19
|
-
const newContent = await readFile(filepath, 'utf8');
|
|
20
|
-
return newContent;
|
|
21
|
-
}
|
|
22
|
-
export function generateFilterScriptFilePath(ruleIds) {
|
|
23
|
-
const basename = `${ruleIds.join('_').replace(/[^\w-]/gu, '')}.js`;
|
|
24
|
-
const filepath = join(getTempDir(), 'filter-script', basename);
|
|
25
|
-
return filepath;
|
|
26
|
-
}
|
|
27
|
-
export function generateFixableMakerScriptFilePath(ruleIds) {
|
|
28
|
-
const basename = `${ruleIds.join('_').replace(/[^\w-]/gu, '')}.js`;
|
|
29
|
-
const filepath = join(getTempDir(), 'fixable-maker-script', basename);
|
|
30
|
-
return filepath;
|
|
31
|
-
}
|
|
32
|
-
export function generateExampleFilterScriptFilePath() {
|
|
33
|
-
return join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'static', 'example-filter-script.js');
|
|
34
|
-
}
|
|
35
|
-
export function generateExampleFixableMakerScriptFilePath() {
|
|
36
|
-
return join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'static', 'example-fixable-maker-script.js');
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=filter-script.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter-script.js","sourceRoot":"","sources":["../../src/util/filter-script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,IAAI,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;AAErC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC,SAAS,gBAAgB;IACvB,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,sBAAsB,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,QAAgB;IACvD,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IACnC,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;QACtC,MAAM,UAAU,CAAC,QAAQ,E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import { access, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { dirname } from 'node:path';
|
|
3
|
-
import type { Remote } from 'comlink';
|
|
4
|
-
import type { ESLint } from 'eslint';
|
|
5
|
-
import { promptToInputReuseFilterScript } from '../cli/prompt.js';
|
|
6
|
-
import { fixingSpinner } from '../cli/spinner.js';
|
|
7
|
-
import type { Undo } from '../core.js';
|
|
8
|
-
import type { SerializableCore } from '../core-worker.js';
|
|
9
|
-
import {
|
|
10
|
-
editFileWithEditor,
|
|
11
|
-
generateExampleFilterScriptFilePath,
|
|
12
|
-
generateFilterScriptFilePath,
|
|
13
|
-
} from '../util/filter-script.js';
|
|
14
|
-
|
|
15
|
-
export async function doApplySuggestionsAction(
|
|
16
|
-
core: Remote<SerializableCore>,
|
|
17
|
-
results: ESLint.LintResult[],
|
|
18
|
-
selectedRuleIds: string[],
|
|
19
|
-
): Promise<Undo> {
|
|
20
|
-
const exampleScript = await readFile(generateExampleFilterScriptFilePath(), 'utf8');
|
|
21
|
-
const filterScriptFilePath = generateFilterScriptFilePath(selectedRuleIds);
|
|
22
|
-
const isFilterScriptExist = await access(filterScriptFilePath)
|
|
23
|
-
.then(() => true)
|
|
24
|
-
.catch(() => false);
|
|
25
|
-
if (isFilterScriptExist) {
|
|
26
|
-
const reuseFilterScript = await promptToInputReuseFilterScript();
|
|
27
|
-
if (!reuseFilterScript) {
|
|
28
|
-
await writeFile(filterScriptFilePath, exampleScript);
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
await mkdir(dirname(filterScriptFilePath), { recursive: true }); // Create the directory because it might not exist
|
|
32
|
-
await writeFile(filterScriptFilePath, exampleScript);
|
|
33
|
-
}
|
|
34
|
-
console.log('Opening editor...');
|
|
35
|
-
|
|
36
|
-
const filterScript = await editFileWithEditor(filterScriptFilePath);
|
|
37
|
-
const undo = await fixingSpinner(async () => core.applySuggestions(results, selectedRuleIds, filterScript));
|
|
38
|
-
return undo;
|
|
39
|
-
}
|