Skip to content

Commit

Permalink
test: update ast alignment tests and simplify shared fixtures (typesc…
Browse files Browse the repository at this point in the history
…ript-eslint#3045)

update babel to 7.12.16
  • Loading branch information
armano2 authored Feb 13, 2021
1 parent 5e5d9b9 commit 792623f
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 95 deletions.
1 change: 0 additions & 1 deletion packages/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"devDependencies": {
"@types/glob": "*",
"@typescript-eslint/experimental-utils": "4.15.0",
"@typescript-eslint/shared-fixtures": "4.15.0",
"glob": "*",
"typescript": "*"
},
Expand Down
1 change: 0 additions & 1 deletion packages/parser/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"references": [
{ "path": "../experimental-utils/tsconfig.build.json" },
{ "path": "../scope-manager/tsconfig.build.json" },
{ "path": "../shared-fixtures/tsconfig.build.json" },
{ "path": "../types/tsconfig.build.json" },
{ "path": "../typescript-estree/tsconfig.build.json" }
]
Expand Down
1 change: 0 additions & 1 deletion packages/parser/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"references": [
{ "path": "../experimental-utils/tsconfig.build.json" },
{ "path": "../scope-manager/tsconfig.build.json" },
{ "path": "../shared-fixtures/tsconfig.build.json" },
{ "path": "../types/tsconfig.build.json" },
{ "path": "../typescript-estree/tsconfig.build.json" }
]
Expand Down
9 changes: 0 additions & 9 deletions packages/shared-fixtures/jsx-known-issues.ts

This file was deleted.

8 changes: 1 addition & 7 deletions packages/shared-fixtures/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{
"name": "@typescript-eslint/shared-fixtures",
"version": "4.15.0",
"private": true,
"scripts": {
"build": "tsc -b tsconfig.build.json",
"clean": "tsc -b tsconfig.build.json --clean",
"postclean": "rimraf dist",
"typecheck": "tsc -p tsconfig.json --noEmit"
}
"private": true
}
12 changes: 0 additions & 12 deletions packages/shared-fixtures/tsconfig.build.json

This file was deleted.

10 changes: 0 additions & 10 deletions packages/shared-fixtures/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/typescript-estree/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
"devDependencies": {
"@babel/code-frame": "^7.12.13",
"@babel/parser": "^7.12.15",
"@babel/parser": "^7.12.16",
"@babel/types": "^7.12.13",
"@types/babel__code-frame": "^7.0.2",
"@types/debug": "*",
Expand Down
64 changes: 30 additions & 34 deletions packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import jsxKnownIssues from '@typescript-eslint/shared-fixtures/dist/jsx-known-issues';
import fs from 'fs';
import glob from 'glob';
import path from 'path';
Expand Down Expand Up @@ -109,20 +108,6 @@ class FixturesTester {
*/
const tester = new FixturesTester();

/**
* JSX fixtures which have known issues for typescript-estree
*/
const jsxFilesWithKnownIssues = jsxKnownIssues.map(f => f.replace('jsx/', ''));

/**
* Current random error difference on jsx/invalid-no-tag-name.src.js
* ts-estree - SyntaxError
* Babel - RangeError
*
* Reported here: https://github.com/babel/babel/issues/6680
*/
jsxFilesWithKnownIssues.push('invalid-no-tag-name');

tester.addFixturePatternConfig('javascript/basics');

tester.addFixturePatternConfig('comments');
Expand Down Expand Up @@ -166,8 +151,8 @@ tester.addFixturePatternConfig('javascript/arrowFunctions', {
* TS1100: "Invalid use of '{0}' in strict mode."
* TODO: do we want TS1100 error code?
*/
'error-strict-eval', // babel parse errors
'error-strict-default-param-eval',
'error-strict-eval',
'error-strict-eval-return',
'error-strict-param-arguments',
'error-strict-param-eval',
Expand Down Expand Up @@ -308,7 +293,30 @@ tester.addFixturePatternConfig('javascript/unicodeCodePointEscapes');
/* ================================================== */

tester.addFixturePatternConfig('jsx', {
ignore: jsxFilesWithKnownIssues,
ignore: [
/**
* JSX fixtures which have known issues for typescript-estree
* https://github.com/Microsoft/TypeScript/issues/7410
*/
'embedded-tags',
/**
* JSX fixtures which have known issues for typescript-estree
* @see https://github.com/Microsoft/TypeScript/issues/7411
*/
'namespaced-attribute-and-value-inserted',
/**
* JSX fixtures which have known issues for typescript-estree
* @see https://github.com/Microsoft/TypeScript/issues/7411
*/
'namespaced-name-and-attribute',
/**
* Current random error difference on jsx/invalid-no-tag-name.src.js
* ts-estree - SyntaxError
* Babel - RangeError
* @see https://github.com/babel/babel/issues/6680
*/
'invalid-no-tag-name',
],
});
tester.addFixturePatternConfig('jsx-useJSXTextNode');

Expand Down Expand Up @@ -342,13 +350,14 @@ tester.addFixturePatternConfig('typescript/basics', {
*/
'interface-with-extends-member-expression',
/**
* https://github.com/typescript-eslint/typescript-eslint/issues/2998
* @see https://github.com/typescript-eslint/typescript-eslint/issues/2998
*/
'type-import-type',
'type-import-type-with-type-parameters-in-type-reference',
/**
* Not yet supported in Babel https://github.com/babel/babel/issues/9228
* Not yet supported in Babel
* Directive field is not added to module and namespace
* @see https://github.com/babel/babel/issues/9228
*/
'directive-in-module',
'directive-in-namespace',
Expand All @@ -368,12 +377,6 @@ tester.addFixturePatternConfig('typescript/basics', {
* https://github.com/babel/babel/issues/12683
*/
'export-named-enum-computed-string',
/**
* Babel: TSTypePredicate does not include `asserts` statement in range
* ts-estree: TSTypePredicate does include `asserts` statement in range
* https://github.com/babel/babel/pull/12763
*/
'type-assertion-with-guard-in-method',
/**
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
* This is intentional; we don't error on semantic problems for these cases
Expand All @@ -387,16 +390,11 @@ tester.addFixturePatternConfig('typescript/basics', {
* TODO: report this to babel
*/
'catch-clause-with-invalid-annotation',
/**
* babel does not take into account leading character into union and intersection
* https://github.com/babel/babel/pull/12758
*/
'union-intersection',
],
ignoreSourceType: [
/**
* Babel reports sourceType script
* https://github.com/babel/babel/issues/9213
* @see https://github.com/babel/babel/issues/9213
*/
'export-assignment',
'import-equal-declaration',
Expand Down Expand Up @@ -493,6 +491,4 @@ tester.addFixturePatternConfig('typescript/namespaces-and-modules', {
],
});

const fixturesToTest = tester.getFixtures();

export { fixturesToTest };
export const fixturesToTest = tester.getFixtures();
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { readFileSync } from 'fs';
import glob from 'glob';
import path from 'path';
import * as parser from '../../src';
import { extname } from 'path';
import { formatSnapshotName, isJSXFileType } from '../../tools/test-utils';

/**
* Process all fixtures, we will only snapshot the ones that have semantic errors
* which are ignored by default parsing logic.
*/
const FIXTURES_DIR =
'../../node_modules/@typescript-eslint/shared-fixtures/fixtures';
const FIXTURES_DIR = path.join(__dirname, '../../../shared-fixtures/fixtures');

const testFiles = glob.sync(`${FIXTURES_DIR}/**/*.src.*`);

describe('Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled', () => {
testFiles.forEach(filename => {
const code = readFileSync(filename, 'utf8');
const fileExtension = extname(filename);
const fileExtension = path.extname(filename);
const config: parser.TSESTreeOptions = {
loc: true,
range: true,
Expand Down
1 change: 0 additions & 1 deletion packages/typescript-estree/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
"include": ["src", "typings"],
"references": [
{ "path": "../shared-fixtures/tsconfig.build.json" },
{ "path": "../types/tsconfig.build.json" },
{ "path": "../visitor-keys/tsconfig.build.json" }
]
Expand Down
1 change: 0 additions & 1 deletion packages/typescript-estree/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"include": ["src", "typings", "tests", "tools"],
"exclude": ["tests/fixtures/**/*"],
"references": [
{ "path": "../shared-fixtures/tsconfig.build.json" },
{ "path": "../types/tsconfig.build.json" },
{ "path": "../visitor-keys/tsconfig.build.json" }
]
Expand Down
26 changes: 13 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"@babel/highlight" "^7.12.13"

"@babel/core@^7.1.0", "@babel/core@^7.7.5":
version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.13.tgz#b73a87a3a3e7d142a66248bf6ad88b9ceb093425"
integrity sha512-BQKE9kXkPlXHPeqissfxo0lySWJcYdEP0hdtJOH/iJfDdhOCcgtNCjftCJg3qqauB4h+lz2N6ixM++b9DN1Tcw==
version "7.12.16"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.16.tgz#8c6ba456b23b680a6493ddcfcd9d3c3ad51cab7c"
integrity sha512-t/hHIB504wWceOeaOoONOhu+gX+hpjfeN6YRBT209X/4sibZQfSF1I0HFRRlBe97UZZosGx5XwUg1ZgNbelmNw==
dependencies:
"@babel/code-frame" "^7.12.13"
"@babel/generator" "^7.12.13"
"@babel/generator" "^7.12.15"
"@babel/helper-module-transforms" "^7.12.13"
"@babel/helpers" "^7.12.13"
"@babel/parser" "^7.12.13"
"@babel/parser" "^7.12.16"
"@babel/template" "^7.12.13"
"@babel/traverse" "^7.12.13"
"@babel/types" "^7.12.13"
Expand All @@ -30,7 +30,7 @@
semver "^5.4.1"
source-map "^0.5.0"

"@babel/generator@^7.12.13":
"@babel/generator@^7.12.13", "@babel/generator@^7.12.15":
version "7.12.15"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.15.tgz#4617b5d0b25cc572474cc1aafee1edeaf9b5368f"
integrity sha512-6F2xHxBiFXWNSGb7vyCUTBF8RCLY66rS0zEPcP8t/nQyXjha5EuK4z7H5o7fWG8B4M7y6mqVWq1J+1PuwRhecQ==
Expand All @@ -56,9 +56,9 @@
"@babel/types" "^7.12.13"

"@babel/helper-member-expression-to-functions@^7.12.13":
version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.12.13.tgz#c5715695b4f8bab32660dbdcdc2341dec7e3df40"
integrity sha512-B+7nN0gIL8FZ8SvMcF+EPyB21KnCcZHQZFczCxbiNGV/O0rsrSBlWGLzmtBJ3GMjSVMIm4lpFhR+VdVBuIsUcQ==
version "7.12.16"
resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.12.16.tgz#41e0916b99f8d5f43da4f05d85f4930fa3d62b22"
integrity sha512-zYoZC1uvebBFmj1wFAlXwt35JLEgecefATtKp20xalwEK8vHAixLBXTGxNrVGEmTT+gzOThUgr8UEdgtalc1BQ==
dependencies:
"@babel/types" "^7.12.13"

Expand Down Expand Up @@ -143,10 +143,10 @@
chalk "^2.0.0"
js-tokens "^4.0.0"

"@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.12.15":
version "7.12.15"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.15.tgz#2b20de7f0b4b332d9b119dd9c33409c538b8aacf"
integrity sha512-AQBOU2Z9kWwSZMd6lNjCX0GUgFonL1wAM1db8L8PMk9UDaGsRCArBkU4Sc+UCM3AE4hjbXx+h58Lb3QT4oRmrA==
"@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.12.16":
version "7.12.16"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.16.tgz#cc31257419d2c3189d394081635703f549fc1ed4"
integrity sha512-c/+u9cqV6F0+4Hpq01jnJO+GLp2DdT63ppz9Xa+6cHaajM9VFzK/iDXiKK65YtpeVwu+ctfS6iqlMqRgQRzeCw==

"@babel/plugin-syntax-async-generators@^7.8.4":
version "7.8.4"
Expand Down

0 comments on commit 792623f

Please sign in to comment.