Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade ts-eslint pkgs #50

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ TypeScript language service plugin to check ESLint errors.
### Requirements (peer dependencies)

- `typescript`
- `@typescript-eslint/parser` >= 3.5.0
- `@typescript-eslint/typescript-estree` >= 3.5.0
- `@typescript-eslint/parser` >= 4.0.0
- `@typescript-eslint/typescript-estree` >= 4.0.0
- `eslint`

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

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

- **If your @typescript-eslint tool's version is < 4.0.0, install `typescript-eslint-language-service@3.1.x`.**
- **If your @typescript-eslint tool's version is <= 3.4.0, install `typescript-eslint-language-service@3.0.x`.**
- **If your @typescript-eslint tool's version is <= 2.x.x, install `typescript-eslint-language-service@2.x.x`.**

Expand Down
2 changes: 1 addition & 1 deletion e2e/projects/other-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"@babel/core": "^7.7.4",
"babel-eslint": "^10.0.3",
"eslint": "^7.0.0",
"typescript": "4.0.1-rc"
"typescript": "~4.0.0"
}
}
4 changes: 2 additions & 2 deletions e2e/projects/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"@typescript-eslint/parser": "~3.9.0",
"@typescript-eslint/parser": "~4.0.0",
"eslint": "^7.0.0",
"typescript": "4.0.1-rc"
"typescript": "~4.0.0"
}
}
6 changes: 3 additions & 3 deletions e2e/projects/ts-eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "~3.9.0",
"@typescript-eslint/parser": "~3.9.0",
"@typescript-eslint/eslint-plugin": "~4.0.0",
"@typescript-eslint/parser": "~4.0.0",
"eslint": "^7.0.0",
"typescript": "4.0.1-rc"
"typescript": "~4.0.0"
}
}
20 changes: 20 additions & 0 deletions e2e/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,28 @@
BASE_DIR=$(cd $(dirname $0); pwd)
yarn link

TS_VER=$(node -e "console.log(require('./package.json').devDependencies['typescript'])")
TSESLINT_VER=$(node -e "console.log(require('./package.json').devDependencies['@typescript-eslint/parser'])")

for dir in $(ls ${BASE_DIR}/projects); do
pushd ${BASE_DIR}/projects/${dir}
cat << EOF | node > PKG
const json = require('./package.json');
const ret = {
...json,
devDependencies: Object.keys(json.devDependencies).reduce((acc, k) => {
if (k === 'typescript') {
return { ...acc, typescript: "${TS_VER}" };
}
if (k.startsWith('@typescript-eslint')) {
return { ...acc, [k]: "${TSESLINT_VER}" };
}
return acc;
}, json.devDependencies),
};
console.log(JSON.stringify(ret, null, 2));
EOF
mv PKG package.json
yarn --pure-lockfile
yarn link typescript-eslint-language-service
popd
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@
"url": "https://github.com/Quramy/typescript-eslint-language-service/issues"
},
"pperDependencies": {
"@typescript-eslint/parser": ">= 3.5.0",
"@typescript-eslint/typescript-estree": ">= 3.5.0",
"@typescript-eslint/parser": ">= 4.0.0",
"@typescript-eslint/typescript-estree": ">= 4.0.0",
"eslint": ">= 6.7.0 <= 6.8.x || >= 7.0.0",
"typescript": "^3.0.0"
"typescript": ">= 3.0.0 || >= 4.0.0"
},
"homepage": "https://github.com/Quramy/typescript-eslint-language-service#readme",
"devDependencies": {
"@types/eslint": "^6.1.3",
"@types/jest": "^25.1.4",
"@types/node": "^14.0.6",
"@typescript-eslint/eslint-plugin": "~3.9.0",
"@typescript-eslint/parser": "~3.9.0",
"@typescript-eslint/typescript-estree": "~3.9.0",
"@typescript-eslint/eslint-plugin": "~4.0.0",
"@typescript-eslint/parser": "~4.0.0",
"@typescript-eslint/typescript-estree": "~4.0.0",
"eslint": "^7.0.0",
"eslint-config-prettier": "^6.11.0",
"fretted-strings": "^1.0.0",
Expand All @@ -49,8 +49,8 @@
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
"rimraf": "^3.0.0",
"ts-jest": "^26.0.0",
"typescript": "4.0.1-rc"
"ts-jest": "^26.3.0",
"typescript": "~4.0.0"
},
"husky": {
"hooks": {
Expand Down
15 changes: 12 additions & 3 deletions src/ast-converter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import { SourceCode, AST, Scope } from "eslint";
import { ParserOptions } from "@typescript-eslint/parser";
import { analyzeScope } from "@typescript-eslint/parser/dist/analyze-scope";
import { ParserOptions } from "@typescript-eslint/types";
import { analyze, AnalyzeOptions } from "@typescript-eslint/scope-manager";
import { Extra } from "@typescript-eslint/typescript-estree/dist/parser-options";
import { visitorKeys } from "@typescript-eslint/visitor-keys";
import { ParseAndGenerateServicesResult, TSESTreeOptions } from "@typescript-eslint/typescript-estree";
Expand Down Expand Up @@ -200,6 +200,15 @@ export class AstConverter {
jsx: validateBoolean(options.ecmaFeatures.jsx),
});

const analyzeOptions: AnalyzeOptions = {
ecmaVersion: options.ecmaVersion,
globalReturn: options.ecmaFeatures.globalReturn,
// jsxPragma: options.jsxPragma,
// jsxFragmentName: options.jsxFragmentName,
lib: options.lib,
sourceType: options.sourceType,
};

if (typeof options.filePath === "string") {
const tsx = options.filePath.endsWith(".tsx");
if (tsx || options.filePath.endsWith(".ts")) {
Expand All @@ -219,7 +228,7 @@ export class AstConverter {
const { ast, services } = this.parseAndGenerateServices(src, parserOptions);
ast.sourceType = options.sourceType;

const scopeManager = analyzeScope(ast as any, parserOptions);
const scopeManager = analyze(ast, analyzeOptions);

return {
ast: ast as AST.Program,
Expand Down
Loading