Skip to content

test(typescript-estree): Update alignment tests #1343

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 5 commits into from
Dec 17, 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
7 changes: 3 additions & 4 deletions packages/typescript-estree/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
},
"devDependencies": {
"@babel/code-frame": "7.5.5",
"@babel/parser": "7.5.5",
"@babel/types": "^7.3.2",
"@types/babel-code-frame": "^6.20.1",
"@babel/parser": "7.7.5",
"@babel/types": "^7.7.4",
"@types/babel__code-frame": "^7.0.1",
"@types/debug": "^4.1.5",
"@types/glob": "^7.1.1",
"@types/is-glob": "^4.0.1",
Expand All @@ -60,7 +60,6 @@
"@types/semver": "^6.2.0",
"@types/tmp": "^0.1.0",
"@typescript-eslint/shared-fixtures": "2.12.0",
"babel-code-frame": "^6.26.0",
"lodash.isplainobject": "4.0.6",
"tmp": "^0.1.0",
"typescript": "*"
Expand Down
91 changes: 40 additions & 51 deletions packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,6 @@ tester.addFixturePatternConfig('javascript/modules', {
* Expected babel parse errors - ts-estree is not currently throwing
*/
'invalid-export-named-default', // babel parse errors

// babel does not recognise these as modules
'export-named-as-default',
'export-named-as-specifier',
'export-named-as-specifiers',
'export-named-specifier',
'export-named-specifiers-comma',
'export-named-specifiers',
/**
* TS 3.7 feature changes
* TODO: remove me when babel adds support
Expand All @@ -406,6 +398,13 @@ tester.addFixturePatternConfig('javascript/modules', {
// 'error-strict',
'error-delete',
'invalid-await',
// babel does not recognise these as modules
'export-named-as-default',
'export-named-as-specifier',
'export-named-as-specifiers',
'export-named-specifier',
'export-named-specifiers-comma',
'export-named-specifiers',
],
});

Expand Down Expand Up @@ -556,16 +555,6 @@ tester.addFixturePatternConfig('typescript/basics', {
*/
'directive-in-module',
'directive-in-namespace',
/**
* Babel parses this incorrectly
* https://github.com/babel/babel/issues/9324
*/
'type-assertion-arrow-function',
/**
* PR for optional parameters in arrow function has been merged into Babel: https://github.com/babel/babel/pull/9463
* TODO: remove me in next babel > 7.3.2
*/
'arrow-function-with-optional-parameter',
/**
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
*/
Expand All @@ -578,10 +567,11 @@ tester.addFixturePatternConfig('typescript/basics', {
*/
'abstract-class-with-abstract-constructor',
/**
* TS 3.7 feature changes
* TODO: remove me when babel adds support
* TS 3.7: optional chaining
* babel: sets optional property as true/undefined
* ts-estree: sets optional property as true/false
*/
// optional chaining
'arrow-function-with-optional-parameter',
'optional-chain',
'optional-chain-with-parens',
'optional-chain-call',
Expand All @@ -595,6 +585,10 @@ tester.addFixturePatternConfig('typescript/basics', {
'never-type-param',
'non-null-assertion-operator',
'type-parameters-comments',
/**
* TS 3.7 feature changes
* TODO: remove me when babel adds support
*/
// type assertion function
'type-assertion-in-function',
'type-assertion-in-arrow-function',
Expand Down Expand Up @@ -638,10 +632,10 @@ tester.addFixturePatternConfig('typescript/decorators/accessor-decorators', {
fileType: 'ts',
ignore: [
/**
* TS 3.7 feature changes
* TODO: remove me when babel adds support
* TS 3.7: optional chaining
* babel: sets optional property as true/undefined
* ts-estree: sets optional property as true/false
*/
// optional chaining
'accessor-decorator-factory-instance-member',
'accessor-decorator-factory-static-member',
'accessor-decorator-instance-member',
Expand All @@ -652,21 +646,21 @@ tester.addFixturePatternConfig('typescript/decorators/class-decorators', {
fileType: 'ts',
ignore: [
/**
* TS 3.7 feature changes
* TODO: remove me when babel adds support
* TS 3.7: optional chaining
* babel: sets optional property as true/undefined
* ts-estree: sets optional property as true/false
*/
// optional chaining
'class-decorator-factory',
],
});
tester.addFixturePatternConfig('typescript/decorators/method-decorators', {
fileType: 'ts',
ignore: [
/**
* TS 3.7 feature changes
* TODO: remove me when babel adds support
* TS 3.7: optional chaining
* babel: sets optional property as true/undefined
* ts-estree: sets optional property as true/false
*/
// optional chaining
'method-decorator-factory-instance-member',
'method-decorator-factory-static-member',
],
Expand All @@ -681,10 +675,10 @@ tester.addFixturePatternConfig('typescript/decorators/parameter-decorators', {
'parameter-array-pattern-decorator',
'parameter-rest-element-decorator',
/**
* TS 3.7 feature changes
* TODO: remove me when babel adds support
* TS 3.7: optional chaining
* babel: sets optional property as true/undefined
* ts-estree: sets optional property as true/false
*/
// optional chaining
'parameter-decorator-constructor',
'parameter-decorator-decorator-instance-member',
'parameter-decorator-decorator-static-member',
Expand All @@ -695,13 +689,17 @@ tester.addFixturePatternConfig('typescript/decorators/property-decorators', {
fileType: 'ts',
ignore: [
/**
* TS 3.7 feature changes
* TODO: remove me when babel adds support
* TS 3.7: optional chaining
* babel: sets optional property as true/undefined
* ts-estree: sets optional property as true/false
*/
// optional chaining
'property-decorator-factory-instance-member',
'property-decorator-factory-static-member',
// declare class properties
/**
* TS 3.7: declare class properties
* babel: sets declare property as true/undefined
* ts-estree: sets declare property as true/false
*/
'property-decorator-instance-member',
'property-decorator-static-member',
],
Expand All @@ -715,10 +713,9 @@ tester.addFixturePatternConfig('typescript/expressions', {
*/
'tagged-template-expression-type-arguments',
/**
* TS 3.7 feature changes
* TODO: remove me when babel adds support
* babel: sets optional property as true/undefined
* ts-estree: sets optional property as true/false
*/
// optional chaining
'call-expression-type-arguments',
],
});
Expand Down Expand Up @@ -752,18 +749,10 @@ tester.addFixturePatternConfig('typescript/types', {
fileType: 'ts',
ignore: [
/**
* AST difference
* TS 3.7: optional chaining
* babel: sets optional property as true/undefined
* ts-estree: sets optional property as true/false
*/
'literal-number-negative',
/**
* Babel parse error: https://github.com/babel/babel/pull/9431
*/
'function-with-array-destruction',
/**
* TS 3.7 feature changes
* TODO: remove me when babel adds support
*/
// optional chaining
'this-type-expanded',
],
});
Expand Down
17 changes: 13 additions & 4 deletions packages/typescript-estree/tests/ast-alignment/parse.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import { ParserPlugin } from '@babel/parser';
import codeFrame from 'babel-code-frame';
import { codeFrameColumns } from '@babel/code-frame';
import * as parser from '../../src/parser';
import * as parseUtils from './utils';

Expand Down Expand Up @@ -109,9 +109,18 @@ export function parse(
} catch (error) {
const loc = error.loc;
if (loc) {
error.codeFrame = codeFrame(text, loc.line, loc.column + 1, {
highlightCode: true,
});
error.codeFrame = codeFrameColumns(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

codeFrame with line and column parameters got deprecated and replaced with codeFrameColumns

text,
{
start: {
line: loc.line,
column: loc.column + 1,
},
},
{
highlightCode: true,
},
);
error.message += `\n${error.codeFrame}`;
}
result.parseError = error;
Expand Down
41 changes: 18 additions & 23 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@
esutils "^2.0.2"
js-tokens "^4.0.0"

"@babel/parser@7.5.5":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.5.5.tgz#02f077ac8817d3df4a832ef59de67565e71cca4b"
integrity sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==
"@babel/parser@7.7.5":
version "7.7.5"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.7.5.tgz#cbf45321619ac12d83363fcf9c94bb67fa646d71"
integrity sha512-KNlOe9+/nk4i29g0VXgl8PEXIRms5xKLJeuZ6UptN0fHv+jDiriG+y94X6qAgWTR0h3KaoM1wK5G5h7MHFRSig==

"@babel/parser@^7.1.0", "@babel/parser@^7.4.3", "@babel/parser@^7.6.0", "@babel/parser@^7.6.2":
version "7.6.2"
Expand Down Expand Up @@ -133,7 +133,7 @@
globals "^11.1.0"
lodash "^4.17.13"

"@babel/types@^7.0.0", "@babel/types@^7.3.0", "@babel/types@^7.3.2", "@babel/types@^7.4.0", "@babel/types@^7.4.4", "@babel/types@^7.6.0":
"@babel/types@^7.0.0", "@babel/types@^7.3.0", "@babel/types@^7.4.0", "@babel/types@^7.4.4", "@babel/types@^7.6.0":
version "7.6.1"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.6.1.tgz#53abf3308add3ac2a2884d539151c57c4b3ac648"
integrity sha512-X7gdiuaCmA0uRjCmRtYJNAVCc/q+5xSgsfKJHqMN4iNLILX39677fJE1O40arPMh0TTtS9ItH67yre6c7k6t0g==
Expand All @@ -142,6 +142,15 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@babel/types@^7.7.4":
version "7.7.4"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.7.4.tgz#516570d539e44ddf308c07569c258ff94fde9193"
integrity sha512-cz5Ji23KCi4T+YIE/BolWosrJuSmoZeN1EFnRtBwF+KKLi8GG/Z2c2hOJJeCXPk4mwk4QFvTmwIodJowXgttRA==
dependencies:
esutils "^2.0.2"
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@cnakazawa/watch@^1.0.3":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.3.tgz#099139eaec7ebf07a27c1786a3ff64f39464d2ef"
Expand Down Expand Up @@ -1277,10 +1286,10 @@
dependencies:
any-observable "^0.3.0"

"@types/babel-code-frame@^6.20.1":
version "6.20.2"
resolved "https://registry.yarnpkg.com/@types/babel-code-frame/-/babel-code-frame-6.20.2.tgz#d923c88d94e66b864fd3693f07b18ad78489a222"
integrity sha512-HAdhFeYOZKIkrR2jbonCJxp3I/o2G/kxY+CIx7qX9Kmv5jY+9D7OgmgSLdRqeHacB5RlqE5efj2WIDFL9NXCyg==
"@types/babel__code-frame@^7.0.1":
version "7.0.1"
resolved "https://registry.yarnpkg.com/@types/babel__code-frame/-/babel__code-frame-7.0.1.tgz#baf2529c4abbfb5e4008c845efcfe39a187e2f99"
integrity sha512-FFfbQozKxYmOnCKFYV+EQprjBI7u2yaNc2ly/K9AhzyC8MzXtCtSRqptpw+HUJxhwCOo5mLwf1ATmzyhOaVbDg==

"@types/babel__core@^7.1.0":
version "7.1.3"
Expand Down Expand Up @@ -1816,15 +1825,6 @@ aws4@^1.8.0:
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==

babel-code-frame@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=
dependencies:
chalk "^1.1.3"
esutils "^2.0.2"
js-tokens "^3.0.2"

babel-jest@^24.9.0:
version "24.9.0"
resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-24.9.0.tgz#3fc327cb8467b89d14d7bc70e315104a783ccd54"
Expand Down Expand Up @@ -4838,11 +4838,6 @@ jest@^24.9.0:
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==

js-tokens@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls=

js-yaml@^3.13.1:
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy