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.
Files changed (203) hide show
  1. package/README.md +19 -10
  2. package/dist/action/convert-error-to-warning-per-file.d.ts +4 -0
  3. package/dist/action/convert-error-to-warning-per-file.d.ts.map +1 -0
  4. package/dist/action/convert-error-to-warning-per-file.js +8 -0
  5. package/dist/action/convert-error-to-warning-per-file.js.map +1 -0
  6. package/dist/action/disable-per-file.d.ts +4 -0
  7. package/dist/action/disable-per-file.d.ts.map +1 -0
  8. package/dist/action/disable-per-file.js +12 -0
  9. package/dist/action/disable-per-file.js.map +1 -0
  10. package/dist/action/disable-per-line.d.ts +4 -0
  11. package/dist/action/disable-per-line.d.ts.map +1 -0
  12. package/dist/action/disable-per-line.js +12 -0
  13. package/dist/action/disable-per-line.js.map +1 -0
  14. package/dist/action/fix.d.ts +4 -0
  15. package/dist/action/fix.d.ts.map +1 -0
  16. package/dist/action/fix.js +6 -0
  17. package/dist/action/fix.js.map +1 -0
  18. package/dist/action/index.d.ts +6 -0
  19. package/dist/action/index.d.ts.map +1 -0
  20. package/dist/action/index.js +6 -0
  21. package/dist/action/index.js.map +1 -0
  22. package/dist/action/print-result-details.d.ts +4 -0
  23. package/dist/action/print-result-details.d.ts.map +1 -0
  24. package/dist/action/print-result-details.js +36 -0
  25. package/dist/action/print-result-details.js.map +1 -0
  26. package/dist/cli/log.d.ts +7 -0
  27. package/dist/cli/log.d.ts.map +1 -0
  28. package/dist/cli/log.js +35 -0
  29. package/dist/cli/log.js.map +1 -0
  30. package/dist/cli/package.d.ts +2 -0
  31. package/dist/cli/package.d.ts.map +1 -0
  32. package/dist/cli/package.js +6 -0
  33. package/dist/cli/package.js.map +1 -0
  34. package/dist/cli/pager.d.ts +2 -0
  35. package/dist/cli/pager.d.ts.map +1 -0
  36. package/dist/cli/pager.js +34 -0
  37. package/dist/cli/pager.js.map +1 -0
  38. package/dist/cli/parse-argv.d.ts +4 -0
  39. package/dist/cli/parse-argv.d.ts.map +1 -0
  40. package/dist/cli/parse-argv.js +103 -0
  41. package/dist/cli/parse-argv.js.map +1 -0
  42. package/dist/cli/prompt.d.ts +51 -0
  43. package/dist/cli/prompt.d.ts.map +1 -0
  44. package/dist/cli/prompt.js +97 -0
  45. package/dist/cli/prompt.js.map +1 -0
  46. package/dist/cli/run.d.ts +6 -0
  47. package/dist/cli/run.d.ts.map +1 -0
  48. package/dist/cli/run.js +28 -0
  49. package/dist/cli/run.js.map +1 -0
  50. package/dist/core.d.ts +82 -0
  51. package/dist/core.d.ts.map +1 -0
  52. package/dist/core.js +189 -0
  53. package/dist/core.js.map +1 -0
  54. package/dist/eslint/linter.d.ts +18 -0
  55. package/dist/eslint/linter.d.ts.map +1 -0
  56. package/dist/eslint/linter.js +71 -0
  57. package/dist/eslint/linter.js.map +1 -0
  58. package/dist/eslint/report-translator.d.ts +9 -0
  59. package/dist/eslint/report-translator.d.ts.map +1 -0
  60. package/dist/eslint/report-translator.js +75 -0
  61. package/dist/eslint/report-translator.js.map +1 -0
  62. package/dist/eslint/rule-fixer.d.ts +80 -0
  63. package/dist/eslint/rule-fixer.d.ts.map +1 -0
  64. package/dist/eslint/rule-fixer.js +114 -0
  65. package/dist/eslint/rule-fixer.js.map +1 -0
  66. package/dist/eslint/source-code-fixer.d.ts +15 -0
  67. package/dist/eslint/source-code-fixer.d.ts.map +1 -0
  68. package/dist/eslint/source-code-fixer.js +131 -0
  69. package/dist/eslint/source-code-fixer.js.map +1 -0
  70. package/dist/fix/apply-auto-fixes.d.ts +8 -0
  71. package/dist/fix/apply-auto-fixes.d.ts.map +1 -0
  72. package/dist/fix/apply-auto-fixes.js +8 -0
  73. package/dist/fix/apply-auto-fixes.js.map +1 -0
  74. package/dist/fix/apply-suggestions.d.ts +11 -0
  75. package/dist/fix/apply-suggestions.d.ts.map +1 -0
  76. package/dist/fix/apply-suggestions.js +25 -0
  77. package/dist/fix/apply-suggestions.js.map +1 -0
  78. package/dist/fix/convert-error-to-warning-per-file.d.ts +10 -0
  79. package/dist/fix/convert-error-to-warning-per-file.d.ts.map +1 -0
  80. package/dist/fix/convert-error-to-warning-per-file.js +28 -0
  81. package/dist/fix/convert-error-to-warning-per-file.js.map +1 -0
  82. package/dist/fix/disable-per-file.d.ts +12 -0
  83. package/dist/fix/disable-per-file.d.ts.map +1 -0
  84. package/dist/fix/disable-per-file.js +63 -0
  85. package/dist/fix/disable-per-file.js.map +1 -0
  86. package/dist/fix/disable-per-line.d.ts +12 -0
  87. package/dist/fix/disable-per-line.d.ts.map +1 -0
  88. package/dist/fix/disable-per-line.js +72 -0
  89. package/dist/fix/disable-per-line.js.map +1 -0
  90. package/dist/fix/index.d.ts +19 -0
  91. package/dist/fix/index.d.ts.map +1 -0
  92. package/dist/fix/index.js +8 -0
  93. package/dist/fix/index.js.map +1 -0
  94. package/dist/fix/make-fixable-and-fix.d.ts +11 -0
  95. package/dist/fix/make-fixable-and-fix.d.ts.map +1 -0
  96. package/dist/fix/make-fixable-and-fix.js +35 -0
  97. package/dist/fix/make-fixable-and-fix.js.map +1 -0
  98. package/dist/formatter/colors.d.ts +4 -0
  99. package/dist/formatter/colors.d.ts.map +1 -0
  100. package/dist/formatter/colors.js +5 -0
  101. package/dist/formatter/colors.js.map +1 -0
  102. package/dist/formatter/filter-rule-statistics.d.ts +9 -0
  103. package/dist/formatter/filter-rule-statistics.d.ts.map +1 -0
  104. package/dist/formatter/filter-rule-statistics.js +22 -0
  105. package/dist/formatter/filter-rule-statistics.js.map +1 -0
  106. package/dist/formatter/format-by-files.d.ts +3 -0
  107. package/dist/formatter/format-by-files.d.ts.map +1 -0
  108. package/dist/formatter/format-by-files.js +42 -0
  109. package/dist/formatter/format-by-files.js.map +1 -0
  110. package/dist/formatter/format-by-rules.d.ts +9 -0
  111. package/dist/formatter/format-by-rules.d.ts.map +1 -0
  112. package/dist/formatter/format-by-rules.js +33 -0
  113. package/dist/formatter/format-by-rules.js.map +1 -0
  114. package/dist/formatter/format-table.d.ts +4 -0
  115. package/dist/formatter/format-table.d.ts.map +1 -0
  116. package/dist/formatter/format-table.js +62 -0
  117. package/dist/formatter/format-table.js.map +1 -0
  118. package/dist/formatter/index.d.ts +7 -0
  119. package/dist/formatter/index.d.ts.map +1 -0
  120. package/dist/formatter/index.js +9 -0
  121. package/dist/formatter/index.js.map +1 -0
  122. package/dist/formatter/sort-rule-statistics.d.ts +5 -0
  123. package/dist/formatter/sort-rule-statistics.d.ts.map +1 -0
  124. package/dist/formatter/sort-rule-statistics.js +34 -0
  125. package/dist/formatter/sort-rule-statistics.js.map +1 -0
  126. package/dist/formatter/take-rule-statistics.d.ts +18 -0
  127. package/dist/formatter/take-rule-statistics.d.ts.map +1 -0
  128. package/dist/formatter/take-rule-statistics.js +51 -0
  129. package/dist/formatter/take-rule-statistics.js.map +1 -0
  130. package/dist/index.d.ts +6 -0
  131. package/dist/index.d.ts.map +1 -0
  132. package/dist/index.js +6 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/plugin.d.ts +4 -0
  135. package/dist/plugin.d.ts.map +1 -0
  136. package/dist/plugin.js +87 -0
  137. package/dist/plugin.js.map +1 -0
  138. package/dist/scene/check-results.d.ts +21 -0
  139. package/dist/scene/check-results.d.ts.map +1 -0
  140. package/dist/scene/check-results.js +19 -0
  141. package/dist/scene/check-results.js.map +1 -0
  142. package/dist/scene/index.d.ts +25 -0
  143. package/dist/scene/index.d.ts.map +1 -0
  144. package/dist/scene/index.js +6 -0
  145. package/dist/scene/index.js.map +1 -0
  146. package/dist/scene/lint.d.ts +7 -0
  147. package/dist/scene/lint.d.ts.map +1 -0
  148. package/dist/scene/lint.js +34 -0
  149. package/dist/scene/lint.js.map +1 -0
  150. package/dist/scene/select-action.d.ts +19 -0
  151. package/dist/scene/select-action.d.ts.map +1 -0
  152. package/dist/scene/select-action.js +44 -0
  153. package/dist/scene/select-action.js.map +1 -0
  154. package/dist/scene/select-rule-ids.d.ts +14 -0
  155. package/dist/scene/select-rule-ids.d.ts.map +1 -0
  156. package/dist/scene/select-rule-ids.js +10 -0
  157. package/dist/scene/select-rule-ids.js.map +1 -0
  158. package/dist/type.d.ts +14 -0
  159. package/dist/type.d.ts.map +1 -0
  160. package/dist/type.js +2 -0
  161. package/dist/type.js.map +1 -0
  162. package/dist/util/array.d.ts +3 -0
  163. package/dist/util/array.d.ts.map +1 -0
  164. package/dist/util/array.js +14 -0
  165. package/dist/util/array.js.map +1 -0
  166. package/dist/util/eslint.d.ts +103 -0
  167. package/dist/util/eslint.d.ts.map +1 -0
  168. package/dist/util/eslint.js +220 -0
  169. package/dist/util/eslint.js.map +1 -0
  170. package/dist/util/terminal-link.d.ts +2 -0
  171. package/dist/util/terminal-link.d.ts.map +1 -0
  172. package/dist/util/terminal-link.js +16 -0
  173. package/dist/util/terminal-link.js.map +1 -0
  174. package/dist/util/type-check.d.ts +3 -0
  175. package/dist/util/type-check.d.ts.map +1 -0
  176. package/dist/util/type-check.js +8 -0
  177. package/dist/util/type-check.js.map +1 -0
  178. package/package.json +22 -24
  179. package/src/action/convert-error-to-warning-per-file.ts +4 -6
  180. package/src/action/disable-per-file.ts +4 -6
  181. package/src/action/disable-per-line.ts +4 -6
  182. package/src/action/fix.ts +4 -10
  183. package/src/action/print-result-details.ts +5 -9
  184. package/src/cli/log.ts +25 -0
  185. package/src/cli/parse-argv.ts +32 -11
  186. package/src/cli/prompt.ts +56 -92
  187. package/src/cli/run.ts +3 -29
  188. package/src/core.ts +13 -6
  189. package/src/fix/disable-per-file.ts +1 -1
  190. package/src/fix/disable-per-line.ts +1 -1
  191. package/src/formatter/filter-rule-statistics.ts +27 -0
  192. package/src/formatter/format-by-rules.ts +10 -7
  193. package/src/formatter/index.ts +4 -3
  194. package/src/index.ts +1 -1
  195. package/src/scene/check-results.ts +2 -5
  196. package/src/scene/lint.ts +14 -12
  197. package/src/scene/select-action.ts +2 -4
  198. package/src/scene/select-rule-ids.ts +2 -6
  199. package/src/type.ts +2 -0
  200. package/src/util/terminal-link.ts +16 -0
  201. package/src/cli/spinner.ts +0 -22
  202. package/src/core-worker.ts +0 -55
  203. package/src/typings/enquirer.d.ts +0 -7
