eslint-interactive 13.0.0 → 14.0.0
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 +19 -10
- package/dist/action/convert-error-to-warning-per-file.d.ts +4 -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 +4 -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 +4 -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 +4 -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 +6 -0
- package/dist/action/index.d.ts.map +1 -0
- package/dist/action/index.js +6 -0
- package/dist/action/index.js.map +1 -0
- package/dist/action/print-result-details.d.ts +4 -0
- package/dist/action/print-result-details.d.ts.map +1 -0
- package/dist/action/print-result-details.js +36 -0
- package/dist/action/print-result-details.js.map +1 -0
- package/dist/cli/log.d.ts +7 -0
- package/dist/cli/log.d.ts.map +1 -0
- package/dist/cli/log.js +35 -0
- package/dist/cli/log.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 +4 -0
- package/dist/cli/parse-argv.d.ts.map +1 -0
- package/dist/cli/parse-argv.js +103 -0
- package/dist/cli/parse-argv.js.map +1 -0
- package/dist/cli/prompt.d.ts +51 -0
- package/dist/cli/prompt.d.ts.map +1 -0
- package/dist/cli/prompt.js +97 -0
- package/dist/cli/prompt.js.map +1 -0
- package/dist/cli/run.d.ts +6 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +28 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/core.d.ts +82 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +189 -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 +71 -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 +75 -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 +114 -0
- package/dist/eslint/rule-fixer.js.map +1 -0
- package/dist/eslint/source-code-fixer.d.ts +15 -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 +72 -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 +11 -0
- package/dist/fix/make-fixable-and-fix.d.ts.map +1 -0
- package/dist/fix/make-fixable-and-fix.js +35 -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/filter-rule-statistics.d.ts +9 -0
- package/dist/formatter/filter-rule-statistics.d.ts.map +1 -0
- package/dist/formatter/filter-rule-statistics.js +22 -0
- package/dist/formatter/filter-rule-statistics.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 +42 -0
- package/dist/formatter/format-by-files.js.map +1 -0
- package/dist/formatter/format-by-rules.d.ts +9 -0
- package/dist/formatter/format-by-rules.d.ts.map +1 -0
- package/dist/formatter/format-by-rules.js +33 -0
- package/dist/formatter/format-by-rules.js.map +1 -0
- package/dist/formatter/format-table.d.ts +4 -0
- package/dist/formatter/format-table.d.ts.map +1 -0
- package/dist/formatter/format-table.js +62 -0
- package/dist/formatter/format-table.js.map +1 -0
- package/dist/formatter/index.d.ts +7 -0
- package/dist/formatter/index.d.ts.map +1 -0
- package/dist/formatter/index.js +9 -0
- package/dist/formatter/index.js.map +1 -0
- 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/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 +6 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +4 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +87 -0
- package/dist/plugin.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 +19 -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 +7 -0
- package/dist/scene/lint.d.ts.map +1 -0
- package/dist/scene/lint.js +34 -0
- package/dist/scene/lint.js.map +1 -0
- package/dist/scene/select-action.d.ts +19 -0
- package/dist/scene/select-action.d.ts.map +1 -0
- package/dist/scene/select-action.js +44 -0
- package/dist/scene/select-action.js.map +1 -0
- package/dist/scene/select-rule-ids.d.ts +14 -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/type.d.ts +14 -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/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/eslint.d.ts +103 -0
- package/dist/util/eslint.d.ts.map +1 -0
- package/dist/util/eslint.js +220 -0
- package/dist/util/eslint.js.map +1 -0
- package/dist/util/terminal-link.d.ts +2 -0
- package/dist/util/terminal-link.d.ts.map +1 -0
- package/dist/util/terminal-link.js +16 -0
- package/dist/util/terminal-link.js.map +1 -0
- package/dist/util/type-check.d.ts +3 -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 +22 -24
- package/src/action/convert-error-to-warning-per-file.ts +4 -6
- package/src/action/disable-per-file.ts +4 -6
- package/src/action/disable-per-line.ts +4 -6
- package/src/action/fix.ts +4 -10
- package/src/action/print-result-details.ts +5 -9
- package/src/cli/log.ts +25 -0
- package/src/cli/parse-argv.ts +32 -11
- package/src/cli/prompt.ts +56 -92
- package/src/cli/run.ts +3 -29
- package/src/core.ts +13 -6
- package/src/fix/disable-per-file.ts +1 -1
- package/src/fix/disable-per-line.ts +1 -1
- package/src/formatter/filter-rule-statistics.ts +27 -0
- package/src/formatter/format-by-rules.ts +10 -7
- package/src/formatter/index.ts +4 -3
- package/src/index.ts +1 -1
- package/src/scene/check-results.ts +2 -5
- package/src/scene/lint.ts +14 -12
- package/src/scene/select-action.ts +2 -4
- package/src/scene/select-rule-ids.ts +2 -6
- package/src/type.ts +2 -0
- package/src/util/terminal-link.ts +16 -0
- package/src/cli/spinner.ts +0 -22
- package/src/core-worker.ts +0 -55
- package/src/typings/enquirer.d.ts +0 -7
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { unique } from './array.js';
|
|
2
|
+
const COMMENT_RE = /^\s*(?<header>eslint-disable|eslint-disable-next-line)\s+(?<ruleList>[@a-z0-9\-_$/]*(?:\s*,\s*[@a-z0-9\-_$/]*)*(?:\s*,)?)(?:\s+--\s+(?<description>.*\S))?\s*$/u;
|
|
3
|
+
const SHEBANG_PATTERN = /^#!.+?\r?\n/u;
|
|
4
|
+
/**
|
|
5
|
+
* Parses the comment as an ESLint disable comment.
|
|
6
|
+
* Returns undefined if the comment cannot be parsed as a disable comment.
|
|
7
|
+
*
|
|
8
|
+
* ## Reference: Structure of a disable comment
|
|
9
|
+
* /* eslint-disable-next-line rule-a, rule-b, rule-c, rule-d -- I'm the rules.
|
|
10
|
+
* ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^
|
|
11
|
+
* | | | |
|
|
12
|
+
* header | | |
|
|
13
|
+
* ruleList | |
|
|
14
|
+
* descriptionHeader |
|
|
15
|
+
* description
|
|
16
|
+
*/
|
|
17
|
+
export function parseDisableComment(comment) {
|
|
18
|
+
// NOTE: Comment nodes should always have range and loc, but they are optional in the types.
|
|
19
|
+
// If range or loc is missing, consider the parsing failed.
|
|
20
|
+
if (!comment.range || !comment.loc)
|
|
21
|
+
return undefined;
|
|
22
|
+
const result = COMMENT_RE.exec(comment.value);
|
|
23
|
+
if (!result)
|
|
24
|
+
return undefined;
|
|
25
|
+
if (!result.groups)
|
|
26
|
+
return undefined;
|
|
27
|
+
const { header, ruleList, description } = result.groups;
|
|
28
|
+
if (header === undefined || ruleList === undefined)
|
|
29
|
+
return undefined;
|
|
30
|
+
const ruleIds = ruleList
|
|
31
|
+
.split(',')
|
|
32
|
+
.map((r) => r.trim())
|
|
33
|
+
// Exclude empty strings
|
|
34
|
+
.filter((ruleId) => ruleId !== '');
|
|
35
|
+
const scope = header === 'eslint-disable-next-line' ? 'next-line' : 'file';
|
|
36
|
+
// A file scope comment must be block-style.
|
|
37
|
+
if (scope === 'file' && comment.type === 'Line')
|
|
38
|
+
return undefined;
|
|
39
|
+
return {
|
|
40
|
+
type: comment.type,
|
|
41
|
+
scope: header === 'eslint-disable-next-line' ? 'next-line' : 'file',
|
|
42
|
+
ruleIds,
|
|
43
|
+
// description is optional
|
|
44
|
+
...(description === '' || description === undefined ? {} : { description }),
|
|
45
|
+
range: comment.range,
|
|
46
|
+
loc: comment.loc,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Convert text to comment text.
|
|
51
|
+
*/
|
|
52
|
+
export function toCommentText(args) {
|
|
53
|
+
const { type, text } = args;
|
|
54
|
+
if (type === 'Line') {
|
|
55
|
+
return `// ${text}`;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return `/* ${text} */`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Convert `DisableComment` to comment text.
|
|
63
|
+
*/
|
|
64
|
+
export function toDisableCommentText({ type, scope, ruleIds, description, }) {
|
|
65
|
+
const header = scope === 'next-line' ? 'eslint-disable-next-line' : 'eslint-disable';
|
|
66
|
+
const ruleList = unique(ruleIds).join(', ');
|
|
67
|
+
const footer = description === undefined ? '' : ` -- ${description}`;
|
|
68
|
+
return toCommentText({ type, text: `${header} ${ruleList}${footer}` });
|
|
69
|
+
}
|
|
70
|
+
function getIndentFromLine(sourceCode, line) {
|
|
71
|
+
const headNodeIndex = sourceCode.getIndexFromLoc({ line, column: 0 });
|
|
72
|
+
// Extract the same indent as the line we want to fix
|
|
73
|
+
const indent = sourceCode.text.slice(headNodeIndex, headNodeIndex +
|
|
74
|
+
sourceCode.text
|
|
75
|
+
.slice(headNodeIndex)
|
|
76
|
+
// ref: https://tc39.es/ecma262/#sec-white-space
|
|
77
|
+
// eslint-disable-next-line no-control-regex
|
|
78
|
+
.search(/[^\u{0009}\u{000B}\u{000C}\u{FEFF}\p{gc=Space_Separator}]/u));
|
|
79
|
+
return indent;
|
|
80
|
+
}
|
|
81
|
+
function isLineInJSXText(sourceCode, line) {
|
|
82
|
+
const headNodeIndex = sourceCode.getIndexFromLoc({ line, column: 0 });
|
|
83
|
+
const headNode = sourceCode.getNodeByRangeIndex(headNodeIndex);
|
|
84
|
+
return headNode?.type === 'JSXText';
|
|
85
|
+
}
|
|
86
|
+
export function isLineInTemplateLiteral(sourceCode, line) {
|
|
87
|
+
const headNodeIndex = sourceCode.getIndexFromLoc({ line, column: 0 });
|
|
88
|
+
const headNode = sourceCode.getNodeByRangeIndex(headNodeIndex);
|
|
89
|
+
return headNode?.type === 'TemplateElement';
|
|
90
|
+
}
|
|
91
|
+
export function getStartColumnOfTemplateExpression(sourceCode, message) {
|
|
92
|
+
for (let i = message.column; i >= 1; i--) {
|
|
93
|
+
const index = sourceCode.getIndexFromLoc({
|
|
94
|
+
line: message.line,
|
|
95
|
+
// Convert 1-indexed to 0-indexed
|
|
96
|
+
column: i - 1,
|
|
97
|
+
});
|
|
98
|
+
const node = sourceCode.getNodeByRangeIndex(index);
|
|
99
|
+
if (node?.type === 'TemplateElement') {
|
|
100
|
+
return i;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
throw new Error(`unreachable: The line ${message.line} does not have a template element.`);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Merge the ruleIds of the disable comments.
|
|
107
|
+
* @param a The ruleIds of first disable comment
|
|
108
|
+
* @param b The ruleIds of second disable comment
|
|
109
|
+
* @returns The ruleIds of merged disable comment
|
|
110
|
+
*/
|
|
111
|
+
export function mergeRuleIds(a, b) {
|
|
112
|
+
return unique([...a, ...b]);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Merge the description of the disable comments.
|
|
116
|
+
* @param a The description of first disable comment
|
|
117
|
+
* @param b The description of second disable comment
|
|
118
|
+
* @returns The description of merged disable comment
|
|
119
|
+
*/
|
|
120
|
+
export function mergeDescription(a, b) {
|
|
121
|
+
if (a === undefined && b === undefined)
|
|
122
|
+
return undefined;
|
|
123
|
+
if (a === undefined)
|
|
124
|
+
return b;
|
|
125
|
+
if (b === undefined)
|
|
126
|
+
return a;
|
|
127
|
+
return `${a}, ${b}`;
|
|
128
|
+
}
|
|
129
|
+
export function insertDescriptionCommentStatementBeforeLine(args) {
|
|
130
|
+
const { fixer, sourceCode, line, column, description } = args;
|
|
131
|
+
const indent = getIndentFromLine(sourceCode, line);
|
|
132
|
+
const headNodeIndex = sourceCode.getIndexFromLoc({ line, column });
|
|
133
|
+
if (isLineInJSXText(sourceCode, line)) {
|
|
134
|
+
const commentText = toCommentText({ type: 'Block', text: description });
|
|
135
|
+
return fixer.insertTextBeforeRange([headNodeIndex, headNodeIndex], `${indent}{${commentText}}\n`);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const commentText = toCommentText({ type: 'Line', text: description });
|
|
139
|
+
return fixer.insertTextBeforeRange([headNodeIndex, headNodeIndex], `${indent}${commentText}\n`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Update existing disable comment.
|
|
144
|
+
* @returns The eslint's fix object
|
|
145
|
+
*/
|
|
146
|
+
export function updateDisableComment(args) {
|
|
147
|
+
const { fixer, disableComment: existingDisableComment, newRules, newDescription } = args;
|
|
148
|
+
const newDisableCommentText = toDisableCommentText({
|
|
149
|
+
type: existingDisableComment.type,
|
|
150
|
+
scope: existingDisableComment.scope,
|
|
151
|
+
ruleIds: newRules,
|
|
152
|
+
description: newDescription,
|
|
153
|
+
});
|
|
154
|
+
return fixer.replaceTextRange(existingDisableComment.range, newDisableCommentText);
|
|
155
|
+
}
|
|
156
|
+
export function insertDisableCommentStatementBeforeLine(args) {
|
|
157
|
+
const { fixer, sourceCode, line, column, scope, ruleIds, description } = args;
|
|
158
|
+
const indent = getIndentFromLine(sourceCode, line);
|
|
159
|
+
const headNodeIndex = sourceCode.getIndexFromLoc({ line, column });
|
|
160
|
+
const isInJSXText = isLineInJSXText(sourceCode, line);
|
|
161
|
+
const type = isInJSXText || scope === 'file' ? 'Block' : 'Line';
|
|
162
|
+
const disableCommentText = toDisableCommentText({
|
|
163
|
+
type,
|
|
164
|
+
scope,
|
|
165
|
+
ruleIds,
|
|
166
|
+
description,
|
|
167
|
+
});
|
|
168
|
+
if (isInJSXText) {
|
|
169
|
+
return fixer.insertTextBeforeRange([headNodeIndex, headNodeIndex], `${indent}{${disableCommentText}}\n`);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
return fixer.insertTextBeforeRange([headNodeIndex, headNodeIndex], `${indent}${disableCommentText}\n`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Convert `InlineConfigComment` to comment text.
|
|
177
|
+
*/
|
|
178
|
+
export function toInlineConfigCommentText({ rulesRecord, description }) {
|
|
179
|
+
const header = 'eslint';
|
|
180
|
+
const rulesRecordText = Object.entries(rulesRecord)
|
|
181
|
+
.map(([ruleId, ruleEntry]) => {
|
|
182
|
+
// TODO: Inherit options of the rule set by the user in ESLint config if the option exists.
|
|
183
|
+
return `${ruleId}: ${JSON.stringify(ruleEntry)}`;
|
|
184
|
+
})
|
|
185
|
+
.join(', ');
|
|
186
|
+
if (description === undefined) {
|
|
187
|
+
return `/* ${header} ${rulesRecordText} */`;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
return `/* ${header} ${rulesRecordText} -- ${description} */`;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Create the results with only messages with the specified rule ids.
|
|
195
|
+
* @param results The lint results.
|
|
196
|
+
* @param ruleIds The rule ids.
|
|
197
|
+
* @returns The results with only messages with the specified rule ids
|
|
198
|
+
*/
|
|
199
|
+
export function filterResultsByRuleId(results, ruleIds) {
|
|
200
|
+
return results
|
|
201
|
+
.map((result) => {
|
|
202
|
+
return {
|
|
203
|
+
...result,
|
|
204
|
+
messages: result.messages.filter((message) => ruleIds.includes(message.ruleId)),
|
|
205
|
+
};
|
|
206
|
+
})
|
|
207
|
+
.filter((result) => result.messages.length > 0);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Find shebang from the first line of the file.
|
|
211
|
+
* @param sourceCodeText The source code text of the file.
|
|
212
|
+
* @returns The information of shebang. If the file does not have shebang, return null.
|
|
213
|
+
*/
|
|
214
|
+
export function findShebang(sourceCodeText) {
|
|
215
|
+
const result = SHEBANG_PATTERN.exec(sourceCodeText);
|
|
216
|
+
if (!result)
|
|
217
|
+
return null;
|
|
218
|
+
return { range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M,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAChF,CAAC;IACJ,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,cAAsB;IAChD,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACpD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-link.d.ts","sourceRoot":"","sources":["../../src/util/terminal-link.ts"],"names":[],"mappings":"AAaA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const OSC = '\x1B]';
|
|
2
|
+
const BEL = '\x07';
|
|
3
|
+
function buildOsc8Link(text, url) {
|
|
4
|
+
return `${OSC}8;;${url}${BEL}${text}${OSC}8;;${BEL}`;
|
|
5
|
+
}
|
|
6
|
+
function supportsHyperlinks() {
|
|
7
|
+
if (process.env['FORCE_HYPERLINK'] === '1')
|
|
8
|
+
return true;
|
|
9
|
+
if (process.env['FORCE_HYPERLINK'] === '0')
|
|
10
|
+
return false;
|
|
11
|
+
return process.stdout.isTTY;
|
|
12
|
+
}
|
|
13
|
+
export function terminalLink(text, url) {
|
|
14
|
+
return supportsHyperlinks() ? buildOsc8Link(text, url) : text;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=terminal-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-link.js","sourceRoot":"","sources":["../../src/util/terminal-link.ts"],"names":[],"mappings":"AAAA,MAAM,GAAG,GAAG,OAAO,CAAC;AACpB,MAAM,GAAG,GAAG,MAAM,CAAC;AAEnB,SAAS,aAAa,CAAC,IAAY,EAAE,GAAW;IAC9C,OAAO,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,MAAM,GAAG,EAAE,CAAC;AACvD,CAAC;AAED,SAAS,kBAAkB;IACzB,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IACxD,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,GAAG;QAAE,OAAO,KAAK,CAAC;IACzD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,OAAO,kBAAkB,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-check.d.ts","sourceRoot":"","sources":["../../src/util/type-check.ts"],"names":[],"mappings":"AACA,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAEnD;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,IAAI,MAAM,CAElF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-check.js","sourceRoot":"","sources":["../../src/util/type-check.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,kBAAkB,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAS,KAAgC;IAC/D,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-interactive",
|
|
3
3
|
"description": "The CLI tool to run `eslint --fix` for each rule",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "14.0.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/mizdra/eslint-interactive.git"
|
|
@@ -18,23 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsc -p tsconfig.build.json",
|
|
23
|
-
"predev": "pnpm run build",
|
|
24
|
-
"dev": "cd example && ../bin/eslint-interactive.js ./lib",
|
|
25
|
-
"lint": "pnpm run --no-bail /^lint:.*/",
|
|
26
|
-
"lint:tsc": "tsc -p tsconfig.json --noEmit",
|
|
27
|
-
"lint:eslint": "eslint .",
|
|
28
|
-
"lint:prettier": "prettier --check .",
|
|
29
|
-
"lint-fix": "pnpm run --no-bail /^lint-fix:.*/",
|
|
30
|
-
"lint-fix:eslint": "eslint . --fix",
|
|
31
|
-
"lint-fix:prettier": "prettier --write .",
|
|
32
|
-
"test": "vitest --run",
|
|
33
|
-
"pree2e": "pnpm run build --noCheck",
|
|
34
|
-
"e2e": "vitest -c vite.config.e2e.ts --run"
|
|
35
|
-
},
|
|
36
21
|
"prettier": "@mizdra/prettier-config-mizdra",
|
|
37
|
-
"packageManager": "pnpm@10.10.0",
|
|
38
22
|
"devDependencies": {
|
|
39
23
|
"@eslint/eslintrc": "^3.3.3",
|
|
40
24
|
"@mizdra/eslint-config-mizdra": "^7.0.0",
|
|
@@ -44,22 +28,21 @@
|
|
|
44
28
|
"@types/node": "^22.15.3",
|
|
45
29
|
"dedent": "^1.5.3",
|
|
46
30
|
"eslint": "^10.0.1",
|
|
31
|
+
"eslint-v10": "npm:eslint@^10.0.1",
|
|
32
|
+
"eslint-v9": "npm:eslint@^9.39.4",
|
|
47
33
|
"prettier": "3.5.3",
|
|
48
34
|
"stream-match": "^4.1.0",
|
|
49
35
|
"typescript": "^5.8.3",
|
|
50
36
|
"vitest": "^2.1.1"
|
|
51
37
|
},
|
|
52
38
|
"dependencies": {
|
|
53
|
-
"
|
|
54
|
-
"enquirer": "^2.4.1",
|
|
55
|
-
"nanospinner": "^1.2.2",
|
|
56
|
-
"terminal-link": "^3.0.0"
|
|
39
|
+
"@clack/prompts": "^1.3.0"
|
|
57
40
|
},
|
|
58
41
|
"peerDependencies": {
|
|
59
42
|
"eslint": ">=9.0.0"
|
|
60
43
|
},
|
|
61
44
|
"engines": {
|
|
62
|
-
"node": "^
|
|
45
|
+
"node": "^22.12.0 || >=24.0.0"
|
|
63
46
|
},
|
|
64
47
|
"publishConfig": {
|
|
65
48
|
"access": "public",
|
|
@@ -79,5 +62,20 @@
|
|
|
79
62
|
"!src/**/__snapshots__",
|
|
80
63
|
"dist",
|
|
81
64
|
"static"
|
|
82
|
-
]
|
|
83
|
-
|
|
65
|
+
],
|
|
66
|
+
"scripts": {
|
|
67
|
+
"build": "tsc -p tsconfig.build.json",
|
|
68
|
+
"predev": "pnpm run build",
|
|
69
|
+
"dev": "cd example && ../bin/eslint-interactive.js ./lib",
|
|
70
|
+
"lint": "pnpm run --no-bail /^lint:.*/",
|
|
71
|
+
"lint:tsc": "tsc -p tsconfig.json --noEmit",
|
|
72
|
+
"lint:eslint": "eslint .",
|
|
73
|
+
"lint:prettier": "prettier --check .",
|
|
74
|
+
"lint-fix": "pnpm run --no-bail /^lint-fix:.*/",
|
|
75
|
+
"lint-fix:eslint": "eslint . --fix",
|
|
76
|
+
"lint-fix:prettier": "prettier --write .",
|
|
77
|
+
"test": "vitest --run",
|
|
78
|
+
"pree2e": "pnpm run build --noCheck",
|
|
79
|
+
"e2e": "vitest -c vite.config.e2e.ts --run"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import type { Remote } from 'comlink';
|
|
2
1
|
import type { ESLint } from 'eslint';
|
|
2
|
+
import { withProgress } from '../cli/log.js';
|
|
3
3
|
import { promptToInputDescription } from '../cli/prompt.js';
|
|
4
|
-
import {
|
|
5
|
-
import type { Undo } from '../core.js';
|
|
6
|
-
import type { SerializableCore } from '../core-worker.js';
|
|
4
|
+
import type { Core, Undo } from '../core.js';
|
|
7
5
|
|
|
8
6
|
export async function doConvertErrorToWarningPerFileAction(
|
|
9
|
-
core:
|
|
7
|
+
core: Core,
|
|
10
8
|
results: ESLint.LintResult[],
|
|
11
9
|
selectedRuleIds: string[],
|
|
12
10
|
): Promise<Undo> {
|
|
13
11
|
const description = await promptToInputDescription();
|
|
14
|
-
const undo = await
|
|
12
|
+
const undo = await withProgress('Fixing', async () =>
|
|
15
13
|
core.convertErrorToWarningPerFile(results, selectedRuleIds, description),
|
|
16
14
|
);
|
|
17
15
|
return undo;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type { Remote } from 'comlink';
|
|
2
1
|
import type { ESLint } from 'eslint';
|
|
2
|
+
import { withProgress } from '../cli/log.js';
|
|
3
3
|
import type { DescriptionPosition } from '../cli/prompt.js';
|
|
4
4
|
import { promptToInputDescription, promptToInputDescriptionPosition } from '../cli/prompt.js';
|
|
5
|
-
import {
|
|
6
|
-
import type { Undo } from '../core.js';
|
|
7
|
-
import type { SerializableCore } from '../core-worker.js';
|
|
5
|
+
import type { Core, Undo } from '../core.js';
|
|
8
6
|
|
|
9
7
|
export async function doDisablePerFileAction(
|
|
10
|
-
core:
|
|
8
|
+
core: Core,
|
|
11
9
|
results: ESLint.LintResult[],
|
|
12
10
|
selectedRuleIds: string[],
|
|
13
11
|
): Promise<Undo> {
|
|
@@ -16,7 +14,7 @@ export async function doDisablePerFileAction(
|
|
|
16
14
|
if (description) {
|
|
17
15
|
descriptionPosition = await promptToInputDescriptionPosition();
|
|
18
16
|
}
|
|
19
|
-
const undo = await
|
|
17
|
+
const undo = await withProgress('Fixing', async () =>
|
|
20
18
|
core.disablePerFile(results, selectedRuleIds, description, descriptionPosition),
|
|
21
19
|
);
|
|
22
20
|
return undo;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type { Remote } from 'comlink';
|
|
2
1
|
import type { ESLint } from 'eslint';
|
|
2
|
+
import { withProgress } from '../cli/log.js';
|
|
3
3
|
import type { DescriptionPosition } from '../cli/prompt.js';
|
|
4
4
|
import { promptToInputDescription, promptToInputDescriptionPosition } from '../cli/prompt.js';
|
|
5
|
-
import {
|
|
6
|
-
import type { Undo } from '../core.js';
|
|
7
|
-
import type { SerializableCore } from '../core-worker.js';
|
|
5
|
+
import type { Core, Undo } from '../core.js';
|
|
8
6
|
|
|
9
7
|
export async function doDisablePerLineAction(
|
|
10
|
-
core:
|
|
8
|
+
core: Core,
|
|
11
9
|
results: ESLint.LintResult[],
|
|
12
10
|
selectedRuleIds: string[],
|
|
13
11
|
): Promise<Undo> {
|
|
@@ -16,7 +14,7 @@ export async function doDisablePerLineAction(
|
|
|
16
14
|
if (description) {
|
|
17
15
|
descriptionPosition = await promptToInputDescriptionPosition();
|
|
18
16
|
}
|
|
19
|
-
const undo = await
|
|
17
|
+
const undo = await withProgress('Fixing', async () =>
|
|
20
18
|
core.disablePerLine(results, selectedRuleIds, description, descriptionPosition),
|
|
21
19
|
);
|
|
22
20
|
return undo;
|
package/src/action/fix.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import type { Remote } from 'comlink';
|
|
2
1
|
import type { ESLint } from 'eslint';
|
|
3
|
-
import {
|
|
4
|
-
import type { Undo } from '../core.js';
|
|
5
|
-
import type { SerializableCore } from '../core-worker.js';
|
|
2
|
+
import { withProgress } from '../cli/log.js';
|
|
3
|
+
import type { Core, Undo } from '../core.js';
|
|
6
4
|
|
|
7
|
-
export async function doFixAction(
|
|
8
|
-
core
|
|
9
|
-
results: ESLint.LintResult[],
|
|
10
|
-
selectedRuleIds: string[],
|
|
11
|
-
): Promise<Undo> {
|
|
12
|
-
const undo = await fixingSpinner(async () => core.applyAutoFixes(results, selectedRuleIds));
|
|
5
|
+
export async function doFixAction(core: Core, results: ESLint.LintResult[], selectedRuleIds: string[]): Promise<Undo> {
|
|
6
|
+
const undo = await withProgress('Fixing', async () => core.applyAutoFixes(results, selectedRuleIds));
|
|
13
7
|
return undo;
|
|
14
8
|
}
|
|
@@ -4,23 +4,19 @@ import { tmpdir } from 'node:os';
|
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
6
6
|
import { stripVTControlCharacters, styleText } from 'node:util';
|
|
7
|
-
import
|
|
7
|
+
import { log } from '@clack/prompts';
|
|
8
8
|
import type { ESLint } from 'eslint';
|
|
9
9
|
import { VERSION } from '../cli/package.js';
|
|
10
10
|
import { pager } from '../cli/pager.js';
|
|
11
11
|
import { promptToInputDisplayMode } from '../cli/prompt.js';
|
|
12
|
-
import type {
|
|
12
|
+
import type { Core } from '../core.js';
|
|
13
13
|
import { unreachable } from '../util/type-check.js';
|
|
14
14
|
|
|
15
|
-
export async function doPrintResultDetailsAction(
|
|
16
|
-
core: Remote<SerializableCore>,
|
|
17
|
-
results: ESLint.LintResult[],
|
|
18
|
-
selectedRuleIds: string[],
|
|
19
|
-
) {
|
|
15
|
+
export async function doPrintResultDetailsAction(core: Core, results: ESLint.LintResult[], selectedRuleIds: string[]) {
|
|
20
16
|
const displayMode = await promptToInputDisplayMode();
|
|
21
17
|
const formattedResultDetails = await core.formatResultDetails(results, selectedRuleIds);
|
|
22
18
|
if (displayMode === 'printInTerminal') {
|
|
23
|
-
|
|
19
|
+
log.message(formattedResultDetails);
|
|
24
20
|
} else if (displayMode === 'printInTerminalWithPager') {
|
|
25
21
|
await pager(formattedResultDetails);
|
|
26
22
|
} else if (displayMode === 'writeToFile') {
|
|
@@ -28,7 +24,7 @@ export async function doPrintResultDetailsAction(
|
|
|
28
24
|
const filePath = join(tempDir, 'lint-result-details.txt');
|
|
29
25
|
await mkdir(tempDir, { recursive: true }); // Create the directory because it might not exist
|
|
30
26
|
await writeFile(filePath, stripVTControlCharacters(formattedResultDetails), 'utf8');
|
|
31
|
-
|
|
27
|
+
log.message(styleText('cyan', `Wrote to ${filePath}`));
|
|
32
28
|
} else {
|
|
33
29
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
34
30
|
unreachable(`Unknown display mode: ${displayMode}`);
|
package/src/cli/log.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
2
2
|
import { styleText } from 'node:util';
|
|
3
|
+
import { taskLog } from '@clack/prompts';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Log an error message to stderr
|
|
@@ -8,3 +9,27 @@ import { styleText } from 'node:util';
|
|
|
8
9
|
export function error(message: string) {
|
|
9
10
|
process.stderr.write(styleText('red', 'Error') + ': ' + message + '\n');
|
|
10
11
|
}
|
|
12
|
+
|
|
13
|
+
export async function withProgress<T>(taskName: 'Linting' | 'Fixing' | 'Undoing', cb: () => Promise<T>): Promise<T> {
|
|
14
|
+
const log = taskLog({
|
|
15
|
+
title: `${taskName}...`,
|
|
16
|
+
});
|
|
17
|
+
startProgress();
|
|
18
|
+
try {
|
|
19
|
+
const result = await cb();
|
|
20
|
+
log.success(`${taskName} completed.`);
|
|
21
|
+
return result;
|
|
22
|
+
} finally {
|
|
23
|
+
endProgress();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function startProgress(): void {
|
|
28
|
+
if (!process.stdout.isTTY) return;
|
|
29
|
+
process.stdout.write('\x1b]9;4;3\x07');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function endProgress(): void {
|
|
33
|
+
if (!process.stdout.isTTY) return;
|
|
34
|
+
process.stdout.write('\x1b]9;4;0\x07');
|
|
35
|
+
}
|
package/src/cli/parse-argv.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { parseArgs } from 'node:util';
|
|
2
|
-
import type { Config, SortField, SortOrder } from '../type.js';
|
|
2
|
+
import type { Config, FilterCriterion, SortField, SortOrder } from '../type.js';
|
|
3
3
|
import { VERSION } from './package.js';
|
|
4
4
|
|
|
5
5
|
const VALID_SORT_FIELDS: readonly SortField[] = ['rule', 'error', 'warning', 'fixable', 'suggestions'];
|
|
6
6
|
const VALID_SORT_ORDERS: readonly SortOrder[] = ['asc', 'desc'];
|
|
7
|
+
const VALID_FILTER_CRITERIA: readonly FilterCriterion[] = ['fixable', 'has-suggestions'];
|
|
7
8
|
|
|
8
9
|
/** Parse CLI options */
|
|
9
10
|
export function parseArgv(argv: string[]): Config {
|
|
@@ -11,6 +12,8 @@ export function parseArgv(argv: string[]): Config {
|
|
|
11
12
|
'config': { type: 'string', short: 'c' },
|
|
12
13
|
'format': { type: 'string' },
|
|
13
14
|
'quiet': { type: 'boolean' },
|
|
15
|
+
'ignore-pattern': { type: 'string', multiple: true },
|
|
16
|
+
'ignore': { type: 'boolean' },
|
|
14
17
|
'cache': { type: 'boolean' },
|
|
15
18
|
'cache-location': { type: 'string' },
|
|
16
19
|
'version': { type: 'boolean' },
|
|
@@ -18,6 +21,7 @@ export function parseArgv(argv: string[]): Config {
|
|
|
18
21
|
'flag': { type: 'string', multiple: true },
|
|
19
22
|
'sort': { type: 'string' },
|
|
20
23
|
'sort-order': { type: 'string' },
|
|
24
|
+
'filter': { type: 'string', multiple: true },
|
|
21
25
|
} as const;
|
|
22
26
|
|
|
23
27
|
const { values, positionals } = parseArgs({
|
|
@@ -41,6 +45,15 @@ export function parseArgv(argv: string[]): Config {
|
|
|
41
45
|
// eslint-disable-next-line n/no-process-exit
|
|
42
46
|
process.exit(1);
|
|
43
47
|
}
|
|
48
|
+
if (values.filter !== undefined) {
|
|
49
|
+
for (const filter of values.filter) {
|
|
50
|
+
if (!VALID_FILTER_CRITERIA.includes(filter as FilterCriterion)) {
|
|
51
|
+
console.error(`Invalid --filter value: "${filter}". Must be one of: ${VALID_FILTER_CRITERIA.join(', ')}`);
|
|
52
|
+
// eslint-disable-next-line n/no-process-exit
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
44
57
|
|
|
45
58
|
if (values.version) {
|
|
46
59
|
console.log(VERSION);
|
|
@@ -54,16 +67,20 @@ export function parseArgv(argv: string[]): Config {
|
|
|
54
67
|
eslint-interactive [...patterns]
|
|
55
68
|
|
|
56
69
|
Options:
|
|
57
|
-
--help
|
|
58
|
-
--version
|
|
59
|
-
-c, --config <path>
|
|
60
|
-
--format <nameOrPath>
|
|
61
|
-
--quiet
|
|
62
|
-
--
|
|
63
|
-
--
|
|
64
|
-
--
|
|
65
|
-
--
|
|
66
|
-
--
|
|
70
|
+
--help Show help
|
|
71
|
+
--version Show version number
|
|
72
|
+
-c, --config <path> Use this configuration, overriding config options if present
|
|
73
|
+
--format <nameOrPath> Specify the format to be used for the "Display problem messages" action
|
|
74
|
+
--quiet Report errors only
|
|
75
|
+
--ignore-pattern <string> Patterns of files to ignore
|
|
76
|
+
--no-ignore Disable use of ignore files and patterns
|
|
77
|
+
--cache Only check changed files
|
|
78
|
+
--cache-location <path> Path to the cache file or directory
|
|
79
|
+
--flag <name> Enable a feature flag (requires ESLint v9.6.0+)
|
|
80
|
+
--sort <field> Sort rules by: rule, error, warning, fixable, suggestions
|
|
81
|
+
--sort-order <direction> Sort direction: asc, desc (default: desc for counts, asc for rule)
|
|
82
|
+
--filter <criterion> Show only rules matching the criterion: fixable, has-suggestions
|
|
83
|
+
(repeatable; multiple values are OR-ed)
|
|
67
84
|
|
|
68
85
|
Examples:
|
|
69
86
|
eslint-interactive Lint all files in the project
|
|
@@ -71,6 +88,7 @@ Examples:
|
|
|
71
88
|
eslint-interactive 'src/**/*.{ts,tsx,vue}' Lint with glob pattern
|
|
72
89
|
eslint-interactive --sort error Sort rules by error count (descending)
|
|
73
90
|
eslint-interactive --sort rule Sort rules by rule name (ascending)
|
|
91
|
+
eslint-interactive --filter fixable Show only rules that have fixable problems
|
|
74
92
|
`.trim(),
|
|
75
93
|
);
|
|
76
94
|
// eslint-disable-next-line n/no-process-exit
|
|
@@ -84,11 +102,14 @@ Examples:
|
|
|
84
102
|
patterns,
|
|
85
103
|
formatterName,
|
|
86
104
|
quiet: values.quiet,
|
|
105
|
+
ignorePatterns: values['ignore-pattern'],
|
|
106
|
+
ignore: values.ignore,
|
|
87
107
|
overrideConfigFile: values.config,
|
|
88
108
|
cache: values.cache,
|
|
89
109
|
cacheLocation: values['cache-location'],
|
|
90
110
|
flags: values.flag,
|
|
91
111
|
sort: values.sort as SortField | undefined,
|
|
92
112
|
sortOrder: values['sort-order'] as SortOrder | undefined,
|
|
113
|
+
filters: values.filter as FilterCriterion[] | undefined,
|
|
93
114
|
};
|
|
94
115
|
}
|