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/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-interactive",
|
|
3
|
+
"description": "The CLI tool to run `eslint --fix` for each rule",
|
|
4
|
+
"version": "8.1.0",
|
|
5
|
+
"repository": "https://github.com/mizdra/eslint-interactive.git",
|
|
6
|
+
"author": "mizdra <pp.mizdra@gmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"private": false,
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": "./dist/index.js",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc -p tsconfig.src.json",
|
|
13
|
+
"dev": "tsc-watch -p tsconfig.src.json --onSuccess 'bin/eslint-interactive.js fixtures --rulesdir fixtures/rules --ext .js,.jsx,.mjs'",
|
|
14
|
+
"lint": "run-s -c lint:*",
|
|
15
|
+
"lint:tsc": "run-s -c lint:tsc:*",
|
|
16
|
+
"lint:tsc:src": "tsc -p tsconfig.src.json --noEmit",
|
|
17
|
+
"lint:tsc:test": "tsc -p tsconfig.test.json --noEmit",
|
|
18
|
+
"lint:eslint": "eslint --ignore-pattern '/fixtures/' --ignore-pattern '/e2e-test/' .",
|
|
19
|
+
"lint:prettier": "prettier --check .",
|
|
20
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --colors",
|
|
21
|
+
"postbuild:test": "./run-e2e-test.sh",
|
|
22
|
+
"postbuild:benchmark": "node benchmark/run.js"
|
|
23
|
+
},
|
|
24
|
+
"prettier": "@mizdra/prettier-config-mizdra",
|
|
25
|
+
"renovate": "github>mizdra/renovate-config-mizdra",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@jest/types": "^27.5.1",
|
|
28
|
+
"@mizdra/eslint-config-mizdra": "^1.1.0",
|
|
29
|
+
"@mizdra/prettier-config-mizdra": "^0.4.0",
|
|
30
|
+
"@types/cli-table": "^0.3.0",
|
|
31
|
+
"@types/eslint": "^8.4.1",
|
|
32
|
+
"@types/estraverse": "^5.1.1",
|
|
33
|
+
"@types/estree": "^0.0.50",
|
|
34
|
+
"@types/jest": "^27.0.3",
|
|
35
|
+
"@types/node": "^14.14.10",
|
|
36
|
+
"@types/terminal-link": "^1.2.0",
|
|
37
|
+
"@types/yargs": "^16.0.4",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
|
39
|
+
"@typescript-eslint/parser": "^5.11.0",
|
|
40
|
+
"enhanced-resolve": "^5.8.3",
|
|
41
|
+
"eslint": "^8.9.0",
|
|
42
|
+
"eslint-config-prettier": "^8.3.0",
|
|
43
|
+
"eslint-plugin-import": "^2.25.4",
|
|
44
|
+
"jest": "^27.5.1",
|
|
45
|
+
"jest-mock-process": "^1.4.1",
|
|
46
|
+
"npm-run-all": "^4.1.5",
|
|
47
|
+
"prettier": "2.5.1",
|
|
48
|
+
"strip-ansi": "^7.0.1",
|
|
49
|
+
"ts-jest": "^27.1.3",
|
|
50
|
+
"tsc-watch": "^4.2.9",
|
|
51
|
+
"typescript": "^4.6.0-dev.20220210"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"boxen": "^6.2.1",
|
|
55
|
+
"cachedir": "^2.3.0",
|
|
56
|
+
"chalk": "^5.0.0",
|
|
57
|
+
"cli-table": "^0.3.11",
|
|
58
|
+
"comlink": "^4.3.1",
|
|
59
|
+
"enquirer": "^2.3.6",
|
|
60
|
+
"eslint-formatter-codeframe": "^7.32.1",
|
|
61
|
+
"estraverse": "^5.3.0",
|
|
62
|
+
"is-installed-globally": "^0.4.0",
|
|
63
|
+
"node-pager": "^0.3.6",
|
|
64
|
+
"ora": "^6.0.1",
|
|
65
|
+
"terminal-link": "^3.0.0",
|
|
66
|
+
"yargs": "^16.2.0"
|
|
67
|
+
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"eslint": "^7.0.0 || ^8.0.0"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": "^14.13.1 || >=16.0.0"
|
|
73
|
+
},
|
|
74
|
+
"publishConfig": {
|
|
75
|
+
"access": "public",
|
|
76
|
+
"registry": "https://registry.npmjs.org/"
|
|
77
|
+
},
|
|
78
|
+
"bin": {
|
|
79
|
+
"eslint-interactive": "bin/eslint-interactive.js"
|
|
80
|
+
},
|
|
81
|
+
"keywords": [
|
|
82
|
+
"eslint"
|
|
83
|
+
],
|
|
84
|
+
"files": [
|
|
85
|
+
"bin",
|
|
86
|
+
"src",
|
|
87
|
+
"!src/test-util",
|
|
88
|
+
"!src/**/*.test.ts",
|
|
89
|
+
"!src/**/__snapshots__",
|
|
90
|
+
"dist",
|
|
91
|
+
"static"
|
|
92
|
+
]
|
|
93
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { access, mkdir, readFile, writeFile } from 'fs/promises';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
import { Remote } from 'comlink';
|
|
4
|
+
import { ESLint } from 'eslint';
|
|
5
|
+
import { fixingSpinner } from '../cli/ora.js';
|
|
6
|
+
import { promptToInputReuseFilterScript } from '../cli/prompt.js';
|
|
7
|
+
import { SerializableCore } from '../core-worker.js';
|
|
8
|
+
import { Undo } from '../core.js';
|
|
9
|
+
import {
|
|
10
|
+
editFileWithEditor,
|
|
11
|
+
generateExampleFilterScriptFilePath,
|
|
12
|
+
generateFilterScriptFilePath,
|
|
13
|
+
} from '../util/filter-script.js';
|
|
14
|
+
|
|
15
|
+
export async function doApplySuggestionsAction(
|
|
16
|
+
core: Remote<SerializableCore>,
|
|
17
|
+
results: ESLint.LintResult[],
|
|
18
|
+
selectedRuleIds: string[],
|
|
19
|
+
): Promise<Undo> {
|
|
20
|
+
const exampleScript = await readFile(generateExampleFilterScriptFilePath(), 'utf8');
|
|
21
|
+
const filterScriptFilePath = generateFilterScriptFilePath(selectedRuleIds);
|
|
22
|
+
const isFilterScriptExist = await access(filterScriptFilePath)
|
|
23
|
+
.then(() => true)
|
|
24
|
+
.catch(() => false);
|
|
25
|
+
if (isFilterScriptExist) {
|
|
26
|
+
const reuseFilterScript = await promptToInputReuseFilterScript();
|
|
27
|
+
if (!reuseFilterScript) {
|
|
28
|
+
await writeFile(filterScriptFilePath, exampleScript);
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
// ディレクトリがない可能性を考慮して作成しておく
|
|
32
|
+
await mkdir(dirname(filterScriptFilePath), { recursive: true });
|
|
33
|
+
await writeFile(filterScriptFilePath, exampleScript);
|
|
34
|
+
}
|
|
35
|
+
console.log('Opening editor...');
|
|
36
|
+
|
|
37
|
+
const filterScript = await editFileWithEditor(filterScriptFilePath);
|
|
38
|
+
const undo = await fixingSpinner(async () => core.applySuggestions(results, selectedRuleIds, filterScript));
|
|
39
|
+
return undo;
|
|
40
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Remote } from 'comlink';
|
|
2
|
+
import { ESLint } from 'eslint';
|
|
3
|
+
import { fixingSpinner } from '../cli/ora.js';
|
|
4
|
+
import { promptToInputDescription } from '../cli/prompt.js';
|
|
5
|
+
import { SerializableCore } from '../core-worker.js';
|
|
6
|
+
import { Undo } from '../core.js';
|
|
7
|
+
|
|
8
|
+
export async function doDisablePerFileAction(
|
|
9
|
+
core: Remote<SerializableCore>,
|
|
10
|
+
results: ESLint.LintResult[],
|
|
11
|
+
selectedRuleIds: string[],
|
|
12
|
+
): Promise<Undo> {
|
|
13
|
+
const description = await promptToInputDescription();
|
|
14
|
+
const undo = await fixingSpinner(async () => core.disablePerFile(results, selectedRuleIds, description));
|
|
15
|
+
return undo;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Remote } from 'comlink';
|
|
2
|
+
import { ESLint } from 'eslint';
|
|
3
|
+
import { fixingSpinner } from '../cli/ora.js';
|
|
4
|
+
import { promptToInputDescription } from '../cli/prompt.js';
|
|
5
|
+
import { SerializableCore } from '../core-worker.js';
|
|
6
|
+
import { Undo } from '../core.js';
|
|
7
|
+
|
|
8
|
+
export async function doDisablePerLineAction(
|
|
9
|
+
core: Remote<SerializableCore>,
|
|
10
|
+
results: ESLint.LintResult[],
|
|
11
|
+
selectedRuleIds: string[],
|
|
12
|
+
): Promise<Undo> {
|
|
13
|
+
const description = await promptToInputDescription();
|
|
14
|
+
const undo = await fixingSpinner(async () => core.disablePerLine(results, selectedRuleIds, description));
|
|
15
|
+
return undo;
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Remote } from 'comlink';
|
|
2
|
+
import { ESLint } from 'eslint';
|
|
3
|
+
import { fixingSpinner } from '../cli/ora.js';
|
|
4
|
+
import { SerializableCore } from '../core-worker.js';
|
|
5
|
+
import { Undo } from '../core.js';
|
|
6
|
+
|
|
7
|
+
export async function doFixAction(
|
|
8
|
+
core: Remote<SerializableCore>,
|
|
9
|
+
results: ESLint.LintResult[],
|
|
10
|
+
selectedRuleIds: string[],
|
|
11
|
+
): Promise<Undo> {
|
|
12
|
+
const undo = await fixingSpinner(async () => core.applyAutoFixes(results, selectedRuleIds));
|
|
13
|
+
return undo;
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { access, mkdir, readFile, writeFile } from 'fs/promises';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
import { Remote } from 'comlink';
|
|
4
|
+
import { ESLint } from 'eslint';
|
|
5
|
+
import { fixingSpinner } from '../cli/ora.js';
|
|
6
|
+
import { promptToInputReuseScript } from '../cli/prompt.js';
|
|
7
|
+
import { SerializableCore } from '../core-worker.js';
|
|
8
|
+
import { Undo } from '../core.js';
|
|
9
|
+
import {
|
|
10
|
+
editFileWithEditor,
|
|
11
|
+
generateExampleFixableMakerScriptFilePath,
|
|
12
|
+
generateFixableMakerScriptFilePath,
|
|
13
|
+
} from '../util/filter-script.js';
|
|
14
|
+
|
|
15
|
+
export async function doMakeFixableAndFixAction(
|
|
16
|
+
core: Remote<SerializableCore>,
|
|
17
|
+
results: ESLint.LintResult[],
|
|
18
|
+
selectedRuleIds: string[],
|
|
19
|
+
): Promise<Undo> {
|
|
20
|
+
const exampleScript = await readFile(generateExampleFixableMakerScriptFilePath(), 'utf8');
|
|
21
|
+
const fixableMakerScriptFilePath = generateFixableMakerScriptFilePath(selectedRuleIds);
|
|
22
|
+
const isFixableMakerScriptExist = await access(fixableMakerScriptFilePath)
|
|
23
|
+
.then(() => true)
|
|
24
|
+
.catch(() => false);
|
|
25
|
+
if (isFixableMakerScriptExist) {
|
|
26
|
+
const reuseScript = await promptToInputReuseScript();
|
|
27
|
+
if (!reuseScript) {
|
|
28
|
+
await writeFile(fixableMakerScriptFilePath, exampleScript);
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
// ディレクトリがない可能性を考慮して作成しておく
|
|
32
|
+
await mkdir(dirname(fixableMakerScriptFilePath), { recursive: true });
|
|
33
|
+
await writeFile(fixableMakerScriptFilePath, exampleScript);
|
|
34
|
+
}
|
|
35
|
+
console.log('Opening editor...');
|
|
36
|
+
|
|
37
|
+
const fixableMakerScript = await editFileWithEditor(fixableMakerScriptFilePath);
|
|
38
|
+
const undo = await fixingSpinner(async () => core.makeFixableAndFix(results, selectedRuleIds, fixableMakerScript));
|
|
39
|
+
return undo;
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Remote } from 'comlink';
|
|
2
|
+
import { ESLint } from 'eslint';
|
|
3
|
+
import pager from 'node-pager';
|
|
4
|
+
import { promptToInputDisplayMode } from '../cli/prompt.js';
|
|
5
|
+
import { SerializableCore } from '../core-worker.js';
|
|
6
|
+
|
|
7
|
+
export async function doPrintResultDetailsAction(
|
|
8
|
+
core: Remote<SerializableCore>,
|
|
9
|
+
results: ESLint.LintResult[],
|
|
10
|
+
selectedRuleIds: string[],
|
|
11
|
+
) {
|
|
12
|
+
const displayMode = await promptToInputDisplayMode();
|
|
13
|
+
if (displayMode === 'withPager') {
|
|
14
|
+
await pager(await core.formatResultDetails(results, selectedRuleIds));
|
|
15
|
+
} else {
|
|
16
|
+
console.log(await core.formatResultDetails(results, selectedRuleIds));
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/cli/log.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import boxen from 'boxen';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Log a warning message to stderr
|
|
5
|
+
* @param message The message to warn
|
|
6
|
+
*/
|
|
7
|
+
export function warn(message: string) {
|
|
8
|
+
console.error(
|
|
9
|
+
boxen(message, { title: 'WARNING', borderColor: 'yellow', padding: { top: 0, left: 1, right: 1, bottom: 0 } }),
|
|
10
|
+
);
|
|
11
|
+
}
|
package/src/cli/ora.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { oraPromise } from 'ora';
|
|
2
|
+
|
|
3
|
+
export async function lintingSpinner<T>(cb: () => Promise<T>): Promise<T> {
|
|
4
|
+
return oraPromise(cb, {
|
|
5
|
+
text: 'Linting...',
|
|
6
|
+
spinner: 'clock',
|
|
7
|
+
successText: 'Linting done.',
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function fixingSpinner<T>(cb: () => Promise<T>): Promise<T> {
|
|
12
|
+
return oraPromise(cb, {
|
|
13
|
+
text: 'Fixing...',
|
|
14
|
+
spinner: 'clock',
|
|
15
|
+
successText: 'Fixing done.',
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function undoingSpinner<T>(cb: () => Promise<T>): Promise<T> {
|
|
20
|
+
return oraPromise(cb, {
|
|
21
|
+
text: 'Undoing...',
|
|
22
|
+
spinner: 'timeTravel',
|
|
23
|
+
successText: 'Undoing done.',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const PACKAGE_JSON = JSON.parse(
|
|
6
|
+
readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json'), 'utf8'),
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export const VERSION: string = PACKAGE_JSON.version;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import yargs from 'yargs';
|
|
2
|
+
import { Config, DEFAULT_BASE_CONFIG } from '../core.js';
|
|
3
|
+
import { VERSION } from './package.js';
|
|
4
|
+
|
|
5
|
+
/** Parse argv into the config object of eslint-interactive */
|
|
6
|
+
export function parseArgv(argv: string[]): Config {
|
|
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 = parsedArgv.rulesdir?.map((rulePath) => rulePath.toString());
|
|
39
|
+
const extensions = parsedArgv.ext
|
|
40
|
+
?.map((extension) => extension.toString())
|
|
41
|
+
// map '.js,.ts' into ['.js', '.ts']
|
|
42
|
+
.flatMap((extension) => extension.split(','));
|
|
43
|
+
const formatterName = parsedArgv.format;
|
|
44
|
+
return {
|
|
45
|
+
patterns,
|
|
46
|
+
rulePaths,
|
|
47
|
+
extensions,
|
|
48
|
+
formatterName,
|
|
49
|
+
cache: parsedArgv.cache,
|
|
50
|
+
cacheLocation: parsedArgv['cache-location'],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/* istanbul ignore file */
|
|
2
|
+
|
|
3
|
+
import enquirer from 'enquirer';
|
|
4
|
+
import { ESLint } from 'eslint';
|
|
5
|
+
import { takeRuleStatistics } from '../formatter/index.js';
|
|
6
|
+
|
|
7
|
+
const { prompt } = enquirer;
|
|
8
|
+
|
|
9
|
+
// When combined with worker, for some reason the enquirer grabs the SIGINT and the process continues to survive.
|
|
10
|
+
// Therefore, the process is explicitly terminated.
|
|
11
|
+
const onCancel = () => process.exit();
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The type that indicates what to do with the problems of selected rules.
|
|
15
|
+
*/
|
|
16
|
+
export type Action =
|
|
17
|
+
| 'printResultDetails'
|
|
18
|
+
| 'applyAutoFixes'
|
|
19
|
+
| 'disablePerLine'
|
|
20
|
+
| 'disablePerFile'
|
|
21
|
+
| 'applySuggestions'
|
|
22
|
+
| 'makeFixableAndFix'
|
|
23
|
+
| 'reselectRules';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The type representing how to display the lint results.
|
|
27
|
+
*
|
|
28
|
+
* `withPager` means that the lint results will be displayed with a pager (like `less` command).
|
|
29
|
+
* `withoutPager` means that the lint results will be displayed without a pager.
|
|
30
|
+
*/
|
|
31
|
+
export type DisplayMode = 'withPager' | 'withoutPager';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The type that represents what to do next.
|
|
35
|
+
*/
|
|
36
|
+
export type NextStep = 'fixOtherRules' | 'exit' | 'undoTheFix';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Ask the user for the rule ids to which they want to apply the action.
|
|
40
|
+
* @param ruleIdsInResults The rule ids that are in the lint results.
|
|
41
|
+
* @returns The rule ids
|
|
42
|
+
*/
|
|
43
|
+
export async function promptToInputRuleIds(ruleIdsInResults: string[]): Promise<string[]> {
|
|
44
|
+
const { ruleIds } = await prompt<{ ruleIds: string[] }>([
|
|
45
|
+
{
|
|
46
|
+
name: 'ruleIds',
|
|
47
|
+
type: 'multiselect',
|
|
48
|
+
message: 'Which rules would you like to apply action?',
|
|
49
|
+
hint: 'Select all you want with <space> key.',
|
|
50
|
+
choices: ruleIdsInResults,
|
|
51
|
+
validate(value) {
|
|
52
|
+
return value.length === 0 ? `Select at least one rule with <space> key.` : true;
|
|
53
|
+
},
|
|
54
|
+
onCancel,
|
|
55
|
+
},
|
|
56
|
+
]);
|
|
57
|
+
return ruleIds;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Ask the user what action they want to perform.
|
|
62
|
+
* @returns The action name
|
|
63
|
+
*/
|
|
64
|
+
export async function promptToInputAction(
|
|
65
|
+
results: ESLint.LintResult[],
|
|
66
|
+
selectedRuleIds: string[],
|
|
67
|
+
initialAction?: Action,
|
|
68
|
+
): Promise<Action> {
|
|
69
|
+
const ruleStatistics = takeRuleStatistics(results).filter((ruleStatistic) =>
|
|
70
|
+
selectedRuleIds.includes(ruleStatistic.ruleId),
|
|
71
|
+
);
|
|
72
|
+
const foldedStatistics = ruleStatistics.reduce(
|
|
73
|
+
(a, b) => ({
|
|
74
|
+
isFixableCount: a.isFixableCount + b.isFixableCount,
|
|
75
|
+
hasSuggestionsCount: a.hasSuggestionsCount + b.hasSuggestionsCount,
|
|
76
|
+
}),
|
|
77
|
+
{ isFixableCount: 0, hasSuggestionsCount: 0 },
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const choices = [
|
|
81
|
+
{ name: 'printResultDetails', message: '🔎 Display details of lint results' },
|
|
82
|
+
{ name: 'applyAutoFixes', message: '🔧 Run `eslint --fix`', disabled: foldedStatistics.isFixableCount === 0 },
|
|
83
|
+
{ name: 'disablePerLine', message: '🔧 Disable per line' },
|
|
84
|
+
{ name: 'disablePerFile', message: '🔧 Disable per file' },
|
|
85
|
+
{
|
|
86
|
+
name: 'applySuggestions',
|
|
87
|
+
message: '🔧 Apply suggestions (experimental, for experts)',
|
|
88
|
+
disabled: foldedStatistics.hasSuggestionsCount === 0,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'makeFixableAndFix',
|
|
92
|
+
message: '🔧 Make forcibly fixable and run `eslint --fix` (experimental, for experts)',
|
|
93
|
+
},
|
|
94
|
+
{ name: 'reselectRules', message: '↩️ Reselect rules' },
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
const { action } = await prompt<{
|
|
98
|
+
action: Action;
|
|
99
|
+
}>([
|
|
100
|
+
{
|
|
101
|
+
name: 'action',
|
|
102
|
+
type: 'select',
|
|
103
|
+
message: 'Which action do you want to do?',
|
|
104
|
+
choices,
|
|
105
|
+
initial: choices.findIndex((choice) => choice.name === initialAction) ?? 0,
|
|
106
|
+
onCancel,
|
|
107
|
+
},
|
|
108
|
+
]);
|
|
109
|
+
return action;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Ask the user how to display the lint results.
|
|
114
|
+
* @returns How to display
|
|
115
|
+
*/
|
|
116
|
+
export async function promptToInputDisplayMode(): Promise<DisplayMode> {
|
|
117
|
+
const { displayMode } = await prompt<{
|
|
118
|
+
displayMode: DisplayMode;
|
|
119
|
+
}>([
|
|
120
|
+
{
|
|
121
|
+
name: 'displayMode',
|
|
122
|
+
type: 'select',
|
|
123
|
+
message: 'What format do you want to display the problem message in?',
|
|
124
|
+
choices: [
|
|
125
|
+
{ name: 'withPager', message: '↕️ Display with pager' },
|
|
126
|
+
{ name: 'withoutPager', message: '📃 Display without pager' },
|
|
127
|
+
],
|
|
128
|
+
onCancel,
|
|
129
|
+
},
|
|
130
|
+
]);
|
|
131
|
+
return displayMode;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Ask the user a description to leave in disable comment.
|
|
136
|
+
* @returns The description
|
|
137
|
+
*/
|
|
138
|
+
export async function promptToInputDescription(): Promise<string | undefined> {
|
|
139
|
+
const { description } = await prompt<{
|
|
140
|
+
description: string;
|
|
141
|
+
}>([
|
|
142
|
+
{
|
|
143
|
+
name: 'description',
|
|
144
|
+
type: 'input',
|
|
145
|
+
message: 'Leave a code comment with your reason for disabling (Optional)',
|
|
146
|
+
onCancel,
|
|
147
|
+
},
|
|
148
|
+
]);
|
|
149
|
+
return description === '' ? undefined : description;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Ask the user what to do next.
|
|
154
|
+
* @returns What to do next.
|
|
155
|
+
*/
|
|
156
|
+
export async function promptToInputWhatToDoNext(): Promise<NextStep> {
|
|
157
|
+
const { nextStep } = await prompt<{ nextStep: NextStep }>([
|
|
158
|
+
{
|
|
159
|
+
name: 'nextStep',
|
|
160
|
+
type: 'select',
|
|
161
|
+
message: "What's the next step?",
|
|
162
|
+
choices: [
|
|
163
|
+
{ name: 'fixOtherRules', message: '🔧 Fix other rules' },
|
|
164
|
+
{ name: 'undoTheFix', message: '↩️ Undo the fix' },
|
|
165
|
+
{ name: 'exit', message: '💚 Exit' },
|
|
166
|
+
],
|
|
167
|
+
onCancel,
|
|
168
|
+
},
|
|
169
|
+
]);
|
|
170
|
+
return nextStep;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Ask the user if they want to reuse the filter script.
|
|
175
|
+
* @returns If it reuses, `true`, if not, `false`.
|
|
176
|
+
*/
|
|
177
|
+
export async function promptToInputReuseFilterScript(): Promise<boolean> {
|
|
178
|
+
const { reuseFilterScript } = await prompt<{ reuseFilterScript: boolean }>([
|
|
179
|
+
{
|
|
180
|
+
name: 'reuseFilterScript',
|
|
181
|
+
type: 'confirm',
|
|
182
|
+
message: 'Do you want to reuse a previously edited filter script?',
|
|
183
|
+
initial: true,
|
|
184
|
+
onCancel,
|
|
185
|
+
},
|
|
186
|
+
]);
|
|
187
|
+
return reuseFilterScript;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Ask the user if they want to reuse the script.
|
|
192
|
+
* @returns If it reuses, `true`, if not, `false`.
|
|
193
|
+
*/
|
|
194
|
+
export async function promptToInputReuseScript(): Promise<boolean> {
|
|
195
|
+
const { reuseScript } = await prompt<{ reuseScript: boolean }>([
|
|
196
|
+
{
|
|
197
|
+
name: 'reuseScript',
|
|
198
|
+
type: 'confirm',
|
|
199
|
+
message: 'Do you want to reuse a previously edited script?',
|
|
200
|
+
initial: true,
|
|
201
|
+
onCancel,
|
|
202
|
+
},
|
|
203
|
+
]);
|
|
204
|
+
return reuseScript;
|
|
205
|
+
}
|
package/src/cli/run.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { dirname, join } from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { Worker } from 'worker_threads';
|
|
4
|
+
import { wrap } from 'comlink';
|
|
5
|
+
import nodeEndpoint from 'comlink/dist/esm/node-adapter.mjs';
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
7
|
+
import isInstalledGlobally = require('is-installed-globally');
|
|
8
|
+
import { warn } from '../cli/log.js';
|
|
9
|
+
import { parseArgv } from '../cli/parse-argv.js';
|
|
10
|
+
import { SerializableCore } from '../core-worker.js';
|
|
11
|
+
import { lint, selectAction, selectRuleIds, checkResults, NextScene } from '../scene/index.js';
|
|
12
|
+
|
|
13
|
+
export type Options = {
|
|
14
|
+
argv: string[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Run eslint-interactive.
|
|
19
|
+
*/
|
|
20
|
+
export async function run(options: Options) {
|
|
21
|
+
if (isInstalledGlobally) {
|
|
22
|
+
warn(
|
|
23
|
+
'eslint-interactive is installed globally. ' +
|
|
24
|
+
'The globally installed eslint-interactive is not officially supported because some features do not work. ' +
|
|
25
|
+
'It is recommended to install eslint-interactive locally.',
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
const config = parseArgv(options.argv);
|
|
29
|
+
|
|
30
|
+
// Directly executing the Core API will hog the main thread and halt the spinner.
|
|
31
|
+
// So we wrap it with comlink and run it on the Worker.
|
|
32
|
+
const worker = new Worker(join(dirname(fileURLToPath(import.meta.url)), '..', 'core-worker.js'));
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
const ProxiedCore = wrap<typeof SerializableCore>((nodeEndpoint as any)(worker));
|
|
35
|
+
const core = await new ProxiedCore(config);
|
|
36
|
+
|
|
37
|
+
let nextScene: NextScene = { name: 'lint' };
|
|
38
|
+
while (nextScene.name !== 'exit') {
|
|
39
|
+
if (nextScene.name === 'lint') {
|
|
40
|
+
nextScene = await lint(core);
|
|
41
|
+
} else if (nextScene.name === 'selectRuleIds') {
|
|
42
|
+
nextScene = await selectRuleIds(core, nextScene.args);
|
|
43
|
+
} else if (nextScene.name === 'selectAction') {
|
|
44
|
+
nextScene = await selectAction(core, nextScene.args);
|
|
45
|
+
} else if (nextScene.name === 'checkResults') {
|
|
46
|
+
nextScene = await checkResults(nextScene.args);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
await worker.terminate();
|
|
50
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { parentPort, MessageChannel } from 'worker_threads';
|
|
2
|
+
import { expose, proxy } from 'comlink';
|
|
3
|
+
import nodeEndpoint from 'comlink/dist/esm/node-adapter.mjs';
|
|
4
|
+
import { ESLint } from 'eslint';
|
|
5
|
+
import { Core, Config } from './core.js';
|
|
6
|
+
import { FixableMaker, SuggestionFilter } from './plugin/index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @file This is a wrapper module for using the Core API with comlink.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
if (parentPort === null) throw new Error('This module must be started on a worker.');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* This is a wrapper for using the Core API from comlink.
|
|
16
|
+
*
|
|
17
|
+
* The arguments of the methods wrapped in comlink must be serializable.
|
|
18
|
+
* The methods in this class are serializable versions of the Core API methods.
|
|
19
|
+
*/
|
|
20
|
+
export class SerializableCore {
|
|
21
|
+
readonly core: Core;
|
|
22
|
+
constructor(config: Config) {
|
|
23
|
+
this.core = new Core(config);
|
|
24
|
+
}
|
|
25
|
+
async lint(...args: Parameters<Core['lint']>): ReturnType<Core['lint']> {
|
|
26
|
+
return this.core.lint(...args);
|
|
27
|
+
}
|
|
28
|
+
formatResultSummary(...args: Parameters<Core['formatResultSummary']>): ReturnType<Core['formatResultSummary']> {
|
|
29
|
+
return this.core.formatResultSummary(...args);
|
|
30
|
+
}
|
|
31
|
+
async formatResultDetails(...args: Parameters<Core['formatResultDetails']>): ReturnType<Core['formatResultDetails']> {
|
|
32
|
+
return this.core.formatResultDetails(...args);
|
|
33
|
+
}
|
|
34
|
+
async applyAutoFixes(...args: Parameters<Core['applyAutoFixes']>): ReturnType<Core['applyAutoFixes']> {
|
|
35
|
+
return proxy(await this.core.applyAutoFixes(...args));
|
|
36
|
+
}
|
|
37
|
+
async disablePerLine(...args: Parameters<Core['disablePerLine']>): ReturnType<Core['disablePerLine']> {
|
|
38
|
+
return proxy(await this.core.disablePerLine(...args));
|
|
39
|
+
}
|
|
40
|
+
async disablePerFile(...args: Parameters<Core['disablePerFile']>): ReturnType<Core['disablePerFile']> {
|
|
41
|
+
return proxy(await this.core.disablePerFile(...args));
|
|
42
|
+
}
|
|
43
|
+
async applySuggestions(
|
|
44
|
+
results: ESLint.LintResult[],
|
|
45
|
+
ruleIds: string[],
|
|
46
|
+
filterScript: string,
|
|
47
|
+
): ReturnType<Core['applySuggestions']> {
|
|
48
|
+
const filter = eval(filterScript) as SuggestionFilter;
|
|
49
|
+
return proxy(await this.core.applySuggestions(results, ruleIds, filter));
|
|
50
|
+
}
|
|
51
|
+
async makeFixableAndFix(
|
|
52
|
+
results: ESLint.LintResult[],
|
|
53
|
+
ruleIds: string[],
|
|
54
|
+
fixableMakerScript: string,
|
|
55
|
+
): ReturnType<Core['makeFixableAndFix']> {
|
|
56
|
+
const fixableMaker = eval(fixableMakerScript) as FixableMaker;
|
|
57
|
+
return proxy(await this.core.makeFixableAndFix(results, ruleIds, fixableMaker));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// workaround for https://github.com/GoogleChromeLabs/comlink/issues/466
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
+
(globalThis as any).MessageChannel = MessageChannel;
|
|
64
|
+
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
+
expose(SerializableCore, (nodeEndpoint as any)(parentPort));
|