Skip to content

Commit 5c096de

Browse files
armano2bradzacher
andcommitted
test(typescript-estree): Update alignment tests (typescript-eslint#1343)
Co-authored-by: Brad Zacher <brad.zacher@gmail.com>
1 parent a5f7d22 commit 5c096de

File tree

4 files changed

+74
-82
lines changed

4 files changed

+74
-82
lines changed

packages/typescript-estree/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
},
5050
"devDependencies": {
5151
"@babel/code-frame": "7.5.5",
52-
"@babel/parser": "7.5.5",
53-
"@babel/types": "^7.3.2",
54-
"@types/babel-code-frame": "^6.20.1",
52+
"@babel/parser": "7.7.5",
53+
"@babel/types": "^7.7.4",
54+
"@types/babel__code-frame": "^7.0.1",
5555
"@types/debug": "^4.1.5",
5656
"@types/glob": "^7.1.1",
5757
"@types/is-glob": "^4.0.1",
@@ -60,7 +60,6 @@
6060
"@types/semver": "^6.2.0",
6161
"@types/tmp": "^0.1.0",
6262
"@typescript-eslint/shared-fixtures": "2.12.0",
63-
"babel-code-frame": "^6.26.0",
6463
"lodash.isplainobject": "4.0.6",
6564
"tmp": "^0.1.0",
6665
"typescript": "*"

packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts

Lines changed: 40 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,6 @@ tester.addFixturePatternConfig('javascript/modules', {
386386
* Expected babel parse errors - ts-estree is not currently throwing
387387
*/
388388
'invalid-export-named-default', // babel parse errors
389-
390-
// babel does not recognise these as modules
391-
'export-named-as-default',
392-
'export-named-as-specifier',
393-
'export-named-as-specifiers',
394-
'export-named-specifier',
395-
'export-named-specifiers-comma',
396-
'export-named-specifiers',
397389
/**
398390
* TS 3.7 feature changes
399391
* TODO: remove me when babel adds support
@@ -406,6 +398,13 @@ tester.addFixturePatternConfig('javascript/modules', {
406398
// 'error-strict',
407399
'error-delete',
408400
'invalid-await',
401+
// babel does not recognise these as modules
402+
'export-named-as-default',
403+
'export-named-as-specifier',
404+
'export-named-as-specifiers',
405+
'export-named-specifier',
406+
'export-named-specifiers-comma',
407+
'export-named-specifiers',
409408
],
410409
});
411410

@@ -556,16 +555,6 @@ tester.addFixturePatternConfig('typescript/basics', {
556555
*/
557556
'directive-in-module',
558557
'directive-in-namespace',
559-
/**
560-
* Babel parses this incorrectly
561-
* https://github.com/babel/babel/issues/9324
562-
*/
563-
'type-assertion-arrow-function',
564-
/**
565-
* PR for optional parameters in arrow function has been merged into Babel: https://github.com/babel/babel/pull/9463
566-
* TODO: remove me in next babel > 7.3.2
567-
*/
568-
'arrow-function-with-optional-parameter',
569558
/**
570559
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
571560
*/
@@ -578,10 +567,11 @@ tester.addFixturePatternConfig('typescript/basics', {
578567
*/
579568
'abstract-class-with-abstract-constructor',
580569
/**
581-
* TS 3.7 feature changes
582-
* TODO: remove me when babel adds support
570+
* TS 3.7: optional chaining
571+
* babel: sets optional property as true/undefined
572+
* ts-estree: sets optional property as true/false
583573
*/
584-
// optional chaining
574+
'arrow-function-with-optional-parameter',
585575
'optional-chain',
586576
'optional-chain-with-parens',
587577
'optional-chain-call',
@@ -595,6 +585,10 @@ tester.addFixturePatternConfig('typescript/basics', {
595585
'never-type-param',
596586
'non-null-assertion-operator',
597587
'type-parameters-comments',
588+
/**
589+
* TS 3.7 feature changes
590+
* TODO: remove me when babel adds support
591+
*/
598592
// type assertion function
599593
'type-assertion-in-function',
600594
'type-assertion-in-arrow-function',
@@ -638,10 +632,10 @@ tester.addFixturePatternConfig('typescript/decorators/accessor-decorators', {
638632
fileType: 'ts',
639633
ignore: [
640634
/**
641-
* TS 3.7 feature changes
642-
* TODO: remove me when babel adds support
635+
* TS 3.7: optional chaining
636+
* babel: sets optional property as true/undefined
637+
* ts-estree: sets optional property as true/false
643638
*/
644-
// optional chaining
645639
'accessor-decorator-factory-instance-member',
646640
'accessor-decorator-factory-static-member',
647641
'accessor-decorator-instance-member',
@@ -652,21 +646,21 @@ tester.addFixturePatternConfig('typescript/decorators/class-decorators', {
652646
fileType: 'ts',
653647
ignore: [
654648
/**
655-
* TS 3.7 feature changes
656-
* TODO: remove me when babel adds support
649+
* TS 3.7: optional chaining
650+
* babel: sets optional property as true/undefined
651+
* ts-estree: sets optional property as true/false
657652
*/
658-
// optional chaining
659653
'class-decorator-factory',
660654
],
661655
});
662656
tester.addFixturePatternConfig('typescript/decorators/method-decorators', {
663657
fileType: 'ts',
664658
ignore: [
665659
/**
666-
* TS 3.7 feature changes
667-
* TODO: remove me when babel adds support
660+
* TS 3.7: optional chaining
661+
* babel: sets optional property as true/undefined
662+
* ts-estree: sets optional property as true/false
668663
*/
669-
// optional chaining
670664
'method-decorator-factory-instance-member',
671665
'method-decorator-factory-static-member',
672666
],
@@ -681,10 +675,10 @@ tester.addFixturePatternConfig('typescript/decorators/parameter-decorators', {
681675
'parameter-array-pattern-decorator',
682676
'parameter-rest-element-decorator',
683677
/**
684-
* TS 3.7 feature changes
685-
* TODO: remove me when babel adds support
678+
* TS 3.7: optional chaining
679+
* babel: sets optional property as true/undefined
680+
* ts-estree: sets optional property as true/false
686681
*/
687-
// optional chaining
688682
'parameter-decorator-constructor',
689683
'parameter-decorator-decorator-instance-member',
690684
'parameter-decorator-decorator-static-member',
@@ -695,13 +689,17 @@ tester.addFixturePatternConfig('typescript/decorators/property-decorators', {
695689
fileType: 'ts',
696690
ignore: [
697691
/**
698-
* TS 3.7 feature changes
699-
* TODO: remove me when babel adds support
692+
* TS 3.7: optional chaining
693+
* babel: sets optional property as true/undefined
694+
* ts-estree: sets optional property as true/false
700695
*/
701-
// optional chaining
702696
'property-decorator-factory-instance-member',
703697
'property-decorator-factory-static-member',
704-
// declare class properties
698+
/**
699+
* TS 3.7: declare class properties
700+
* babel: sets declare property as true/undefined
701+
* ts-estree: sets declare property as true/false
702+
*/
705703
'property-decorator-instance-member',
706704
'property-decorator-static-member',
707705
],
@@ -715,10 +713,9 @@ tester.addFixturePatternConfig('typescript/expressions', {
715713
*/
716714
'tagged-template-expression-type-arguments',
717715
/**
718-
* TS 3.7 feature changes
719-
* TODO: remove me when babel adds support
716+
* babel: sets optional property as true/undefined
717+
* ts-estree: sets optional property as true/false
720718
*/
721-
// optional chaining
722719
'call-expression-type-arguments',
723720
],
724721
});
@@ -752,18 +749,10 @@ tester.addFixturePatternConfig('typescript/types', {
752749
fileType: 'ts',
753750
ignore: [
754751
/**
755-
* AST difference
752+
* TS 3.7: optional chaining
753+
* babel: sets optional property as true/undefined
754+
* ts-estree: sets optional property as true/false
756755
*/
757-
'literal-number-negative',
758-
/**
759-
* Babel parse error: https://github.com/babel/babel/pull/9431
760-
*/
761-
'function-with-array-destruction',
762-
/**
763-
* TS 3.7 feature changes
764-
* TODO: remove me when babel adds support
765-
*/
766-
// optional chaining
767756
'this-type-expanded',
768757
],
769758
});

packages/typescript-estree/tests/ast-alignment/parse.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22

33
import { ParserPlugin } from '@babel/parser';
4-
import codeFrame from 'babel-code-frame';
4+
import { codeFrameColumns } from '@babel/code-frame';
55
import * as parser from '../../src/parser';
66
import * as parseUtils from './utils';
77

@@ -109,9 +109,18 @@ export function parse(
109109
} catch (error) {
110110
const loc = error.loc;
111111
if (loc) {
112-
error.codeFrame = codeFrame(text, loc.line, loc.column + 1, {
113-
highlightCode: true,
114-
});
112+
error.codeFrame = codeFrameColumns(
113+
text,
114+
{
115+
start: {
116+
line: loc.line,
117+
column: loc.column + 1,
118+
},
119+
},
120+
{
121+
highlightCode: true,
122+
},
123+
);
115124
error.message += `\n${error.codeFrame}`;
116125
}
117126
result.parseError = error;

yarn.lock

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@
8585
esutils "^2.0.2"
8686
js-tokens "^4.0.0"
8787

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

9393
"@babel/parser@^7.1.0", "@babel/parser@^7.4.3", "@babel/parser@^7.6.0", "@babel/parser@^7.6.2":
9494
version "7.6.2"
@@ -133,7 +133,7 @@
133133
globals "^11.1.0"
134134
lodash "^4.17.13"
135135

136-
"@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":
136+
"@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":
137137
version "7.6.1"
138138
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.6.1.tgz#53abf3308add3ac2a2884d539151c57c4b3ac648"
139139
integrity sha512-X7gdiuaCmA0uRjCmRtYJNAVCc/q+5xSgsfKJHqMN4iNLILX39677fJE1O40arPMh0TTtS9ItH67yre6c7k6t0g==
@@ -142,6 +142,15 @@
142142
lodash "^4.17.13"
143143
to-fast-properties "^2.0.0"
144144

145+
"@babel/types@^7.7.4":
146+
version "7.7.4"
147+
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.7.4.tgz#516570d539e44ddf308c07569c258ff94fde9193"
148+
integrity sha512-cz5Ji23KCi4T+YIE/BolWosrJuSmoZeN1EFnRtBwF+KKLi8GG/Z2c2hOJJeCXPk4mwk4QFvTmwIodJowXgttRA==
149+
dependencies:
150+
esutils "^2.0.2"
151+
lodash "^4.17.13"
152+
to-fast-properties "^2.0.0"
153+
145154
"@cnakazawa/watch@^1.0.3":
146155
version "1.0.3"
147156
resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.3.tgz#099139eaec7ebf07a27c1786a3ff64f39464d2ef"
@@ -1277,10 +1286,10 @@
12771286
dependencies:
12781287
any-observable "^0.3.0"
12791288

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

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

1819-
babel-code-frame@^6.26.0:
1820-
version "6.26.0"
1821-
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
1822-
integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=
1823-
dependencies:
1824-
chalk "^1.1.3"
1825-
esutils "^2.0.2"
1826-
js-tokens "^3.0.2"
1827-
18281828
babel-jest@^24.9.0:
18291829
version "24.9.0"
18301830
resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-24.9.0.tgz#3fc327cb8467b89d14d7bc70e315104a783ccd54"
@@ -4838,11 +4838,6 @@ jest@^24.9.0:
48384838
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
48394839
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
48404840

4841-
js-tokens@^3.0.2:
4842-
version "3.0.2"
4843-
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
4844-
integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls=
4845-
48464841
js-yaml@^3.13.1:
48474842
version "3.13.1"
48484843
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"

0 commit comments

Comments
 (0)
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