Skip to content

Commit f632e8d

Browse files
authored
Merge pull request #50 from Quramy/upgrade-ts-eslint-v4
upgrade ts-eslint pkgs
2 parents 008c2d0 + 9ceffee commit f632e8d

File tree

8 files changed

+918
-755
lines changed

8 files changed

+918
-755
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ TypeScript language service plugin to check ESLint errors.
1919
### Requirements (peer dependencies)
2020

2121
- `typescript`
22-
- `@typescript-eslint/parser` >= 3.5.0
23-
- `@typescript-eslint/typescript-estree` >= 3.5.0
22+
- `@typescript-eslint/parser` >= 4.0.0
23+
- `@typescript-eslint/typescript-estree` >= 4.0.0
2424
- `eslint`
2525

2626
### Install
@@ -68,6 +68,7 @@ By default, this plugins watches only `.eslintrc.*` files that exist in your pro
6868

6969
### If you use older version of `@typescript-eslint` packages
7070

71+
- **If your @typescript-eslint tool's version is < 4.0.0, install `[email protected]`.**
7172
- **If your @typescript-eslint tool's version is <= 3.4.0, install `[email protected]`.**
7273
- **If your @typescript-eslint tool's version is <= 2.x.x, install `[email protected]`.**
7374

e2e/projects/other-parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"@babel/core": "^7.7.4",
99
"babel-eslint": "^10.0.3",
1010
"eslint": "^7.0.0",
11-
"typescript": "4.0.1-rc"
11+
"typescript": "~4.0.0"
1212
}
1313
}

e2e/projects/simple/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"test": "echo \"Error: no test specified\" && exit 1"
66
},
77
"devDependencies": {
8-
"@typescript-eslint/parser": "~3.9.0",
8+
"@typescript-eslint/parser": "~4.0.0",
99
"eslint": "^7.0.0",
10-
"typescript": "4.0.1-rc"
10+
"typescript": "~4.0.0"
1111
}
1212
}

e2e/projects/ts-eslint-plugin/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"test": "echo \"Error: no test specified\" && exit 1"
66
},
77
"devDependencies": {
8-
"@typescript-eslint/eslint-plugin": "~3.9.0",
9-
"@typescript-eslint/parser": "~3.9.0",
8+
"@typescript-eslint/eslint-plugin": "~4.0.0",
9+
"@typescript-eslint/parser": "~4.0.0",
1010
"eslint": "^7.0.0",
11-
"typescript": "4.0.1-rc"
11+
"typescript": "~4.0.0"
1212
}
1313
}

e2e/setup.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,28 @@
33
BASE_DIR=$(cd $(dirname $0); pwd)
44
yarn link
55

6+
TS_VER=$(node -e "console.log(require('./package.json').devDependencies['typescript'])")
7+
TSESLINT_VER=$(node -e "console.log(require('./package.json').devDependencies['@typescript-eslint/parser'])")
8+
69
for dir in $(ls ${BASE_DIR}/projects); do
710
pushd ${BASE_DIR}/projects/${dir}
11+
cat << EOF | node > PKG
12+
const json = require('./package.json');
13+
const ret = {
14+
...json,
15+
devDependencies: Object.keys(json.devDependencies).reduce((acc, k) => {
16+
if (k === 'typescript') {
17+
return { ...acc, typescript: "${TS_VER}" };
18+
}
19+
if (k.startsWith('@typescript-eslint')) {
20+
return { ...acc, [k]: "${TSESLINT_VER}" };
21+
}
22+
return acc;
23+
}, json.devDependencies),
24+
};
25+
console.log(JSON.stringify(ret, null, 2));
26+
EOF
27+
mv PKG package.json
828
yarn --pure-lockfile
929
yarn link typescript-eslint-language-service
1030
popd

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@
2828
"url": "https://github.com/Quramy/typescript-eslint-language-service/issues"
2929
},
3030
"pperDependencies": {
31-
"@typescript-eslint/parser": ">= 3.5.0",
32-
"@typescript-eslint/typescript-estree": ">= 3.5.0",
31+
"@typescript-eslint/parser": ">= 4.0.0",
32+
"@typescript-eslint/typescript-estree": ">= 4.0.0",
3333
"eslint": ">= 6.7.0 <= 6.8.x || >= 7.0.0",
34-
"typescript": "^3.0.0"
34+
"typescript": ">= 3.0.0 || >= 4.0.0"
3535
},
3636
"homepage": "https://github.com/Quramy/typescript-eslint-language-service#readme",
3737
"devDependencies": {
3838
"@types/eslint": "^6.1.3",
3939
"@types/jest": "^25.1.4",
4040
"@types/node": "^14.0.6",
41-
"@typescript-eslint/eslint-plugin": "~3.9.0",
42-
"@typescript-eslint/parser": "~3.9.0",
43-
"@typescript-eslint/typescript-estree": "~3.9.0",
41+
"@typescript-eslint/eslint-plugin": "~4.0.0",
42+
"@typescript-eslint/parser": "~4.0.0",
43+
"@typescript-eslint/typescript-estree": "~4.0.0",
4444
"eslint": "^7.0.0",
4545
"eslint-config-prettier": "^6.11.0",
4646
"fretted-strings": "^1.0.0",
@@ -49,8 +49,8 @@
4949
"prettier": "^2.0.5",
5050
"pretty-quick": "^2.0.1",
5151
"rimraf": "^3.0.0",
52-
"ts-jest": "^26.0.0",
53-
"typescript": "4.0.1-rc"
52+
"ts-jest": "^26.3.0",
53+
"typescript": "~4.0.0"
5454
},
5555
"husky": {
5656
"hooks": {

src/ast-converter.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ts from "typescript";
22
import { SourceCode, AST, Scope } from "eslint";
3-
import { ParserOptions } from "@typescript-eslint/parser";
4-
import { analyzeScope } from "@typescript-eslint/parser/dist/analyze-scope";
3+
import { ParserOptions } from "@typescript-eslint/types";
4+
import { analyze, AnalyzeOptions } from "@typescript-eslint/scope-manager";
55
import { Extra } from "@typescript-eslint/typescript-estree/dist/parser-options";
66
import { visitorKeys } from "@typescript-eslint/visitor-keys";
77
import { ParseAndGenerateServicesResult, TSESTreeOptions } from "@typescript-eslint/typescript-estree";
@@ -200,6 +200,15 @@ export class AstConverter {
200200
jsx: validateBoolean(options.ecmaFeatures.jsx),
201201
});
202202

203+
const analyzeOptions: AnalyzeOptions = {
204+
ecmaVersion: options.ecmaVersion,
205+
globalReturn: options.ecmaFeatures.globalReturn,
206+
// jsxPragma: options.jsxPragma,
207+
// jsxFragmentName: options.jsxFragmentName,
208+
lib: options.lib,
209+
sourceType: options.sourceType,
210+
};
211+
203212
if (typeof options.filePath === "string") {
204213
const tsx = options.filePath.endsWith(".tsx");
205214
if (tsx || options.filePath.endsWith(".ts")) {
@@ -219,7 +228,7 @@ export class AstConverter {
219228
const { ast, services } = this.parseAndGenerateServices(src, parserOptions);
220229
ast.sourceType = options.sourceType;
221230

222-
const scopeManager = analyzeScope(ast as any, parserOptions);
231+
const scopeManager = analyze(ast, analyzeOptions);
223232

224233
return {
225234
ast: ast as AST.Program,

0 commit comments

Comments
 (0)