@@ -0,0 +1,4 @@
1
+ import type { ESLint, SourceCode } from 'eslint';
2
+ export declare function getLastSourceCode(): SourceCode | null;
3
+ export declare const plugin: ESLint.Plugin;
4
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAQ,UAAU,EAAE,MAAM,QAAQ,CAAC;AAIvD,wBAAgB,iBAAiB,sBAEhC;AAED,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MA4E3B,CAAC"}
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,MAAM,UAAU,iBAAiB;IAC/B,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAkB;IACnC,KAAK,EAAE;QACL;;;WAGG;QACH,sBAAsB,EAAE;YACtB,MAAM,CAAC,OAAO;gBACZ,cAAc,GAAG,OAAO,CAAC,UAAwB,CAAC;gBAClD,OAAO,EAAE,CAAC;YACZ,CAAC;SACF;QACD,gGAAgG;QAChG,6BAA6B,EAAE;YAC7B,MAAM,CAAC,OAAyB;gBAC9B,OA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AC,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;AAErC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/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,CAWvC"}
@@ -0,0 +1,19 @@
1
+ import { withProgress } from '../cli/log.js';
2
+ import { promptToInputWhatToDoNext } from '../cli/prompt.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 withProgress('Undoing', async () => undo());
12
+ return {
13
+ name: 'selectAction',
14
+ args: { results, ruleIdsInResults, selectedRuleIds, initialAction: selectedAction },
15
+ };
16
+ }
17
+ return { name: 'lint' };
18
+ }
19
+ //# sourceMappingURL=check-results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-results.js","sourceRoot":"","sources":["../../src/scene/check-results.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAiB7D;;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,YAAY,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QAClD,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,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,7 @@
1
+ import type { Core } from '../core.js';
2
+ import type { NextScene } from './index.js';
3
+ /**
4
+ * Run the scene to lint.
5
+ */
6
+ export declare function lint(core: Core): Promise<NextScene>;
7
+ //# sourceMappingURL=lint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/scene/lint.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,wBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,CAgCzD"}
@@ -0,0 +1,34 @@
1
+ import { log } from '@clack/prompts';
2
+ import { error, withProgress } from '../cli/log.js';
3
+ /**
4
+ * Run the scene to lint.
5
+ */
6
+ export async function lint(core) {
7
+ const results = await withProgress('Linting', async () => core.lint());
8
+ // Check for ESLint core problems (ruleId === null) first.
9
+ // These represent config errors, syntax errors, etc. that eslint-interactive cannot fix.
10
+ const hasESLintCoreProblems = results.flatMap((result) => result.messages).some((message) => message.ruleId === null);
11
+ if (hasESLintCoreProblems) {
12
+ error('ESLint Core Problems are found. ' +
13
+ 'The problems cannot be fixed by eslint-interactive. ' +
14
+ 'Check the details of the problem and fix it. ' +
15
+ 'This is usually caused by the invalid eslint config or the invalid syntax of the linted code.');
16
+ log.message(await core.formatResultDetails(results, [null]), {});
17
+ // eslint-disable-next-line n/no-process-exit
18
+ process.exit(1);
19
+ }
20
+ const ruleIdsInResults = core.getFilteredAndSortedRuleIds(results);
21
+ if (ruleIdsInResults.length === 0) {
22
+ const hasAnyMessage = results.some((result) => result.messages.length > 0);
23
+ if (hasAnyMessage) {
24
+ log.message('💚 No rules match the given --filter.');
25
+ }
26
+ else {
27
+ log.message('💚 No rules with problems.');
28
+ }
29
+ return { name: 'exit' };
30
+ }
31
+ log.message(core.formatResultSummary(results));
32
+ return { name: 'selectRuleIds', args: { results, ruleIdsInResults } };
33
+ }
34
+ //# sour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,CAAC,OAAO,CAAC,uCAAuC,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC;IACD,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IAE/C,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC;AACxE,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { ESLint } from 'eslint';
2
+ import type { Action } from '../cli/prompt.js';
3
+ import type { Core } from '../core.js';
4
+ import type { NextScene } from './index.js';
5
+ export type SelectActionArgs = {
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 action to be initially selected. */
13
+ initialAction?: Action;
14
+ };
15
+ /**
16
+ * Run the scene where a user select the action to be performed for the problems of selected rules.
17
+ */
18
+ export declare function selectAction(core: Core, { results, ruleIdsInResults, selectedRuleIds, initialAction }: SelectActionArgs): Promise<NextScene>;
19
+ //# 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,QAAQ,CAAC;AAQrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,IAAI,EAAQ,MAAM,YAAY,CAAC;AAE7C,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,IAAI,EACV,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":"AACA,OAAO,EACL,oCAAoC,EACpC,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,EACX,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAcpD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAU,EACV,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAoB;IAE/E,MAAM,cAAc,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;IAE1F,MAAM,kBAAkB,GAAc,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC;IACrG,MAAM,iBAAiB,GAAc,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,EAAE,CAAC;IAEpH,SAAS,uBAAuB,CAAC,IAAU;QACzC,OAAO;YACL,IAAI,EAAE,cAAc;YACpB,IAAI,E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
@@ -0,0 +1,14 @@
1
+ import type { ESLint } from 'eslint';
2
+ import type { Core } from '../core.js';
3
+ import type { NextScene } from './index.js';
4
+ export type SelectRuleIdsArgs = {
5
+ /** The lint results of the project */
6
+ results: ESLint.LintResult[];
7
+ /** The rule ids that are in the `results`. */
8
+ ruleIdsInResults: string[];
9
+ };
10
+ /**
11
+ * Run the scene where a user select rule ids.
12
+ */
13
+ export declare function selectRuleIds(core: Core, { results, ruleIdsInResults }: SelectRuleIdsArgs): Promise<NextScene>;
14
+ //# 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,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,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,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,CAGpH"}
@@ -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":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AASlD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAU,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAqB;IAC9F,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,14 @@
1
+ import type { ESLint } from 'eslint';
2
+ export type SortField = 'rule' | 'error' | 'warning' | 'fixable' | 'suggestions';
3
+ export type SortOrder = 'asc' | 'desc';
4
+ export type FilterCriterion = 'fixable' | 'has-suggestions';
5
+ /** The config of eslint-interactive */
6
+ export type Config = ESLint.Options & {
7
+ patterns: string[];
8
+ formatterName?: string | undefined;
9
+ quiet?: boolean | undefined;
10
+ sort?: SortField | undefined;
11
+ sortOrder?: SortOrder | undefined;
12
+ filters?: FilterCriterion[] | undefined;
13
+ };
14
+ //# 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;AACvC,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,iBAAiB,CAAC;AAE5D,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;IAClC,OAAO,CAAC,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC;CACzC,CAAC"}
package/dist/type.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export declare function unique<T>(array: T[]): T[];
2
+ export declare function groupBy<T, K>(array: T[], toKey: (item: T) => K): Map<K, T[]>;
3
+ //# sourceMappingURL=array.d.ts.map
@@ -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,QAAQ,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAQtD,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxB,GAAG,EAAE,cAAc,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CA8BhF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE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