From 4d9d0caec09b42aa2278daee09c431bb896a3145 Mon Sep 17 00:00:00 2001 From: Armano Date: Fri, 12 Feb 2021 08:41:03 +0100 Subject: [PATCH] test: update ast alignment tests and simplify shared fixtures update babel to 7.12.16 --- packages/parser/package.json | 1 - packages/parser/tsconfig.build.json | 1 - packages/parser/tsconfig.json | 1 - packages/shared-fixtures/jsx-known-issues.ts | 9 --- packages/shared-fixtures/package.json | 8 +-- packages/shared-fixtures/tsconfig.build.json | 12 ---- packages/shared-fixtures/tsconfig.json | 10 --- packages/typescript-estree/package.json | 2 +- .../tests/ast-alignment/fixtures-to-test.ts | 64 +++++++++---------- .../lib/semantic-diagnostics-enabled.test.ts | 8 +-- .../typescript-estree/tsconfig.build.json | 1 - packages/typescript-estree/tsconfig.json | 1 - yarn.lock | 26 ++++---- 13 files changed, 49 insertions(+), 95 deletions(-) delete mode 100644 packages/shared-fixtures/jsx-known-issues.ts delete mode 100644 packages/shared-fixtures/tsconfig.build.json delete mode 100644 packages/shared-fixtures/tsconfig.json diff --git a/packages/parser/package.json b/packages/parser/package.json index e37b2c0289f9..b0a7c08c9f36 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -52,7 +52,6 @@ "devDependencies": { "@types/glob": "*", "@typescript-eslint/experimental-utils": "4.15.0", - "@typescript-eslint/shared-fixtures": "4.15.0", "glob": "*", "typescript": "*" }, diff --git a/packages/parser/tsconfig.build.json b/packages/parser/tsconfig.build.json index 1d11694fd082..1725797310b0 100644 --- a/packages/parser/tsconfig.build.json +++ b/packages/parser/tsconfig.build.json @@ -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" } ] diff --git a/packages/parser/tsconfig.json b/packages/parser/tsconfig.json index 6f9d20826372..f69f9ce10787 100644 --- a/packages/parser/tsconfig.json +++ b/packages/parser/tsconfig.json @@ -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" } ] diff --git a/packages/shared-fixtures/jsx-known-issues.ts b/packages/shared-fixtures/jsx-known-issues.ts deleted file mode 100644 index 6f1178c7a824..000000000000 --- a/packages/shared-fixtures/jsx-known-issues.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Export the list to allow it to be used within both unit and AST comparison tests - */ -export default [ - 'jsx/embedded-tags', // https://github.com/Microsoft/TypeScript/issues/7410 - 'jsx/namespaced-attribute-and-value-inserted', // https://github.com/Microsoft/TypeScript/issues/7411 - 'jsx/namespaced-name-and-attribute', // https://github.com/Microsoft/TypeScript/issues/7411 - 'jsx/invalid-namespace-value-with-dots' // https://github.com/Microsoft/TypeScript/issues/7411 -]; diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index be9dcfe88770..9d934f4382ae 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -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 } diff --git a/packages/shared-fixtures/tsconfig.build.json b/packages/shared-fixtures/tsconfig.build.json deleted file mode 100644 index a4799817b0e5..000000000000 --- a/packages/shared-fixtures/tsconfig.build.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "composite": true, - "outDir": "./dist", - "rootDir": ".", - "resolveJsonModule": true - }, - "files": [ - "jsx-known-issues.ts" - ] -} diff --git a/packages/shared-fixtures/tsconfig.json b/packages/shared-fixtures/tsconfig.json deleted file mode 100644 index 75086e9799bd..000000000000 --- a/packages/shared-fixtures/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.build.json", - "compilerOptions": { - "composite": false, - "rootDir": "." - }, - "files": [ - "jsx-known-issues.ts" - ] -} diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index a90f15edcef5..8c7453e023c0 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -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": "*", diff --git a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts index 75a10d577d78..0515aa57f4d9 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -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'; @@ -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'); @@ -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', @@ -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'); @@ -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', @@ -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 @@ -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', @@ -493,6 +491,4 @@ tester.addFixturePatternConfig('typescript/namespaces-and-modules', { ], }); -const fixturesToTest = tester.getFixtures(); - -export { fixturesToTest }; +export const fixturesToTest = tester.getFixtures(); diff --git a/packages/typescript-estree/tests/lib/semantic-diagnostics-enabled.test.ts b/packages/typescript-estree/tests/lib/semantic-diagnostics-enabled.test.ts index 150e55792c68..31f212261e20 100644 --- a/packages/typescript-estree/tests/lib/semantic-diagnostics-enabled.test.ts +++ b/packages/typescript-estree/tests/lib/semantic-diagnostics-enabled.test.ts @@ -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, diff --git a/packages/typescript-estree/tsconfig.build.json b/packages/typescript-estree/tsconfig.build.json index ca949f029eb8..84504e296c84 100644 --- a/packages/typescript-estree/tsconfig.build.json +++ b/packages/typescript-estree/tsconfig.build.json @@ -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" } ] diff --git a/packages/typescript-estree/tsconfig.json b/packages/typescript-estree/tsconfig.json index f17eec807167..bc1141dd051a 100644 --- a/packages/typescript-estree/tsconfig.json +++ b/packages/typescript-estree/tsconfig.json @@ -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" } ] diff --git a/yarn.lock b/yarn.lock index 96ae56adedb4..222f1c915069 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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== @@ -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" @@ -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"