eslint-interactive 8.1.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/LICENSE +25 -0
- package/README.md +147 -0
- package/bin/eslint-interactive.js +10 -0
- package/dist/action/apply-suggestions.d.ts +6 -0
- package/dist/action/apply-suggestions.d.ts.map +1 -0
- package/dist/action/apply-suggestions.js +28 -0
- package/dist/action/apply-suggestions.js.map +1 -0
- package/dist/action/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 +8 -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 +8 -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 +7 -0
- package/dist/action/index.d.ts.map +1 -0
- package/dist/action/index.js +7 -0
- package/dist/action/index.js.map +1 -0
- package/dist/action/make-fixable-and-fix.d.ts +6 -0
- package/dist/action/make-fixable-and-fix.d.ts.map +1 -0
- package/dist/action/make-fixable-and-fix.js +28 -0
- package/dist/action/make-fixable-and-fix.js.map +1 -0
- package/dist/action/print-result-details.d.ts +5 -0
- package/dist/action/print-result-details.d.ts.map +1 -0
- package/dist/action/print-result-details.js +12 -0
- package/dist/action/print-result-details.js.map +1 -0
- package/dist/cli/log.d.ts +6 -0
- package/dist/cli/log.d.ts.map +1 -0
- package/dist/cli/log.js +9 -0
- package/dist/cli/log.js.map +1 -0
- package/dist/cli/ora.d.ts +4 -0
- package/dist/cli/ora.d.ts.map +1 -0
- package/dist/cli/ora.js +23 -0
- package/dist/cli/ora.js.map +1 -0
- package/dist/cli/package.d.ts +2 -0
- package/dist/cli/package.d.ts.map +1 -0
- package/dist/cli/package.js +6 -0
- package/dist/cli/package.js.map +1 -0
- package/dist/cli/parse-argv.d.ts +4 -0
- package/dist/cli/parse-argv.d.ts.map +1 -0
- package/dist/cli/parse-argv.js +50 -0
- package/dist/cli/parse-argv.js.map +1 -0
- package/dist/cli/prompt.d.ts +53 -0
- package/dist/cli/prompt.d.ts.map +1 -0
- package/dist/cli/prompt.js +154 -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 +46 -0
- package/dist/cli/run.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 +52 -0
- package/dist/core-worker.js.map +1 -0
- package/dist/core.d.ts +84 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +196 -0
- package/dist/core.js.map +1 -0
- package/dist/formatter/colors.d.ts +4 -0
- package/dist/formatter/colors.d.ts.map +1 -0
- package/dist/formatter/colors.js +5 -0
- package/dist/formatter/colors.js.map +1 -0
- package/dist/formatter/format-by-files.d.ts +3 -0
- package/dist/formatter/format-by-files.d.ts.map +1 -0
- package/dist/formatter/format-by-files.js +41 -0
- package/dist/formatter/format-by-files.js.map +1 -0
- package/dist/formatter/format-by-rules.d.ts +3 -0
- package/dist/formatter/format-by-rules.d.ts.map +1 -0
- package/dist/formatter/format-by-rules.js +34 -0
- package/dist/formatter/format-by-rules.js.map +1 -0
- package/dist/formatter/index.d.ts +4 -0
- package/dist/formatter/index.d.ts.map +1 -0
- package/dist/formatter/index.js +7 -0
- package/dist/formatter/index.js.map +1 -0
- package/dist/formatter/take-rule-statistics.d.ts +18 -0
- package/dist/formatter/take-rule-statistics.d.ts.map +1 -0
- package/dist/formatter/take-rule-statistics.js +51 -0
- package/dist/formatter/take-rule-statistics.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin/fix/apply-auto-fixes.d.ts +8 -0
- package/dist/plugin/fix/apply-auto-fixes.d.ts.map +1 -0
- package/dist/plugin/fix/apply-auto-fixes.js +8 -0
- package/dist/plugin/fix/apply-auto-fixes.js.map +1 -0
- package/dist/plugin/fix/apply-suggestions.d.ts +11 -0
- package/dist/plugin/fix/apply-suggestions.d.ts.map +1 -0
- package/dist/plugin/fix/apply-suggestions.js +25 -0
- package/dist/plugin/fix/apply-suggestions.js.map +1 -0
- package/dist/plugin/fix/disable-per-file.d.ts +10 -0
- package/dist/plugin/fix/disable-per-file.d.ts.map +1 -0
- package/dist/plugin/fix/disable-per-file.js +39 -0
- package/dist/plugin/fix/disable-per-file.js.map +1 -0
- package/dist/plugin/fix/disable-per-line.d.ts +10 -0
- package/dist/plugin/fix/disable-per-line.d.ts.map +1 -0
- package/dist/plugin/fix/disable-per-line.js +54 -0
- package/dist/plugin/fix/disable-per-line.js.map +1 -0
- package/dist/plugin/fix/index.d.ts +6 -0
- package/dist/plugin/fix/index.d.ts.map +1 -0
- package/dist/plugin/fix/index.js +6 -0
- package/dist/plugin/fix/index.js.map +1 -0
- package/dist/plugin/fix/make-fixable-and-fix.d.ts +12 -0
- package/dist/plugin/fix/make-fixable-and-fix.d.ts.map +1 -0
- package/dist/plugin/fix/make-fixable-and-fix.js +61 -0
- package/dist/plugin/fix/make-fixable-and-fix.js.map +1 -0
- package/dist/plugin/fix-rule.d.ts +10 -0
- package/dist/plugin/fix-rule.d.ts.map +1 -0
- package/dist/plugin/fix-rule.js +124 -0
- package/dist/plugin/fix-rule.js.map +1 -0
- package/dist/plugin/index.d.ts +49 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +11 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/prefer-addition-shorthand-rule.d.ts +7 -0
- package/dist/plugin/prefer-addition-shorthand-rule.d.ts.map +1 -0
- package/dist/plugin/prefer-addition-shorthand-rule.js +54 -0
- package/dist/plugin/prefer-addition-shorthand-rule.js.map +1 -0
- package/dist/plugin/rule-fixer.d.ts +80 -0
- package/dist/plugin/rule-fixer.d.ts.map +1 -0
- package/dist/plugin/rule-fixer.js +118 -0
- package/dist/plugin/rule-fixer.js.map +1 -0
- package/dist/scene/check-results.d.ts +21 -0
- package/dist/scene/check-results.d.ts.map +1 -0
- package/dist/scene/check-results.js +22 -0
- package/dist/scene/check-results.js.map +1 -0
- package/dist/scene/index.d.ts +25 -0
- package/dist/scene/index.d.ts.map +1 -0
- package/dist/scene/index.js +6 -0
- package/dist/scene/index.js.map +1 -0
- package/dist/scene/lint.d.ts +8 -0
- package/dist/scene/lint.d.ts.map +1 -0
- package/dist/scene/lint.js +31 -0
- package/dist/scene/lint.js.map +1 -0
- package/dist/scene/select-action.d.ts +20 -0
- package/dist/scene/select-action.d.ts.map +1 -0
- package/dist/scene/select-action.js +46 -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/tsconfig.src.tsbuildinfo +1 -0
- package/dist/util/array.d.ts +3 -0
- package/dist/util/array.d.ts.map +1 -0
- package/dist/util/array.js +14 -0
- package/dist/util/array.js.map +1 -0
- package/dist/util/cache.d.ts +5 -0
- package/dist/util/cache.d.ts.map +1 -0
- package/dist/util/cache.js +13 -0
- package/dist/util/cache.js.map +1 -0
- package/dist/util/eslint.d.ts +68 -0
- package/dist/util/eslint.d.ts.map +1 -0
- package/dist/util/eslint.js +147 -0
- package/dist/util/eslint.js.map +1 -0
- package/dist/util/filter-script.d.ts +6 -0
- package/dist/util/filter-script.d.ts.map +1 -0
- package/dist/util/filter-script.js +39 -0
- package/dist/util/filter-script.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 +93 -0
- package/src/action/apply-suggestions.ts +40 -0
- package/src/action/disable-per-file.ts +16 -0
- package/src/action/disable-per-line.ts +16 -0
- package/src/action/fix.ts +14 -0
- package/src/action/index.ts +6 -0
- package/src/action/make-fixable-and-fix.ts +40 -0
- package/src/action/print-result-details.ts +18 -0
- package/src/cli/log.ts +11 -0
- package/src/cli/ora.ts +25 -0
- package/src/cli/package.ts +9 -0
- package/src/cli/parse-argv.ts +52 -0
- package/src/cli/prompt.ts +205 -0
- package/src/cli/run.ts +50 -0
- package/src/core-worker.ts +66 -0
- package/src/core.ts +240 -0
- package/src/formatter/colors.ts +5 -0
- package/src/formatter/format-by-files.ts +48 -0
- package/src/formatter/format-by-rules.ts +37 -0
- package/src/formatter/index.ts +9 -0
- package/src/formatter/take-rule-statistics.ts +66 -0
- package/src/index.ts +4 -0
- package/src/plugin/fix/apply-auto-fixes.ts +13 -0
- package/src/plugin/fix/apply-suggestions.ts +44 -0
- package/src/plugin/fix/disable-per-file.ts +53 -0
- package/src/plugin/fix/disable-per-line.ts +65 -0
- package/src/plugin/fix/index.ts +13 -0
- package/src/plugin/fix/make-fixable-and-fix.ts +77 -0
- package/src/plugin/fix-rule.ts +142 -0
- package/src/plugin/index.ts +66 -0
- package/src/plugin/prefer-addition-shorthand-rule.ts +56 -0
- package/src/plugin/rule-fixer.ts +147 -0
- package/src/scene/check-results.ts +43 -0
- package/src/scene/index.ts +18 -0
- package/src/scene/lint.ts +41 -0
- package/src/scene/select-action.ts +70 -0
- package/src/scene/select-rule-ids.ts +24 -0
- package/src/typings/cachedir.d.ts +5 -0
- package/src/typings/node-pager.d.ts +4 -0
- package/src/util/array.ts +16 -0
- package/src/util/cache.ts +11 -0
- package/src/util/eslint.ts +162 -0
- package/src/util/filter-script.ts +45 -0
- package/src/util/type-check.ts +8 -0
- package/static/example-filter-script.js +49 -0
- package/static/example-fixable-maker-script.js +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 mizdra (owner of mizdra/eslint-interactive)
|
|
4
|
+
Copyright (c) 2015 David Waterston (owner of davidwaterston/eslint-summary)
|
|
5
|
+
Copyright (c) 2015 Omer Ganim (owner of ganimomer/eslint-stats)
|
|
6
|
+
Copyright (c) 2015 Ian VanSchooten (owner of IanVS/eslint-stats)
|
|
7
|
+
Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img alt="Cover image" src="./docs/cover.svg" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h2 align="center">The CLI tool to fix huge number of ESLint errors</h2>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<em>Quick fixes, per rule.</em>
|
|
9
|
+
<br />
|
|
10
|
+
<em>
|
|
11
|
+
Run <code>eslint --fix</code>, disable per line, apply suggestions, and more!
|
|
12
|
+
</em>
|
|
13
|
+
<img alt="Screenshot" src="./docs/screenshot.png" />
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
## Motivation
|
|
17
|
+
|
|
18
|
+
The default ESLint output contains a lot of useful messages for developers, such as the source of the error and hints for fixing it. While this works for many use cases, it does not work well in situations where many messages are reported. For example, when introducing ESLint into a project, or when making big changes to the `.eslintrc` of a project. In these situations, the output of ESLint can be quite large, making it difficult for developers to analyze the output. It is also difficult for the developer to fix messages mechanically, because messages of many rules are mixed up in the output.
|
|
19
|
+
|
|
20
|
+
In such the above situation, I think two things are important:
|
|
21
|
+
|
|
22
|
+
- Show a summary of all problems (called _"warnings"_ or _"errors"_ in ESLint) so that the whole picture can be easily understood
|
|
23
|
+
- Showing the details of each problem will confuse developers.
|
|
24
|
+
- Provide an efficient way to fix many problems
|
|
25
|
+
- `eslint --fix` is one of the best ways to fix problems efficiently, but it auto-fixes all rule problems at once.
|
|
26
|
+
- Depending on the rule, auto-fix may affect the behavior of the code, so auto-fix should be done with care.
|
|
27
|
+
- Therefore, it is desirable to provide a way to auto-fix in smaller units than `eslint --fix`.
|
|
28
|
+
|
|
29
|
+
So, I created a tool called `eslint-interactive` which wraps ESLint. This tool groups all problems by rule and outputs formatted number of problems per rule. In addition to the breakdown of problems per rule, it also outputs the number of fixable problems and other hints to help developers fix problems.
|
|
30
|
+
|
|
31
|
+
It also supports the following actions in addition to `eslint --fix`. All actions can be applied for each rule:
|
|
32
|
+
|
|
33
|
+
- Display details of lint results
|
|
34
|
+
- Run `eslint --fix`
|
|
35
|
+
- Disable per line (by `// eslint-disable-next-line <rule-name>`)
|
|
36
|
+
- Disable per file (`/* eslint-disable <rule-name> */`)
|
|
37
|
+
- Apply suggestions
|
|
38
|
+
- Make forcibly fixable and run `eslint --fix`
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
:memo: NOTE: The globally installed `eslint-interactive` is **not officially supported**. It is recommended to install `eslint-interactive` locally. See [FAQ](#why-is-global-installation-not-officially-supported).
|
|
43
|
+
|
|
44
|
+
```console
|
|
45
|
+
$ # For npm
|
|
46
|
+
$ npm i -D eslint-interactive
|
|
47
|
+
$ npx eslint-interactive --help
|
|
48
|
+
|
|
49
|
+
$ # For yarn
|
|
50
|
+
$ yarn add -D eslint-interactive
|
|
51
|
+
$ yarn eslint-interactive --help
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
The interface of `eslint-interactive` is partially compatible with `eslint`. So, in most cases, simply replacing `eslint` with `eslint-interactive` in the command to lint (e.g. `eslint ./src --ext .ts,.tsx`) will work. However, eslint-interactive is installed locally, so you need to add `npx`.
|
|
57
|
+
|
|
58
|
+
```console
|
|
59
|
+
$ # Show help
|
|
60
|
+
$ npx eslint-interactive --help
|
|
61
|
+
eslint-interactive [file.js] [dir]
|
|
62
|
+
|
|
63
|
+
Options:
|
|
64
|
+
--help Show help [boolean]
|
|
65
|
+
--version Show version number [boolean]
|
|
66
|
+
--rulesdir Use additional rules from this directory [array]
|
|
67
|
+
--ext Specify JavaScript file extensions [array]
|
|
68
|
+
--format Specify the format to be used for the `Display problem messa
|
|
69
|
+
ges` action [string] [default: "codeframe"]
|
|
70
|
+
--cache Only check changed files [boolean] [default: true]
|
|
71
|
+
--cache-location Path to the cache file or directory
|
|
72
|
+
[string] [default: "/tmp/.eslintcache"]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
$ # Examples
|
|
76
|
+
$ npx eslint-interactive ./src
|
|
77
|
+
$ npx eslint-interactive ./src ./test
|
|
78
|
+
$ npx eslint-interactive './src/**/*.{ts,tsx,vue}'
|
|
79
|
+
$ npx eslint-interactive ./src --ext .ts,.tsx,.vue
|
|
80
|
+
$ npx eslint-interactive ./src --rulesdir ./rules
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Available actions
|
|
84
|
+
|
|
85
|
+
Actions can be executed per rule.
|
|
86
|
+
|
|
87
|
+
- Display details of lint results
|
|
88
|
+
- Displays ESLint error reports.
|
|
89
|
+
- Run `eslint --fix`
|
|
90
|
+
- Apply fixable problems.
|
|
91
|
+
- Disable per line
|
|
92
|
+
- Add disable comments (`// eslint-disable-next-line <rule-name>`) per line.
|
|
93
|
+
- Disable per file
|
|
94
|
+
- Add disable comments (`// eslint-disable <rule-name>`) per file.
|
|
95
|
+
- Apply suggestions (experimental, for experts)
|
|
96
|
+
- Select one of the applicable suggestions and apply it. ([What's _suggestions_?](#whats-suggestions))
|
|
97
|
+
- Users can write JavaScript code to programmatically select the suggestion to be applied.
|
|
98
|
+
- The tool will tell you how to use the feature in detail. Please follow the instructions of the tool.
|
|
99
|
+
- This feature is experimental and may change significantly.
|
|
100
|
+
- Make forcibly fixable and run `eslint --fix` (experimental, for experts)
|
|
101
|
+
- This feature make forcibly un-fixable problems fixable, and apply them.
|
|
102
|
+
- The tool will tell you how to use the feature in detail. Please follow the instructions of the tool.
|
|
103
|
+
- This feature is experimental and may change significantly.
|
|
104
|
+
|
|
105
|
+
## Programmable API
|
|
106
|
+
|
|
107
|
+
See [Programmable API documentation](./docs/programmable-api.md).
|
|
108
|
+
|
|
109
|
+
## FAQ
|
|
110
|
+
|
|
111
|
+
### What's _suggestions_?
|
|
112
|
+
|
|
113
|
+
> Excerpt a quote from [official ESLint documentation](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
|
|
114
|
+
|
|
115
|
+
In some cases fixes aren't appropriate to be automatically applied, for example, if a fix potentially changes functionality or if there are multiple valid ways to fix a rule depending on the implementation intent. In such a case, the ESLint rule provides candidates for a fix. These are called _suggestions_.
|
|
116
|
+
|
|
117
|
+
Suggestion can be one or more. The user has to manually decide if that fix should be applied or which fix should be applied because automatically applying of suggestion is inappropriate. For this reason, ESLint has stated that it will not officially provide a way to automatically apply suggestion ([ref](https://github.com/eslint/rfcs/tree/64b2511da6f2c10e1692671315459eb916aea53f/designs/2019-suggestions#:~:text=Unlike%20fixes%2C%20suggestion%20will%20not%20expose%20a%20new%20API%20function)). Instead, tools such as [`vscode-eslint`](https://github.com/microsoft/vscode-eslint) allow users to apply suggestions manually ([ref](https://github.com/microsoft/vscode-eslint/pull/814#issuecomment-587011529)).
|
|
118
|
+
|
|
119
|
+
### Why is global installation not officially supported?
|
|
120
|
+
|
|
121
|
+
`eslint` is installed locally in most projects. In such a case, if `eslint-interactive` is installed globally, it will be installed in a different space than `eslint`. The space separation makes some resources of `eslint-interactive` inaccessible from `eslint` and may break them (ref: [#77](https://github.com/mizdra/eslint-interactive/issues/77)). Therefore, global installation of `eslint-interactive` is not officially supported.
|
|
122
|
+
|
|
123
|
+
### Is global installation prohibited?
|
|
124
|
+
|
|
125
|
+
No. `eslint-interactive` does not prohibit global installation. Global installation is allowed because it has the advantage of saving installation effort. However, it is not officially supported and users must use it at their own risk.
|
|
126
|
+
|
|
127
|
+
If the global installation does not work, you can send a patch by pull request. However, whether the patch will be accepted depends on the case.
|
|
128
|
+
|
|
129
|
+
### What's the difference from [eslint-nibble](https://github.com/IanVS/eslint-nibble)?
|
|
130
|
+
|
|
131
|
+
A tool similar to `eslint-interactive` is [eslint-nibble](https://github.com/IanVS/eslint-nibble). Both tools solve the same problem, but `eslint-interactive` has some features that `eslint-nibble` does not have. For example, `eslint-interactive` prints the number of fixable problems per rule, while `eslint-nibble` does not. Also, `eslint-interactive` has various tricks to speed up the cycle of auto-fixing per-rule, but `eslint-nibble` auto-fixes once and terminates the process every time, so it is not as fast as `eslint-interactive`.
|
|
132
|
+
|
|
133
|
+
I think these features are very important to solve the aforementioned problem. At first, I thought of implementing these features in `eslint-nibble`, but it required a major rewrite of the code, so I implemented it as a new tool `eslint-interactive`. Although `eslint-interactive` is a tool independent of `eslint-nibble`, it is influenced by the ideas of `eslint-nibble` and inherits some of its code. That's why you can find the names of [@IanVS](https://github.com/IanVS) and others in [the license of `eslint-interactive`](https://github.com/mizdra/eslint-interactive/blob/main/LICENSE).
|
|
134
|
+
|
|
135
|
+
Thanks, [@IanVS](https://github.com/IanVS).
|
|
136
|
+
|
|
137
|
+
### What's the difference from [suppress-eslint-errors](https://github.com/amanda-mitchell/suppress-eslint-errors)?
|
|
138
|
+
|
|
139
|
+
[suppress-eslint-errors](https://github.com/amanda-mitchell/suppress-eslint-errors) is an excellent tool to add comments for disable mechanically. Just like `eslint-interactive`, it allows you to add disable comments for each rule and leave the purpose of disable as a comment. There is no functional difference between the two, but there is a difference in the API used to insert the comments.
|
|
140
|
+
|
|
141
|
+
`suppress-eslint-errors` uses [`jscodeshift`](https://github.com/facebook/jscodeshift) to insert comments. `jscodeshift` modifies the file in parallel, so `suppress-eslint-errors` has the advantage of being able to insert comments faster. However, `jscodeshift` cannot reuse the AST of ESLint, so you need to reparse the code in `jscodeshift`. This means that you have to pass `jscodeshift` the information it needs to parse your code (parser type, parser options). In fact, `suppress-eslint-errors` requires `--extensions` and `--parser` command line option. Normally, users specify the parsing options in `.eslintrc`, so passing these options may seem cumbersome. Also, due to the difference in the way ESLint and `jscodeshift` parse, it may not be possible to insert comments correctly.
|
|
142
|
+
|
|
143
|
+
On the other hand, `eslint-interactive` uses [`ESLint.outputFixes`](https://eslint.org/docs/developer-guide/nodejs-api#-eslintoutputfixesresults) to insert comments. It uses ESLint's API to do everything from parsing the code to inserting the comments, so it works as expected in many cases. Also, `eslint-interactive` will parse the code using the parsing options specified in `.eslintrc`. Therefore, comments can be inserted without any additional command line options. By the way, comment insertion is slower than `suppress-eslint-errors` because, unlike `suppress-eslint-errors`, it cannot modify files in parallel. However, this limitation may be improved when ESLint supports parallel processing in the near future.
|
|
144
|
+
|
|
145
|
+
## Benchmark
|
|
146
|
+
|
|
147
|
+
- https://mizdra.github.io/eslint-interactive/dev/bench/
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Remote } from 'comlink';
|
|
2
|
+
import { ESLint } from 'eslint';
|
|
3
|
+
import { SerializableCore } from '../core-worker.js';
|
|
4
|
+
import { Undo } from '../core.js';
|
|
5
|
+
export declare function doApplySuggestionsAction(core: Remote<SerializableCore>, results: ESLint.LintResult[], selectedRuleIds: string[]): Promise<Undo>;
|
|
6
|
+
//# sourceMappingURL=apply-suggestions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-suggestions.d.ts","sourceRoot":"","sources":["../../src/action/apply-suggestions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOlC,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAC9B,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAC5B,eAAe,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { access, mkdir, readFile, writeFile } from 'fs/promises';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
import { fixingSpinner } from '../cli/ora.js';
|
|
4
|
+
import { promptToInputReuseFilterScript } from '../cli/prompt.js';
|
|
5
|
+
import { editFileWithEditor, generateExampleFilterScriptFilePath, generateFilterScriptFilePath, } from '../util/filter-script.js';
|
|
6
|
+
export async function doApplySuggestionsAction(core, results, selectedRuleIds) {
|
|
7
|
+
const exampleScript = await readFile(generateExampleFilterScriptFilePath(), 'utf8');
|
|
8
|
+
const filterScriptFilePath = generateFilterScriptFilePath(selectedRuleIds);
|
|
9
|
+
const isFilterScriptExist = await access(filterScriptFilePath)
|
|
10
|
+
.then(() => true)
|
|
11
|
+
.catch(() => false);
|
|
12
|
+
if (isFilterScriptExist) {
|
|
13
|
+
const reuseFilterScript = await promptToInputReuseFilterScript();
|
|
14
|
+
if (!reuseFilterScript) {
|
|
15
|
+
await writeFile(filterScriptFilePath, exampleScript);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
// ディレクトリがない可能性を考慮して作成しておく
|
|
20
|
+
await mkdir(dirname(filterScriptFilePath), { recursive: true });
|
|
21
|
+
await writeFile(filterScriptFilePath, exampleScript);
|
|
22
|
+
}
|
|
23
|
+
console.log('Opening editor...');
|
|
24
|
+
const filterScript = await editFileWithEditor(filterScriptFilePath);
|
|
25
|
+
const undo = await fixingSpinner(async () => core.applySuggestions(results, selectedRuleIds, filterScript));
|
|
26
|
+
return undo;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=apply-suggestions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-suggestions.js","sourceRoot":"","sources":["../../src/action/apply-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAGlE,OAAO,EACL,kBAAkB,EAClB,mCAAmC,EACnC,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,IAA8B,EAC9B,OAA4B,EAC5B,eAAyB;IAEzB,MAAM,aAAa,GAAG,MAAM,QAAQ,CAAC,mCAAmC,EAAE,EAAE,MAAM,CAAC,CAAC;IACpF,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,eAAe,CAAC,CAAC;IAC3E,MAAM,mBAAmB,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC;SAC3D,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;SAChB,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IACtB,IAAI,mBAAmB,EAAE;QACvB,MAAM,iBAAiB,GAAG,MAAM,8BAA8B,EAAE,CAAC;QACjE,IAAI,CAAC,iBAAiB,EAAE;YACtB,MAAM,SAAS,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC;SACtD;KACF;SAAM;QACL,0BAA0B;QAC1B,MAAM,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,MAAM,SAAS,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC;KACtD;IACD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAEjC,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC,CAAC;IAC5G,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Remote } from 'comlink';
|
|
2
|
+
import { ESLint } from 'eslint';
|
|
3
|
+
import { SerializableCore } from '../core-worker.js';
|
|
4
|
+
import { Undo } from '../core.js';
|
|
5
|
+
export declare function doDisablePerFileAction(core: Remote<SerializableCore>, results: ESLint.LintResult[], selectedRuleIds: string[]): Promise<Undo>;
|
|
6
|
+
//# sourceMappingURL=disable-per-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disable-per-file.d.ts","sourceRoot":"","sources":["../../src/action/disable-per-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAC9B,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAC5B,eAAe,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { fixingSpinner } from '../cli/ora.js';
|
|
2
|
+
import { promptToInputDescription } from '../cli/prompt.js';
|
|
3
|
+
export async function doDisablePerFileAction(core, results, selectedRuleIds) {
|
|
4
|
+
const description = await promptToInputDescription();
|
|
5
|
+
const undo = await fixingSpinner(async () => core.disablePerFile(results, selectedRuleIds, description));
|
|
6
|
+
return undo;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=disable-per-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disable-per-file.js","sourceRoot":"","sources":["../../src/action/disable-per-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAI5D,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,IAA8B,EAC9B,OAA4B,EAC5B,eAAyB;IAEzB,MAAM,WAAW,GAAG,MAAM,wBAAwB,EAAE,CAAC;IACrD,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC;IACzG,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Remote } from 'comlink';
|
|
2
|
+
import { ESLint } from 'eslint';
|
|
3
|
+
import { SerializableCore } from '../core-worker.js';
|
|
4
|
+
import { Undo } from '../core.js';
|
|
5
|
+
export declare function doDisablePerLineAction(core: Remote<SerializableCore>, results: ESLint.LintResult[], selectedRuleIds: string[]): Promise<Undo>;
|
|
6
|
+
//# sourceMappingURL=disable-per-line.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disable-per-line.d.ts","sourceRoot":"","sources":["../../src/action/disable-per-line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAC9B,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAC5B,eAAe,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { fixingSpinner } from '../cli/ora.js';
|
|
2
|
+
import { promptToInputDescription } from '../cli/prompt.js';
|
|
3
|
+
export async function doDisablePerLineAction(core, results, selectedRuleIds) {
|
|
4
|
+
const description = await promptToInputDescription();
|
|
5
|
+
const undo = await fixingSpinner(async () => core.disablePerLine(results, selectedRuleIds, description));
|
|
6
|
+
return undo;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=disable-per-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disable-per-line.js","sourceRoot":"","sources":["../../src/action/disable-per-line.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAI5D,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,IAA8B,EAC9B,OAA4B,EAC5B,eAAyB;IAEzB,MAAM,WAAW,GAAG,MAAM,wBAAwB,EAAE,CAAC;IACrD,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC;IACzG,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Remote } from 'comlink';
|
|
2
|
+
import { ESLint } from 'eslint';
|
|
3
|
+
import { SerializableCore } from '../core-worker.js';
|
|
4
|
+
import { Undo } from '../core.js';
|
|
5
|
+
export declare function doFixAction(core: Remote<SerializableCore>, results: ESLint.LintResult[], selectedRuleIds: string[]): Promise<Undo>;
|
|
6
|
+
//# sourceMappingURL=fix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix.d.ts","sourceRoot":"","sources":["../../src/action/fix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAC9B,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAC5B,eAAe,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC,CAGf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix.js","sourceRoot":"","sources":["../../src/action/fix.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI9C,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAA8B,EAC9B,OAA4B,EAC5B,eAAyB;IAEzB,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;IAC5F,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { doApplySuggestionsAction } from './apply-suggestions.js';
|
|
2
|
+
export { doDisablePerFileAction } from './disable-per-file.js';
|
|
3
|
+
export { doDisablePerLineAction } from './disable-per-line.js';
|
|
4
|
+
export { doFixAction } from './fix.js';
|
|
5
|
+
export { doMakeFixableAndFixAction } from './make-fixable-and-fix.js';
|
|
6
|
+
export { doPrintResultDetailsAction } from './print-result-details.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/action/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { doApplySuggestionsAction } from './apply-suggestions.js';
|
|
2
|
+
export { doDisablePerFileAction } from './disable-per-file.js';
|
|
3
|
+
export { doDisablePerLineAction } from './disable-per-line.js';
|
|
4
|
+
export { doFixAction } from './fix.js';
|
|
5
|
+
export { doMakeFixableAndFixAction } from './make-fixable-and-fix.js';
|
|
6
|
+
export { doPrintResultDetailsAction } from './print-result-details.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/action/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Remote } from 'comlink';
|
|
2
|
+
import { ESLint } from 'eslint';
|
|
3
|
+
import { SerializableCore } from '../core-worker.js';
|
|
4
|
+
import { Undo } from '../core.js';
|
|
5
|
+
export declare function doMakeFixableAndFixAction(core: Remote<SerializableCore>, results: ESLint.LintResult[], selectedRuleIds: string[]): Promise<Undo>;
|
|
6
|
+
//# sourceMappingURL=make-fixable-and-fix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-fixable-and-fix.d.ts","sourceRoot":"","sources":["../../src/action/make-fixable-and-fix.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOlC,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAC9B,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAC5B,eAAe,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { access, mkdir, readFile, writeFile } from 'fs/promises';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
import { fixingSpinner } from '../cli/ora.js';
|
|
4
|
+
import { promptToInputReuseScript } from '../cli/prompt.js';
|
|
5
|
+
import { editFileWithEditor, generateExampleFixableMakerScriptFilePath, generateFixableMakerScriptFilePath, } from '../util/filter-script.js';
|
|
6
|
+
export async function doMakeFixableAndFixAction(core, results, selectedRuleIds) {
|
|
7
|
+
const exampleScript = await readFile(generateExampleFixableMakerScriptFilePath(), 'utf8');
|
|
8
|
+
const fixableMakerScriptFilePath = generateFixableMakerScriptFilePath(selectedRuleIds);
|
|
9
|
+
const isFixableMakerScriptExist = await access(fixableMakerScriptFilePath)
|
|
10
|
+
.then(() => true)
|
|
11
|
+
.catch(() => false);
|
|
12
|
+
if (isFixableMakerScriptExist) {
|
|
13
|
+
const reuseScript = await promptToInputReuseScript();
|
|
14
|
+
if (!reuseScript) {
|
|
15
|
+
await writeFile(fixableMakerScriptFilePath, exampleScript);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
// ディレクトリがない可能性を考慮して作成しておく
|
|
20
|
+
await mkdir(dirname(fixableMakerScriptFilePath), { recursive: true });
|
|
21
|
+
await writeFile(fixableMakerScriptFilePath, exampleScript);
|
|
22
|
+
}
|
|
23
|
+
console.log('Opening editor...');
|
|
24
|
+
const fixableMakerScript = await editFileWithEditor(fixableMakerScriptFilePath);
|
|
25
|
+
const undo = await fixingSpinner(async () => core.makeFixableAndFix(results, selectedRuleIds, fixableMakerScript));
|
|
26
|
+
return undo;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=make-fixable-and-fix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-fixable-and-fix.js","sourceRoot":"","sources":["../../src/action/make-fixable-and-fix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EACL,kBAAkB,EAClB,yCAAyC,EACzC,kCAAkC,GACnC,MAAM,0BAA0B,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,IAA8B,EAC9B,OAA4B,EAC5B,eAAyB;IAEzB,MAAM,aAAa,GAAG,MAAM,QAAQ,CAAC,yCAAyC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC1F,MAAM,0BAA0B,GAAG,kCAAkC,CAAC,eAAe,CAAC,CAAC;IACvF,MAAM,yBAAyB,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC;SACvE,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;SAChB,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IACtB,IAAI,yBAAyB,EAAE;QAC7B,MAAM,WAAW,GAAG,MAAM,wBAAwB,EAAE,CAAC;QACrD,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,SAAS,CAAC,0BAA0B,EAAE,aAAa,CAAC,CAAC;SAC5D;KACF;SAAM;QACL,0BAA0B;QAC1B,MAAM,KAAK,CAAC,OAAO,CAAC,0BAA0B,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtE,MAAM,SAAS,CAAC,0BAA0B,EAAE,aAAa,CAAC,CAAC;KAC5D;IACD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAEjC,MAAM,kBAAkB,GAAG,MAAM,kBAAkB,CAAC,0BAA0B,CAAC,CAAC;IAChF,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,eAAe,EAAE,kBAAkB,CAAC,CAAC,CAAC;IACnH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Remote } from 'comlink';
|
|
2
|
+
import { ESLint } from 'eslint';
|
|
3
|
+
import { SerializableCore } from '../core-worker.js';
|
|
4
|
+
export declare function doPrintResultDetailsAction(core: Remote<SerializableCore>, results: ESLint.LintResult[], selectedRuleIds: string[]): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=print-result-details.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print-result-details.d.ts","sourceRoot":"","sources":["../../src/action/print-result-details.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAC9B,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,EAC5B,eAAe,EAAE,MAAM,EAAE,iBAQ1B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import pager from 'node-pager';
|
|
2
|
+
import { promptToInputDisplayMode } from '../cli/prompt.js';
|
|
3
|
+
export async function doPrintResultDetailsAction(core, results, selectedRuleIds) {
|
|
4
|
+
const displayMode = await promptToInputDisplayMode();
|
|
5
|
+
if (displayMode === 'withPager') {
|
|
6
|
+
await pager(await core.formatResultDetails(results, selectedRuleIds));
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
console.log(await core.formatResultDetails(results, selectedRuleIds));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=print-result-details.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print-result-details.js","sourceRoot":"","sources":["../../src/action/print-result-details.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,IAA8B,EAC9B,OAA4B,EAC5B,eAAyB;IAEzB,MAAM,WAAW,GAAG,MAAM,wBAAwB,EAAE,CAAC;IACrD,IAAI,WAAW,KAAK,WAAW,EAAE;QAC/B,MAAM,KAAK,CAAC,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;KACvE;SAAM;QACL,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;KACvE;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/cli/log.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,QAInC"}
|
package/dist/cli/log.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import boxen from 'boxen';
|
|
2
|
+
/**
|
|
3
|
+
* Log a warning message to stderr
|
|
4
|
+
* @param message The message to warn
|
|
5
|
+
*/
|
|
6
|
+
export function warn(message) {
|
|
7
|
+
console.error(boxen(message, { title: 'WARNING', borderColor: 'yellow', padding: { top: 0, left: 1, right: 1, bottom: 0 } }));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/cli/log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAC/G,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ora.d.ts","sourceRoot":"","sources":["../../src/cli/ora.ts"],"names":[],"mappings":"AAEA,wBAAsB,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMxE;AAED,wBAAsB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMvE;AAED,wBAAsB,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMxE"}
|
package/dist/cli/ora.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { oraPromise } from 'ora';
|
|
2
|
+
export async function lintingSpinner(cb) {
|
|
3
|
+
return oraPromise(cb, {
|
|
4
|
+
text: 'Linting...',
|
|
5
|
+
spinner: 'clock',
|
|
6
|
+
successText: 'Linting done.',
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export async function fixingSpinner(cb) {
|
|
10
|
+
return oraPromise(cb, {
|
|
11
|
+
text: 'Fixing...',
|
|
12
|
+
spinner: 'clock',
|
|
13
|
+
successText: 'Fixing done.',
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export async function undoingSpinner(cb) {
|
|
17
|
+
return oraPromise(cb, {
|
|
18
|
+
text: 'Undoing...',
|
|
19
|
+
spinner: 'timeTravel',
|
|
20
|
+
successText: 'Undoing done.',
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=ora.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ora.js","sourceRoot":"","sources":["../../src/cli/ora.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEjC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAI,EAAoB;IAC1D,OAAO,UAAU,CAAC,EAAE,EAAE;QACpB,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,eAAe;KAC7B,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAI,EAAoB;IACzD,OAAO,UAAU,CAAC,EAAE,EAAE;QACpB,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,cAAc;KAC5B,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAI,EAAoB;IAC1D,OAAO,UAAU,CAAC,EAAE,EAAE;QACpB,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,eAAe;KAC7B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/cli/package.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,OAAO,EAAE,MAA6B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
const PACKAGE_JSON = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json'), 'utf8'));
|
|
5
|
+
export const VERSION = PACKAGE_JSON.version;
|
|
6
|
+
//# sourceMappingURL=package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/cli/package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAC7B,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAChG,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAW,YAAY,CAAC,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-argv.d.ts","sourceRoot":"","sources":["../../src/cli/parse-argv.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAuB,MAAM,YAAY,CAAC;AAGzD,8DAA8D;AAC9D,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CA8ChD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import yargs from 'yargs';
|
|
2
|
+
import { DEFAULT_BASE_CONFIG } from '../core.js';
|
|
3
|
+
import { VERSION } from './package.js';
|
|
4
|
+
/** Parse argv into the config object of eslint-interactive */
|
|
5
|
+
export function parseArgv(argv) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const parsedArgv = yargs(argv.slice(2))
|
|
8
|
+
.version(VERSION)
|
|
9
|
+
.usage('$0 [file.js] [dir]')
|
|
10
|
+
.option('rulesdir', {
|
|
11
|
+
type: 'array',
|
|
12
|
+
describe: 'Use additional rules from this directory',
|
|
13
|
+
})
|
|
14
|
+
.nargs('rulesdir', 1)
|
|
15
|
+
.option('ext', {
|
|
16
|
+
type: 'array',
|
|
17
|
+
describe: 'Specify JavaScript file extensions',
|
|
18
|
+
})
|
|
19
|
+
.nargs('ext', 1)
|
|
20
|
+
.option('format', {
|
|
21
|
+
type: 'string',
|
|
22
|
+
describe: 'Specify the format to be used for the `Display problem messages` action',
|
|
23
|
+
default: DEFAULT_BASE_CONFIG.formatterName,
|
|
24
|
+
})
|
|
25
|
+
.option('cache', {
|
|
26
|
+
type: 'boolean',
|
|
27
|
+
describe: 'Only check changed files',
|
|
28
|
+
default: DEFAULT_BASE_CONFIG.cache,
|
|
29
|
+
})
|
|
30
|
+
.option('cache-location', {
|
|
31
|
+
type: 'string',
|
|
32
|
+
describe: `Path to the cache file or directory`,
|
|
33
|
+
default: DEFAULT_BASE_CONFIG.cacheLocation,
|
|
34
|
+
}).argv;
|
|
35
|
+
// NOTE: convert `string` type because yargs convert `'10'` (`string` type) into `10` (`number` type)
|
|
36
|
+
// and `lintFiles` only accepts `string[]`.
|
|
37
|
+
const patterns = parsedArgv._.map((pattern) => pattern.toString());
|
|
38
|
+
const rulePaths = (_a = parsedArgv.rulesdir) === null || _a === void 0 ? void 0 : _a.map((rulePath) => rulePath.toString());
|
|
39
|
+
const extensions = (_b = parsedArgv.ext) === null || _b === void 0 ? void 0 : _b.map((extension) => extension.toString()).flatMap((extension) => extension.split(','));
|
|
40
|
+
const formatterName = parsedArgv.format;
|
|
41
|
+
return {
|
|
42
|
+
patterns,
|
|
43
|
+
rulePaths,
|
|
44
|
+
extensions,
|
|
45
|
+
formatterName,
|
|
46
|
+
cache: parsedArgv.cache,
|
|
47
|
+
cacheLocation: parsedArgv['cache-location'],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=parse-argv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-argv.js","sourceRoot":"","sources":["../../src/cli/parse-argv.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAU,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,8DAA8D;AAC9D,MAAM,UAAU,SAAS,CAAC,IAAc;;IACtC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACpC,OAAO,CAAC,OAAO,CAAC;SAChB,KAAK,CAAC,oBAAoB,CAAC;SAC3B,MAAM,CAAC,UAAU,EAAE;QAClB,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,0CAA0C;KACrD,CAAC;SACD,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;SACpB,MAAM,CAAC,KAAK,EAAE;QACb,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,oCAAoC;KAC/C,CAAC;SACD,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;SACf,MAAM,CAAC,QAAQ,EAAE;QAChB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,yEAAyE;QACnF,OAAO,EAAE,mBAAmB,CAAC,aAAa;KAC3C,CAAC;SACD,MAAM,CAAC,OAAO,EAAE;QACf,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,0BAA0B;QACpC,OAAO,EAAE,mBAAmB,CAAC,KAAK;KACnC,CAAC;SACD,MAAM,CAAC,gBAAgB,EAAE;QACxB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,qCAAqC;QAC/C,OAAO,EAAE,mBAAmB,CAAC,aAAa;KAC3C,CAAC,CAAC,IAAI,CAAC;IACV,qGAAqG;IACrG,2CAA2C;IAC3C,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,MAAA,UAAU,CAAC,QAAQ,0CAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9E,MAAM,UAAU,GAAG,MAAA,UAAU,CAAC,GAAG,0CAC7B,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,EAExC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC;IACxC,OAAO;QACL,QAAQ;QACR,SAAS;QACT,UAAU;QACV,aAAa;QACb,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,aAAa,EAAE,UAAU,CAAC,gBAAgB,CAAC;KAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ESLint } from 'eslint';
|
|
2
|
+
/**
|
|
3
|
+
* The type that indicates what to do with the problems of selected rules.
|
|
4
|
+
*/
|
|
5
|
+
export declare type Action = 'printResultDetails' | 'applyAutoFixes' | 'disablePerLine' | 'disablePerFile' | 'applySuggestions' | 'makeFixableAndFix' | 'reselectRules';
|
|
6
|
+
/**
|
|
7
|
+
* The type representing how to display the lint results.
|
|
8
|
+
*
|
|
9
|
+
* `withPager` means that the lint results will be displayed with a pager (like `less` command).
|
|
10
|
+
* `withoutPager` means that the lint results will be displayed without a pager.
|
|
11
|
+
*/
|
|
12
|
+
export declare type DisplayMode = 'withPager' | 'withoutPager';
|
|
13
|
+
/**
|
|
14
|
+
* The type that represents what to do next.
|
|
15
|
+
*/
|
|
16
|
+
export declare type NextStep = 'fixOtherRules' | 'exit' | 'undoTheFix';
|
|
17
|
+
/**
|
|
18
|
+
* Ask the user for the rule ids to which they want to apply the action.
|
|
19
|
+
* @param ruleIdsInResults The rule ids that are in the lint results.
|
|
20
|
+
* @returns The rule ids
|
|
21
|
+
*/
|
|
22
|
+
export declare function promptToInputRuleIds(ruleIdsInResults: string[]): Promise<string[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Ask the user what action they want to perform.
|
|
25
|
+
* @returns The action name
|
|
26
|
+
*/
|
|
27
|
+
export declare function promptToInputAction(results: ESLint.LintResult[], selectedRuleIds: string[], initialAction?: Action): Promise<Action>;
|
|
28
|
+
/**
|
|
29
|
+
* Ask the user how to display the lint results.
|
|
30
|
+
* @returns How to display
|
|
31
|
+
*/
|
|
32
|
+
export declare function promptToInputDisplayMode(): Promise<DisplayMode>;
|
|
33
|
+
/**
|
|
34
|
+
* Ask the user a description to leave in disable comment.
|
|
35
|
+
* @returns The description
|
|
36
|
+
*/
|
|
37
|
+
export declare function promptToInputDescription(): Promise<string | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* Ask the user what to do next.
|
|
40
|
+
* @returns What to do next.
|
|
41
|
+
*/
|
|
42
|
+
export declare function promptToInputWhatToDoNext(): Promise<NextStep>;
|
|
43
|
+
/**
|
|
44
|
+
* Ask the user if they want to reuse the filter script.
|
|
45
|
+
* @returns If it reuses, `true`, if not, `false`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function promptToInputReuseFilterScript(): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Ask the user if they want to reuse the script.
|
|
50
|
+
* @returns If it reuses, `true`, if not, `false`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function promptToInputReuseScript(): Promise<boolean>;
|
|
53
|
+
//# sourceMappingURL=prompt.d.ts.map
|