eslint-interactive 13.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/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 +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 +5 -0
- package/dist/action/print-result-details.d.ts.map +1 -0
- package/dist/action/print-result-details.js +35 -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 +10 -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 +82 -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 +135 -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 +52 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/spinner.d.ts +4 -0
- package/dist/cli/spinner.d.ts.map +1 -0
- package/dist/cli/spinner.js +20 -0
- package/dist/cli/spinner.js.map +1 -0
- package/dist/core-worker.d.ts +21 -0
- package/dist/core-worker.d.ts.map +1 -0
- package/dist/core-worker.js +47 -0
- package/dist/core-worker.js.map +1 -0
- package/dist/core.d.ts +82 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +186 -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/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 +8 -0
- package/dist/formatter/format-by-rules.d.ts.map +1 -0
- package/dist/formatter/format-by-rules.js +31 -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 +6 -0
- package/dist/formatter/index.d.ts.map +1 -0
- package/dist/formatter/index.js +8 -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 +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 +30 -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 +44 -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/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/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/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 +18 -19
- package/src/index.ts +0 -0
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
let lastSourceCode = null;
|
|
2
|
+
export function getLastSourceCode() {
|
|
3
|
+
return lastSourceCode;
|
|
4
|
+
}
|
|
5
|
+
export const plugin = {
|
|
6
|
+
rules: {
|
|
7
|
+
/**
|
|
8
|
+
* This is a rule for getting a `SourceCode` instance.
|
|
9
|
+
* `ESLint` class does not provide a method for getting a `SourceCode` instance. As an alternative, we have prepared this custom rule.
|
|
10
|
+
*/
|
|
11
|
+
'source-code-snatcher': {
|
|
12
|
+
create(context) {
|
|
13
|
+
lastSourceCode = context.sourceCode;
|
|
14
|
+
return {};
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
/** This is a rule for testing purposes. It reports without end location (endLine/endColumn). */
|
|
18
|
+
'report-without-end-location': {
|
|
19
|
+
create(context) {
|
|
20
|
+
return {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
22
|
+
Program(node) {
|
|
23
|
+
context.report({
|
|
24
|
+
loc: node.loc.start,
|
|
25
|
+
message: 'Report without end location.',
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
/** This is a rule for testing purposes. */
|
|
32
|
+
'prefer-addition-shorthand': {
|
|
33
|
+
meta: {
|
|
34
|
+
type: 'suggestion',
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
hasSuggestions: true,
|
|
37
|
+
},
|
|
38
|
+
create(context) {
|
|
39
|
+
return {
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
41
|
+
AssignmentExpression: (node) => {
|
|
42
|
+
if (node.left.type !== 'Identifier')
|
|
43
|
+
return;
|
|
44
|
+
const leftIdentifier = node.left;
|
|
45
|
+
if (node.right.type !== 'BinaryExpression')
|
|
46
|
+
return;
|
|
47
|
+
const rightBinaryExpression = node.right;
|
|
48
|
+
if (rightBinaryExpression.operator !== '+')
|
|
49
|
+
return;
|
|
50
|
+
if (rightBinaryExpression.left.type !== 'Identifier')
|
|
51
|
+
return;
|
|
52
|
+
const rightIdentifier = rightBinaryExpression.left;
|
|
53
|
+
if (leftIdentifier.name !== rightIdentifier.name)
|
|
54
|
+
return;
|
|
55
|
+
if (rightBinaryExpression.right.type !== 'Literal' || rightBinaryExpression.right.value !== 1)
|
|
56
|
+
return;
|
|
57
|
+
context.report({
|
|
58
|
+
node,
|
|
59
|
+
message: 'The addition method is redundant.',
|
|
60
|
+
suggest: [
|
|
61
|
+
{
|
|
62
|
+
desc: 'Use `val += 1` instead.',
|
|
63
|
+
fix(fixer) {
|
|
64
|
+
return fixer.replaceText(node, `${leftIdentifier.name} += 1`);
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
desc: 'Use `val++` instead.',
|
|
69
|
+
fix(fixer) {
|
|
70
|
+
return fixer.replaceText(node, `${leftIdentifier.name}++`);
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
desc: 'Use `++val` instead.',
|
|
75
|
+
fix(fixer) {
|
|
76
|
+
return fixer.replaceText(node, `++${leftIdentifier.name}`);
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAEA,IAAI,cAAc,GAAsB,IAAI,CAAC;AAE7C,MAA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AI;4BAAE,OAAO;wBACzD,IAAI,qBAAqB,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,qBAAqB,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;4BAAE,OAAO;wBAEtG,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,OAAO,EAAE,mCAAmC;4BAC5C,OAAO,EAAE;gCACP;oCACE,IAAI,EAAE,yBAAyB;oCAC/B,GAAG,CAAC,KAAK;wCACP,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,cAAc,CAAC,IAAI,OAAO,CAAC,CAAC;oCAChE,CAAC;iCACF;gCACD;oCACE,IAAI,EAAE,sBAAsB;oCAC5B,GAAG,CAAC,KAAK;wCACP,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC;oCAC7D,CAAC;iCACF;gCACD;oCACE,IAAI,EAAE,sBAAsB;oCAC5B,GAAG,CAAC,KAAK;wCACP,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;oCAC7D,CAAC;iCACF;6BACF;yBACF,CAAC,CAAC;oBACL,CAAC;iBACF,CAAC;YACJ,CAAC;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ESLint } from 'eslint';
|
|
2
|
+
import type { Action } from '../cli/prompt.js';
|
|
3
|
+
import type { Undo } from '../core.js';
|
|
4
|
+
import type { NextScene } from './index.js';
|
|
5
|
+
export type CheckResultsArgs = {
|
|
6
|
+
/** The lint results of the project */
|
|
7
|
+
results: ESLint.LintResult[];
|
|
8
|
+
/** The rule ids that are in the `results`. */
|
|
9
|
+
ruleIdsInResults: string[];
|
|
10
|
+
/** The rule ids to perform the action. */
|
|
11
|
+
selectedRuleIds: string[];
|
|
12
|
+
/** The function to execute undo. */
|
|
13
|
+
undo: Undo;
|
|
14
|
+
/** The selected actions. */
|
|
15
|
+
selectedAction: Action;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Run the scene where a user check the fix results.
|
|
19
|
+
*/
|
|
20
|
+
export declare function checkResults({ results, ruleIdsInResults, selectedRuleIds, undo, selectedAction, }: CheckResultsArgs): Promise<NextScene>;
|
|
21
|
+
//# sourceMappingURL=check-results.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-results.d.ts","sourceRoot":"","sources":["../../src/scene/check-results.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7B,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,0CAA0C;IAC1C,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,oCAAoC;IACpC,IAAI,EAAE,IAAI,CAAC;IACX,4BAA4B;IAC5B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,wBAAsB,YAAY,CAAC,EACjC,OAAO,EACP,gBAAgB,EAChB,eAAe,EACf,IAAI,EACJ,cAAc,GACf,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAcvC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { promptToInputWhatToDoNext } from '../cli/prompt.js';
|
|
2
|
+
import { undoingSpinner } from '../cli/spinner.js';
|
|
3
|
+
/**
|
|
4
|
+
* Run the scene where a user check the fix results.
|
|
5
|
+
*/
|
|
6
|
+
export async function checkResults({ results, ruleIdsInResults, selectedRuleIds, undo, selectedAction, }) {
|
|
7
|
+
const nextStep = await promptToInputWhatToDoNext();
|
|
8
|
+
if (nextStep === 'exit')
|
|
9
|
+
return { name: 'exit' };
|
|
10
|
+
if (nextStep === 'undoTheFix') {
|
|
11
|
+
await undoingSpinner(async () => undo());
|
|
12
|
+
return {
|
|
13
|
+
name: 'selectAction',
|
|
14
|
+
args: { results, ruleIdsInResults, selectedRuleIds, initialAction: selectedAction },
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
console.log();
|
|
18
|
+
console.log('─'.repeat(process.stdout.columns));
|
|
19
|
+
console.log();
|
|
20
|
+
return { name: 'lint' };
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=check-results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-results.js","sourceRoot":"","sources":["../../src/scene/check-results.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAiBnD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,EACjC,OAAO,EACP,gBAAgB,EAChB,eAAe,EACf,IAAI,EACJ,cAAc,GACG;IACjB,MAAM,QAAQ,GAAG,MAAM,yBAAyB,EAAE,CAAC;IACnD,IAAI,QAAQ,KAAK,MAAM;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACjD,IAAI,QAAQ,KAAK,YAAY,EAAE,CAAC;QAC9B,MAAM,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QACzC,OAAO;YACL,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE;SACpF,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CheckResultsArgs } from './check-results.js';
|
|
2
|
+
import { selectAction, type SelectActionArgs } from './select-action.js';
|
|
3
|
+
import { selectRuleIds, type SelectRuleIdsArgs } from './select-rule-ids.js';
|
|
4
|
+
export { selectAction, type SelectActionArgs, selectRuleIds, type SelectRuleIdsArgs };
|
|
5
|
+
export { lint } from './lint.js';
|
|
6
|
+
export { checkResults } from './check-results.js';
|
|
7
|
+
/**
|
|
8
|
+
* The return type when calling a scene function.
|
|
9
|
+
* Indicates which scene to jump to next.
|
|
10
|
+
*/
|
|
11
|
+
export type NextScene = {
|
|
12
|
+
name: 'lint';
|
|
13
|
+
} | {
|
|
14
|
+
name: 'selectRuleIds';
|
|
15
|
+
args: SelectRuleIdsArgs;
|
|
16
|
+
} | {
|
|
17
|
+
name: 'selectAction';
|
|
18
|
+
args: SelectActionArgs;
|
|
19
|
+
} | {
|
|
20
|
+
name: 'checkResults';
|
|
21
|
+
args: CheckResultsArgs;
|
|
22
|
+
} | {
|
|
23
|
+
name: 'exit';
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scene/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,CAAC;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { selectAction } from './select-action.js';
|
|
2
|
+
import { selectRuleIds } from './select-rule-ids.js';
|
|
3
|
+
export { selectAction, selectRuleIds };
|
|
4
|
+
export { lint } from './lint.js';
|
|
5
|
+
export { checkResults } from './check-results.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/scene/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAyB,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,aAAa,EAA0B,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,YAAY,EAAyB,aAAa,EAA0B,CAAC;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Remote } from 'comlink';
|
|
2
|
+
import type { SerializableCore } from '../core-worker.js';
|
|
3
|
+
import type { NextScene } from './index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Run the scene to lint.
|
|
6
|
+
*/
|
|
7
|
+
export declare function lint(core: Remote<SerializableCore>): Promise<NextScene>;
|
|
8
|
+
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/scene/lint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CA6B7E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { error } from '../cli/log.js';
|
|
2
|
+
import { lintingSpinner } from '../cli/spinner.js';
|
|
3
|
+
/**
|
|
4
|
+
* Run the scene to lint.
|
|
5
|
+
*/
|
|
6
|
+
export async function lint(core) {
|
|
7
|
+
const results = await lintingSpinner(async () => core.lint());
|
|
8
|
+
console.log();
|
|
9
|
+
// Check for ESLint core problems (ruleId === null) first.
|
|
10
|
+
// These represent config errors, syntax errors, etc. that eslint-interactive cannot fix.
|
|
11
|
+
const hasESLintCoreProblems = results.flatMap((result) => result.messages).some((message) => message.ruleId === null);
|
|
12
|
+
if (hasESLintCoreProblems) {
|
|
13
|
+
error('ESLint Core Problems are found. ' +
|
|
14
|
+
'The problems cannot be fixed by eslint-interactive. ' +
|
|
15
|
+
'Check the details of the problem and fix it. ' +
|
|
16
|
+
'This is usually caused by the invalid eslint config or the invalid syntax of the linted code.');
|
|
17
|
+
console.log(await core.formatResultDetails(results, [null]));
|
|
18
|
+
// eslint-disable-next-line n/no-process-exit
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
const ruleIdsInResults = await core.getSortedRuleIdsInResults(results);
|
|
22
|
+
if (ruleIdsInResults.length === 0) {
|
|
23
|
+
console.log('💚 No error found.');
|
|
24
|
+
return { name: 'exit' };
|
|
25
|
+
}
|
|
26
|
+
console.log(await core.formatResultSummary(results));
|
|
27
|
+
console.log();
|
|
28
|
+
return { name: 'selectRuleIds', args: { results, ruleIdsInResults } };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=lint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/scene/lint.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAA8B;IACvD,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,EAAE,CAAC;IAEd,0DAA0D;IAC1D,yFAAyF;IACzF,MAAM,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;IACtH,IAAI,qBAAqB,EAAE,CAAC;QAC1B,KAAK,CACH,kCAAkC;YAChC,sDAAsD;YACtD,+CAA+C;YAC/C,+FAA+F,CAClG,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7D,6CAA6C;QAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAEvE,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAClC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IAErD,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Remote } from 'comlink';
|
|
2
|
+
import type { ESLint } from 'eslint';
|
|
3
|
+
import type { Action } from '../cli/prompt.js';
|
|
4
|
+
import type { SerializableCore } from '../core-worker.js';
|
|
5
|
+
import type { NextScene } from './index.js';
|
|
6
|
+
export type SelectActionArgs = {
|
|
7
|
+
/** The lint results of the project */
|
|
8
|
+
results: ESLint.LintResult[];
|
|
9
|
+
/** The rule ids that are in the `results`. */
|
|
10
|
+
ruleIdsInResults: string[];
|
|
11
|
+
/** The rule ids to perform the action. */
|
|
12
|
+
selectedRuleIds: string[];
|
|
13
|
+
/** The action to be initially selected. */
|
|
14
|
+
initialAction?: Action;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Run the scene where a user select the action to be performed for the problems of selected rules.
|
|
18
|
+
*/
|
|
19
|
+
export declare function selectAction(core: Remote<SerializableCore>, { results, ruleIdsInResults, selectedRuleIds, initialAction }: SelectActionArgs): Promise<NextScene>;
|
|
20
|
+
//# sourceMappingURL=select-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-action.d.ts","sourceRoot":"","sources":["../../src/scene/select-action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAQrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7B,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,0CAA0C;IAC1C,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAC9B,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,EAAE,gBAAgB,GAC9E,OAAO,CAAC,SAAS,CAAC,CAkCpB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { doConvertErrorToWarningPerFileAction, doDisablePerFileAction, doDisablePerLineAction, doFixAction, doPrintResultDetailsAction, } from '../action/index.js';
|
|
2
|
+
import { promptToInputAction } from '../cli/prompt.js';
|
|
3
|
+
import { unreachable } from '../util/type-check.js';
|
|
4
|
+
/**
|
|
5
|
+
* Run the scene where a user select the action to be performed for the problems of selected rules.
|
|
6
|
+
*/
|
|
7
|
+
export async function selectAction(core, { results, ruleIdsInResults, selectedRuleIds, initialAction }) {
|
|
8
|
+
const selectedAction = await promptToInputAction(results, selectedRuleIds, initialAction);
|
|
9
|
+
const selectRuleIdsScene = { name: 'selectRuleIds', args: { results, ruleIdsInResults } };
|
|
10
|
+
const selectActionScene = { name: 'selectAction', args: { results, ruleIdsInResults, selectedRuleIds } };
|
|
11
|
+
function createCheckResultsScene(undo) {
|
|
12
|
+
return {
|
|
13
|
+
name: 'checkResults',
|
|
14
|
+
args: { results, ruleIdsInResults, selectedRuleIds, undo, selectedAction },
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (selectedAction === 'reselectRules')
|
|
18
|
+
return selectRuleIdsScene;
|
|
19
|
+
if (selectedAction === 'relintAndReselectRules')
|
|
20
|
+
return { name: 'lint' };
|
|
21
|
+
if (selectedAction === 'printResultDetails') {
|
|
22
|
+
await doPrintResultDetailsAction(core, results, selectedRuleIds);
|
|
23
|
+
return selectActionScene;
|
|
24
|
+
}
|
|
25
|
+
else if (selectedAction === 'applyAutoFixes') {
|
|
26
|
+
const undo = await doFixAction(core, results, selectedRuleIds);
|
|
27
|
+
return createCheckResultsScene(undo);
|
|
28
|
+
}
|
|
29
|
+
else if (selectedAction === 'disablePerLine') {
|
|
30
|
+
const undo = await doDisablePerLineAction(core, results, selectedRuleIds);
|
|
31
|
+
return createCheckResultsScene(undo);
|
|
32
|
+
}
|
|
33
|
+
else if (selectedAction === 'disablePerFile') {
|
|
34
|
+
const undo = await doDisablePerFileAction(core, results, selectedRuleIds);
|
|
35
|
+
return createCheckResultsScene(undo);
|
|
36
|
+
}
|
|
37
|
+
else if (selectedAction === 'convertErrorToWarningPerFile') {
|
|
38
|
+
const undo = await doConvertErrorToWarningPerFileAction(core, results, selectedRuleIds);
|
|
39
|
+
return createCheckResultsScene(undo);
|
|
40
|
+
}
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
42
|
+
return unreachable(`unknown action: ${selectedAction}`);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=select-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-action.js","sourceRoot":"","sources":["../../src/scene/select-action.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oCAAoC,EACpC,sBAA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;QAC/D,OAAO,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,cAAc,KAAK,gBAAgB,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;QAC1E,OAAO,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,cAAc,KAAK,gBAAgB,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;QAC1E,OAAO,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,cAAc,KAAK,8BAA8B,EAAE,CAAC;QAC7D,MAAM,IAAI,GAAG,MAAM,oCAAoC,CAAC,IAAI,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;QACxF,OAAO,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IACD,4EAA4E;IAC5E,OAAO,WAAW,CAAC,mBAAmB,cAAc,EAAE,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Remote } from 'comlink';
|
|
2
|
+
import type { ESLint } from 'eslint';
|
|
3
|
+
import type { SerializableCore } from '../core-worker.js';
|
|
4
|
+
import type { NextScene } from './index.js';
|
|
5
|
+
export type SelectRuleIdsArgs = {
|
|
6
|
+
/** The lint results of the project */
|
|
7
|
+
results: ESLint.LintResult[];
|
|
8
|
+
/** The rule ids that are in the `results`. */
|
|
9
|
+
ruleIdsInResults: string[];
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Run the scene where a user select rule ids.
|
|
13
|
+
*/
|
|
14
|
+
export declare function selectRuleIds(core: Remote<SerializableCore>, { results, ruleIdsInResults }: SelectRuleIdsArgs): Promise<NextScene>;
|
|
15
|
+
//# sourceMappingURL=select-rule-ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-rule-ids.d.ts","sourceRoot":"","sources":["../../src/scene/select-rule-ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7B,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAC9B,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,iBAAiB,GAC/C,OAAO,CAAC,SAAS,CAAC,CAGpB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { promptToInputRuleIds } from '../cli/prompt.js';
|
|
2
|
+
import { selectAction } from './select-action.js';
|
|
3
|
+
/**
|
|
4
|
+
* Run the scene where a user select rule ids.
|
|
5
|
+
*/
|
|
6
|
+
export async function selectRuleIds(core, { results, ruleIdsInResults }) {
|
|
7
|
+
const selectedRuleIds = await promptToInputRuleIds(ruleIdsInResults);
|
|
8
|
+
return selectAction(core, { results, ruleIdsInResults, selectedRuleIds });
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=select-rule-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-rule-ids.js","sourceRoot":"","sources":["../../src/scene/select-rule-ids.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AASlD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAA8B,EAC9B,EAAE,OAAO,EAAE,gBAAgB,EAAqB;IAEhD,MAAM,eAAe,GAAG,MAAM,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACrE,OAAO,YAAY,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC,CAAC;AAC5E,CAAC"}
|
package/dist/type.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ESLint } from 'eslint';
|
|
2
|
+
export type SortField = 'rule' | 'error' | 'warning' | 'fixable' | 'suggestions';
|
|
3
|
+
export type SortOrder = 'asc' | 'desc';
|
|
4
|
+
/** The config of eslint-interactive */
|
|
5
|
+
export type Config = ESLint.Options & {
|
|
6
|
+
patterns: string[];
|
|
7
|
+
formatterName?: string | undefined;
|
|
8
|
+
quiet?: boolean | undefined;
|
|
9
|
+
sort?: SortField | undefined;
|
|
10
|
+
sortOrder?: SortOrder | undefined;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,CAAC;AACjF,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;AAEvC,uCAAuC;AACvC,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,GAAG;IACpC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACnC,CAAC"}
|
package/dist/type.js
ADDED
package/dist/type.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/util/array.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEzC;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAW5E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function unique(array) {
|
|
2
|
+
return [...new Set(array)];
|
|
3
|
+
}
|
|
4
|
+
export function groupBy(array, toKey) {
|
|
5
|
+
const map = new Map();
|
|
6
|
+
for (const item of array) {
|
|
7
|
+
const key = toKey(item);
|
|
8
|
+
const oldValue = map.get(key);
|
|
9
|
+
const newValue = oldValue ? [...oldValue, item] : [item];
|
|
10
|
+
map.set(key, newValue);
|
|
11
|
+
}
|
|
12
|
+
return map;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../src/util/array.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,MAAM,CAAI,KAAU;IAClC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,OAAO,CAAO,KAAU,EAAE,KAAqB;IAC7D,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAE9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QACxB,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACzD,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { AST, ESLint, Linter, Rule, SourceCode } from 'eslint';
|
|
2
|
+
import type { Comment, SourceLocation } from 'estree';
|
|
3
|
+
export type DisableComment = {
|
|
4
|
+
type: 'Block' | 'Line';
|
|
5
|
+
scope: 'next-line' | 'file';
|
|
6
|
+
ruleIds: string[];
|
|
7
|
+
description?: string | undefined;
|
|
8
|
+
range: [number, number];
|
|
9
|
+
loc: SourceLocation;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Parses the comment as an ESLint disable comment.
|
|
13
|
+
* Returns undefined if the comment cannot be parsed as a disable comment.
|
|
14
|
+
*
|
|
15
|
+
* ## Reference: Structure of a disable comment
|
|
16
|
+
* /* eslint-disable-next-line rule-a, rule-b, rule-c, rule-d -- I'm the rules.
|
|
17
|
+
* ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^
|
|
18
|
+
* | | | |
|
|
19
|
+
* header | | |
|
|
20
|
+
* ruleList | |
|
|
21
|
+
* descriptionHeader |
|
|
22
|
+
* description
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseDisableComment(comment: Comment): DisableComment | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Convert text to comment text.
|
|
27
|
+
*/
|
|
28
|
+
export declare function toCommentText(args: {
|
|
29
|
+
type: 'Line' | 'Block';
|
|
30
|
+
text: string;
|
|
31
|
+
}): string;
|
|
32
|
+
/**
|
|
33
|
+
* Convert `DisableComment` to comment text.
|
|
34
|
+
*/
|
|
35
|
+
export declare function toDisableCommentText({ type, scope, ruleIds, description, }: Omit<DisableComment, 'range' | 'loc'>): string;
|
|
36
|
+
export declare function isLineInTemplateLiteral(sourceCode: SourceCode, line: number): boolean;
|
|
37
|
+
export declare function getStartColumnOfTemplateExpression(sourceCode: SourceCode, message: Linter.LintMessage): number;
|
|
38
|
+
/**
|
|
39
|
+
* Merge the ruleIds of the disable comments.
|
|
40
|
+
* @param a The ruleIds of first disable comment
|
|
41
|
+
* @param b The ruleIds of second disable comment
|
|
42
|
+
* @returns The ruleIds of merged disable comment
|
|
43
|
+
*/
|
|
44
|
+
export declare function mergeRuleIds(a: string[], b: string[]): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Merge the description of the disable comments.
|
|
47
|
+
* @param a The description of first disable comment
|
|
48
|
+
* @param b The description of second disable comment
|
|
49
|
+
* @returns The description of merged disable comment
|
|
50
|
+
*/
|
|
51
|
+
export declare function mergeDescription(a: string | undefined, b: string | undefined): string | undefined;
|
|
52
|
+
export declare function insertDescriptionCommentStatementBeforeLine(args: {
|
|
53
|
+
fixer: Rule.RuleFixer;
|
|
54
|
+
sourceCode: SourceCode;
|
|
55
|
+
line: number;
|
|
56
|
+
column: number;
|
|
57
|
+
description: string;
|
|
58
|
+
}): Rule.Fix;
|
|
59
|
+
/**
|
|
60
|
+
* Update existing disable comment.
|
|
61
|
+
* @returns The eslint's fix object
|
|
62
|
+
*/
|
|
63
|
+
export declare function updateDisableComment(args: {
|
|
64
|
+
fixer: Rule.RuleFixer;
|
|
65
|
+
disableComment: DisableComment;
|
|
66
|
+
newRules: string[];
|
|
67
|
+
newDescription: string | undefined;
|
|
68
|
+
}): Rule.Fix;
|
|
69
|
+
export declare function insertDisableCommentStatementBeforeLine(args: {
|
|
70
|
+
fixer: Rule.RuleFixer;
|
|
71
|
+
sourceCode: SourceCode;
|
|
72
|
+
line: number;
|
|
73
|
+
column: number;
|
|
74
|
+
scope: 'file' | 'next-line';
|
|
75
|
+
ruleIds: string[];
|
|
76
|
+
description: string | undefined;
|
|
77
|
+
}): Rule.Fix;
|
|
78
|
+
type InlineConfigComment = {
|
|
79
|
+
description?: string | undefined;
|
|
80
|
+
rulesRecord: Partial<Linter.RulesRecord>;
|
|
81
|
+
range: [number, number];
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Convert `InlineConfigComment` to comment text.
|
|
85
|
+
*/
|
|
86
|
+
export declare function toInlineConfigCommentText({ rulesRecord, description }: Omit<InlineConfigComment, 'range'>): string;
|
|
87
|
+
/**
|
|
88
|
+
* Create the results with only messages with the specified rule ids.
|
|
89
|
+
* @param results The lint results.
|
|
90
|
+
* @param ruleIds The rule ids.
|
|
91
|
+
* @returns The results with only messages with the specified rule ids
|
|
92
|
+
*/
|
|
93
|
+
export declare function filterResultsByRuleId(results: ESLint.LintResult[], ruleIds: (string | null)[]): ESLint.LintResult[];
|
|
94
|
+
/**
|
|
95
|
+
* Find shebang from the first line of the file.
|
|
96
|
+
* @param sourceCodeText The source code text of the file.
|
|
97
|
+
* @returns The information of shebang. If the file does not have shebang, return null.
|
|
98
|
+
*/
|
|
99
|
+
export declare function findShebang(sourceCodeText: string): {
|
|
100
|
+
range: AST.Range;
|
|
101
|
+
} | null;
|
|
102
|
+
export {};
|
|
103
|
+
//# sourceMappingURL=eslint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint.d.ts","sourceRoot":"","sources":["../../src/util/eslint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM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