Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit fbb98c4

Browse files
committed
Breaking: Updates to AST node types of some TSNodes (fixes #386)
1 parent 9c71a62 commit fbb98c4

File tree

5 files changed

+236
-222
lines changed

5 files changed

+236
-222
lines changed

README.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,26 @@ Issues and pull requests will be triaged and responded to as quickly as possible
6767

6868
## Build Commands
6969

70-
* `npm test` - run all linting and tests
71-
* `npm run lint` - run all linting
70+
* To run all of the linting, unit tests and AST alignment tests with Babylon:
71+
```
72+
npm test
73+
```
74+
75+
* To run just the linting:
76+
```
77+
npm run lint
78+
```
79+
80+
* To run just the unit tests:
81+
```
82+
npm run jest
83+
```
84+
85+
* To run just the AST alignment tests with Babylon:
86+
```
87+
npm run ast-alignment-tests
88+
```
7289

7390
## License
7491

7592
TypeScript ESLint Parser is licensed under a permissive BSD 2-clause license.
76-

lib/ast-node-types.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ module.exports = {
9797
ThisExpression: "ThisExpression",
9898
ThrowStatement: "ThrowStatement",
9999
TryStatement: "TryStatement",
100-
101100
/**
102101
* TS-prefixed nodes
103102
*/
@@ -140,17 +139,16 @@ module.exports = {
140139
TSStaticKeyword: "TSStaticKeyword",
141140
TSStringKeyword: "TSStringKeyword",
142141
TSSymbolKeyword: "TSSymbolKeyword",
142+
TSTypeAnnotation: "TSTypeAnnotation",
143143
TSTypeLiteral: "TSTypeLiteral",
144+
TSTypeParameter: "TSTypeParameter",
145+
TSTypeParameterDeclaration: "TSTypeParameterDeclaration",
146+
TSTypeParameterInstantiation: "TSTypeParameterInstantiation",
144147
TSTypePredicate: "TSTypePredicate",
145148
TSTypeReference: "TSTypeReference",
146149
TSUnionType: "TSUnionType",
147150
TSUndefinedKeyword: "TSUndefinedKeyword",
148151
TSVoidKeyword: "TSVoidKeyword",
149-
150-
TypeAnnotation: "TypeAnnotation",
151-
TypeParameter: "TypeParameter",
152-
TypeParameterDeclaration: "TypeParameterDeclaration",
153-
TypeParameterInstantiation: "TypeParameterInstantiation",
154152
UnaryExpression: "UnaryExpression",
155153
UpdateExpression: "UpdateExpression",
156154
VariableDeclaration: "VariableDeclaration",

lib/convert.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ module.exports = function convert(config) {
8989
const annotationStartCol = child.getFullStart() - 1;
9090
const loc = nodeUtils.getLocFor(annotationStartCol, child.end, ast);
9191
return {
92-
type: AST_NODE_TYPES.TypeAnnotation,
92+
type: AST_NODE_TYPES.TSTypeAnnotation,
9393
loc,
9494
range: [annotationStartCol, child.end],
9595
typeAnnotation: annotation
@@ -107,7 +107,7 @@ module.exports = function convert(config) {
107107
const greaterThanToken = nodeUtils.findNextToken(lastTypeArgument, ast);
108108

109109
return {
110-
type: AST_NODE_TYPES.TypeParameterInstantiation,
110+
type: AST_NODE_TYPES.TSTypeParameterInstantiation,
111111
range: [
112112
firstTypeArgument.pos - 1,
113113
greaterThanToken.end
@@ -152,7 +152,7 @@ module.exports = function convert(config) {
152152
const greaterThanToken = nodeUtils.findNextToken(lastTypeParameter, ast);
153153

154154
return {
155-
type: AST_NODE_TYPES.TypeParameterDeclaration,
155+
type: AST_NODE_TYPES.TSTypeParameterDeclaration,
156156
range: [
157157
firstTypeParameter.pos - 1,
158158
greaterThanToken.end
@@ -170,7 +170,7 @@ module.exports = function convert(config) {
170170
: typeParameter.default;
171171

172172
return {
173-
type: AST_NODE_TYPES.TypeParameter,
173+
type: AST_NODE_TYPES.TSTypeParameter,
174174
range: [
175175
typeParameter.getStart(),
176176
typeParameter.getEnd()

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"license": "BSD-2-Clause",
2020
"devDependencies": {
2121
"babel-code-frame": "^6.26.0",
22-
"babylon": "7.0.0-beta.24",
22+
"babylon": "^7.0.0-beta.25",
2323
"eslint": "4.6.1",
2424
"eslint-config-eslint": "4.0.0",
2525
"eslint-plugin-node": "5.1.1",

0 commit comments

Comments
 (0)