eslint-interactive 11.0.0 → 11.0.2
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/dist/action/apply-suggestions.d.ts +6 -0
- package/dist/action/apply-suggestions.d.ts.map +1 -0
- package/dist/action/apply-suggestions.js +28 -0
- package/dist/action/apply-suggestions.js.map +1 -0
- package/dist/action/convert-error-to-warning-per-file.d.ts +6 -0
- package/dist/action/convert-error-to-warning-per-file.d.ts.map +1 -0
- package/dist/action/convert-error-to-warning-per-file.js +8 -0
- package/dist/action/convert-error-to-warning-per-file.js.map +1 -0
- package/dist/action/disable-per-file.d.ts +6 -0
- package/dist/action/disable-per-file.d.ts.map +1 -0
- package/dist/action/disable-per-file.js +12 -0
- package/dist/action/disable-per-file.js.map +1 -0
- package/dist/action/disable-per-line.d.ts +6 -0
- package/dist/action/disable-per-line.d.ts.map +1 -0
- package/dist/action/disable-per-line.js +12 -0
- package/dist/action/disable-per-line.js.map +1 -0
- package/dist/action/fix.d.ts +6 -0
- package/dist/action/fix.d.ts.map +1 -0
- package/dist/action/fix.js +6 -0
- package/dist/action/fix.js.map +1 -0
- package/dist/action/index.d.ts +8 -0
- package/dist/action/index.d.ts.map +1 -0
- package/dist/action/index.js +8 -0
- package/dist/action/index.js.map +1 -0
- package/dist/action/make-fixable-and-fix.d.ts +6 -0
- package/dist/action/make-fixable-and-fix.d.ts.map +1 -0
- package/dist/action/make-fixable-and-fix.js +28 -0
- package/dist/action/make-fixable-and-fix.js.map +1 -0
- package/dist/action/print-result-details.d.ts +5 -0
- package/dist/action/print-result-details.d.ts.map +1 -0
- package/dist/action/print-result-details.js +28 -0
- package/dist/action/print-result-details.js.map +1 -0
- package/dist/cli/log.d.ts +6 -0
- package/dist/cli/log.d.ts.map +1 -0
- package/dist/cli/log.js +9 -0
- package/dist/cli/log.js.map +1 -0
- package/dist/cli/ora.d.ts +4 -0
- package/dist/cli/ora.d.ts.map +1 -0
- package/dist/cli/ora.js +23 -0
- package/dist/cli/ora.js.map +1 -0
- package/dist/cli/package.d.ts +2 -0
- package/dist/cli/package.d.ts.map +1 -0
- package/dist/cli/package.js +6 -0
- package/dist/cli/package.js.map +1 -0
- package/dist/cli/pager.d.ts +2 -0
- package/dist/cli/pager.d.ts.map +1 -0
- package/dist/cli/pager.js +34 -0
- package/dist/cli/pager.js.map +1 -0
- package/dist/cli/parse-argv.d.ts +24 -0
- package/dist/cli/parse-argv.d.ts.map +1 -0
- package/dist/cli/parse-argv.js +102 -0
- package/dist/cli/parse-argv.js.map +1 -0
- package/dist/cli/prompt.d.ts +61 -0
- package/dist/cli/prompt.d.ts.map +1 -0
- package/dist/cli/prompt.js +176 -0
- package/dist/cli/prompt.js.map +1 -0
- package/dist/cli/run.d.ts +8 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +66 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/config.d.ts +46 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +91 -0
- package/dist/config.js.map +1 -0
- package/dist/core-worker.d.ts +23 -0
- package/dist/core-worker.d.ts.map +1 -0
- package/dist/core-worker.js +55 -0
- package/dist/core-worker.js.map +1 -0
- package/dist/core.d.ts +79 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +159 -0
- package/dist/core.js.map +1 -0
- package/dist/eslint/linter.d.ts +18 -0
- package/dist/eslint/linter.d.ts.map +1 -0
- package/dist/eslint/linter.js +67 -0
- package/dist/eslint/linter.js.map +1 -0
- package/dist/eslint/report-translator.d.ts +9 -0
- package/dist/eslint/report-translator.d.ts.map +1 -0
- package/dist/eslint/report-translator.js +77 -0
- package/dist/eslint/report-translator.js.map +1 -0
- package/dist/eslint/rule-fixer.d.ts +80 -0
- package/dist/eslint/rule-fixer.d.ts.map +1 -0
- package/dist/eslint/rule-fixer.js +118 -0
- package/dist/eslint/rule-fixer.js.map +1 -0
- package/dist/eslint/source-code-fixer.d.ts +19 -0
- package/dist/eslint/source-code-fixer.d.ts.map +1 -0
- package/dist/eslint/source-code-fixer.js +131 -0
- package/dist/eslint/source-code-fixer.js.map +1 -0
- package/dist/fix/apply-auto-fixes.d.ts +8 -0
- package/dist/fix/apply-auto-fixes.d.ts.map +1 -0
- package/dist/fix/apply-auto-fixes.js +8 -0
- package/dist/fix/apply-auto-fixes.js.map +1 -0
- package/dist/fix/apply-suggestions.d.ts +11 -0
- package/dist/fix/apply-suggestions.d.ts.map +1 -0
- package/dist/fix/apply-suggestions.js +25 -0
- package/dist/fix/apply-suggestions.js.map +1 -0
- package/dist/fix/convert-error-to-warning-per-file.d.ts +10 -0
- package/dist/fix/convert-error-to-warning-per-file.d.ts.map +1 -0
- package/dist/fix/convert-error-to-warning-per-file.js +28 -0
- package/dist/fix/convert-error-to-warning-per-file.js.map +1 -0
- package/dist/fix/disable-per-file.d.ts +12 -0
- package/dist/fix/disable-per-file.d.ts.map +1 -0
- package/dist/fix/disable-per-file.js +63 -0
- package/dist/fix/disable-per-file.js.map +1 -0
- package/dist/fix/disable-per-line.d.ts +12 -0
- package/dist/fix/disable-per-line.d.ts.map +1 -0
- package/dist/fix/disable-per-line.js +61 -0
- package/dist/fix/disable-per-line.js.map +1 -0
- package/dist/fix/index.d.ts +19 -0
- package/dist/fix/index.d.ts.map +1 -0
- package/dist/fix/index.js +8 -0
- package/dist/fix/index.js.map +1 -0
- package/dist/fix/make-fixable-and-fix.d.ts +12 -0
- package/dist/fix/make-fixable-and-fix.d.ts.map +1 -0
- package/dist/fix/make-fixable-and-fix.js +60 -0
- package/dist/fix/make-fixable-and-fix.js.map +1 -0
- package/dist/formatter/colors.d.ts +4 -0
- package/dist/formatter/colors.d.ts.map +1 -0
- package/dist/formatter/colors.js +5 -0
- package/dist/formatter/colors.js.map +1 -0
- package/dist/formatter/format-by-files.d.ts +3 -0
- package/dist/formatter/format-by-files.d.ts.map +1 -0
- package/dist/formatter/format-by-files.js +41 -0
- package/dist/formatter/format-by-files.js.map +1 -0
- package/dist/formatter/format-by-rules.d.ts +3 -0
- package/dist/formatter/format-by-rules.d.ts.map +1 -0
- package/dist/formatter/format-by-rules.js +39 -0
- package/dist/formatter/format-by-rules.js.map +1 -0
- package/dist/formatter/index.d.ts +4 -0
- package/dist/formatter/index.d.ts.map +1 -0
- package/dist/formatter/index.js +7 -0
- package/dist/formatter/index.js.map +1 -0
- package/dist/formatter/take-rule-statistics.d.ts +18 -0
- package/dist/formatter/take-rule-statistics.d.ts.map +1 -0
- package/dist/formatter/take-rule-statistics.js +51 -0
- package/dist/formatter/take-rule-statistics.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/scene/check-results.d.ts +21 -0
- package/dist/scene/check-results.d.ts.map +1 -0
- package/dist/scene/check-results.js +22 -0
- package/dist/scene/check-results.js.map +1 -0
- package/dist/scene/index.d.ts +25 -0
- package/dist/scene/index.d.ts.map +1 -0
- package/dist/scene/index.js +6 -0
- package/dist/scene/index.js.map +1 -0
- package/dist/scene/lint.d.ts +8 -0
- package/dist/scene/lint.d.ts.map +1 -0
- package/dist/scene/lint.js +31 -0
- package/dist/scene/lint.js.map +1 -0
- package/dist/scene/select-action.d.ts +20 -0
- package/dist/scene/select-action.d.ts.map +1 -0
- package/dist/scene/select-action.js +50 -0
- package/dist/scene/select-action.js.map +1 -0
- package/dist/scene/select-rule-ids.d.ts +15 -0
- package/dist/scene/select-rule-ids.d.ts.map +1 -0
- package/dist/scene/select-rule-ids.js +10 -0
- package/dist/scene/select-rule-ids.js.map +1 -0
- package/dist/util/array.d.ts +3 -0
- package/dist/util/array.d.ts.map +1 -0
- package/dist/util/array.js +14 -0
- package/dist/util/array.js.map +1 -0
- package/dist/util/cache.d.ts +5 -0
- package/dist/util/cache.d.ts.map +1 -0
- package/dist/util/cache.js +15 -0
- package/dist/util/cache.js.map +1 -0
- package/dist/util/eslint.d.ts +99 -0
- package/dist/util/eslint.d.ts.map +1 -0
- package/dist/util/eslint.js +201 -0
- package/dist/util/eslint.js.map +1 -0
- package/dist/util/filter-script.d.ts +6 -0
- package/dist/util/filter-script.d.ts.map +1 -0
- package/dist/util/filter-script.js +38 -0
- package/dist/util/filter-script.js.map +1 -0
- package/dist/util/type-check.d.ts +6 -0
- package/dist/util/type-check.d.ts.map +1 -0
- package/dist/util/type-check.js +8 -0
- package/dist/util/type-check.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/cli/prompt.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAUhC;;GAEG;AACH,MAAM,MAAM,MAAM,GACd,oBAAoB,GACpB,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,8BAA8B,GAC9B,kBAAkB,GAClB,mBAAmB,GACnB,eAAe,CAAC;AAEpB;;;;;;GAMG;AACH,KAAK,WAAW,GAAG,iBAAiB,GAAG,0BAA0B,GAAG,aAAa,CAAC;AAElF;;GAEG;AACH,KAAK,QAAQ,GAAG,eAAe,GAAG,MAAM,GAAG,YAAY,CAAC;AAExD,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,cAAc,CAAC;AAE9D;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,gBAAgB,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAgBxF;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAC5B,eAAe,EAAE,MAAM,EAAE,EACzB,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC,CA2CjB;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,WAAW,CAAC,CAiBrE;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAY5E;AAED;;;GAGG;AACH,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAgBrF;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,QAAQ,CAAC,CAenE;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,OAAO,CAAC,CAWvE;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,OAAO,CAAC,CAWjE"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/* istanbul ignore file */
|
|
2
|
+
import enquirer from 'enquirer';
|
|
3
|
+
import { takeRuleStatistics } from '../formatter/index.js';
|
|
4
|
+
const { prompt } = enquirer;
|
|
5
|
+
// When combined with worker, for some reason the enquirer grabs the SIGINT and the process continues to survive.
|
|
6
|
+
// Therefore, the process is explicitly terminated.
|
|
7
|
+
// eslint-disable-next-line n/no-process-exit
|
|
8
|
+
const onCancel = () => process.exit();
|
|
9
|
+
/**
|
|
10
|
+
* Ask the user for the rule ids to which they want to apply the action.
|
|
11
|
+
* @param ruleIdsInResults The rule ids that are in the lint results.
|
|
12
|
+
* @returns The rule ids
|
|
13
|
+
*/
|
|
14
|
+
export async function promptToInputRuleIds(ruleIdsInResults) {
|
|
15
|
+
const { ruleIds } = await prompt([
|
|
16
|
+
{
|
|
17
|
+
name: 'ruleIds',
|
|
18
|
+
type: 'multiselect',
|
|
19
|
+
message: 'Which rules would you like to apply action?',
|
|
20
|
+
// @ts-expect-error
|
|
21
|
+
hint: 'Select all you want with <space> key.',
|
|
22
|
+
choices: ruleIdsInResults,
|
|
23
|
+
validate(value) {
|
|
24
|
+
return value.length === 0 ? `Select at least one rule with <space> key.` : true;
|
|
25
|
+
},
|
|
26
|
+
onCancel,
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
return ruleIds;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Ask the user what action they want to perform.
|
|
33
|
+
* @returns The action name
|
|
34
|
+
*/
|
|
35
|
+
export async function promptToInputAction(results, selectedRuleIds, initialAction) {
|
|
36
|
+
const ruleStatistics = takeRuleStatistics(results).filter((ruleStatistic) => selectedRuleIds.includes(ruleStatistic.ruleId));
|
|
37
|
+
const foldedStatistics = ruleStatistics.reduce((a, b) => ({
|
|
38
|
+
isFixableCount: a.isFixableCount + b.isFixableCount,
|
|
39
|
+
hasSuggestionsCount: a.hasSuggestionsCount + b.hasSuggestionsCount,
|
|
40
|
+
}), { isFixableCount: 0, hasSuggestionsCount: 0 });
|
|
41
|
+
const choices = [
|
|
42
|
+
{ name: 'printResultDetails', message: '🔎 Display details of lint results' },
|
|
43
|
+
{ name: 'applyAutoFixes', message: '🔧 Run `eslint --fix`', disabled: foldedStatistics.isFixableCount === 0 },
|
|
44
|
+
{ name: 'disablePerLine', message: '🔧 Disable per line' },
|
|
45
|
+
{ name: 'disablePerFile', message: '🔧 Disable per file' },
|
|
46
|
+
{ name: 'convertErrorToWarningPerFile', message: '🔧 Convert error to warning per file' },
|
|
47
|
+
{
|
|
48
|
+
name: 'applySuggestions',
|
|
49
|
+
message: '🔧 Apply suggestions (experimental, for experts)',
|
|
50
|
+
disabled: foldedStatistics.hasSuggestionsCount === 0,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'makeFixableAndFix',
|
|
54
|
+
message: '🔧 Make forcibly fixable and run `eslint --fix` (experimental, for experts)',
|
|
55
|
+
},
|
|
56
|
+
{ name: 'reselectRules', message: '↩️ Reselect rules' },
|
|
57
|
+
];
|
|
58
|
+
const { action } = await prompt([
|
|
59
|
+
{
|
|
60
|
+
name: 'action',
|
|
61
|
+
type: 'select',
|
|
62
|
+
message: 'Which action do you want to do?',
|
|
63
|
+
choices,
|
|
64
|
+
initial: choices.findIndex((choice) => choice.name === initialAction) ?? 0,
|
|
65
|
+
onCancel,
|
|
66
|
+
},
|
|
67
|
+
]);
|
|
68
|
+
return action;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Ask the user how to display the lint results.
|
|
72
|
+
* @returns How to display
|
|
73
|
+
*/
|
|
74
|
+
export async function promptToInputDisplayMode() {
|
|
75
|
+
const { displayMode } = await prompt([
|
|
76
|
+
{
|
|
77
|
+
name: 'displayMode',
|
|
78
|
+
type: 'select',
|
|
79
|
+
message: 'In what way are the details displayed?',
|
|
80
|
+
choices: [
|
|
81
|
+
{ name: 'printInTerminal', message: '🖨 Print in terminal' },
|
|
82
|
+
{ name: 'printInTerminalWithPager', message: '↕️ Print in terminal with pager' },
|
|
83
|
+
{ name: 'writeToFile', message: '📝 Write to file' },
|
|
84
|
+
],
|
|
85
|
+
onCancel,
|
|
86
|
+
},
|
|
87
|
+
]);
|
|
88
|
+
return displayMode;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Ask the user a description to leave in directive.
|
|
92
|
+
* @returns The description
|
|
93
|
+
*/
|
|
94
|
+
export async function promptToInputDescription() {
|
|
95
|
+
const { description } = await prompt([
|
|
96
|
+
{
|
|
97
|
+
name: 'description',
|
|
98
|
+
type: 'input',
|
|
99
|
+
message: 'Leave a code comment with your reason for fixing (Optional)',
|
|
100
|
+
onCancel,
|
|
101
|
+
},
|
|
102
|
+
]);
|
|
103
|
+
return description === '' ? undefined : description;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Ask the user a position of the description
|
|
107
|
+
* @returns The description position
|
|
108
|
+
*/
|
|
109
|
+
export async function promptToInputDescriptionPosition() {
|
|
110
|
+
const { descriptionPosition } = await prompt([
|
|
111
|
+
{
|
|
112
|
+
name: 'descriptionPosition',
|
|
113
|
+
type: 'select',
|
|
114
|
+
message: 'Where would you like to position the code comment?',
|
|
115
|
+
choices: [
|
|
116
|
+
{ name: 'sameLine', message: "Same Line - Place on the same line as the eslint's disable comment." },
|
|
117
|
+
{ name: 'previousLine', message: "Previous Line - Place on the line before the eslint's disable comment." },
|
|
118
|
+
],
|
|
119
|
+
onCancel,
|
|
120
|
+
},
|
|
121
|
+
]);
|
|
122
|
+
return descriptionPosition;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Ask the user what to do next.
|
|
126
|
+
* @returns What to do next.
|
|
127
|
+
*/
|
|
128
|
+
export async function promptToInputWhatToDoNext() {
|
|
129
|
+
const { nextStep } = await prompt([
|
|
130
|
+
{
|
|
131
|
+
name: 'nextStep',
|
|
132
|
+
type: 'select',
|
|
133
|
+
message: "What's the next step?",
|
|
134
|
+
choices: [
|
|
135
|
+
{ name: 'fixOtherRules', message: '🔧 Fix other rules' },
|
|
136
|
+
{ name: 'undoTheFix', message: '↩️ Undo the fix' },
|
|
137
|
+
{ name: 'exit', message: '💚 Exit' },
|
|
138
|
+
],
|
|
139
|
+
onCancel,
|
|
140
|
+
},
|
|
141
|
+
]);
|
|
142
|
+
return nextStep;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Ask the user if they want to reuse the filter script.
|
|
146
|
+
* @returns If it reuses, `true`, if not, `false`.
|
|
147
|
+
*/
|
|
148
|
+
export async function promptToInputReuseFilterScript() {
|
|
149
|
+
const { reuseFilterScript } = await prompt([
|
|
150
|
+
{
|
|
151
|
+
name: 'reuseFilterScript',
|
|
152
|
+
type: 'confirm',
|
|
153
|
+
message: 'Do you want to reuse a previously edited filter script?',
|
|
154
|
+
initial: true,
|
|
155
|
+
onCancel,
|
|
156
|
+
},
|
|
157
|
+
]);
|
|
158
|
+
return reuseFilterScript;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Ask the user if they want to reuse the script.
|
|
162
|
+
* @returns If it reuses, `true`, if not, `false`.
|
|
163
|
+
*/
|
|
164
|
+
export async function promptToInputReuseScript() {
|
|
165
|
+
const { reuseScript } = await prompt([
|
|
166
|
+
{
|
|
167
|
+
name: 'reuseScript',
|
|
168
|
+
type: 'confirm',
|
|
169
|
+
message: 'Do you want to reuse a previously edited script?',
|
|
170
|
+
initial: true,
|
|
171
|
+
onCancel,
|
|
172
|
+
},
|
|
173
|
+
]);
|
|
174
|
+
return reuseScript;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/cli/prompt.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;AAE5B,iHAAiH;AACjH,mDAAmD;AACnD,6CAA6C;AAC7C,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;AA+BtC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,gBAA0B;IACnE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAwB;QACtD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,6CAA6C;YACtD,mBAAmB;YACnB,IAAI,EAAE,uCAAuC;YAC7C,OAAO,EAAE,gBAAgB;YACzB,QAAQ,CAAC,KAAK;gBACZ,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC,IAAI,CAAC;YAClF,CAAC;YACD,QAAQ;SACT;KACF,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAA4B,EAC5B,eAAyB,EACzB,aAAsB;IAEtB,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,EAAE,CAC1E,eAAe,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAC/C,CAAC;IACF,MAAM,gBAA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AAC;CAChB,CAAC;AAEF;;GAEG;AACH,wBAAsB,GAAG,CAAC,OAAO,EAAE,OAAO,iBAiDzC"}
|
package/dist/cli/run.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { dirname, join } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { Worker } from 'node:worker_threads';
|
|
4
|
+
import { wrap } from 'comlink';
|
|
5
|
+
import nodeEndpoint from 'comlink/dist/esm/node-adapter.mjs';
|
|
6
|
+
import eslintPkg from 'eslint/use-at-your-own-risk';
|
|
7
|
+
import isInstalledGlobally from 'is-installed-globally';
|
|
8
|
+
import terminalLink from 'terminal-link';
|
|
9
|
+
import { warn } from '../cli/log.js';
|
|
10
|
+
import { parseArgv } from '../cli/parse-argv.js';
|
|
11
|
+
import { translateCLIOptions } from '../config.js';
|
|
12
|
+
import { lint, selectAction, selectRuleIds, checkResults } from '../scene/index.js';
|
|
13
|
+
const { shouldUseFlatConfig } = eslintPkg;
|
|
14
|
+
/**
|
|
15
|
+
* Run eslint-interactive.
|
|
16
|
+
*/
|
|
17
|
+
export async function run(options) {
|
|
18
|
+
if (isInstalledGlobally) {
|
|
19
|
+
warn('eslint-interactive is installed globally. ' +
|
|
20
|
+
'The globally installed eslint-interactive is not officially supported because some features do not work. ' +
|
|
21
|
+
'It is recommended to install eslint-interactive locally.');
|
|
22
|
+
}
|
|
23
|
+
const parsedCLIOptions = parseArgv(options.argv);
|
|
24
|
+
const usingFlatConfig = await shouldUseFlatConfig();
|
|
25
|
+
const config = translateCLIOptions(parsedCLIOptions, usingFlatConfig ? 'flat' : 'eslintrc');
|
|
26
|
+
// Directly executing the Core API will hog the main thread and halt the spinner.
|
|
27
|
+
// So we wrap it with comlink and run it on the Worker.
|
|
28
|
+
const worker = new Worker(join(dirname(fileURLToPath(import.meta.url)), '..', 'core-worker.js'), {
|
|
29
|
+
env: {
|
|
30
|
+
...process.env,
|
|
31
|
+
// NOTE:
|
|
32
|
+
// - `terminal-link` uses `supports-hyperlinks` and `supports-color` to determine if a terminal that supports hyperlinks is in use.
|
|
33
|
+
// - If the terminal does not support hyperlinks, it will fallback to not print the link.
|
|
34
|
+
// - However, due to the specifications of Node.js, the decision does not work well on worker_threads.
|
|
35
|
+
// - So here we use a special environment variable to force the printing mode to be switched.
|
|
36
|
+
// ref: https://github.com/chalk/supports-color/issues/97, https://github.com/nodejs/node/issues/26946
|
|
37
|
+
FORCE_HYPERLINK: terminalLink.isSupported ? '1' : '0',
|
|
38
|
+
},
|
|
39
|
+
// NOTE: Pass CLI options (--experimental-import-meta-resolve, etc.) to the worker
|
|
40
|
+
execArgv: process.execArgv,
|
|
41
|
+
});
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
const ProxiedCore = wrap(nodeEndpoint(worker));
|
|
44
|
+
const core = await new ProxiedCore(config);
|
|
45
|
+
let nextScene = { name: 'lint' };
|
|
46
|
+
while (nextScene.name !== 'exit') {
|
|
47
|
+
if (nextScene.name === 'lint') {
|
|
48
|
+
// eslint-disable-next-line no-await-in-loop
|
|
49
|
+
nextScene = await lint(core);
|
|
50
|
+
}
|
|
51
|
+
else if (nextScene.name === 'selectRuleIds') {
|
|
52
|
+
// eslint-disable-next-line no-await-in-loop
|
|
53
|
+
nextScene = await selectRuleIds(core, nextScene.args);
|
|
54
|
+
}
|
|
55
|
+
else if (nextScene.name === 'selectAction') {
|
|
56
|
+
// eslint-disable-next-line no-await-in-loop
|
|
57
|
+
nextScene = await selectAction(core, nextScene.args);
|
|
58
|
+
}
|
|
59
|
+
else if (nextScene.name === 'checkResults') {
|
|
60
|
+
// eslint-disable-next-line no-await-in-loop
|
|
61
|
+
nextScene = await checkResults(nextScene.args);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
await worker.terminate();
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","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AAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { LegacyESLint, FlatESLint } from 'eslint/use-at-your-own-risk';
|
|
2
|
+
import { ParsedCLIOptions } from './cli/parse-argv.js';
|
|
3
|
+
type LegacyESLintOptions = {
|
|
4
|
+
type: 'eslintrc';
|
|
5
|
+
} & Pick<LegacyESLint.Options, 'useEslintrc' | 'overrideConfigFile' | 'extensions' | 'rulePaths' | 'ignorePath' | 'cache' | 'cacheLocation' | 'overrideConfig' | 'cwd' | 'resolvePluginsRelativeTo'>;
|
|
6
|
+
type FlatESLintOptions = {
|
|
7
|
+
type: 'flat';
|
|
8
|
+
} & Pick<FlatESLint.Options, 'overrideConfigFile' | 'cache' | 'cacheLocation' | 'overrideConfig' | 'cwd'>;
|
|
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
|
+
};
|
|
18
|
+
type ESLintOptionsType = 'eslintrc' | 'flat';
|
|
19
|
+
export declare function translateCLIOptions(options: ParsedCLIOptions, eslintOptionsType: ESLintOptionsType): Config;
|
|
20
|
+
/** Default config of `Core` */
|
|
21
|
+
export declare const configDefaults: {
|
|
22
|
+
formatterName: string;
|
|
23
|
+
quiet: false;
|
|
24
|
+
cwd: string;
|
|
25
|
+
eslintOptions: {
|
|
26
|
+
useEslintrc: true;
|
|
27
|
+
overrideConfigFile: undefined;
|
|
28
|
+
extensions: undefined;
|
|
29
|
+
rulePaths: undefined;
|
|
30
|
+
ignorePath: undefined;
|
|
31
|
+
cache: true;
|
|
32
|
+
cacheLocation: string;
|
|
33
|
+
overrideConfig: undefined;
|
|
34
|
+
resolvePluginsRelativeTo: undefined;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export type NormalizedConfig = {
|
|
38
|
+
patterns: string[];
|
|
39
|
+
formatterName: string;
|
|
40
|
+
quiet: boolean;
|
|
41
|
+
cwd: string;
|
|
42
|
+
eslintOptions: ESLintOptions;
|
|
43
|
+
};
|
|
44
|
+
export declare function normalizeConfig(config: Config): NormalizedConfig;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAsB,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE3E,KAAK,mBAAmB,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG,IAAI,CACpD,YAAY,CAAC,OAAO,EAClB,aAAa,GACb,oBAAoB,GACpB,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,OAAO,GACP,eAAe,GACf,gBAAgB,GAChB,KAAK,GACL,0BAA0B,CAC7B,CAAC;AACF,KAAK,iBAAiB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAC9C,UAAU,CAAC,OAAO,EAClB,oBAAoB,GAAG,OAAO,GAAG,eAAe,GAAG,gBAAgB,GAAG,KAAK,CAC5E,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AAEpE,uCAAuC;AACvC,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,KAAK,iBAAiB,GAAG,UAAU,GAAG,MAAM,CAAC;AAE7C,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,MAAM,CAiC3G;AAED,+BAA+B;AAC/B,eAAO,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,CAmChE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new Error(`Unexpected configType: ${String(eslintOptionsType)}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** Default config of `Core` */
|
|
39
|
+
export const configDefaults = {
|
|
40
|
+
formatterName: cliOptionsDefaults.formatterName,
|
|
41
|
+
quiet: cliOptionsDefaults.quiet,
|
|
42
|
+
cwd: process.cwd(),
|
|
43
|
+
eslintOptions: {
|
|
44
|
+
useEslintrc: cliOptionsDefaults.useEslintrc,
|
|
45
|
+
overrideConfigFile: undefined,
|
|
46
|
+
extensions: undefined,
|
|
47
|
+
rulePaths: undefined,
|
|
48
|
+
ignorePath: undefined,
|
|
49
|
+
cache: cliOptionsDefaults.cache,
|
|
50
|
+
cacheLocation: cliOptionsDefaults.cacheLocation,
|
|
51
|
+
overrideConfig: undefined,
|
|
52
|
+
resolvePluginsRelativeTo: undefined,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
export function normalizeConfig(config) {
|
|
56
|
+
const cwd = config.cwd ?? configDefaults.cwd;
|
|
57
|
+
let eslintOptions;
|
|
58
|
+
if (config.eslintOptions.type === 'eslintrc') {
|
|
59
|
+
eslintOptions = {
|
|
60
|
+
type: 'eslintrc',
|
|
61
|
+
useEslintrc: config.eslintOptions.useEslintrc ?? configDefaults.eslintOptions.useEslintrc,
|
|
62
|
+
overrideConfigFile: config.eslintOptions.overrideConfigFile ?? configDefaults.eslintOptions.overrideConfigFile,
|
|
63
|
+
extensions: config.eslintOptions.extensions ?? configDefaults.eslintOptions.extensions,
|
|
64
|
+
rulePaths: config.eslintOptions.rulePaths ?? configDefaults.eslintOptions.rulePaths,
|
|
65
|
+
ignorePath: config.eslintOptions.ignorePath ?? configDefaults.eslintOptions.ignorePath,
|
|
66
|
+
cache: config.eslintOptions.cache ?? configDefaults.eslintOptions.cache,
|
|
67
|
+
cacheLocation: config.eslintOptions.cacheLocation ?? configDefaults.eslintOptions.cacheLocation,
|
|
68
|
+
overrideConfig: config.eslintOptions.overrideConfig ?? configDefaults.eslintOptions.overrideConfig,
|
|
69
|
+
cwd,
|
|
70
|
+
resolvePluginsRelativeTo: config.eslintOptions.resolvePluginsRelativeTo ?? configDefaults.eslintOptions.resolvePluginsRelativeTo,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
eslintOptions = {
|
|
75
|
+
type: 'flat',
|
|
76
|
+
overrideConfigFile: config.eslintOptions.overrideConfigFile ?? configDefaults.eslintOptions.overrideConfigFile,
|
|
77
|
+
cache: config.eslintOptions.cache ?? configDefaults.eslintOptions.cache,
|
|
78
|
+
cacheLocation: config.eslintOptions.cacheLocation ?? configDefaults.eslintOptions.cacheLocation,
|
|
79
|
+
overrideConfig: config.eslintOptions.overrideConfig ?? configDefaults.eslintOptions.overrideConfig,
|
|
80
|
+
cwd,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
patterns: config.patterns,
|
|
85
|
+
formatterName: config.formatterName ?? configDefaults.formatterName,
|
|
86
|
+
quiet: config.quiet ?? configDefaults.quiet,
|
|
87
|
+
cwd,
|
|
88
|
+
eslintOptions,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAoB,MAAM,qBAAqB,CAAC;AAiC3E,MAAM,UAAU,mBAAmB,CAAC,OAAyB,EAAE,iBAAoC;IACjG,IAAI,iBAAiB,KAAK,UAAU,EAAE;QACpC,OAAO;YACL,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AAa,GAAG;YACd,IAAI,EAAE,MAAM;YACZ,kBAAkB,EAAE,MAAM,CAAC,aAAa,CAAC,kBAAkB,IAAI,cAAc,CAAC,aAAa,CAAC,kBAAkB;YAC9G,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK,IAAI,cAAc,CAAC,aAAa,CAAC,KAAK;YACvE,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC,aAAa,IAAI,cAAc,CAAC,aAAa,CAAC,aAAa;YAC/F,cAAc,EAAE,MAAM,CAAC,aAAa,CAAC,cAAc,IAAI,cAAc,CAAC,aAAa,CAAC,cAAc;YAClG,GAAG;SACJ,CAAC;KACH;IACD,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,cAAc,CAAC,aAAa;QACnE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,cAAc,CAAC,KAAK;QAC3C,GAAG;QACH,aAAa;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ESLint } from 'eslint';
|
|
2
|
+
import { Config } from './config.js';
|
|
3
|
+
import { Core } from './core.js';
|
|
4
|
+
/**
|
|
5
|
+
* This is a wrapper for using the Core API from comlink.
|
|
6
|
+
*
|
|
7
|
+
* The arguments of the methods wrapped in comlink must be serializable.
|
|
8
|
+
* The methods in this class are serializable versions of the Core API methods.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SerializableCore {
|
|
11
|
+
readonly core: Core;
|
|
12
|
+
constructor(config: Config);
|
|
13
|
+
lint(...args: Parameters<Core['lint']>): ReturnType<Core['lint']>;
|
|
14
|
+
formatResultSummary(...args: Parameters<Core['formatResultSummary']>): ReturnType<Core['formatResultSummary']>;
|
|
15
|
+
formatResultDetails(...args: Parameters<Core['formatResultDetails']>): ReturnType<Core['formatResultDetails']>;
|
|
16
|
+
applyAutoFixes(...args: Parameters<Core['applyAutoFixes']>): ReturnType<Core['applyAutoFixes']>;
|
|
17
|
+
disablePerLine(...args: Parameters<Core['disablePerLine']>): ReturnType<Core['disablePerLine']>;
|
|
18
|
+
disablePerFile(...args: Parameters<Core['disablePerFile']>): ReturnType<Core['disablePerFile']>;
|
|
19
|
+
convertErrorToWarningPerFile(...args: Parameters<Core['convertErrorToWarningPerFile']>): ReturnType<Core['convertErrorToWarningPerFile']>;
|
|
20
|
+
applySuggestions(results: ESLint.LintResult[], ruleIds: string[], filterScript: string): ReturnType<Core['applySuggestions']>;
|
|
21
|
+
makeFixableAndFix(results: ESLint.LintResult[], ruleIds: string[], fixableMakerScript: string): ReturnType<Core['makeFixableAndFix']>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=core-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-worker.d.ts","sourceRoot":"","sources":["../src/core-worker.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AASjC;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;gBACR,MAAM,EAAE,MAAM;IAGpB,IAAI,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAGvE,mBAAmB,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAGxG,mBAAmB,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAG9G,cAAc,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAG/F,cAAc,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAG/F,cAAc,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAG/F,4BAA4B,CAChC,GAAG,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,GACxD,UAAU,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;IAG7C,gBAAgB,CACpB,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAC5B,OAAO,EAAE,MAAM,EAAE,EACjB,YAAY,EAAE,MAAM,GACnB,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAKjC,iBAAiB,CACrB,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAC5B,OAAO,EAAE,MAAM,EAAE,EACjB,kBAAkB,EAAE,MAAM,GACzB,UAAU,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;CAKzC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { parentPort } from 'node:worker_threads';
|
|
2
|
+
import { expose, proxy } from 'comlink';
|
|
3
|
+
import nodeEndpoint from 'comlink/dist/esm/node-adapter.mjs';
|
|
4
|
+
import { Core } from './core.js';
|
|
5
|
+
/**
|
|
6
|
+
* @file This is a wrapper module for using the Core API with comlink.
|
|
7
|
+
*/
|
|
8
|
+
if (parentPort === null)
|
|
9
|
+
throw new Error('This module must be started on a worker.');
|
|
10
|
+
/**
|
|
11
|
+
* This is a wrapper for using the Core API from comlink.
|
|
12
|
+
*
|
|
13
|
+
* The arguments of the methods wrapped in comlink must be serializable.
|
|
14
|
+
* The methods in this class are serializable versions of the Core API methods.
|
|
15
|
+
*/
|
|
16
|
+
export class SerializableCore {
|
|
17
|
+
core;
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.core = new Core(config);
|
|
20
|
+
}
|
|
21
|
+
async lint(...args) {
|
|
22
|
+
return this.core.lint(...args);
|
|
23
|
+
}
|
|
24
|
+
formatResultSummary(...args) {
|
|
25
|
+
return this.core.formatResultSummary(...args);
|
|
26
|
+
}
|
|
27
|
+
async formatResultDetails(...args) {
|
|
28
|
+
return this.core.formatResultDetails(...args);
|
|
29
|
+
}
|
|
30
|
+
async applyAutoFixes(...args) {
|
|
31
|
+
return proxy(await this.core.applyAutoFixes(...args));
|
|
32
|
+
}
|
|
33
|
+
async disablePerLine(...args) {
|
|
34
|
+
return proxy(await this.core.disablePerLine(...args));
|
|
35
|
+
}
|
|
36
|
+
async disablePerFile(...args) {
|
|
37
|
+
return proxy(await this.core.disablePerFile(...args));
|
|
38
|
+
}
|
|
39
|
+
async convertErrorToWarningPerFile(...args) {
|
|
40
|
+
return proxy(await this.core.convertErrorToWarningPerFile(...args));
|
|
41
|
+
}
|
|
42
|
+
async applySuggestions(results, ruleIds, filterScript) {
|
|
43
|
+
// eslint-disable-next-line no-eval -- TODO: replace with a better solution
|
|
44
|
+
const filter = eval(filterScript);
|
|
45
|
+
return proxy(await this.core.applySuggestions(results, ruleIds, filter));
|
|
46
|
+
}
|
|
47
|
+
async makeFixableAndFix(results, ruleIds, fixableMakerScript) {
|
|
48
|
+
// eslint-disable-next-line no-eval -- TODO: replace with a better solution
|
|
49
|
+
const fixableMaker = eval(fixableMakerScript);
|
|
50
|
+
return proxy(await this.core.makeFixableAndFix(results, ruleIds, fixableMaker));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
expose(SerializableCore, nodeEndpoint(parentPort));
|
|
55
|
+
//# source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CAAC;IACxD,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,GAAG,IAAwC;QAC9D,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACxD,CAAC;IACD,KAAK,CAAC,4BAA4B,CAChC,GAAG,IAAsD;QAEzD,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACtE,CAAC;IACD,KAAK,CAAC,gBAAgB,CACpB,OAA4B,EAC5B,OAAiB,EACjB,YAAoB;QAEpB,2EAA2E;QAC3E,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAqB,CAAC;QACtD,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3E,CAAC;IACD,KAAK,CAAC,iBAAiB,CACrB,OAA4B,EAC5B,OAAiB,EACjB,kBAA0B;QAE1B,2EAA2E;QAC3E,MAAM,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAiB,CAAC;QAC9D,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;IAClF,CAAC;CACF;AAED,8DAA8D;AAC9D,MAAM,CAAC,gBAAgB,EAAG,YAAoB,CAAC,UAAU,CAAC,CAAC,CAAC"}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ESLint } from 'eslint';
|
|
2
|
+
import { LegacyESLint as LegacyESLintNS } from 'eslint/use-at-your-own-risk';
|
|
3
|
+
import { DescriptionPosition } from './cli/prompt.js';
|
|
4
|
+
import { Config, NormalizedConfig } from './config.js';
|
|
5
|
+
import { FixableMaker, SuggestionFilter } from './fix/index.js';
|
|
6
|
+
export type Undo = () => Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* The core of eslint-interactive.
|
|
9
|
+
* It uses ESLint's Node.js API to output a summary of problems, fix problems, apply suggestions, etc.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Core {
|
|
12
|
+
readonly config: NormalizedConfig;
|
|
13
|
+
readonly eslint: LegacyESLintNS;
|
|
14
|
+
constructor(config: Config);
|
|
15
|
+
/**
|
|
16
|
+
* Lint project.
|
|
17
|
+
* @returns The results of linting
|
|
18
|
+
*/
|
|
19
|
+
lint(): Promise<ESLint.LintResult[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Returns summary of lint results.
|
|
22
|
+
* @param results The lint results of the project to print summary
|
|
23
|
+
*/
|
|
24
|
+
formatResultSummary(results: ESLint.LintResult[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* Returns details of lint results.
|
|
27
|
+
* @param results The lint results of the project to print summary
|
|
28
|
+
* @param ruleIds The rule ids to print details
|
|
29
|
+
*/
|
|
30
|
+
formatResultDetails(results: LegacyESLintNS.LintResult[], ruleIds: (string | null)[]): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Run `eslint --fix`.
|
|
33
|
+
* @param ruleIds The rule ids to fix
|
|
34
|
+
*/
|
|
35
|
+
applyAutoFixes(results: LegacyESLintNS.LintResult[], ruleIds: string[]): Promise<Undo>;
|
|
36
|
+
/**
|
|
37
|
+
* Add disable comments per line.
|
|
38
|
+
* @param results The lint results of the project to add disable comments
|
|
39
|
+
* @param ruleIds The rule ids to add disable comments
|
|
40
|
+
* @param description The description of the disable comments
|
|
41
|
+
* @param descriptionPosition The position of the description
|
|
42
|
+
*/
|
|
43
|
+
disablePerLine(results: LegacyESLintNS.LintResult[], ruleIds: string[], description?: string, descriptionPosition?: DescriptionPosition): Promise<Undo>;
|
|
44
|
+
/**
|
|
45
|
+
* Add disable comments per file.
|
|
46
|
+
* @param results The lint results of the project to add disable comments
|
|
47
|
+
* @param ruleIds The rule ids to add disable comments
|
|
48
|
+
* @param description The description of the disable comments
|
|
49
|
+
* @param descriptionPosition The position of the description
|
|
50
|
+
*/
|
|
51
|
+
disablePerFile(results: LegacyESLintNS.LintResult[], ruleIds: string[], description?: string, descriptionPosition?: DescriptionPosition): Promise<Undo>;
|
|
52
|
+
/**
|
|
53
|
+
* Convert error to warning per file.
|
|
54
|
+
* @param results The lint results of the project to convert
|
|
55
|
+
* @param ruleIds The rule ids to convert
|
|
56
|
+
* @param description The comment explaining the reason for converting
|
|
57
|
+
*/
|
|
58
|
+
convertErrorToWarningPerFile(results: LegacyESLintNS.LintResult[], ruleIds: string[], description?: string): Promise<Undo>;
|
|
59
|
+
/**
|
|
60
|
+
* Apply suggestions.
|
|
61
|
+
* @param results The lint results of the project to apply suggestions
|
|
62
|
+
* @param ruleIds The rule ids to apply suggestions
|
|
63
|
+
* @param filter The script to filter suggestions
|
|
64
|
+
*/
|
|
65
|
+
applySuggestions(results: LegacyESLintNS.LintResult[], ruleIds: string[], filter: SuggestionFilter): Promise<Undo>;
|
|
66
|
+
/**
|
|
67
|
+
* Make forcibly fixable and run `eslint --fix`.
|
|
68
|
+
* @param results The lint results of the project to apply suggestions
|
|
69
|
+
* @param ruleIds The rule ids to apply suggestions
|
|
70
|
+
* @param fixableMaker The function to make `Linter.LintMessage` forcibly fixable.
|
|
71
|
+
*/
|
|
72
|
+
makeFixableAndFix(results: LegacyESLintNS.LintResult[], ruleIds: string[], fixableMaker: FixableMaker): Promise<Undo>;
|
|
73
|
+
/**
|
|
74
|
+
* Fix source codes.
|
|
75
|
+
* @param fix The fix information to do.
|
|
76
|
+
*/
|
|
77
|
+
private fix;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAgB,MAAM,QAAQ,CAAC;AAC9C,OAAkB,EAAE,YAA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