Skip to content

Commit 1932c8b

Browse files
authored
test(typescript-estree): update ast-alignment tests (typescript-eslint#2938)
1 parent a241b25 commit 1932c8b

File tree

4 files changed

+131
-216
lines changed

4 files changed

+131
-216
lines changed

packages/typescript-estree/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
"tsutils": "^3.17.1"
5252
},
5353
"devDependencies": {
54-
"@babel/code-frame": "^7.10.4",
55-
"@babel/parser": "^7.12.7",
56-
"@babel/types": "^7.12.6",
54+
"@babel/code-frame": "^7.12.11",
55+
"@babel/parser": "^7.12.11",
56+
"@babel/types": "^7.12.12",
5757
"@types/babel__code-frame": "^7.0.2",
5858
"@types/debug": "*",
5959
"@types/glob": "*",

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

Lines changed: 7 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,7 @@ tester.addFixturePatternConfig('javascript/arrayLiteral');
141141

142142
tester.addFixturePatternConfig('javascript/simple-literals');
143143

144-
tester.addFixturePatternConfig('javascript/directives', {
145-
ignore: [
146-
/**
147-
* Babel errors on accessors:
148-
* https://github.com/babel/babel/issues/12335
149-
*/
150-
'directive-in-class',
151-
],
152-
});
144+
tester.addFixturePatternConfig('javascript/directives');
153145

154146
tester.addFixturePatternConfig('javascript/experimentalObjectRestSpread');
155147

@@ -184,15 +176,7 @@ tester.addFixturePatternConfig('javascript/arrowFunctions', {
184176
'error-strict-param-no-paren-eval',
185177
],
186178
});
187-
tester.addFixturePatternConfig('javascript/function', {
188-
ignore: [
189-
/**
190-
* Babel has invalid end range of multiline SequenceExpression
191-
* TODO: report it to babel
192-
*/
193-
'return-multiline-sequence',
194-
],
195-
});
179+
tester.addFixturePatternConfig('javascript/function');
196180

197181
tester.addFixturePatternConfig('javascript/bigIntLiterals');
198182
tester.addFixturePatternConfig('javascript/binaryLiterals');
@@ -203,20 +187,15 @@ tester.addFixturePatternConfig('javascript/callExpression');
203187
tester.addFixturePatternConfig('javascript/classes', {
204188
ignore: [
205189
/**
206-
* super() is being used outside of constructor. Other parsers (e.g. espree, acorn) do not error on this.
190+
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
191+
* super() is being used outside of constructor.
192+
* Other parsers (e.g. espree, acorn) do not error on this.
207193
*/
208-
'class-one-method-super', // babel parse errors
194+
'class-one-method-super',
209195
/**
210196
* TS3.6 made computed constructors parse as actual constructors.
211197
*/
212198
'class-two-methods-computed-constructor',
213-
/**
214-
* Babel errors on accessors:
215-
* https://github.com/babel/babel/issues/12335
216-
*/
217-
'class-accessor-properties',
218-
'class-static-methods-and-accessor-properties',
219-
'invalid-class-setter-declaration',
220199
],
221200
});
222201

