Skip to content

test(typescript-estree): enable more alignment tests #114

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 2 commits into from
Jan 21, 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"devDependencies": {
"@babel/code-frame": "7.0.0",
"@babel/parser": "7.2.3",
"@babel/parser": "7.3.0",
"@commitlint/cli": "^7.1.2",
"@commitlint/config-conventional": "^7.1.2",
"@commitlint/travis-cli": "^7.1.2",
Expand Down
1 change: 1 addition & 0 deletions packages/typescript-estree/src/semantic-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function whitelistSupportedDiagnostics(
): ReadonlyArray<ts.DiagnosticWithLocation | ts.Diagnostic> {
return diagnostics.filter(diagnostic => {
switch (diagnostic.code) {
case 1013: // ts 3.2 "A rest parameter or binding pattern may not have a trailing comma."
case 1014: // ts 3.2 "A rest parameter must be last in a parameter list."
case 1044: // ts 3.2 "'{0}' modifier cannot appear on a module or namespace element."
case 1045: // ts 3.2 "A '{0}' modifier cannot be used with an interface declaration."
Expand Down
69 changes: 9 additions & 60 deletions packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,7 @@ tester.addFixturePatternConfig('javascript/simple-literals');

tester.addFixturePatternConfig('javascript/directives');

tester.addFixturePatternConfig('javascript/experimentalObjectRestSpread', {
ignore: [
/**
* Trailing comma is not permitted after a "RestElement" in Babel
*/
'invalid-rest-trailing-comma'
]
});
tester.addFixturePatternConfig('javascript/experimentalObjectRestSpread');

tester.addFixturePatternConfig('javascript/arrowFunctions', {
ignore: [
Expand Down Expand Up @@ -330,16 +323,6 @@ tester.addFixturePatternConfig('typescript/basics', {
* TODO: Investigate in more depth, potentially split up different parts of the interface
*/
'interface-with-all-property-types', // babel parse errors
/**
* PR for generic ArrowFunctionExpression ranges has been merged into Babel: https://github.com/babel/babel/pull/9295
* TODO: remove me in next babel > 7.2.3
*/
'arrow-function-with-type-parameters',
/**
* PR for this type predicate ranges has been merged into Babel: https://github.com/babel/babel/pull/9339
* TODO: remove me in next babel > 7.2.3
*/
'type-guard-in-method',
/**
* there is difference in range between babel and ts-estree
*/
Expand All @@ -351,11 +334,6 @@ tester.addFixturePatternConfig('typescript/basics', {
* TODO: report it to babel
*/
'interface-with-extends-member-expression',
/**
* PR for parsing exported abstract interface has been merged into Babel: https://github.com/babel/babel/pull/9336
* TODO: remove me in next babel > 7.2.3
*/
'abstract-interface',
/**
* Babel bug for optional or abstract methods
* https://github.com/babel/babel/issues/9305
Expand All @@ -364,46 +342,32 @@ tester.addFixturePatternConfig('typescript/basics', {
'abstract-class-with-optional-method', // babel parse errors
'declare-class-with-optional-method', // babel parse errors
/**
* PR for parameter property ranges has been merged into Babel: https://github.com/babel/babel/pull/9284
* TODO: remove me in next babel > 7.2.3
* Was expected to be fixed by PR into Babel: https://github.com/babel/babel/pull/9284
* But not fixed in Babel 7.3
* TODO: Investigate differences
Copy link
Collaborator

@armano2 armano2 Jan 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we have issue with ranges, TSParameterProperty->AssignmentPattern
AssignmentPattern includes modifier into their range

but modifier is attached to TSParameterProperty

*/
'class-with-private-parameter-properties',
'class-with-protected-parameter-properties',
'class-with-public-parameter-properties',
'class-with-readonly-parameter-properties',
/**
* PR for type import has been merged into Babel: https://github.com/babel/babel/pull/9302
* TODO: remove me in next babel > 7.2.3
* Was expected to be fixed by PR into Babel: https://github.com/babel/babel/pull/9302
* But not fixed in Babel 7.3
* TODO: Investigate differences
Copy link
Collaborator

@armano2 armano2 Jan 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in babel i implemented this in a little diffrent way.

we have one node TSImportType with property isTypeOf set to true/false (as is in ts)
in babel its 2 nodes: typeof -> TSImportType

spliting this node to 2 allows us to handle comments in between them typeof /* test */ import

*/
'import-type',
'import-type-with-type-parameters-in-type-reference',
/**
* PR for BigInt support has been merged into Babel: https://github.com/babel/babel/pull/9230
* TODO: remove me in next babel > 7.2.3
*/
'typed-keyword-bigint',
/**
* Not yet supported in Babel https://github.com/babel/babel/issues/9228
* Directive field is not added to module and namespace
*/
'directive-in-module',
'directive-in-namespace',
/**
* PR for type assertions ranges has been merged into Babel: https://github.com/babel/babel/pull/9284
* TODO: remove me in next babel > 7.2.3
*/
'type-assertion',
/**
* Babel parses this incorrectly
* https://github.com/babel/babel/issues/9324
*/
'type-assertion-arrow-function',
/**
* PR for type parsing declare and abstract classes has been merged into Babel: https://github.com/babel/babel/pull/9328
* TODO: remove me in next babel > 7.2.3
*/
'class-multi-line-keyword-declare',
'class-multi-line-keyword-abstract'
'type-assertion-arrow-function'
],
ignoreSourceType: [
/**
Expand Down Expand Up @@ -443,27 +407,12 @@ tester.addFixturePatternConfig('typescript/expressions', {
});

tester.addFixturePatternConfig('typescript/errorRecovery', {
fileType: 'ts',
ignore: [
/**
* PR with errors in empty extends and implements has been merged into Babel: https://github.com/babel/babel/pull/9292
* TODO: remove me in next babel > 7.2.3
*/
'interface-empty-extends',
'class-extends-empty-implements'
]
fileType: 'ts'
});

tester.addFixturePatternConfig('typescript/types', {
fileType: 'ts',
ignore: [
/**
* PR for type Identifier in TSIndexSignature ranges has been merged into Babel: https://github.com/babel/babel/pull/9335
* TODO: remove me in next babel > 7.2.3
*/
'index-signature',
'index-signature-readonly',
'index-signature-without-type',
/**
* AST difference
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,14 @@ Object {
}
`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/destructuring-and-spread/invalid-not-final-array-empty.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/destructuring-and-spread/invalid-not-final-array-empty.src 1`] = `
Object {
"column": 5,
"index": 5,
"lineNumber": 1,
"message": "A rest parameter or binding pattern may not have a trailing comma.",
}
`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/destructuring-and-spread/multi-destructured.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

Expand Down Expand Up @@ -622,7 +629,14 @@ Object {
}
`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/experimentalObjectRestSpread/invalid-rest-trailing-comma.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/experimentalObjectRestSpread/invalid-rest-trailing-comma.src 1`] = `
Object {
"column": 16,
"index": 16,
"lineNumber": 1,
"message": "A rest parameter or binding pattern may not have a trailing comma.",
}
`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/experimentalObjectRestSpread/object-rest.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
esutils "^2.0.2"
js-tokens "^4.0.0"

"@babel/parser@7.2.3":
version "7.2.3"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.2.3.tgz#32f5df65744b70888d17872ec106b02434ba1489"
integrity sha512-0LyEcVlfCoFmci8mXx8A5oIkpkOgyo8dRHtxBnK9RRBwxO2+JZPNsqtVEZQ7mJFPxnXF9lfmU24mHOPI0qnlkA==
"@babel/parser@7.3.0":
version "7.3.0"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.3.0.tgz#930251fe6714df47ce540a919ccdf6dcfb652b61"
integrity sha512-8M30TzMpLHGmuthHZStm4F+az5wxyYeh8U+LWK7+b2qnlQ0anXBmOQ1I8DCMV1K981wPY3C3kWZ4SA1lR3Y3xQ==

"@commitlint/cli@^7.1.2", "@commitlint/cli@^7.3.2":
version "7.3.2"
Expand Down