Skip to content

Commit 792623f

Browse files
authored
test: update ast alignment tests and simplify shared fixtures (typescript-eslint#3045)
update babel to 7.12.16
1 parent 5e5d9b9 commit 792623f

File tree

13 files changed

+49
-95
lines changed

13 files changed

+49
-95
lines changed

packages/parser/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"devDependencies": {
5353
"@types/glob": "*",
5454
"@typescript-eslint/experimental-utils": "4.15.0",
55-
"@typescript-eslint/shared-fixtures": "4.15.0",
5655
"glob": "*",
5756
"typescript": "*"
5857
},

packages/parser/tsconfig.build.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"references": [
1111
{ "path": "../experimental-utils/tsconfig.build.json" },
1212
{ "path": "../scope-manager/tsconfig.build.json" },
13-
{ "path": "../shared-fixtures/tsconfig.build.json" },
1413
{ "path": "../types/tsconfig.build.json" },
1514
{ "path": "../typescript-estree/tsconfig.build.json" }
1615
]

packages/parser/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"references": [
1010
{ "path": "../experimental-utils/tsconfig.build.json" },
1111
{ "path": "../scope-manager/tsconfig.build.json" },
12-
{ "path": "../shared-fixtures/tsconfig.build.json" },
1312
{ "path": "../types/tsconfig.build.json" },
1413
{ "path": "../typescript-estree/tsconfig.build.json" }
1514
]

packages/shared-fixtures/jsx-known-issues.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/shared-fixtures/package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
{
22
"name": "@typescript-eslint/shared-fixtures",
33
"version": "4.15.0",
4-
"private": true,
5-
"scripts": {
6-
"build": "tsc -b tsconfig.build.json",
7-
"clean": "tsc -b tsconfig.build.json --clean",
8-
"postclean": "rimraf dist",
9-
"typecheck": "tsc -p tsconfig.json --noEmit"
10-
}
4+
"private": true
115
}

packages/shared-fixtures/tsconfig.build.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/shared-fixtures/tsconfig.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/typescript-estree/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
},
5252
"devDependencies": {
5353
"@babel/code-frame": "^7.12.13",
54-
"@babel/parser": "^7.12.15",
54+
"@babel/parser": "^7.12.16",
5555
"@babel/types": "^7.12.13",
5656
"@types/babel__code-frame": "^7.0.2",
5757
"@types/debug": "*",

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

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import jsxKnownIssues from '@typescript-eslint/shared-fixtures/dist/jsx-known-issues';
21
import fs from 'fs';
32
import glob from 'glob';
43
import path from 'path';
@@ -109,20 +108,6 @@ class FixturesTester {
109108
*/
110109
const tester = new FixturesTester();
111110

112-
/**
113-
* JSX fixtures which have known issues for typescript-estree
114-
*/
115-
const jsxFilesWithKnownIssues = jsxKnownIssues.map(f => f.replace('jsx/', ''));
116-
117-
/**
118-
* Current random error difference on jsx/invalid-no-tag-name.src.js
119-
* ts-estree - SyntaxError
120-
* Babel - RangeError
121-
*
122-
* Reported here: https://github.com/babel/babel/issues/6680
123-
*/
124-
jsxFilesWithKnownIssues.push('invalid-no-tag-name');
125-
126111
tester.addFixturePatternConfig('javascript/basics');
127112

128113
tester.addFixturePatternConfig('comments');
@@ -166,8 +151,8 @@ tester.addFixturePatternConfig('javascript/arrowFunctions', {
166151
* TS1100: "Invalid use of '{0}' in strict mode."
167152
* TODO: do we want TS1100 error code?
168153
*/
169-
'error-strict-eval', // babel parse errors
170154
'error-strict-default-param-eval',
155+
'error-strict-eval',
171156
'error-strict-eval-return',
172157
'error-strict-param-arguments',
173158
'error-strict-param-eval',
@@ -308,7 +293,30 @@ tester.addFixturePatternConfig('javascript/unicodeCodePointEscapes');
308293
/* ================================================== */
309294

310295
tester.addFixturePatternConfig('jsx', {
311-
ignore: jsxFilesWithKnownIssues,
296+
ignore: [
297+
/**
298+
* JSX fixtures which have known issues for typescript-estree
299+
* https://github.com/Microsoft/TypeScript/issues/7410
300+
*/
301+
'embedded-tags',
302+
/**
303+
* JSX fixtures which have known issues for typescript-estree
304+
* @see https://github.com/Microsoft/TypeScript/issues/7411
305+
*/
306+
'namespaced-attribute-and-value-inserted',
307+
/**
308+
* JSX fixtures which have known issues for typescript-estree
309+
* @see https://github.com/Microsoft/TypeScript/issues/7411
310+
*/
311+
'namespaced-name-and-attribute',
312+
/**
313+
* Current random error difference on jsx/invalid-no-tag-name.src.js
314+
* ts-estree - SyntaxError
315+
* Babel - RangeError
316+
* @see https://github.com/babel/babel/issues/6680
317+
*/
318+
'invalid-no-tag-name',
319+
],
312320
});
313321
tester.addFixturePatternConfig('jsx-useJSXTextNode');
314322

@@ -342,13 +350,14 @@ tester.addFixturePatternConfig('typescript/basics', {
342350
*/
343351
'interface-with-extends-member-expression',
344352
/**
345-
* https://github.com/typescript-eslint/typescript-eslint/issues/2998
353+
* @see https://github.com/typescript-eslint/typescript-eslint/issues/2998
346354
*/
347355
'type-import-type',
348356
'type-import-type-with-type-parameters-in-type-reference',
349357
/**
350-
* Not yet supported in Babel https://github.com/babel/babel/issues/9228
358+
* Not yet supported in Babel
351359
* Directive field is not added to module and namespace
360+
* @see https://github.com/babel/babel/issues/9228
352361
*/
353362
'directive-in-module',
354363
'directive-in-namespace',
@@ -368,12 +377,6 @@ tester.addFixturePatternConfig('typescript/basics', {
368377
* https://github.com/babel/babel/issues/12683
369378
*/
370379
'export-named-enum-computed-string',
371-
/**
372-
* Babel: TSTypePredicate does not include `asserts` statement in range
373-
* ts-estree: TSTypePredicate does include `asserts` statement in range
374-
* https://github.com/babel/babel/pull/12763
375-
*/
376-
'type-assertion-with-guard-in-method',
377380
/**
378381
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
379382
* This is intentional; we don't error on semantic problems for these cases
@@ -387,16 +390,11 @@ tester.addFixturePatternConfig('typescript/basics', {
387390
* TODO: report this to babel
388391
*/
389392
'catch-clause-with-invalid-annotation',
390-
/**
391-
* babel does not take into account leading character into union and intersection
392-
* https://github.com/babel/babel/pull/12758
393-
*/
394-
'union-intersection',
395393
],
396394
ignoreSourceType: [
397395
/**
398396
* Babel reports sourceType script
399-
* https://github.com/babel/babel/issues/9213
397+
* @see https://github.com/babel/babel/issues/9213
400398
*/
401399
'export-assignment',
402400
'import-equal-declaration',
@@ -493,6 +491,4 @@ tester.addFixturePatternConfig('typescript/namespaces-and-modules', {
493491
],
494492
});
495493

496-
const fixturesToTest = tester.getFixtures();
497-
498-
export { fixturesToTest };
494+
export const fixturesToTest = tester.getFixtures();

packages/typescript-estree/tests/lib/semantic-diagnostics-enabled.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { readFileSync } from 'fs';
22
import glob from 'glob';
3+
import path from 'path';
34
import * as parser from '../../src';
4-
import { extname } from 'path';
55
import { formatSnapshotName, isJSXFileType } from '../../tools/test-utils';
66

77
/**
88
* Process all fixtures, we will only snapshot the ones that have semantic errors
99
* which are ignored by default parsing logic.
1010
*/
11-
const FIXTURES_DIR =
12-
'../../node_modules/@typescript-eslint/shared-fixtures/fixtures';
11+
const FIXTURES_DIR = path.join(__dirname, '../../../shared-fixtures/fixtures');
12+
1313
const testFiles = glob.sync(`${FIXTURES_DIR}/**/*.src.*`);
1414

1515
describe('Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled', () => {
1616
testFiles.forEach(filename => {
1717
const code = readFileSync(filename, 'utf8');
18-
const fileExtension = extname(filename);
18+
const fileExtension = path.extname(filename);
1919
const config: parser.TSESTreeOptions = {
2020
loc: true,
2121
range: true,

0 commit comments

Comments
 (0)