@@ -287,15 +266,7 @@ tester.addFixturePatternConfig('javascript/modules', {
287266
tester.addFixturePatternConfig('javascript/newTarget');
288267

289268
tester.addFixturePatternConfig('javascript/objectLiteral');
290-
tester.addFixturePatternConfig('javascript/objectLiteralComputedProperties', {
291-
ignore: [
292-
/**
293-
* Babel errors on accessors:
294-
* https://github.com/babel/babel/issues/12335
295-
*/
296-
'computed-getter-and-setter',
297-
],
298-
});
269+
tester.addFixturePatternConfig('javascript/objectLiteralComputedProperties');
299270

300271
tester.addFixturePatternConfig('javascript/objectLiteralDuplicateProperties', {
301272
ignore: [
@@ -415,13 +386,6 @@ tester.addFixturePatternConfig('typescript/basics', {
415386
'type-guard-in-arrow-function',
416387
'type-guard-in-function',
417388
'type-guard-in-interface',
418-
/**
419-
* TS 3.7: declare class properties
420-
* Babel: declare is not allowed with accessibility modifiers
421-
* TODO: report this to babel
422-
*/
423-
'abstract-class-with-declare-properties',
424-
'class-with-declare-properties',
425389
/**
426390
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
427391
* This is intentional; we don't error on semantic problems for these cases
@@ -431,16 +395,6 @@ tester.addFixturePatternConfig('typescript/basics', {
431395
'catch-clause-with-invalid-annotation',
432396
'export-type-star-from',
433397
'import-type-error',
434-
/**
435-
* Babel reports incorrect location
436-
* https://github.com/babel/babel/issues/11939
437-
*/
438-
'catch-clause-with-annotation',
439-
/**
440-
* Babel errors on accessors:
441-
* https://github.com/babel/babel/issues/12335
442-
*/
443-
'object-with-typed-methods',
444398
],
445399
ignoreSourceType: [
446400
/**
@@ -470,16 +424,6 @@ tester.addFixturePatternConfig('typescript/basics', {
470424

471425
tester.addFixturePatternConfig('typescript/decorators/accessor-decorators', {
472426
fileType: 'ts',
473-
ignore: [
474-
/**
475-
* Babel errors on accessors:
476-
* https://github.com/babel/babel/issues/12335
477-
*/
478-
'accessor-decorator-factory-instance-member',
479-
'accessor-decorator-factory-static-member',
480-
'accessor-decorator-instance-member',
481-
'accessor-decorator-static-member',
482-
],
483427
});
484428
tester.addFixturePatternConfig('typescript/decorators/class-decorators', {
485429
fileType: 'ts',
@@ -514,20 +458,6 @@ tester.addFixturePatternConfig('typescript/errorRecovery', {
514458
* TODO: enable error code TS1019: An index signature parameter cannot have a question mark.
515459
*/
516460
'interface-with-optional-index-signature',
517-
/**
518-
* Expected error on empty type arguments and type parameters
519-
* TypeScript report diagnostics correctly but babel not
520-
* https://github.com/babel/babel/issues/9462
521-
*/
522-
'empty-type-arguments',
523-
'empty-type-arguments-in-call-expression',
524-
'empty-type-arguments-in-new-expression',
525-
'empty-type-parameters',
526-
'empty-type-parameters-in-arrow-function',
527-
'empty-type-parameters-in-constructor',
528-
'empty-type-parameters-in-function-expression',
529-
'empty-type-parameters-in-method',
530-
'empty-type-parameters-in-method-signature',
531461
/**
532462
* Babel correctly errors on this
533463
* TODO: enable error code TS1024: 'readonly' modifier can only appear on a property declaration or index signature.
@@ -546,7 +476,6 @@ tester.addFixturePatternConfig('typescript/types', {
546476
* They produce TSTypeLiteral -> TemplateLiteral, and then force override the expression parser to parse types
547477
* We instead just emit TSTemplateLiteralType.
548478
*/
549-
'template-literal-type-1',
550479
'template-literal-type-2',
551480
'template-literal-type-3',
552481
'template-literal-type-4',

packages/typescript-estree/tests/lib/persistentParse.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function baseTests(
116116

117117
it('allows parsing of deeply nested new files', () => {
118118
const PROJECT_DIR = setup(tsConfigIncludeAll, false);
119-
const bazSlashBar = path.join('baz', 'bar') as 'baz/bar';
119+
const bazSlashBar = 'baz/bar' as const;
120120

121121
// parse once to: assert the config as correct, and to make sure the program is setup
122122
expect(() => parseFile('foo', PROJECT_DIR)).not.toThrow();
@@ -141,7 +141,7 @@ function baseTests(
141141
fs.mkdirSync(path.join(PROJECT_DIR, 'src', 'bat'));
142142
fs.mkdirSync(path.join(PROJECT_DIR, 'src', 'bat', 'baz'));
143143

144-
const bazSlashBar = path.join('bat', 'baz', 'bar') as 'bat/baz/bar';
144+
const bazSlashBar = 'bat/baz/bar' as const;
145145

146146
// write a new file and attempt to parse it
147147
writeFile(PROJECT_DIR, bazSlashBar);
@@ -151,7 +151,7 @@ function baseTests(
151151

152152
it('allows renaming of files', () => {
153153
const PROJECT_DIR = setup(tsConfigIncludeAll, true);
154-
const bazSlashBar = path.join('baz', 'bar') as 'baz/bar';
154+
const bazSlashBar = 'baz/bar' as const;
155155

156156
// parse once to: assert the config as correct, and to make sure the program is setup
157157
expect(() => parseFile('foo', PROJECT_DIR)).not.toThrow();
@@ -279,7 +279,7 @@ describe('persistent parse', () => {
279279

280280
it('handles tsconfigs with no includes/excludes (nested)', () => {
281281
const PROJECT_DIR = setup({}, false);
282-
const bazSlashBar = path.join('baz', 'bar') as 'baz/bar';
282+
const bazSlashBar = 'baz/bar' as const;
283283

284284
// parse once to: assert the config as correct, and to make sure the program is setup
285285
expect(() => parseFile('foo', PROJECT_DIR)).not.toThrow();

0 commit comments

Comments
 (0)