Skip to content

feat(typescript-estree): support for parsing 3.7 features #1045

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

Merged
merged 19 commits into from
Oct 14, 2019
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
3 changes: 3 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
"args": [
"--runInBand",
"--no-coverage",
// needs the '' around it so that the () are properly handled
"'tests/(.+/)?${fileBasenameNoExtension}'"
],
Expand All @@ -27,6 +28,8 @@
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
"args": [
"--runInBand",
"--no-cache",
"--no-coverage",
"${relativeFile}"
],
"sourceMaps": true,
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"javascript.preferences.importModuleSpecifier": "auto",
"typescript.preferences.importModuleSpecifier": "auto",
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
"editor.defaultFormatter": "esbenp.prettier-vscode"
"typescript.preferences.quoteStyle": "single",
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ The latest version under the `canary` tag **(latest commit to master)** is:

## Supported TypeScript Version

We will always endeavor to support the latest stable version of TypeScript. Sometimes, but not always, changes in TypeScript will not require breaking changes in this project, and so we are able to support more than one version of TypeScript.
We will always endeavor to support the latest stable version of TypeScript. Sometimes, but not always, changes in TypeScript will not require breaking changes in this project, and so we are able to support more than one version of TypeScript. In some cases, we may even be able to support additional pre-releases (i.e. betas and release candidates) of TypeScript, but only if doing so does not require us to compromise on support for the latest stable version.

**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.7.0`.**
**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.8.0`.**

This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript.

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@
"ts-jest": "^24.0.0",
"ts-node": "^8.3.0",
"tslint": "^5.19.0",
"typescript": ">=3.2.1 <3.7.0"
"typescript": ">=3.2.1 <3.8.0 >3.7.0-dev.0"
},
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"resolutions": {
"typescript": "^3.7.0-beta"
}
}
4 changes: 2 additions & 2 deletions packages/eslint-plugin-tslint/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"rootDir": ".",
"noEmit": true
"composite": false,
"rootDir": "."
},
"include": ["src", "tests"],
"exclude": ["tests/test-project", "tests/test-tslint-rules-directory"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ export default util.createRule({
case AST_NODE_TYPES.TSTypeLiteral:
return node.members;
}

return [];
}

/**
Expand Down
6 changes: 5 additions & 1 deletion packages/eslint-plugin/src/rules/indent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export default util.createRule<Options, MessageIds>({
range: moduleReference.range,
loc: moduleReference.loc,
},
},
} as TSESTree.VariableDeclarator,
],

// location data
Expand All @@ -313,6 +313,8 @@ export default util.createRule<Options, MessageIds>({
parent: node.parent,
range: node.range,
loc: node.loc,
optional: false,
computed: true,
});
},

Expand Down Expand Up @@ -420,6 +422,8 @@ export default util.createRule<Options, MessageIds>({
parent: node.parent,
range: node.range,
loc: node.loc,
optional: false,
computed: false,
});
},

Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-plugin/src/rules/prefer-readonly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ export default util.createRule<Options, MessageIds>({
function getEsNodesFromViolatingNode(
violatingNode: ParameterOrPropertyDeclaration,
): { esNode: TSESTree.Node; nameNode: TSESTree.Node } {
if (ts.isParameterPropertyDeclaration(violatingNode)) {
if (
ts.isParameterPropertyDeclaration(violatingNode, violatingNode.parent)
) {
return {
esNode: parserServices.tsNodeToESTreeNodeMap.get(violatingNode.name),
nameNode: parserServices.tsNodeToESTreeNodeMap.get(
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"rootDir": ".",
"noEmit": true
"composite": false,
"rootDir": "."
},
"include": ["src", "typings", "tests", "tools"]
}
4 changes: 2 additions & 2 deletions packages/experimental-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"rootDir": ".",
"noEmit": true
"composite": false,
"rootDir": "."
},
"include": ["src", "typings", "tests", "tools"]
}
2 changes: 2 additions & 0 deletions packages/parser/src/visitor-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export const visitorKeys = eslintVisitorKeys.unionWith({
BigIntLiteral: [],
ClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'],
Decorator: ['expression'],
OptionalCallExpression: eslintVisitorKeys.KEYS.CallExpression,
OptionalMemberExpression: eslintVisitorKeys.KEYS.MemberExpression,
TSAbstractClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'],
TSAbstractKeyword: [],
TSAbstractMethodDefinition: ['key', 'value'],
Expand Down
13 changes: 13 additions & 0 deletions packages/parser/tests/lib/__snapshots__/comments.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Object {
"line": 2,
},
},
"optional": false,
"range": Array [
6,
9,
Expand Down Expand Up @@ -11708,6 +11709,7 @@ Object {
"line": 2,
},
},
"optional": false,
"range": Array [
24,
37,
Expand Down Expand Up @@ -12589,6 +12591,7 @@ Object {
"line": 2,
},
},
"optional": false,
"range": Array [
24,
37,
Expand Down Expand Up @@ -14189,6 +14192,7 @@ Object {
"line": 3,
},
},
"optional": false,
"range": Array [
36,
41,
Expand Down Expand Up @@ -15965,6 +15969,7 @@ Object {
"line": 6,
},
},
"optional": false,
"range": Array [
82,
88,
Expand Down Expand Up @@ -16485,6 +16490,7 @@ Object {
"line": 7,
},
},
"optional": false,
"range": Array [
126,
132,
Expand Down Expand Up @@ -18181,6 +18187,7 @@ Object {
],
"type": "Identifier",
},
"optional": false,
"property": Object {
"loc": Object {
"end": Object {
Expand Down Expand Up @@ -18277,6 +18284,7 @@ Object {
],
"type": "Identifier",
},
"optional": false,
"property": Object {
"loc": Object {
"end": Object {
Expand All @@ -18301,6 +18309,7 @@ Object {
],
"type": "MemberExpression",
},
"optional": false,
"property": Object {
"left": Object {
"computed": false,
Expand Down Expand Up @@ -18344,6 +18353,7 @@ Object {
],
"type": "Identifier",
},
"optional": false,
"property": Object {
"loc": Object {
"end": Object {
Expand All @@ -18368,6 +18378,7 @@ Object {
],
"type": "MemberExpression",
},
"optional": false,
"property": Object {
"loc": Object {
"end": Object {
Expand Down Expand Up @@ -18463,6 +18474,7 @@ Object {
"line": 6,
},
},
"optional": false,
"range": Array [
161,
218,
Expand Down Expand Up @@ -18552,6 +18564,7 @@ Object {
],
"type": "Identifier",
},
"optional": false,
"property": Object {
"loc": Object {
"end": Object {
Expand Down
Loading