From 132c0780f2b155e8a7355c449b2e98ed3fec2c6d Mon Sep 17 00:00:00 2001 From: James Henry Date: Sat, 19 Jan 2019 18:18:36 -0500 Subject: [PATCH 01/88] chore: rename and reorg packages (#82) --- .../ISSUE_TEMPLATE/eslint-plugin-tslint.md | 10 +- .../eslint-plugin-typescript.md | 14 +- .../typescript-eslint-parser.md | 6 +- .github/ISSUE_TEMPLATE/typescript-estree.md | 6 +- .prettierignore | 2 +- .travis.yml | 9 +- README.md | 10 +- lerna.json | 2 +- package.json | 5 +- packages/eslint-plugin-tslint/CHANGELOG.md | 27 -- packages/eslint-plugin-tslint/README.md | 12 +- packages/eslint-plugin-tslint/package.json | 7 +- packages/eslint-plugin-tslint/src/index.ts | 4 +- .../eslint-plugin-tslint/tests/index.spec.ts | 16 +- .../lib/configs/recommended.json | 42 -- .../.npmignore | 0 .../LICENSE | 0 .../README.md | 26 +- .../ROADMAP.md | 60 +-- .../rules/adjacent-overload-signatures.md | 0 .../docs/rules/array-type.md | 0 .../docs/rules/ban-types.md | 0 .../docs/rules/camelcase.md | 0 .../docs/rules/class-name-casing.md | 0 .../rules/explicit-function-return-type.md | 0 .../rules/explicit-member-accessibility.md | 0 .../docs/rules/generic-type-naming.md | 0 .../docs/rules/indent.md | 0 .../docs/rules/interface-name-prefix.md | 0 .../docs/rules/member-delimiter-style.md | 0 .../docs/rules/member-naming.md | 0 .../docs/rules/member-ordering.md | 0 .../rules/no-angle-bracket-type-assertion.md | 0 .../docs/rules/no-array-constructor.md | 0 .../docs/rules/no-empty-interface.md | 0 .../docs/rules/no-explicit-any.md | 0 .../docs/rules/no-extraneous-class.md | 0 .../docs/rules/no-inferrable-types.md | 0 .../docs/rules/no-misused-new.md | 0 .../docs/rules/no-namespace.md | 0 .../docs/rules/no-non-null-assertion.md | 0 .../rules/no-object-literal-type-assertion.md | 0 .../docs/rules/no-parameter-properties.md | 0 .../docs/rules/no-this-alias.md | 0 .../docs/rules/no-triple-slash-reference.md | 0 .../docs/rules/no-type-alias.md | 0 .../docs/rules/no-unused-vars.md | 0 .../docs/rules/no-use-before-define.md | 2 +- .../docs/rules/no-var-requires.md | 0 .../docs/rules/prefer-interface.md | 0 .../docs/rules/prefer-namespace-keyword.md | 0 .../docs/rules/type-annotation-spacing.md | 0 .../jest.config.js | 0 .../lib/configs/recommended.json | 42 ++ .../lib/index.js | 0 .../lib/rules/adjacent-overload-signatures.js | 0 .../lib/rules/array-type.js | 0 .../lib/rules/ban-types.js | 0 .../lib/rules/camelcase.js | 0 .../lib/rules/class-name-casing.js | 0 .../rules/explicit-function-return-type.js | 0 .../rules/explicit-member-accessibility.js | 0 .../lib/rules/generic-type-naming.js | 0 .../lib/rules/indent.js | 0 .../lib/rules/interface-name-prefix.js | 0 .../lib/rules/member-delimiter-style.js | 0 .../lib/rules/member-naming.js | 0 .../lib/rules/member-ordering.js | 0 .../rules/no-angle-bracket-type-assertion.js | 0 .../lib/rules/no-array-constructor.js | 0 .../lib/rules/no-empty-interface.js | 0 .../lib/rules/no-explicit-any.js | 0 .../lib/rules/no-extraneous-class.js | 0 .../lib/rules/no-inferrable-types.js | 0 .../lib/rules/no-misused-new.js | 0 .../lib/rules/no-namespace.js | 0 .../lib/rules/no-non-null-assertion.js | 0 .../rules/no-object-literal-type-assertion.js | 0 .../lib/rules/no-parameter-properties.js | 0 .../lib/rules/no-this-alias.js | 0 .../lib/rules/no-triple-slash-reference.js | 0 .../lib/rules/no-type-alias.js | 0 .../lib/rules/no-unused-vars.js | 0 .../lib/rules/no-use-before-define.js | 0 .../lib/rules/no-var-requires.js | 0 .../lib/rules/prefer-interface.js | 0 .../lib/rules/prefer-namespace-keyword.js | 0 .../lib/rules/type-annotation-spacing.js | 0 .../lib/util.js | 6 +- .../package.json | 8 +- .../parser.js | 4 +- .../tests/lib/eslint-rules/no-dupe-args.js | 2 +- .../lib/eslint-rules/no-implicit-globals.js | 2 +- .../tests/lib/eslint-rules/no-redeclare.js | 2 +- .../lib/eslint-rules/no-restricted-globals.js | 2 +- .../tests/lib/eslint-rules/no-shadow.js | 2 +- .../tests/lib/eslint-rules/no-undef.js | 2 +- .../tests/lib/eslint-rules/no-unused-vars.js | 2 +- .../lib/eslint-rules/no-use-before-define.js | 2 +- .../tests/lib/eslint-rules/strict.js | 4 +- .../lib/rules/adjacent-overload-signatures.js | 2 +- .../tests/lib/rules/array-type.js | 4 +- .../tests/lib/rules/ban-types.js | 2 +- .../tests/lib/rules/camelcase.js | 2 +- .../tests/lib/rules/class-name-casing.js | 2 +- .../rules/explicit-function-return-type.js | 2 +- .../rules/explicit-member-accessibility.js | 2 +- .../tests/lib/rules/generic-type-naming.js | 2 +- .../tests/lib/rules/indent.js | 2 +- .../tests/lib/rules/interface-name-prefix.js | 2 +- .../tests/lib/rules/member-delimiter-style.js | 2 +- .../tests/lib/rules/member-naming.js | 2 +- .../tests/lib/rules/member-ordering.js | 2 +- .../rules/no-angle-bracket-type-assertion.js | 2 +- .../tests/lib/rules/no-array-constructor.js | 2 +- .../tests/lib/rules/no-empty-interface.js | 2 +- .../tests/lib/rules/no-explicit-any.js | 2 +- .../tests/lib/rules/no-extraneous-class.js | 2 +- .../tests/lib/rules/no-inferrable-types.js | 2 +- .../tests/lib/rules/no-misused-new.js | 2 +- .../tests/lib/rules/no-namespace.js | 2 +- .../tests/lib/rules/no-non-null-assertion.js | 2 +- .../rules/no-object-literal-type-assertion.js | 2 +- .../lib/rules/no-parameter-properties.js | 2 +- .../tests/lib/rules/no-this-alias.js | 2 +- .../lib/rules/no-triple-slash-reference.js | 4 +- .../tests/lib/rules/no-type-alias.js | 2 +- .../tests/lib/rules/no-unused-vars.js | 2 +- .../tests/lib/rules/no-use-before-define.js | 4 +- .../tests/lib/rules/no-var-requires.js | 2 +- .../tests/lib/rules/prefer-interface.js | 2 +- .../lib/rules/prefer-namespace-keyword.js | 2 +- .../lib/rules/type-annotation-spacing.js | 6 +- .../tests/lib/util.js | 0 .../tools/update-recommended.js | 2 +- packages/parser/CHANGELOG.md | 0 .../LICENSE | 0 .../README.md | 14 +- .../jest.config.js | 0 .../package.json | 8 +- .../src/analyze-scope.ts | 0 .../src/parser-options.ts | 0 .../src/parser.ts | 2 +- .../src/typings.d.ts | 0 .../src/visitor-keys.ts | 0 .../fixtures/basics/delete-expression.src.js | 0 .../basics/do-while-statements.src.js | 0 .../identifiers-double-underscore.src.js | 0 .../tests/fixtures/basics/instanceof.src.js | 0 .../basics/new-with-member-expression.src.js | 0 .../fixtures/basics/new-without-parens.src.js | 0 .../fixtures/basics/typeof-expression.src.js | 0 .../fixtures/basics/update-expression.src.js | 0 .../fixtures/basics/void-expression.src.js | 0 .../tests/fixtures/scope-analysis/535.ts | 0 .../fixtures/scope-analysis/abstract-class.ts | 0 .../scope-analysis/class-implements.ts | 0 .../scope-analysis/class-properties.ts | 0 .../scope-analysis/class-supper-type.ts | 0 .../computed-properties-in-interface.ts | 0 .../computed-properties-in-type.ts | 0 .../scope-analysis/declare-function.ts | 0 .../fixtures/scope-analysis/declare-global.ts | 0 .../fixtures/scope-analysis/declare-module.ts | 0 .../fixtures/scope-analysis/decorators.ts | 0 .../fixtures/scope-analysis/enum-string.ts | 0 .../tests/fixtures/scope-analysis/enum.ts | 0 .../scope-analysis/export-as-namespace.ts | 0 .../fixtures/scope-analysis/expression-as.ts | 0 .../expression-type-parameters.ts | 0 .../scope-analysis/function-overload-2.ts | 0 .../scope-analysis/function-overload.ts | 0 .../scope-analysis/identifier-decorators.ts | 0 .../scope-analysis/ignore-type-only-stuff.ts | 0 .../fixtures/scope-analysis/import-equals.ts | 0 .../fixtures/scope-analysis/interface-type.ts | 0 .../scope-analysis/method-overload.ts | 0 .../fixtures/scope-analysis/namespace.ts | 0 .../fixtures/scope-analysis/rest-element.ts | 0 .../fixtures/scope-analysis/type-alias.ts | 0 .../scope-analysis/type-annotations.ts | 0 .../scope-analysis/type-assertions.ts | 0 .../fixtures/scope-analysis/type-parameter.ts | 0 .../scope-analysis/typeof-in-assertions.ts | 0 .../typeof-in-call-signature.ts | 0 .../scope-analysis/typeof-in-return-type.ts | 0 .../typeof-in-type-parameters.ts | 0 .../fixtures/scope-analysis/typeof-in-var.ts | 0 .../tests/fixtures/scope-analysis/typeof.ts | 0 .../scope-analysis/types-array-type.src.ts | 0 .../types-conditional-with-null.src.ts | 0 .../scope-analysis/types-conditional.src.ts | 0 .../scope-analysis/types-indexed.src.ts | 0 .../fixtures/scope-analysis/types-infer.ts | 0 .../types-intersection-type.src.ts | 0 .../types-mapped-readonly-minus.src.ts | 0 .../types-mapped-readonly-plus.src.ts | 0 .../types-mapped-readonly.src.ts | 0 .../scope-analysis/types-mapped.src.ts | 0 .../scope-analysis/types-nested-types.src.ts | 0 .../types-parenthesized-type.src.ts | 0 .../types-reference-generic-nested.src.ts | 0 .../types-reference-generic.src.ts | 0 .../scope-analysis/types-reference.src.ts | 0 .../scope-analysis/types-tuple-empty.src.ts | 0 .../types-tuple-optional.src.ts | 0 .../scope-analysis/types-tuple-rest.src.ts | 0 .../scope-analysis/types-tuple-type.src.ts | 0 .../scope-analysis/types-tuple.src.ts | 0 .../scope-analysis/types-type-literal.src.ts | 0 .../scope-analysis/types-type-operator.src.ts | 0 .../scope-analysis/types-typeof.src.ts | 0 .../types-union-intersection.src.ts | 0 .../scope-analysis/types-union-type.src.ts | 0 .../fixtures/services/isolated-file.src.ts | 0 .../tests/fixtures/services/tsconfig.json | 0 .../tests/lib/__snapshots__/basics.ts.snap | 0 .../tests/lib/__snapshots__/comments.ts.snap | 0 .../lib/__snapshots__/javascript.ts.snap | 0 .../tests/lib/__snapshots__/jsx.ts.snap | 0 .../lib/__snapshots__/scope-analysis.ts.snap | 0 .../tests/lib/__snapshots__/services.ts.snap | 0 .../tests/lib/__snapshots__/tsx.ts.snap | 0 .../lib/__snapshots__/typescript.ts.snap | 0 .../tests/lib/basics.ts | 12 +- .../tests/lib/comments.ts | 0 .../tests/lib/javascript.ts | 0 .../tests/lib/jsx.ts | 2 +- .../tests/lib/parser.ts | 2 +- .../tests/lib/scope-analysis.ts | 0 .../tests/lib/services.ts | 0 .../tests/lib/tsx.ts | 23 +- .../tests/lib/typescript.ts | 0 .../tools/test-utils.ts | 0 .../tsconfig.json | 0 .../comments/block-trailing-comment.src.js | 0 .../comments/comment-within-condition.src.js | 0 .../export-default-anonymous-class.src.js | 0 .../fixtures/comments/jsdoc-comment.src.js | 0 .../comments/jsx-block-comment.src.js | 0 .../comments/jsx-comment-after-jsx.src.js | 0 .../jsx-comment-after-self-closing-jsx.src.js | 0 .../fixtures/comments/jsx-tag-comments.src.js | 0 ...jsx-text-with-multiline-non-comment.src.js | 0 .../comments/jsx-text-with-url.src.js | 0 .../comments/jsx-with-greather-than.src.js | 0 .../comments/jsx-with-operators.src.js | 0 .../line-comment-with-block-syntax.src.js | 0 .../mix-line-and-block-comments.src.js | 0 .../fixtures/comments/no-comment-regex.src.js | 0 .../comments/no-comment-template.src.js | 0 .../comments/surrounding-call-comments.src.js | 0 .../surrounding-debugger-comments.src.js | 0 .../surrounding-return-comments.src.js | 0 .../surrounding-throw-comments.src.js | 0 .../surrounding-while-loop-comments.src.js | 0 ...tch-fallthrough-comment-in-function.src.js | 0 .../switch-fallthrough-comment.src.js | 0 ...itch-no-default-comment-in-function.src.js | 0 ...default-comment-in-nested-functions.src.js | 0 .../comments/switch-no-default-comment.src.js | 0 .../comments/template-string-block.src.js | 0 .../type-assertion-regression-test.src.ts | 0 .../arrayLiteral/array-literal-in-lhs.src.js | 0 .../array-literals-in-binary-expr.src.js | 0 .../as-param-with-params.src.js | 0 .../javascript/arrowFunctions/as-param.src.js | 0 .../basic-in-binary-expression.src.js | 0 .../javascript/arrowFunctions/basic.src.js | 0 .../block-body-not-object.src.js | 0 .../arrowFunctions/block-body.src.js | 0 .../arrowFunctions/error-dup-params.src.js | 0 .../arrowFunctions/error-missing-paren.src.js | 0 .../arrowFunctions/error-not-arrow.src.js | 0 .../error-numeric-param-multi.src.js | 0 .../arrowFunctions/error-numeric-param.src.js | 0 .../arrowFunctions/error-reverse-arrow.src.js | 0 .../error-strict-default-param-eval.src.js | 0 .../error-strict-dup-params.src.js | 0 .../error-strict-eval-return.src.js | 0 .../arrowFunctions/error-strict-eval.src.js | 0 .../arrowFunctions/error-strict-octal.src.js | 0 .../error-strict-param-arguments.src.js | 0 .../error-strict-param-eval.src.js | 0 .../error-strict-param-names.src.js | 0 ...ror-strict-param-no-paren-arguments.src.js | 0 .../error-strict-param-no-paren-eval.src.js | 0 .../arrowFunctions/error-two-lines.src.js | 0 .../arrowFunctions/error-wrapped-param.src.js | 0 .../arrowFunctions/expression.src.js | 0 .../javascript/arrowFunctions/iife.src.js | 0 .../arrowFunctions/multiple-params.src.js | 0 .../arrowFunctions/no-auto-return.src.js | 0 .../not-strict-arguments.src.js | 0 .../not-strict-eval-params.src.js | 0 .../arrowFunctions/not-strict-eval.src.js | 0 .../arrowFunctions/not-strict-octal.src.js | 0 .../return-arrow-function.src.js | 0 .../arrowFunctions/return-sequence.src.js | 0 .../arrowFunctions/single-param-parens.src.js | 0 .../single-param-return-identifier.src.js | 0 .../arrowFunctions/single-param.src.js | 0 .../basics/and-operator-array-object.src.js | 0 .../basics/delete-expression.src.js | 0 .../basics/do-while-statements.src.js | 0 .../identifiers-double-underscore.src.js | 0 .../javascript/basics/instanceof.src.js | 0 .../basics/new-with-member-expression.src.js | 0 .../basics/new-without-parens.src.js | 0 .../basics/or-operator-array-object.src.js | 0 .../basics/typeof-expression.src.js | 0 .../basics/update-expression.src.js | 0 .../javascript/basics/void-expression.src.js | 0 .../javascript/bigIntLiterals/binary.src.js | 0 .../javascript/bigIntLiterals/decimal.src.js | 0 .../javascript/bigIntLiterals/hex.src.js | 0 .../javascript/bigIntLiterals/octal.src.js | 0 .../javascript/binaryLiterals/invalid.src.js | 0 .../binaryLiterals/lowercase.src.js | 0 .../binaryLiterals/uppercase.src.js | 0 .../javascript/blockBindings/const.src.js | 0 .../blockBindings/let-in-switchcase.src.js | 0 .../javascript/blockBindings/let.src.js | 0 .../call-expression-with-array.src.js | 0 .../call-expression-with-object.src.js | 0 .../callExpression/mixed-expression.src.js | 0 .../new-expression-with-array.src.js | 0 .../new-expression-with-object.src.js | 0 .../classes/class-accessor-properties.src.js | 0 .../class-computed-static-method.src.js | 0 .../classes/class-expression.src.js | 0 .../class-method-named-prototype.src.js | 0 .../classes/class-method-named-static.src.js | 0 .../class-method-named-with-space.src.js | 0 .../classes/class-one-method-super.src.js | 0 .../classes/class-one-method.src.js | 0 ...class-static-method-named-prototype.src.js | 0 .../class-static-method-named-static.src.js | 0 .../classes/class-static-method.src.js | 0 ...tic-methods-and-accessor-properties.src.js | 0 .../class-two-computed-static-methods.src.js | 0 ...ss-two-methods-computed-constructor.src.js | 0 .../classes/class-two-methods-semi.src.js | 0 .../class-two-methods-three-semi.src.js | 0 .../classes/class-two-methods-two-semi.src.js | 0 .../classes/class-two-methods.src.js | 0 ...wo-static-methods-named-constructor.src.js | 0 .../class-with-constructor-parameters.src.js | 0 .../class-with-constructor-with-space.src.js | 0 .../classes/class-with-constructor.src.js | 0 .../derived-class-assign-to-var.src.js | 0 .../classes/derived-class-expression.src.js | 0 .../classes/empty-class-double-semi.src.js | 0 .../classes/empty-class-semi.src.js | 0 .../javascript/classes/empty-class.src.js | 0 .../empty-literal-derived-class.src.js | 0 .../classes/invalid-class-declaration.src.js | 0 .../invalid-class-setter-declaration.src.js | 0 .../invalid-class-two-super-classes.src.js | 0 .../classes/named-class-expression.src.js | 0 .../named-derived-class-expression.src.js | 0 .../defaultParams/class-constructor.src.js | 0 .../defaultParams/class-method.src.js | 0 .../defaultParams/declaration.src.js | 0 .../defaultParams/expression.src.js | 0 .../javascript/defaultParams/method.src.js | 0 .../defaultParams/not-all-params.src.js | 0 .../arrow-param-array.src.js | 0 .../arrow-param-nested-array.src.js | 0 .../arrow-param-nested-object-named.src.js | 0 .../arrow-param-nested-object.src.js | 0 .../arrow-param-object.src.js | 0 .../param-defaults-array.src.js | 0 .../param-defaults-object-nested.src.js | 0 .../param-defaults-object.src.js | 0 .../array-const-undefined.src.js | 0 .../array-let-undefined.src.js | 0 .../object-const-named.src.js | 0 .../object-const-undefined.src.js | 0 .../object-let-named.src.js | 0 .../object-let-undefined.src.js | 0 .../param-array.src.js | 0 .../param-object-short.src.js | 0 .../param-object-wrapped.src.js | 0 .../param-object.src.js | 0 .../destructuring-and-forOf/loop.src.js | 0 .../complex-destructured.src.js | 0 .../destructured-array-literal.src.js | 0 .../destructuring-param.src.js | 0 ...r-complex-destructured-spread-first.src.js | 0 .../invalid-not-final-array-empty.src.js | 0 .../multi-destructured.src.js | 0 .../not-final-array.src.js | 0 .../single-destructured.src.js | 0 .../var-complex-destructured.src.js | 0 .../var-destructured-array-literal.src.js | 0 .../var-multi-destructured.src.js | 0 .../var-single-destructured.src.js | 0 .../destructuring/array-member.src.js | 0 .../destructuring/array-to-array.src.js | 0 .../destructuring/array-var-undefined.src.js | 0 .../call-expression-destruction-array.src.js | 0 .../call-expression-destruction-object.src.js | 0 .../class-constructor-params-array.src.js | 0 ...s-constructor-params-defaults-array.src.js | 0 ...-constructor-params-defaults-object.src.js | 0 .../class-constructor-params-object.src.js | 0 .../class-method-params-array.src.js | 0 .../class-method-params-defaults-array.src.js | 0 ...class-method-params-defaults-object.src.js | 0 .../class-method-params-object.src.js | 0 .../destructuring/defaults-array-all.src.js | 0 ...efaults-array-longform-nested-multi.src.js | 0 .../destructuring/defaults-array-multi.src.js | 0 .../defaults-array-nested-all.src.js | 0 .../defaults-array-nested-multi.src.js | 0 .../destructuring/defaults-array.src.js | 0 .../destructuring/defaults-object-all.src.js | 0 .../defaults-object-assign.src.js | 0 .../defaults-object-longform-all.src.js | 0 .../defaults-object-longform-multi.src.js | 0 .../defaults-object-longform.src.js | 0 .../defaults-object-mixed-multi.src.js | 0 .../defaults-object-multi.src.js | 0 .../defaults-object-nested-all.src.js | 0 .../defaults-object-nested-multi.src.js | 0 .../destructuring/defaults-object.src.js | 0 .../destructured-array-catch.src.js | 0 .../destructured-object-catch.src.js | 0 .../invalid-defaults-object-assign.src.js | 0 .../destructuring/named-param.src.js | 0 .../destructuring/nested-array.src.js | 0 .../destructuring/nested-object.src.js | 0 .../destructuring/object-var-named.src.js | 0 .../destructuring/object-var-undefined.src.js | 0 .../destructuring/param-defaults-array.src.js | 0 .../param-defaults-object-nested.src.js | 0 .../param-defaults-object.src.js | 0 .../destructuring/params-array-wrapped.src.js | 0 .../destructuring/params-array.src.js | 0 .../destructuring/params-multi-object.src.js | 0 .../destructuring/params-nested-array.src.js | 0 .../destructuring/params-nested-object.src.js | 0 .../params-object-wrapped.src.js | 0 .../destructuring/params-object.src.js | 0 .../destructuring/sparse-array.src.js | 0 .../javascript/directives/block.src.js | 0 .../directives/directive-in-class.src.js | 0 .../directives/first-expression.src.js | 0 .../directives/function-non-strict.src.js | 0 .../directives/non-directive-string.src.js | 0 .../directives/non-unique-directive.src.js | 0 .../directives/program-order.src.js | 0 .../javascript/directives/program.src.js | 0 .../fixtures/javascript/directives/raw.src.js | 0 .../async-generators.src.js | 0 .../async-iterator.src.js | 0 .../dynamic-import.src.js | 0 .../arg-spread.src.js | 0 .../destructuring-assign-mirror.src.js | 0 .../function-parameter-object-spread.src.js | 0 .../invalid-rest-trailing-comma.src.js | 0 .../invalid-rest.src.js | 0 .../object-rest.src.js | 0 .../property-spread.src.js | 0 .../shorthand-method-args.src.js | 0 .../shorthand-methods.src.js | 0 .../shorthand-properties.src.js | 0 .../single-spread.src.js | 0 .../spread-trailing-comma.src.js | 0 .../two-spread.src.js | 0 .../optional-catch-binding-finally.src.js | 0 .../optional-catch-binding.src.js | 0 .../exponential-operators.src.js | 0 .../fixtures/javascript/for/for-empty.src.js | 0 .../fixtures/javascript/for/for-loop.src.js | 0 .../javascript/for/for-with-coma.src.js | 0 .../javascript/for/for-with-const.src.js | 0 .../javascript/for/for-with-function.src.js | 0 .../javascript/for/for-with-let.src.js | 0 .../javascript/forIn/for-in-array.src.js | 0 .../forIn/for-in-bare-nonstrict.src.js | 0 .../forIn/for-in-destruction-object.src.js | 0 .../forIn/for-in-destruction.src.js | 0 .../forIn/for-in-object-with-body.src.js | 0 .../javascript/forIn/for-in-object.src.js | 0 .../forIn/for-in-with-assigment.src.js | 0 .../forIn/for-in-with-bare-assigment.src.js | 0 .../javascript/forIn/for-in-with-const.src.js | 0 .../forIn/for-in-with-milti-asigment.src.js | 0 .../javascript/forIn/for-in-with-rest.src.js | 0 .../javascript/forIn/for-in-with-var.src.js | 0 .../javascript/forOf/for-of-array.src.js | 0 .../forOf/for-of-destruction-object.src.js | 0 .../forOf/for-of-destruction.src.js | 0 .../javascript/forOf/for-of-object.src.js | 0 .../for-of-with-function-initializer.src.js | 0 .../javascript/forOf/for-of-with-rest.src.js | 0 .../forOf/for-of-with-var-and-braces.src.js | 0 .../for-of-with-var-and-no-braces.src.js | 0 ...lid-for-of-with-const-and-no-braces.src.js | 0 ...valid-for-of-with-let-and-no-braces.src.js | 0 .../generators/anonymous-generator.src.js | 0 .../async-generator-function.src.js | 0 .../generators/async-generator-method.src.js | 0 .../javascript/generators/double-yield.src.js | 0 .../empty-generator-declaration.src.js | 0 .../generators/generator-declaration.src.js | 0 .../generators/yield-delegation.src.js | 0 .../yield-without-value-in-call.src.js | 0 .../yield-without-value-no-semi.src.js | 0 .../generators/yield-without-value.src.js | 0 .../globalReturn/return-identifier.src.js | 0 .../globalReturn/return-no-arg.src.js | 0 .../globalReturn/return-true.src.js | 0 .../javascript/hexLiterals/invalid.src.js | 0 .../javascript/hexLiterals/lowercase.src.js | 0 .../javascript/hexLiterals/uppercase.src.js | 0 .../importMeta/simple-import-meta.src.js | 0 .../javascript/labels/label-break.src.js | 0 .../javascript/labels/label-continue.src.js | 0 .../javascript/modules/error-delete.src.js | 0 .../javascript/modules/error-function.src.js | 0 .../javascript/modules/error-strict.src.js | 0 .../modules/export-default-array.src.js | 0 .../modules/export-default-class.src.js | 0 .../modules/export-default-expression.src.js | 0 .../modules/export-default-function.src.js | 0 .../modules/export-default-named-class.src.js | 0 .../export-default-named-function.src.js | 0 .../modules/export-default-number.src.js | 0 .../modules/export-default-object.src.js | 0 .../modules/export-default-value.src.js | 0 .../modules/export-from-batch.src.js | 0 .../modules/export-from-default.src.js | 0 .../export-from-named-as-default.src.js | 0 .../export-from-named-as-specifier.src.js | 0 .../export-from-named-as-specifiers.src.js | 0 .../modules/export-from-specifier.src.js | 0 .../modules/export-from-specifiers.src.js | 0 .../javascript/modules/export-function.src.js | 0 .../modules/export-named-as-default.src.js | 0 .../modules/export-named-as-specifier.src.js | 0 .../modules/export-named-as-specifiers.src.js | 0 .../modules/export-named-class.src.js | 0 .../modules/export-named-empty.src.js | 0 .../modules/export-named-specifier.src.js | 0 .../export-named-specifiers-comma.src.js | 0 .../modules/export-named-specifiers.src.js | 0 .../export-var-anonymous-function.src.js | 0 .../modules/export-var-number.src.js | 0 .../javascript/modules/export-var.src.js | 0 ...import-default-and-named-specifiers.src.js | 0 ...rt-default-and-namespace-specifiers.src.js | 0 .../modules/import-default-as.src.js | 0 .../javascript/modules/import-default.src.js | 0 .../javascript/modules/import-jquery.src.js | 0 .../javascript/modules/import-module.src.js | 0 .../modules/import-named-as-specifier.src.js | 0 .../modules/import-named-as-specifiers.src.js | 0 .../modules/import-named-empty.src.js | 0 .../modules/import-named-specifier.src.js | 0 .../import-named-specifiers-comma.src.js | 0 .../modules/import-named-specifiers.src.js | 0 .../modules/import-namespace-specifier.src.js | 0 .../modules/import-null-as-nil.src.js | 0 .../javascript/modules/invalid-await.src.js | 0 .../javascript/modules/invalid-class.src.js | 0 ...id-export-batch-missing-from-clause.src.js | 0 .../modules/invalid-export-batch-token.src.js | 0 .../invalid-export-default-equal.src.js | 0 .../invalid-export-default-token.src.js | 0 .../modules/invalid-export-default.src.js | 0 .../invalid-export-named-default.src.js | 0 .../invalid-export-named-extra-comma.src.js | 0 .../invalid-export-named-middle-comma.src.js | 0 ...t-default-after-named-after-default.src.js | 0 .../invalid-import-default-after-named.src.js | 0 ...rt-default-missing-module-specifier.src.js | 0 ...lid-import-default-module-specifier.src.js | 0 .../modules/invalid-import-default.src.js | 0 ...lid-import-missing-module-specifier.src.js | 0 .../invalid-import-module-specifier.src.js | 0 .../invalid-import-named-after-named.src.js | 0 ...nvalid-import-named-after-namespace.src.js | 0 ...nvalid-import-named-as-missing-from.src.js | 0 .../invalid-import-named-extra-comma.src.js | 0 .../invalid-import-named-middle-comma.src.js | 0 ...nvalid-import-namespace-after-named.src.js | 0 ...invalid-import-namespace-missing-as.src.js | 0 .../newTarget/invalid-new-target.src.js | 0 .../newTarget/invalid-unknown-property.src.js | 0 .../newTarget/simple-new-target.src.js | 0 .../object-literal-in-lhs.src.js | 0 .../computed-addition-property.src.js | 0 .../computed-and-identifier.src.js | 0 .../computed-getter-and-setter.src.js | 0 .../computed-string-property.src.js | 0 .../computed-variable-property.src.js | 0 .../invalid-computed-variable-property.src.js | 0 ...andalone-computed-variable-property.src.js | 0 ...standalone-expression-with-addition.src.js | 0 .../standalone-expression-with-method.src.js | 0 .../standalone-expression.src.js | 0 .../error-proto-property.src.js | 0 .../error-proto-string-property.src.js | 0 .../strict-duplicate-properties.src.js | 0 .../strict-duplicate-string-properties.src.js | 0 .../invalid-method-no-braces.src.js | 0 .../method-property.src.js | 0 .../simple-method-named-get.src.js | 0 .../simple-method-named-set.src.js | 0 .../simple-method-with-argument.src.js | 0 .../simple-method-with-string-name.src.js | 0 .../simple-method.src.js | 0 .../string-name-method-property.src.js | 0 .../shorthand-properties.src.js | 0 .../javascript/octalLiterals/invalid.src.js | 0 .../javascript/octalLiterals/legacy.src.js | 0 .../javascript/octalLiterals/lowercase.src.js | 0 .../octalLiterals/strict-uppercase.src.js | 0 .../javascript/octalLiterals/uppercase.src.js | 0 .../javascript/regex/regexp-simple.src.js | 0 .../regexUFlag/regex-u-extended-escape.src.js | 0 .../regex-u-invalid-extended-escape.src.js | 0 .../regexUFlag/regex-u-simple.src.js | 0 .../regexYFlag/regexp-y-simple.src.js | 0 .../javascript/restParams/basic-rest.src.js | 0 .../restParams/class-constructor.src.js | 0 .../javascript/restParams/class-method.src.js | 0 .../restParams/error-no-default.src.js | 0 .../restParams/error-not-last.src.js | 0 .../restParams/func-expression-multi.src.js | 0 .../restParams/func-expression.src.js | 0 .../restParams/invalid-rest-param.src.js | 0 .../javascript/restParams/single-rest.src.js | 0 .../literal-float-negative.src.js | 0 .../simple-literals/literal-float.src.js | 0 .../simple-literals/literal-null.src.js | 0 .../literal-number-negative.src.js | 0 .../simple-literals/literal-number.src.js | 0 .../simple-literals/literal-string.src.js | 0 .../simple-literals/literal-undefined.src.js | 0 .../javascript/spread/complex-spread.src.js | 0 .../javascript/spread/error-invalid-if.src.js | 0 .../spread/error-invalid-sequence.src.js | 0 .../spread/multi-function-call.src.js | 0 .../javascript/spread/not-final-param.src.js | 0 .../spread/simple-function-call.src.js | 0 .../templateStrings/deeply-nested.src.js | 0 .../error-octal-literal.src.js | 0 .../templateStrings/escape-characters.src.js | 0 .../templateStrings/expressions.src.js | 0 .../multi-line-template-string.src.js | 0 .../simple-template-string.src.js | 0 .../templateStrings/single-dollar-sign.src.js | 0 .../tagged-no-placeholders.src.js | 0 .../tagged-template-string.src.js | 0 .../basic-string-literal.src.js | 0 .../complex-string-literal.src.js | 0 .../invalid-empty-escape.src.js | 0 .../invalid-too-large-escape.src.js | 0 .../self-closing-tag-inside-tag.src.js | 0 .../jsx-useJSXTextNode/test-content.src.js | 0 .../fixtures/jsx/attributes.src.js | 0 .../fixtures/jsx/element-keyword-name.src.js | 0 .../fixtures/jsx/embedded-comment.src.js | 0 .../fixtures/jsx/embedded-conditional.src.js | 0 .../jsx/embedded-invalid-js-identifier.src.js | 0 .../fixtures/jsx/embedded-tags.src.js | 0 .../fixtures/jsx/empty-placeholder.src.js | 0 .../fixtures/jsx/escape-patterns.src.js | 0 .../invalid-attribute-missing-equals.src.js | 0 .../fixtures/jsx/invalid-attribute.src.js | 0 .../fixtures/jsx/invalid-broken-tag.src.js | 0 .../jsx/invalid-computed-end-tag-name.src.js | 0 ...nvalid-computed-string-end-tag-name.src.js | 0 .../jsx/invalid-embedded-expression.src.js | 0 .../jsx/invalid-leading-dot-tag-name.src.js | 0 ...matching-placeholder-in-closing-tag.src.js | 0 .../jsx/invalid-mismatched-closing-tag.src.js | 0 .../invalid-mismatched-closing-tags.src.js | 0 .../invalid-mismatched-dot-tag-name.src.js | 0 .../invalid-mismatched-namespace-tag.src.js | 0 ...g-closing-tag-attribute-placeholder.src.js | 0 .../jsx/invalid-missing-closing-tag.src.js | 0 .../jsx/invalid-missing-namespace-name.src.js | 0 .../invalid-missing-namespace-value.src.js | 0 .../invalid-missing-spread-operator.src.js | 0 .../invalid-namespace-name-with-docts.src.js | 0 .../invalid-namespace-value-with-dots.src.js | 0 ...valid-no-common-parent-with-comment.src.js | 0 .../jsx/invalid-no-common-parent.src.js | 0 .../fixtures/jsx/invalid-no-tag-name.src.js | 0 .../invalid-placeholder-in-closing-tag.src.js | 0 ...valid-shorthand-fragment-no-closing.src.js | 0 .../jsx/invalid-trailing-dot-tag-name.src.js | 0 .../jsx/invalid-unexpected-comma.src.js | 0 .../fixtures/jsx/japanese-characters.src.js | 0 .../fixtures/jsx/less-than-operator.src.js | 0 .../jsx/member-expression-this.src.js | 0 .../fixtures/jsx/member-expression.src.js | 0 .../fixtures/jsx/multiple-blank-spaces.src.js | 0 ...spaced-attribute-and-value-inserted.src.js | 0 .../jsx/namespaced-name-and-attribute.src.js | 0 .../jsx/newslines-and-entities.src.js | 0 .../jsx/self-closing-tag-inside-tag.src.js | 0 .../jsx/self-closing-tag-with-newline.src.js | 0 .../fixtures/jsx/self-closing-tag.src.js | 0 .../jsx/shorthand-fragment-with-child.src.js | 0 .../fixtures/jsx/shorthand-fragment.src.js | 0 .../fixtures/jsx/spread-child.src.js | 0 ...tor-attribute-and-regular-attribute.src.js | 0 .../jsx/spread-operator-attributes.src.js | 0 .../fixtures/jsx/tag-names-with-dots.src.js | 0 .../jsx/tag-names-with-multi-dots.src.js | 0 .../fixtures/jsx/test-content.src.js | 0 .../trailing-spread-operator-attribute.src.js | 0 .../jsx/unknown-escape-pattern.src.js | 0 .../fixtures/tsx/generic-jsx-element.src.tsx | 0 .../fixtures/tsx/react-typed-props.src.tsx | 0 .../type-parameter-whitespace-loc.src.ts | 0 .../type-parameters.src.ts | 0 ...act-class-with-abstract-constructor.src.ts | 0 ...abstract-class-with-abstract-method.src.ts | 0 ...ract-class-with-abstract-properties.src.ts | 0 ...ass-with-abstract-readonly-property.src.ts | 0 ...abstract-class-with-optional-method.src.ts | 0 .../basics/abstract-interface.src.ts | 0 ...arrow-function-with-type-parameters.src.ts | 0 .../basics/async-function-expression.src.ts | 0 ...async-function-with-var-declaration.src.ts | 0 .../call-signatures-with-generics.src.ts | 0 .../typescript/basics/call-signatures.src.ts | 0 .../basics/cast-as-expression.src.ts | 0 .../basics/cast-as-multi-assign.src.ts | 0 .../typescript/basics/cast-as-multi.src.ts | 0 .../typescript/basics/cast-as-operator.src.ts | 0 .../typescript/basics/cast-as-simple.src.ts | 0 .../class-multi-line-keyword-abstract.src.ts | 0 .../class-multi-line-keyword-declare.src.ts | 0 .../class-with-accessibility-modifiers.src.ts | 0 ...class-with-constructor-and-modifier.src.ts | 0 ...ss-with-constructor-and-return-type.src.ts | 0 ...ith-constructor-and-type-parameters.src.ts | 0 .../class-with-definite-assignment.src.ts | 0 ...ss-with-export-parameter-properties.src.ts | 0 .../class-with-extends-and-implements.src.ts | 0 ...class-with-extends-generic-multiple.src.ts | 0 .../basics/class-with-extends-generic.src.ts | 0 .../class-with-generic-method-default.src.ts | 0 .../basics/class-with-generic-method.src.ts | 0 .../class-with-implements-and-extends.src.ts | 0 ...ss-with-implements-generic-multiple.src.ts | 0 .../class-with-implements-generic.src.ts | 0 .../basics/class-with-implements.src.ts | 0 .../basics/class-with-method.src.ts | 0 .../basics/class-with-mixin-reference.src.ts | 0 .../typescript/basics/class-with-mixin.src.ts | 0 ...ass-with-optional-computed-property.src.ts | 0 .../basics/class-with-optional-methods.src.ts | 0 .../class-with-optional-properties.src.ts | 0 ...ss-with-optional-property-undefined.src.ts | 0 ...s-with-private-parameter-properties.src.ts | 0 .../class-with-property-function.src.ts | 0 .../basics/class-with-property-values.src.ts | 0 ...with-protected-parameter-properties.src.ts | 0 ...ss-with-public-parameter-properties.src.ts | 0 ...-with-readonly-parameter-properties.src.ts | 0 .../class-with-readonly-property.src.ts | 0 ...ss-with-static-parameter-properties.src.ts | 0 ...th-two-methods-computed-constructor.src.ts | 0 .../class-with-type-parameter-default.src.ts | 0 ...lass-with-type-parameter-underscore.src.ts | 0 .../basics/class-with-type-parameter.src.ts | 0 .../typescript/basics/const-enum.src.ts | 0 .../declare-class-with-optional-method.src.ts | 0 .../typescript/basics/declare-function.src.ts | 0 .../destructuring-assignment-nested.src.ts | 0 .../destructuring-assignment-object.src.ts | 0 .../destructuring-assignment-property.src.ts | 0 .../basics/destructuring-assignment.src.ts | 0 .../basics/directive-in-module.src.ts | 0 .../basics/directive-in-namespace.src.ts | 0 .../basics/export-as-namespace.src.ts | 0 .../basics/export-assignment.src.ts | 0 .../export-declare-const-named-enum.src.ts | 0 .../basics/export-declare-named-enum.src.ts | 0 .../export-default-class-with-generic.src.ts | 0 ...efault-class-with-multiple-generics.src.ts | 0 .../export-named-class-with-generic.src.ts | 0 ...-named-class-with-multiple-generics.src.ts | 0 .../basics/export-named-enum.src.ts | 0 .../export-type-alias-declaration.src.ts | 0 .../export-type-class-declaration.src.ts | 0 .../export-type-function-declaration.src.ts | 0 .../basics/function-overloads.src.ts | 0 .../basics/function-with-await.src.ts | 0 ...bject-type-with-optional-properties.src.ts | 0 ...with-object-type-without-annotation.src.ts | 0 ...-type-parameters-that-have-comments.src.ts | 0 ...ith-type-parameters-with-constraint.src.ts | 0 .../function-with-type-parameters.src.ts | 0 .../function-with-types-assignation.src.ts | 0 .../basics/function-with-types.src.ts | 0 .../basics/import-equal-declaration.src.ts | 0 .../import-export-equal-declaration.src.ts | 0 ...h-type-parameters-in-type-reference.src.ts | 0 .../typescript/basics/import-type.src.ts | 0 .../basics/interface-extends-multiple.src.ts | 0 .../basics/interface-extends.src.ts | 0 .../basics/interface-type-parameters.src.ts | 0 .../interface-with-all-property-types.src.ts | 0 ...nature-with-parameter-accessibility.src.ts | 0 ...face-with-extends-member-expression.src.ts | 0 ...erface-with-extends-type-parameters.src.ts | 0 .../basics/interface-with-generic.src.ts | 0 .../basics/interface-with-jsdoc.src.ts | 0 .../basics/interface-with-method.src.ts | 0 .../interface-with-optional-properties.src.ts | 0 .../interface-without-type-annotation.src.ts | 0 .../typescript/basics/keyof-operator.src.ts | 0 .../basics/nested-type-arguments.src.ts | 0 .../typescript/basics/never-type-param.src.ts | 0 .../basics/non-null-assertion-operator.src.ts | 0 ...null-and-undefined-type-annotations.src.ts | 0 .../object-with-escaped-properties.src.ts | 0 .../basics/object-with-typed-methods.src.ts | 0 .../basics/parenthesized-use-strict.src.ts | 0 .../basics/symbol-type-param.src.ts | 0 ...ion-with-constrained-type-parameter.src.ts | 0 .../basics/type-alias-declaration.src.ts | 0 ...ype-alias-object-without-annotation.src.ts | 0 .../type-assertion-arrow-function.src.ts | 0 .../typescript/basics/type-assertion.src.ts | 0 .../type-guard-in-arrow-function.src.ts | 0 .../basics/type-guard-in-function.src.ts | 0 .../basics/type-guard-in-interface.src.ts | 0 .../basics/type-guard-in-method.src.ts | 0 .../basics/type-parameters-comments.src.ts | 0 .../basics/type-reference-comments.src.ts | 0 .../basics/typed-keyword-bigint.src.ts | 0 .../basics/typed-keyword-boolean.src.ts | 0 .../basics/typed-keyword-false.src.ts | 0 .../basics/typed-keyword-never.src.ts | 0 .../basics/typed-keyword-null.src.ts | 0 .../basics/typed-keyword-number.src.ts | 0 .../basics/typed-keyword-object.src.ts | 0 .../basics/typed-keyword-string.src.ts | 0 .../basics/typed-keyword-symbol.src.ts | 0 .../basics/typed-keyword-true.src.ts | 0 .../basics/typed-keyword-undefined.src.ts | 0 .../basics/typed-keyword-unknown.src.ts | 0 .../basics/typed-keyword-void.src.ts | 0 .../basics/typed-method-signature.src.ts | 0 .../typescript/basics/typed-this.src.ts | 0 .../typescript/basics/unique-symbol.src.ts | 0 .../basics/unknown-type-annotation.src.ts | 0 .../var-with-definite-assignment.src.ts | 0 .../basics/var-with-dotted-type.src.ts | 0 .../typescript/basics/var-with-type.src.ts | 0 ...declaration-type-annotation-spacing.src.ts | 0 .../typescript/declare/abstract-class.src.ts | 0 .../fixtures/typescript/declare/class.src.ts | 0 .../fixtures/typescript/declare/enum.src.ts | 0 .../typescript/declare/function.src.ts | 0 .../typescript/declare/interface.src.ts | 0 .../fixtures/typescript/declare/module.src.ts | 0 .../typescript/declare/namespace.src.ts | 0 .../typescript/declare/type-alias.src.ts | 0 .../typescript/declare/variable.src.ts | 0 ...r-decorator-factory-instance-member.src.ts | 0 ...sor-decorator-factory-static-member.src.ts | 0 .../accessor-decorator-instance-member.src.ts | 0 .../accessor-decorator-static-member.src.ts | 0 .../class-decorator-factory.src.ts | 0 .../class-decorators/class-decorator.src.ts | 0 ...d-decorator-factory-instance-member.src.ts | 0 ...hod-decorator-factory-static-member.src.ts | 0 .../method-decorator-instance-member.src.ts | 0 .../method-decorator-static-member.src.ts | 0 .../parameter-decorator-constructor.src.ts | 0 ...decorator-decorator-instance-member.src.ts | 0 ...r-decorator-decorator-static-member.src.ts | 0 ...parameter-decorator-instance-member.src.ts | 0 .../parameter-decorator-static-member.src.ts | 0 ...y-decorator-factory-instance-member.src.ts | 0 ...rty-decorator-factory-static-member.src.ts | 0 .../property-decorator-instance-member.src.ts | 0 .../property-decorator-static-member.src.ts | 0 .../class-empty-extends-implements.src.ts | 0 .../errorRecovery/class-empty-extends.src.ts | 0 .../class-extends-empty-implements.src.ts | 0 .../class-multiple-implements.src.ts | 0 .../decorator-on-enum-declaration.src.ts | 0 .../decorator-on-interface-declaration.src.ts | 0 .../errorRecovery/empty-type-arguments.src.ts | 0 .../errorRecovery/enum-with-keywords.src.ts | 0 .../index-signature-parameters.src.ts | 0 .../interface-empty-extends.src.ts | 0 .../errorRecovery/interface-implements.src.ts | 0 .../interface-index-signature-export.src.ts | 0 .../interface-index-signature-private.src.ts | 0 ...interface-index-signature-protected.src.ts | 0 .../interface-index-signature-public.src.ts | 0 .../interface-index-signature-static.src.ts | 0 .../interface-method-export.src.ts | 0 .../interface-method-private.src.ts | 0 .../interface-method-protected.src.ts | 0 .../interface-method-public.src.ts | 0 .../interface-method-static.src.ts | 0 .../interface-multiple-extends.src.ts | 0 .../interface-property-export.src.ts | 0 .../interface-property-private.src.ts | 0 .../interface-property-protected.src.ts | 0 .../interface-property-public.src.ts | 0 .../interface-property-static.src.ts | 0 ...terface-property-with-default-value.src.ts | 0 .../object-assertion-not-allowed.src.ts | 0 .../object-optional-not-allowed.src.ts | 0 .../errorRecovery/solo-const.src.ts | 0 .../call-expression-type-arguments.src.ts | 0 .../new-expression-type-arguments.src.ts | 0 ...-template-expression-type-arguments.src.ts | 0 ...ient-module-declaration-with-import.src.ts | 0 ...re-namespace-with-exported-function.src.ts | 0 .../global-module-declaration.src.ts | 0 .../module-with-default-exports.src.ts | 0 .../nested-internal-module.src.ts | 0 ...horthand-ambient-module-declaration.src.ts | 0 .../typescript/types/array-type.src.ts | 0 .../types/conditional-infer-nested.src.ts | 0 .../types/conditional-infer-simple.src.ts | 0 .../typescript/types/conditional-infer.src.ts | 0 .../types/conditional-with-null.src.ts | 0 .../typescript/types/conditional.src.ts | 0 .../types/constructor-generic.src.ts | 0 .../types/constructor-in-generic.src.ts | 0 .../types/constructor-with-rest.src.ts | 0 .../typescript/types/constructor.src.ts | 0 .../typescript/types/function-generic.src.ts | 0 .../types/function-in-generic.src.ts | 0 .../types/function-with-rest.src.ts | 0 .../types/function-with-this.src.ts | 0 .../fixtures/typescript/types/function.src.ts | 0 .../types/index-signature-readonly.src.ts | 0 .../types/index-signature-without-type.src.ts | 0 .../typescript/types/index-signature.src.ts | 0 .../fixtures/typescript/types/indexed.src.ts | 0 .../typescript/types/intersection-type.src.ts | 0 .../types/literal-number-negative.src.ts | 0 .../typescript/types/literal-number.src.ts | 0 .../typescript/types/literal-string.src.ts | 0 .../types/mapped-readonly-minus.src.ts | 0 .../types/mapped-readonly-plus.src.ts | 0 .../typescript/types/mapped-readonly.src.ts | 0 .../fixtures/typescript/types/mapped.src.ts | 0 .../typescript/types/nested-types.src.ts | 0 .../types/parenthesized-type.src.ts | 0 .../types/reference-generic-nested.src.ts | 0 .../typescript/types/reference-generic.src.ts | 0 .../typescript/types/reference.src.ts | 0 .../types/this-type-expanded.src.ts | 0 .../typescript/types/this-type.src.ts | 0 .../typescript/types/tuple-empty.src.ts | 0 .../typescript/types/tuple-optional.src.ts | 0 .../typescript/types/tuple-rest.src.ts | 0 .../typescript/types/tuple-type.src.ts | 0 .../fixtures/typescript/types/tuple.src.ts | 0 .../typescript/types/type-literal.src.ts | 0 .../typescript/types/type-operator.src.ts | 0 .../fixtures/typescript/types/typeof.src.ts | 0 .../types/union-intersection.src.ts | 0 .../typescript/types/union-type.src.ts | 0 .../jsx-known-issues.ts | 0 .../package.json | 0 .../typescript-eslint-parser/CHANGELOG.md | 368 ------------------ packages/typescript-estree/README.md | 9 +- packages/typescript-estree/package.json | 4 +- .../tests/ast-alignment/fixtures-to-test.ts | 4 +- .../tests/ast-alignment/parse.ts | 2 +- .../tests/ast-alignment/spec.ts | 2 +- packages/typescript-estree/tests/lib/jsx.ts | 2 +- tests/integration/docker-compose.yml | 4 +- .../.eslintrc.yml | 16 +- .../test.js.snap | 6 +- .../test.sh | 6 + .../utils/generate-package-json.js | 10 +- yarn.lock | 197 ++-------- 989 files changed, 286 insertions(+), 825 deletions(-) delete mode 100644 packages/eslint-plugin-typescript/lib/configs/recommended.json rename packages/{eslint-plugin-typescript => eslint-plugin}/.npmignore (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/LICENSE (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/README.md (85%) rename packages/{eslint-plugin-typescript => eslint-plugin}/ROADMAP.md (94%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/adjacent-overload-signatures.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/array-type.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/ban-types.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/camelcase.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/class-name-casing.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/explicit-function-return-type.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/explicit-member-accessibility.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/generic-type-naming.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/indent.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/interface-name-prefix.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/member-delimiter-style.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/member-naming.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/member-ordering.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-angle-bracket-type-assertion.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-array-constructor.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-empty-interface.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-explicit-any.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-extraneous-class.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-inferrable-types.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-misused-new.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-namespace.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-non-null-assertion.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-object-literal-type-assertion.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-parameter-properties.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-this-alias.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-triple-slash-reference.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-type-alias.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-unused-vars.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-use-before-define.md (98%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/no-var-requires.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/prefer-interface.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/prefer-namespace-keyword.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/docs/rules/type-annotation-spacing.md (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/jest.config.js (100%) create mode 100644 packages/eslint-plugin/lib/configs/recommended.json rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/index.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/adjacent-overload-signatures.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/array-type.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/ban-types.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/camelcase.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/class-name-casing.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/explicit-function-return-type.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/explicit-member-accessibility.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/generic-type-naming.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/indent.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/interface-name-prefix.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/member-delimiter-style.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/member-naming.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/member-ordering.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-angle-bracket-type-assertion.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-array-constructor.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-empty-interface.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-explicit-any.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-extraneous-class.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-inferrable-types.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-misused-new.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-namespace.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-non-null-assertion.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-object-literal-type-assertion.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-parameter-properties.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-this-alias.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-triple-slash-reference.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-type-alias.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-unused-vars.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-use-before-define.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/no-var-requires.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/prefer-interface.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/prefer-namespace-keyword.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/rules/type-annotation-spacing.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/lib/util.js (93%) rename packages/{eslint-plugin-typescript => eslint-plugin}/package.json (84%) rename packages/{eslint-plugin-typescript => eslint-plugin}/parser.js (61%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/eslint-rules/no-dupe-args.js (94%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/eslint-rules/no-implicit-globals.js (94%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/eslint-rules/no-redeclare.js (95%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/eslint-rules/no-restricted-globals.js (95%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/eslint-rules/no-shadow.js (95%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/eslint-rules/no-undef.js (97%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/eslint-rules/no-unused-vars.js (95%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/eslint-rules/no-use-before-define.js (95%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/eslint-rules/strict.js (84%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/adjacent-overload-signatures.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/array-type.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/ban-types.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/camelcase.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/class-name-casing.js (98%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/explicit-function-return-type.js (98%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/explicit-member-accessibility.js (98%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/generic-type-naming.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/indent.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/interface-name-prefix.js (98%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/member-delimiter-style.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/member-naming.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/member-ordering.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-angle-bracket-type-assertion.js (98%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-array-constructor.js (98%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-empty-interface.js (97%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-explicit-any.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-extraneous-class.js (98%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-inferrable-types.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-misused-new.js (98%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-namespace.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-non-null-assertion.js (96%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-object-literal-type-assertion.js (97%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-parameter-properties.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-this-alias.js (98%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-triple-slash-reference.js (94%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-type-alias.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-unused-vars.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-use-before-define.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/no-var-requires.js (97%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/prefer-interface.js (97%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/prefer-namespace-keyword.js (98%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/rules/type-annotation-spacing.js (99%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tests/lib/util.js (100%) rename packages/{eslint-plugin-typescript => eslint-plugin}/tools/update-recommended.js (96%) create mode 100644 packages/parser/CHANGELOG.md rename packages/{typescript-eslint-parser => parser}/LICENSE (100%) rename packages/{typescript-eslint-parser => parser}/README.md (84%) rename packages/{typescript-eslint-parser => parser}/jest.config.js (100%) rename packages/{typescript-eslint-parser => parser}/package.json (86%) rename packages/{typescript-eslint-parser => parser}/src/analyze-scope.ts (100%) rename packages/{typescript-eslint-parser => parser}/src/parser-options.ts (100%) rename packages/{typescript-eslint-parser => parser}/src/parser.ts (97%) rename packages/{typescript-eslint-parser => parser}/src/typings.d.ts (100%) rename packages/{typescript-eslint-parser => parser}/src/visitor-keys.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/basics/delete-expression.src.js (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/basics/do-while-statements.src.js (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/basics/identifiers-double-underscore.src.js (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/basics/instanceof.src.js (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/basics/new-with-member-expression.src.js (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/basics/new-without-parens.src.js (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/basics/typeof-expression.src.js (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/basics/update-expression.src.js (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/basics/void-expression.src.js (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/535.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/abstract-class.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/class-implements.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/class-properties.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/class-supper-type.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/computed-properties-in-interface.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/computed-properties-in-type.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/declare-function.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/declare-global.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/declare-module.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/decorators.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/enum-string.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/enum.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/export-as-namespace.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/expression-as.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/expression-type-parameters.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/function-overload-2.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/function-overload.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/identifier-decorators.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/ignore-type-only-stuff.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/import-equals.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/interface-type.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/method-overload.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/namespace.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/rest-element.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/type-alias.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/type-annotations.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/type-assertions.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/type-parameter.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/typeof-in-assertions.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/typeof-in-call-signature.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/typeof-in-return-type.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/typeof-in-type-parameters.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/typeof-in-var.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/typeof.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-array-type.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-conditional-with-null.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-conditional.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-indexed.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-infer.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-intersection-type.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-mapped-readonly-minus.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-mapped-readonly-plus.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-mapped-readonly.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-mapped.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-nested-types.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-parenthesized-type.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-reference-generic-nested.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-reference-generic.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-reference.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-tuple-empty.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-tuple-optional.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-tuple-rest.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-tuple-type.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-tuple.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-type-literal.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-type-operator.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-typeof.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-union-intersection.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/scope-analysis/types-union-type.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/services/isolated-file.src.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/fixtures/services/tsconfig.json (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/__snapshots__/basics.ts.snap (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/__snapshots__/comments.ts.snap (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/__snapshots__/javascript.ts.snap (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/__snapshots__/jsx.ts.snap (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/__snapshots__/scope-analysis.ts.snap (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/__snapshots__/services.ts.snap (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/__snapshots__/tsx.ts.snap (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/__snapshots__/typescript.ts.snap (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/basics.ts (84%) rename packages/{typescript-eslint-parser => parser}/tests/lib/comments.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/javascript.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/jsx.ts (93%) rename packages/{typescript-eslint-parser => parser}/tests/lib/parser.ts (94%) rename packages/{typescript-eslint-parser => parser}/tests/lib/scope-analysis.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/services.ts (100%) rename packages/{typescript-eslint-parser => parser}/tests/lib/tsx.ts (85%) rename packages/{typescript-eslint-parser => parser}/tests/lib/typescript.ts (100%) rename packages/{typescript-eslint-parser => parser}/tools/test-utils.ts (100%) rename packages/{typescript-eslint-parser => parser}/tsconfig.json (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/block-trailing-comment.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/comment-within-condition.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/export-default-anonymous-class.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/jsdoc-comment.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/jsx-block-comment.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/jsx-comment-after-jsx.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/jsx-comment-after-self-closing-jsx.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/jsx-tag-comments.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/jsx-text-with-multiline-non-comment.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/jsx-text-with-url.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/jsx-with-greather-than.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/jsx-with-operators.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/line-comment-with-block-syntax.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/mix-line-and-block-comments.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/no-comment-regex.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/no-comment-template.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/surrounding-call-comments.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/surrounding-debugger-comments.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/surrounding-return-comments.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/surrounding-throw-comments.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/surrounding-while-loop-comments.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/switch-fallthrough-comment-in-function.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/switch-fallthrough-comment.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/switch-no-default-comment-in-function.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/switch-no-default-comment-in-nested-functions.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/switch-no-default-comment.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/template-string-block.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/comments/type-assertion-regression-test.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrayLiteral/array-literal-in-lhs.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrayLiteral/array-literals-in-binary-expr.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/as-param-with-params.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/as-param.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/basic-in-binary-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/basic.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/block-body-not-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/block-body.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-dup-params.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-missing-paren.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-not-arrow.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-numeric-param-multi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-numeric-param.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-reverse-arrow.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-strict-default-param-eval.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-strict-dup-params.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-strict-eval-return.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-strict-eval.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-strict-octal.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-strict-param-arguments.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-strict-param-eval.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-strict-param-names.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-strict-param-no-paren-arguments.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-strict-param-no-paren-eval.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-two-lines.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/error-wrapped-param.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/iife.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/multiple-params.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/no-auto-return.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/not-strict-arguments.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/not-strict-eval-params.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/not-strict-eval.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/not-strict-octal.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/return-arrow-function.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/return-sequence.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/single-param-parens.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/single-param-return-identifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/arrowFunctions/single-param.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/basics/and-operator-array-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/basics/delete-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/basics/do-while-statements.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/basics/identifiers-double-underscore.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/basics/instanceof.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/basics/new-with-member-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/basics/new-without-parens.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/basics/or-operator-array-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/basics/typeof-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/basics/update-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/basics/void-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/bigIntLiterals/binary.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/bigIntLiterals/decimal.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/bigIntLiterals/hex.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/bigIntLiterals/octal.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/binaryLiterals/invalid.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/binaryLiterals/lowercase.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/binaryLiterals/uppercase.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/blockBindings/const.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/blockBindings/let-in-switchcase.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/blockBindings/let.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/callExpression/call-expression-with-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/callExpression/call-expression-with-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/callExpression/mixed-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/callExpression/new-expression-with-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/callExpression/new-expression-with-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-accessor-properties.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-computed-static-method.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-method-named-prototype.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-method-named-static.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-method-named-with-space.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-one-method-super.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-one-method.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-static-method-named-prototype.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-static-method-named-static.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-static-method.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-static-methods-and-accessor-properties.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-two-computed-static-methods.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-two-methods-computed-constructor.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-two-methods-semi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-two-methods-three-semi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-two-methods-two-semi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-two-methods.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-two-static-methods-named-constructor.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-with-constructor-parameters.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-with-constructor-with-space.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/class-with-constructor.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/derived-class-assign-to-var.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/derived-class-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/empty-class-double-semi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/empty-class-semi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/empty-class.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/empty-literal-derived-class.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/invalid-class-declaration.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/invalid-class-setter-declaration.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/invalid-class-two-super-classes.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/named-class-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/classes/named-derived-class-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/defaultParams/class-constructor.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/defaultParams/class-method.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/defaultParams/declaration.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/defaultParams/expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/defaultParams/method.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/defaultParams/not-all-params.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-object-named.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-object-nested.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-blockBindings/array-const-undefined.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-blockBindings/array-let-undefined.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-blockBindings/object-const-named.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-blockBindings/object-const-undefined.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-blockBindings/object-let-named.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-blockBindings/object-let-undefined.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-defaultParams/param-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-defaultParams/param-object-short.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-defaultParams/param-object-wrapped.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-defaultParams/param-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-forOf/loop.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-spread/complex-destructured.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-spread/destructured-array-literal.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-spread/destructuring-param.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-spread/error-complex-destructured-spread-first.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-spread/invalid-not-final-array-empty.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-spread/multi-destructured.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-spread/not-final-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-spread/single-destructured.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-spread/var-complex-destructured.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-spread/var-destructured-array-literal.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-spread/var-multi-destructured.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring-and-spread/var-single-destructured.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/array-member.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/array-to-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/array-var-undefined.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/call-expression-destruction-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/call-expression-destruction-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/class-constructor-params-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/class-constructor-params-defaults-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/class-constructor-params-defaults-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/class-constructor-params-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/class-method-params-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/class-method-params-defaults-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/class-method-params-defaults-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/class-method-params-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-array-all.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-array-longform-nested-multi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-array-multi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-array-nested-all.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-array-nested-multi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-object-all.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-object-assign.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-object-longform-all.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-object-longform-multi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-object-longform.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-object-mixed-multi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-object-multi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-object-nested-all.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-object-nested-multi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/defaults-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/destructured-array-catch.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/destructured-object-catch.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/invalid-defaults-object-assign.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/named-param.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/nested-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/nested-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/object-var-named.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/object-var-undefined.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/param-defaults-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/param-defaults-object-nested.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/param-defaults-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/params-array-wrapped.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/params-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/params-multi-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/params-nested-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/params-nested-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/params-object-wrapped.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/params-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/destructuring/sparse-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/directives/block.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/directives/directive-in-class.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/directives/first-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/directives/function-non-strict.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/directives/non-directive-string.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/directives/non-unique-directive.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/directives/program-order.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/directives/program.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/directives/raw.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalAsyncIteration/async-generators.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalAsyncIteration/async-iterator.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalDynamicImport/dynamic-import.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/arg-spread.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/destructuring-assign-mirror.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/function-parameter-object-spread.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/invalid-rest-trailing-comma.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/invalid-rest.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/object-rest.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/property-spread.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/shorthand-method-args.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/shorthand-methods.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/shorthand-properties.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/single-spread.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/spread-trailing-comma.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalObjectRestSpread/two-spread.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalOptionalCatchBinding/optional-catch-binding-finally.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/experimentalOptionalCatchBinding/optional-catch-binding.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/exponentiationOperators/exponential-operators.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/for/for-empty.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/for/for-loop.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/for/for-with-coma.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/for/for-with-const.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/for/for-with-function.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/for/for-with-let.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forIn/for-in-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forIn/for-in-bare-nonstrict.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forIn/for-in-destruction-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forIn/for-in-destruction.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forIn/for-in-object-with-body.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forIn/for-in-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forIn/for-in-with-assigment.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forIn/for-in-with-bare-assigment.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forIn/for-in-with-const.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forIn/for-in-with-milti-asigment.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forIn/for-in-with-rest.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forIn/for-in-with-var.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forOf/for-of-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forOf/for-of-destruction-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forOf/for-of-destruction.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forOf/for-of-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forOf/for-of-with-function-initializer.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forOf/for-of-with-rest.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forOf/for-of-with-var-and-braces.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forOf/for-of-with-var-and-no-braces.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forOf/invalid-for-of-with-const-and-no-braces.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/forOf/invalid-for-of-with-let-and-no-braces.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/generators/anonymous-generator.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/generators/async-generator-function.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/generators/async-generator-method.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/generators/double-yield.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/generators/empty-generator-declaration.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/generators/generator-declaration.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/generators/yield-delegation.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/generators/yield-without-value-in-call.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/generators/yield-without-value-no-semi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/generators/yield-without-value.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/globalReturn/return-identifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/globalReturn/return-no-arg.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/globalReturn/return-true.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/hexLiterals/invalid.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/hexLiterals/lowercase.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/hexLiterals/uppercase.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/importMeta/simple-import-meta.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/labels/label-break.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/labels/label-continue.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/error-delete.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/error-function.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/error-strict.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-default-array.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-default-class.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-default-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-default-function.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-default-named-class.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-default-named-function.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-default-number.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-default-object.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-default-value.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-from-batch.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-from-default.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-from-named-as-default.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-from-named-as-specifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-from-named-as-specifiers.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-from-specifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-from-specifiers.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-function.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-named-as-default.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-named-as-specifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-named-as-specifiers.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-named-class.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-named-empty.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-named-specifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-named-specifiers-comma.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-named-specifiers.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-var-anonymous-function.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-var-number.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/export-var.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-default-and-named-specifiers.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-default-and-namespace-specifiers.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-default-as.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-default.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-jquery.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-module.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-named-as-specifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-named-as-specifiers.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-named-empty.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-named-specifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-named-specifiers-comma.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-named-specifiers.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-namespace-specifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/import-null-as-nil.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-await.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-class.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-export-batch-missing-from-clause.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-export-batch-token.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-export-default-equal.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-export-default-token.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-export-default.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-export-named-default.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-export-named-extra-comma.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-export-named-middle-comma.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-default-after-named-after-default.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-default-after-named.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-default-missing-module-specifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-default-module-specifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-default.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-missing-module-specifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-module-specifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-named-after-named.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-named-after-namespace.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-named-as-missing-from.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-named-extra-comma.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-named-middle-comma.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-namespace-after-named.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/modules/invalid-import-namespace-missing-as.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/newTarget/invalid-new-target.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/newTarget/invalid-unknown-property.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/newTarget/simple-new-target.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteral/object-literal-in-lhs.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralComputedProperties/computed-addition-property.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralComputedProperties/computed-and-identifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralComputedProperties/computed-getter-and-setter.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralComputedProperties/computed-string-property.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralComputedProperties/computed-variable-property.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralComputedProperties/invalid-computed-variable-property.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralComputedProperties/invalid-standalone-computed-variable-property.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralComputedProperties/standalone-expression-with-addition.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralComputedProperties/standalone-expression-with-method.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralComputedProperties/standalone-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralDuplicateProperties/error-proto-property.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralDuplicateProperties/error-proto-string-property.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralDuplicateProperties/strict-duplicate-properties.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralDuplicateProperties/strict-duplicate-string-properties.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralShorthandMethods/invalid-method-no-braces.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralShorthandMethods/method-property.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralShorthandMethods/simple-method-named-get.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralShorthandMethods/simple-method-named-set.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralShorthandMethods/simple-method-with-argument.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralShorthandMethods/simple-method-with-string-name.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralShorthandMethods/simple-method.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralShorthandMethods/string-name-method-property.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/objectLiteralShorthandProperties/shorthand-properties.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/octalLiterals/invalid.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/octalLiterals/legacy.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/octalLiterals/lowercase.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/octalLiterals/strict-uppercase.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/octalLiterals/uppercase.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/regex/regexp-simple.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/regexUFlag/regex-u-extended-escape.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/regexUFlag/regex-u-invalid-extended-escape.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/regexUFlag/regex-u-simple.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/regexYFlag/regexp-y-simple.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/restParams/basic-rest.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/restParams/class-constructor.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/restParams/class-method.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/restParams/error-no-default.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/restParams/error-not-last.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/restParams/func-expression-multi.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/restParams/func-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/restParams/invalid-rest-param.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/restParams/single-rest.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/simple-literals/literal-float-negative.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/simple-literals/literal-float.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/simple-literals/literal-null.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/simple-literals/literal-number-negative.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/simple-literals/literal-number.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/simple-literals/literal-string.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/simple-literals/literal-undefined.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/spread/complex-spread.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/spread/error-invalid-if.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/spread/error-invalid-sequence.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/spread/multi-function-call.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/spread/not-final-param.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/spread/simple-function-call.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/templateStrings/deeply-nested.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/templateStrings/error-octal-literal.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/templateStrings/escape-characters.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/templateStrings/expressions.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/templateStrings/multi-line-template-string.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/templateStrings/simple-template-string.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/templateStrings/single-dollar-sign.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/templateStrings/tagged-no-placeholders.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/templateStrings/tagged-template-string.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/unicodeCodePointEscapes/basic-string-literal.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/unicodeCodePointEscapes/complex-string-literal.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/unicodeCodePointEscapes/invalid-empty-escape.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/javascript/unicodeCodePointEscapes/invalid-too-large-escape.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx-useJSXTextNode/self-closing-tag-inside-tag.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx-useJSXTextNode/test-content.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/attributes.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/element-keyword-name.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/embedded-comment.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/embedded-conditional.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/embedded-invalid-js-identifier.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/embedded-tags.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/empty-placeholder.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/escape-patterns.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-attribute-missing-equals.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-attribute.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-broken-tag.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-computed-end-tag-name.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-computed-string-end-tag-name.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-embedded-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-leading-dot-tag-name.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-matching-placeholder-in-closing-tag.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-mismatched-closing-tag.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-mismatched-closing-tags.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-mismatched-dot-tag-name.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-mismatched-namespace-tag.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-missing-closing-tag-attribute-placeholder.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-missing-closing-tag.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-missing-namespace-name.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-missing-namespace-value.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-missing-spread-operator.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-namespace-name-with-docts.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-namespace-value-with-dots.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-no-common-parent-with-comment.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-no-common-parent.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-no-tag-name.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-placeholder-in-closing-tag.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-shorthand-fragment-no-closing.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-trailing-dot-tag-name.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/invalid-unexpected-comma.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/japanese-characters.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/less-than-operator.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/member-expression-this.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/member-expression.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/multiple-blank-spaces.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/namespaced-attribute-and-value-inserted.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/namespaced-name-and-attribute.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/newslines-and-entities.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/self-closing-tag-inside-tag.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/self-closing-tag-with-newline.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/self-closing-tag.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/shorthand-fragment-with-child.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/shorthand-fragment.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/spread-child.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/spread-operator-attribute-and-regular-attribute.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/spread-operator-attributes.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/tag-names-with-dots.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/tag-names-with-multi-dots.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/test-content.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/trailing-spread-operator-attribute.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/jsx/unknown-escape-pattern.src.js (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/tsx/generic-jsx-element.src.tsx (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/tsx/react-typed-props.src.tsx (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/babylon-convergence/type-parameter-whitespace-loc.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/babylon-convergence/type-parameters.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/abstract-class-with-abstract-constructor.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/abstract-class-with-abstract-method.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/abstract-class-with-abstract-properties.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/abstract-class-with-optional-method.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/abstract-interface.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/arrow-function-with-type-parameters.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/async-function-expression.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/async-function-with-var-declaration.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/call-signatures-with-generics.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/call-signatures.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/cast-as-expression.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/cast-as-multi-assign.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/cast-as-multi.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/cast-as-operator.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/cast-as-simple.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-multi-line-keyword-abstract.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-multi-line-keyword-declare.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-accessibility-modifiers.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-constructor-and-modifier.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-constructor-and-return-type.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-constructor-and-type-parameters.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-definite-assignment.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-export-parameter-properties.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-extends-and-implements.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-extends-generic-multiple.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-extends-generic.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-generic-method-default.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-generic-method.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-implements-and-extends.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-implements-generic-multiple.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-implements-generic.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-implements.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-method.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-mixin-reference.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-mixin.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-optional-computed-property.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-optional-methods.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-optional-properties.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-optional-property-undefined.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-private-parameter-properties.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-property-function.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-property-values.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-protected-parameter-properties.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-public-parameter-properties.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-readonly-parameter-properties.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-readonly-property.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-static-parameter-properties.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-two-methods-computed-constructor.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-type-parameter-default.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-type-parameter-underscore.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/class-with-type-parameter.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/const-enum.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/declare-class-with-optional-method.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/declare-function.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/destructuring-assignment-nested.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/destructuring-assignment-object.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/destructuring-assignment-property.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/destructuring-assignment.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/directive-in-module.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/directive-in-namespace.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/export-as-namespace.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/export-assignment.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/export-declare-const-named-enum.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/export-declare-named-enum.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/export-default-class-with-generic.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/export-default-class-with-multiple-generics.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/export-named-class-with-generic.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/export-named-class-with-multiple-generics.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/export-named-enum.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/export-type-alias-declaration.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/export-type-class-declaration.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/export-type-function-declaration.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/function-overloads.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/function-with-await.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/function-with-object-type-with-optional-properties.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/function-with-object-type-without-annotation.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/function-with-type-parameters-that-have-comments.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/function-with-type-parameters-with-constraint.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/function-with-type-parameters.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/function-with-types-assignation.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/function-with-types.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/import-equal-declaration.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/import-export-equal-declaration.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/import-type-with-type-parameters-in-type-reference.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/import-type.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/interface-extends-multiple.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/interface-extends.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/interface-type-parameters.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/interface-with-all-property-types.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/interface-with-construct-signature-with-parameter-accessibility.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/interface-with-extends-member-expression.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/interface-with-extends-type-parameters.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/interface-with-generic.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/interface-with-jsdoc.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/interface-with-method.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/interface-with-optional-properties.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/interface-without-type-annotation.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/keyof-operator.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/nested-type-arguments.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/never-type-param.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/non-null-assertion-operator.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/null-and-undefined-type-annotations.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/object-with-escaped-properties.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/object-with-typed-methods.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/parenthesized-use-strict.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/symbol-type-param.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/type-alias-declaration-with-constrained-type-parameter.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/type-alias-declaration.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/type-alias-object-without-annotation.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/type-assertion-arrow-function.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/type-assertion.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/type-guard-in-arrow-function.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/type-guard-in-function.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/type-guard-in-interface.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/type-guard-in-method.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/type-parameters-comments.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/type-reference-comments.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-bigint.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-boolean.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-false.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-never.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-null.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-number.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-object.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-string.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-symbol.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-true.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-undefined.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-unknown.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-keyword-void.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-method-signature.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/typed-this.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/unique-symbol.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/unknown-type-annotation.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/var-with-definite-assignment.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/var-with-dotted-type.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/var-with-type.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/basics/variable-declaration-type-annotation-spacing.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/declare/abstract-class.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/declare/class.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/declare/enum.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/declare/function.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/declare/interface.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/declare/module.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/declare/namespace.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/declare/type-alias.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/declare/variable.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-factory-instance-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-factory-static-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-instance-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-static-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/class-decorators/class-decorator-factory.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/class-decorators/class-decorator.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/method-decorators/method-decorator-factory-instance-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/method-decorators/method-decorator-factory-static-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/method-decorators/method-decorator-instance-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/method-decorators/method-decorator-static-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-constructor.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-instance-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-static-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/property-decorators/property-decorator-factory-instance-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/property-decorators/property-decorator-factory-static-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/property-decorators/property-decorator-instance-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/decorators/property-decorators/property-decorator-static-member.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/class-empty-extends-implements.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/class-empty-extends.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/class-extends-empty-implements.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/class-multiple-implements.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/decorator-on-enum-declaration.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/decorator-on-interface-declaration.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/empty-type-arguments.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/enum-with-keywords.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/index-signature-parameters.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-empty-extends.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-implements.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-index-signature-export.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-index-signature-private.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-index-signature-protected.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-index-signature-public.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-index-signature-static.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-method-export.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-method-private.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-method-protected.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-method-public.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-method-static.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-multiple-extends.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-property-export.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-property-private.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-property-protected.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-property-public.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-property-static.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/interface-property-with-default-value.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/object-assertion-not-allowed.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/object-optional-not-allowed.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/errorRecovery/solo-const.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/expressions/call-expression-type-arguments.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/expressions/new-expression-type-arguments.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/expressions/tagged-template-expression-type-arguments.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/namespaces-and-modules/ambient-module-declaration-with-import.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/namespaces-and-modules/declare-namespace-with-exported-function.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/namespaces-and-modules/global-module-declaration.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/namespaces-and-modules/module-with-default-exports.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/namespaces-and-modules/nested-internal-module.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/namespaces-and-modules/shorthand-ambient-module-declaration.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/array-type.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/conditional-infer-nested.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/conditional-infer-simple.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/conditional-infer.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/conditional-with-null.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/conditional.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/constructor-generic.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/constructor-in-generic.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/constructor-with-rest.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/constructor.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/function-generic.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/function-in-generic.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/function-with-rest.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/function-with-this.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/function.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/index-signature-readonly.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/index-signature-without-type.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/index-signature.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/indexed.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/intersection-type.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/literal-number-negative.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/literal-number.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/literal-string.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/mapped-readonly-minus.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/mapped-readonly-plus.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/mapped-readonly.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/mapped.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/nested-types.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/parenthesized-type.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/reference-generic-nested.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/reference-generic.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/reference.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/this-type-expanded.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/this-type.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/tuple-empty.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/tuple-optional.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/tuple-rest.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/tuple-type.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/tuple.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/type-literal.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/type-operator.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/typeof.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/union-intersection.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/fixtures/typescript/types/union-type.src.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/jsx-known-issues.ts (100%) rename packages/{typescript-eslint-shared-fixtures => shared-fixtures}/package.json (100%) delete mode 100644 packages/typescript-eslint-parser/CHANGELOG.md diff --git a/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md b/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md index 45bcc4faea88..d78e999d908e 100644 --- a/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md +++ b/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md @@ -1,8 +1,8 @@ --- -name: eslint-plugin-tslint -about: Report an issue with the eslint-plugin-tslint package +name: '@typescript-eslint/eslint-plugin-tslint' +about: Report an issue with the '@typescript-eslint/eslint-plugin-tslint' package title: '' -labels: 'package: eslint-plugin-tslint, triage' +labels: 'package: @typescript-eslint/eslint-plugin-tslint, triage' assignees: '' --- @@ -13,8 +13,8 @@ assignees: '' **What version of the following packages are you using?** -- eslint-plugin-tslint: -- typescript-eslint-parser: +- @typescript-eslint/eslint-plugin-tslint: +- @typescript-eslint/parser: - TypeScript: - ESLint: diff --git a/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md b/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md index 73a267c54343..b7566c0069ca 100644 --- a/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md +++ b/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md @@ -1,6 +1,6 @@ --- -name: eslint-plugin-typescript -about: Report an issue with the eslint-plugin-typescript package +name: '@typescript-eslint/eslint-plugin' +about: Report an issue with the '@typescript-eslint/eslint-plugin' package title: '' labels: 'package: eslint-plugin, triage' assignees: '' @@ -38,8 +38,8 @@ Please try to avoid code that isn't directly related to the bug, as it makes it **Versions** -| package | version | -| -------------------------- | ------- | -| `eslint-plugin-typescript` | `X.Y.Z` | -| `typescript-eslint-parser` | `X.Y.Z` | -| `typescript` | `X.Y.Z` | +| package | version | +| ---------------------------------- | ------- | +| `@typescript-eslint/eslint-plugin` | `X.Y.Z` | +| `@typescript-eslint/parser` | `X.Y.Z` | +| `typescript` | `X.Y.Z` | diff --git a/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md b/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md index 21301124a3b6..601087f77e82 100644 --- a/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md +++ b/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md @@ -1,6 +1,6 @@ --- -name: 'typescript-eslint-parser' -about: Report an issue with the typescript-eslint-parser package +name: '@typescript-eslint/parser' +about: Report an issue with the '@typescript-eslint/parser' package title: '' labels: 'package: parser, triage' assignees: '' @@ -13,7 +13,7 @@ assignees: '' **What version of the following packages are you using?** -- typescript-eslint-parser: +- @typescript-eslint/parser: - TypeScript: - ESLint: diff --git a/.github/ISSUE_TEMPLATE/typescript-estree.md b/.github/ISSUE_TEMPLATE/typescript-estree.md index 650f84db5142..f6b12ebafe9e 100644 --- a/.github/ISSUE_TEMPLATE/typescript-estree.md +++ b/.github/ISSUE_TEMPLATE/typescript-estree.md @@ -1,6 +1,6 @@ --- -name: typescript-estree -about: Report an issue with the `typescript-estree` package +name: '@typescript-eslint/typescript-estree' +about: Report an issue with the `@typescript-eslint/typescript-estree` package title: '' labels: 'package: typescript-estree, triage' assignees: '' @@ -8,7 +8,7 @@ assignees: '' **What version of TypeScript are you using?** -**What version of `typescript-estree` are you using?** +**What version of `@typescript-eslint/typescript-estree` are you using?** **What code were you trying to parse?** diff --git a/.prettierignore b/.prettierignore index 21ee8e970ee5..49b3a61e6d8f 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,7 +1,7 @@ **/tests/fixtures/**/* **/dist **/coverage -**/typescript-eslint-shared-fixtures +**/shared-fixtures **/tests/integration/fixtures/**/* **/lib/configs/recommended.json **/.vscode diff --git a/.travis.yml b/.travis.yml index 15d701f55054..10d7a2a909e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,8 @@ install: script: - commitlint-travis - yarn check-format - - yarn workspace eslint-plugin-typescript docs:check + # TODO: Fix this check + # - yarn workspace eslint-plugin docs:check - yarn build - yarn test - yarn integration-tests @@ -29,3 +30,9 @@ after_success: branches: only: - master +deploy: + on: + branch: master + provider: script + script: npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN && npx lerna publish --canary --force-publish --yes + skip_cleanup: true diff --git a/README.md b/README.md index 19ff42e897fc..47493a417b0e 100644 --- a/README.md +++ b/README.md @@ -16,15 +16,15 @@ This repo contains several packages which allow ESLint users to lint their TypeScript code. -- [`typescript-estree`](./packages/typescript-estree/) - An entirely generic TypeScript parser which takes TypeScript source code and produces an ESTree-compatible AST

+- [`@typescript-eslint/typescript-estree`](./packages/typescript-estree/) - An entirely generic TypeScript parser which takes TypeScript source code and produces an ESTree-compatible AST

- This package is also used to power the amazing opinionated code formatter [Prettier](https://prettier.io)'s own TypeScript use-case. -- [`typescript-eslint-parser`](./packages/typescript-eslint-parser/) - An ESLint-specific parser which leverages `typescript-estree` and is designed to be used as a replacement for ESLint's default parser, `espree`. +- [`@typescript-eslint/parser`](./packages/parser/) - An ESLint-specific parser which leverages `typescript-estree` and is designed to be used as a replacement for ESLint's default parser, `espree`. -- [`eslint-plugin-typescript`](./packages/eslint-plugin-typescript/) - An ESLint-specific plugin which, when used in conjunction with `typescript-eslint-parser`, allows for TypeScript-specific linting rules to run. +- [`@typescript-eslint/eslint-plugin`](./packages/eslint-plugin/) - An ESLint-specific plugin which, when used in conjunction with `@typescript-eslint/parser`, allows for TypeScript-specific linting rules to run. -- [`eslint-plugin-tslint`](./packages/eslint-plugin-tslint) - An ESLint-specific plugin which runs an instance of TSLint within your ESLint setup to allow for users to more easily migrate from TSLint to ESLint. +- [`@typescript-eslint/eslint-plugin-tslint`](./packages/eslint-plugin-tslint) - An ESLint-specific plugin which runs an instance of TSLint within your ESLint setup to allow for users to more easily migrate from TSLint to ESLint. ## Supported TypeScript Version @@ -42,4 +42,4 @@ COMING SOON! ## License -TypeScript ESTree inherits from the the original TypeScript ESLint Parser license, as the majority of the work began there. It is licensed under a permissive BSD 2-clause license. +TypeScript ESLint inherits from the the original TypeScript ESLint Parser license, as the majority of the work began there. It is licensed under a permissive BSD 2-clause license. diff --git a/lerna.json b/lerna.json index a3794ba26608..c5fbf20147b6 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.0.0", + "version": "0.2.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/package.json b/package.json index 4b0fbbeebba4..5cb4261cb79a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "typescript-eslint", + "name": "@typescript-eslint/typescript-eslint", "private": true, "workspaces": [ "packages/*" @@ -62,7 +62,7 @@ "@types/node": "^10.12.2", "@types/semver": "^5.5.0", "cz-conventional-changelog": "2.1.0", - "eslint": "^4.19.1", + "eslint": "^5.12.1", "glob": "7.1.2", "husky": "0.14.3", "jest": "23.6.0", @@ -72,6 +72,7 @@ "prettier": "^1.14.3", "rimraf": "^2.6.3", "ts-jest": "^23.10.4", + "tslint": "^5.11.0", "typescript": "~3.2.1" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index 762c01b51ef9..e69de29bb2d1 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -1,27 +0,0 @@ -# [3.1.0](https://github.com/JamesHenry/eslint-plugin-tslint/compare/v3.0.0...v3.1.0) (2018-10-19) - -### Bug Fixes - -- Tiny lint note elimination ([a731838](https://github.com/JamesHenry/eslint-plugin-tslint/commit/a731838)) - -### Features - -- Support for tslint property ([18a4afb](https://github.com/JamesHenry/eslint-plugin-tslint/commit/18a4afb)), closes [#40](https://github.com/JamesHenry/eslint-plugin-tslint/issues/40) - -# [3.0.0](https://github.com/JamesHenry/eslint-plugin-tslint/compare/v2.1.0...v3.0.0) (2018-09-09) - -### Bug Fixes - -- Fixed bug when file not defined in tsconfig ([20b498b](https://github.com/JamesHenry/eslint-plugin-tslint/commit/20b498b)) -- Pass sourceText parameter to service getSource ([dd4c2f8](https://github.com/JamesHenry/eslint-plugin-tslint/commit/dd4c2f8)) -- Update program when sourceFile was updated ([0fe933c](https://github.com/JamesHenry/eslint-plugin-tslint/commit/0fe933c)) -- Updated typescript-service dependency ([2f4f434](https://github.com/JamesHenry/eslint-plugin-tslint/commit/2f4f434)) - -### Features - -- **core:** Added support rules requires type information ([6bc1deb](https://github.com/JamesHenry/eslint-plugin-tslint/commit/6bc1deb)), closes [#32](https://github.com/JamesHenry/eslint-plugin-tslint/issues/32) [#34](https://github.com/JamesHenry/eslint-plugin-tslint/issues/34) -- Post merge adapdation from tslint2 repository ([477c656](https://github.com/JamesHenry/eslint-plugin-tslint/commit/477c656)), closes [#32](https://github.com/JamesHenry/eslint-plugin-tslint/issues/32) [#34](https://github.com/JamesHenry/eslint-plugin-tslint/issues/34) - -### BREAKING CHANGES - -- New dependency diff --git a/packages/eslint-plugin-tslint/README.md b/packages/eslint-plugin-tslint/README.md index 388238b6a5fc..09cc6e4c0b71 100644 --- a/packages/eslint-plugin-tslint/README.md +++ b/packages/eslint-plugin-tslint/README.md @@ -1,19 +1,17 @@ # ESLint Plugin TSLint -[![Travis](https://img.shields.io/travis/JamesHenry/eslint-plugin-tslint.svg?style=flat-square)](https://travis-ci.org/JamesHenry/eslint-plugin-tslint) -[![GitHub license](https://img.shields.io/npm/l/eslint-plugin-tslint.svg?style=flat-square)](https://github.com/JamesHenry/eslint-plugin-tslint/blob/master/LICENSE) -[![NPM Version](https://img.shields.io/npm/v/eslint-plugin-tslint.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-tslint) -[![NPM Downloads](https://img.shields.io/npm/dt/eslint-plugin-tslint.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-tslint) +[![Travis](https://img.shields.io/travis/@typescript-eslint/eslint-plugin-tslint.svg?style=flat-square)](https://travis-ci.org/@typescript-eslint/eslint-plugin-tslint) +[![GitHub license](https://img.shields.io/npm/l/@typescript-eslint/eslint-plugin-tslint.svg?style=flat-square)](https://github.com/@typescript-eslint/eslint-plugin-tslint/blob/master/LICENSE) +[![NPM Version](https://img.shields.io/npm/v/@typescript-eslint/eslint-plugin-tslint.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin-tslint) +[![NPM Downloads](https://img.shields.io/npm/dt/@typescript-eslint/eslint-plugin-tslint.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin-tslint) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) -[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release) -[![greenkeeper.io](https://badges.greenkeeper.io/JamesHenry/mongoose-schema-to-typescript-interface.svg?style=flat-square)](https://greenkeeper.io) ESLint plugin wraps a TSLint configuration and lints the whole source using TSLint. ## INSTALL ``` -npm i -D eslint-plugin-tslint +npm i -D @typescript-eslint/eslint-plugin-tslint ``` ## USAGE diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 3ffb8277614c..8fe4231573e1 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { - "name": "eslint-plugin-tslint", - "version": "3.1.0", + "name": "@typescript-eslint/eslint-plugin-tslint", + "version": "0.2.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -33,7 +33,6 @@ "devDependencies": { "@types/eslint": "^4.16.3", "@types/lodash.memoize": "^4.1.4", - "typescript-eslint-parser": "21.0.2", - "tslint": "^5.11.0" + "@typescript-eslint/parser": "0.2.0" } } diff --git a/packages/eslint-plugin-tslint/src/index.ts b/packages/eslint-plugin-tslint/src/index.ts index 72d476b3b886..78e946af6294 100644 --- a/packages/eslint-plugin-tslint/src/index.ts +++ b/packages/eslint-plugin-tslint/src/index.ts @@ -98,11 +98,11 @@ export const rules = { /** * The user needs to have configured "project" in their parserOptions - * for typescript-eslint-parser + * for @typescript-eslint/parser */ if (!parserServices || !parserServices.program) { throw new Error( - `You must provide a value for the "parserOptions.project" property for typescript-eslint-parser` + `You must provide a value for the "parserOptions.project" property for @typescript-eslint/parser` ); } diff --git a/packages/eslint-plugin-tslint/tests/index.spec.ts b/packages/eslint-plugin-tslint/tests/index.spec.ts index 4b8394d20f03..1b78c3943f85 100644 --- a/packages/eslint-plugin-tslint/tests/index.spec.ts +++ b/packages/eslint-plugin-tslint/tests/index.spec.ts @@ -10,7 +10,7 @@ const parserOptions: any = { ecmaFeatures: {}, /** * Project is needed to generate the parserServices - * within typescript-eslint-parser + * within @typescript-eslint/parser */ project: './tests/tsconfig.json' }; @@ -40,7 +40,7 @@ ruleTester.run('tslint/config', rules.config, { valid: [ { code: 'var foo = true;', - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', parserOptions, options: [tslintRulesConfig] }, @@ -50,7 +50,7 @@ ruleTester.run('tslint/config', rules.config, { /\n/g, ' ' ), - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', parserOptions: { ...parserOptions, project: `${__dirname}/test-project/tsconfig.json` @@ -63,7 +63,7 @@ ruleTester.run('tslint/config', rules.config, { }, { code: 'throw "should be ok because rule is not loaded";', - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', parserOptions, options: [tslintRulesConfig] } @@ -72,7 +72,7 @@ ruleTester.run('tslint/config', rules.config, { invalid: [ { options: [{ lintFile: './tests/test-project/tslint.json' }], - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', parserOptions, code: 'throw "err" // no-string-throw', errors: [ @@ -84,7 +84,7 @@ ruleTester.run('tslint/config', rules.config, { }, { code: 'var foo = true // semicolon', - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', parserOptions, options: [tslintRulesConfig], output: 'var foo = true // semicolon', @@ -98,7 +98,7 @@ ruleTester.run('tslint/config', rules.config, { }, { code: 'var foo = true // fail', - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', parserOptions, options: [tslintRulesDirectoryConfig], output: 'var foo = true // fail', @@ -116,7 +116,7 @@ ruleTester.run('tslint/config', rules.config, { /\n/g, ' ' ), - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', parserOptions: { ...parserOptions, project: `${__dirname}/test-project/tsconfig.json` diff --git a/packages/eslint-plugin-typescript/lib/configs/recommended.json b/packages/eslint-plugin-typescript/lib/configs/recommended.json deleted file mode 100644 index 44d970341802..000000000000 --- a/packages/eslint-plugin-typescript/lib/configs/recommended.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "parser": "eslint-plugin-typescript/parser", - "parserOptions": { - "sourceType": "module" - }, - "plugins": [ - "typescript" - ], - "rules": { - "typescript/adjacent-overload-signatures": "error", - "typescript/array-type": "error", - "typescript/ban-types": "error", - "camelcase": "off", - "typescript/camelcase": "error", - "typescript/class-name-casing": "error", - "typescript/explicit-function-return-type": "warn", - "typescript/explicit-member-accessibility": "error", - "indent": "off", - "typescript/indent": "error", - "typescript/interface-name-prefix": "error", - "typescript/member-delimiter-style": "error", - "typescript/no-angle-bracket-type-assertion": "error", - "no-array-constructor": "off", - "typescript/no-array-constructor": "error", - "typescript/no-empty-interface": "error", - "typescript/no-explicit-any": "warn", - "typescript/no-inferrable-types": "error", - "typescript/no-misused-new": "error", - "typescript/no-namespace": "error", - "typescript/no-non-null-assertion": "error", - "typescript/no-object-literal-type-assertion": "error", - "typescript/no-parameter-properties": "error", - "typescript/no-triple-slash-reference": "error", - "no-unused-vars": "off", - "typescript/no-unused-vars": "warn", - "typescript/no-use-before-define": "error", - "typescript/no-var-requires": "error", - "typescript/prefer-interface": "error", - "typescript/prefer-namespace-keyword": "error", - "typescript/type-annotation-spacing": "error" - } -} diff --git a/packages/eslint-plugin-typescript/.npmignore b/packages/eslint-plugin/.npmignore similarity index 100% rename from packages/eslint-plugin-typescript/.npmignore rename to packages/eslint-plugin/.npmignore diff --git a/packages/eslint-plugin-typescript/LICENSE b/packages/eslint-plugin/LICENSE similarity index 100% rename from packages/eslint-plugin-typescript/LICENSE rename to packages/eslint-plugin/LICENSE diff --git a/packages/eslint-plugin-typescript/README.md b/packages/eslint-plugin/README.md similarity index 85% rename from packages/eslint-plugin-typescript/README.md rename to packages/eslint-plugin/README.md index 94306e30dcef..82e116951b03 100644 --- a/packages/eslint-plugin-typescript/README.md +++ b/packages/eslint-plugin/README.md @@ -1,12 +1,8 @@ -# eslint-plugin-typescript +# @typescript-eslint/eslint-plugin -[![NPM version](https://img.shields.io/npm/v/eslint-plugin-typescript.svg)](https://www.npmjs.com/package/eslint-plugin-typescript) -[![NPM downloads](https://img.shields.io/npm/dm/eslint-plugin-typescript.svg)](https://www.npmjs.com/package/eslint-plugin-typescript) -[![TravisCI](https://img.shields.io/travis/bradzacher/eslint-plugin-typescript.svg)](https://travis-ci.com/bradzacher/eslint-plugin-typescript) - -TypeScript support for ESLint. (This is still in the very early stages, so please be patient.) - -### The below readme is for the upcoming 1.0.0 release. [Please see this tag for the current NPM version (0.14.0)](https://github.com/bradzacher/eslint-plugin-typescript/tree/0.14.0) +[![NPM version](https://img.shields.io/npm/v/@typescript-eslint/eslint-plugin.svg)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) +[![NPM downloads](https://img.shields.io/npm/dm/@typescript-eslint/eslint-plugin.svg)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) +[![TravisCI](https://img.shields.io/travis/@typescript-eslint/eslint-plugin.svg)](https://travis-ci.com/@typescript-eslint/eslint-plugin) ## Installation @@ -22,33 +18,33 @@ Next, install `typescript` if you haven’t already: $ npm i typescript@~3.1.1 --save-dev ``` -Last, install `eslint-plugin-typescript`: +Last, install `@typescript-eslint/eslint-plugin`: ```shellsession -$ npm install eslint-plugin-typescript --save-dev +$ npm install @typescript-eslint/eslint-plugin --save-dev ``` -**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-typescript` globally. +**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `@typescript-eslint/eslint-plugin` globally. ## Usage -Add `eslint-plugin-typescript/parser` to the `parser` field and `typescript` to the plugins section of your `.eslintrc` configuration file: +Add `@typescript-eslint/eslint-plugin/parser` to the `parser` field and `typescript` to the plugins section of your `.eslintrc` configuration file: ```json { - "parser": "eslint-plugin-typescript/parser", + "parser": "@typescript-eslint/eslint-plugin/parser", "plugins": ["typescript"] } ``` -Note: The plugin provides its own version of the `typescript-eslint-parser` via `eslint-plugin-typescript/parser`. +Note: The plugin provides its own version of the `@typescript-eslint/parser` via `@typescript-eslint/eslint-plugin/parser`. This helps us guarantee 100% compatibility between the plugin and the parser. Then configure the rules you want to use under the rules section. ```json { - "parser": "eslint-plugin-typescript/parser", + "parser": "@typescript-eslint/eslint-plugin/parser", "plugins": ["typescript"], "rules": { "typescript/rule-name": "error" diff --git a/packages/eslint-plugin-typescript/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md similarity index 94% rename from packages/eslint-plugin-typescript/ROADMAP.md rename to packages/eslint-plugin/ROADMAP.md index 052ff7cdcb6c..eb0cf5e33ec4 100644 --- a/packages/eslint-plugin-typescript/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -555,36 +555,36 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- [no-with]: https://eslint.org/docs/rules/no-with [no-warning-comments]: https://eslint.org/docs/rules/no-warning-comments - - -[`typescript/adjacent-overload-signatures`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/adjacent-overload-signatures.md -[`typescript/ban-types`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/ban-types.md -[`typescript/explicit-member-accessibility`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/explicit-member-accessibility.md -[`typescript/member-ordering`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/member-ordering.md -[`typescript/no-explicit-any`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-explicit-any.md -[`typescript/no-empty-interface`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-empty-interface.md -[`typescript/no-inferrable-types`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-inferrable-types.md -[`typescript/prefer-namespace-keyword`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/prefer-namespace-keyword.md -[`typescript/no-namespace`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-namespace.md -[`typescript/no-non-null-assertion`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-non-null-assertion.md -[`typescript/no-triple-slash-reference`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-triple-slash-reference.md -[`typescript/no-var-requires`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-var-requires.md -[`typescript/type-annotation-spacing`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/type-annotation-spacing.md -[`typescript/no-misused-new`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-misused-new.md -[`typescript/no-object-literal-type-assertion`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-object-literal-type-assertion.md -[`typescript/no-this-alias`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-this-alias.md -[`typescript/no-extraneous-class`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-extraneous-class.md -[`typescript/no-unused-vars`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-unused-vars.md -[`typescript/no-use-before-define`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-use-before-define.md -[`typescript/indent`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/indent.md -[`typescript/array-type`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/array-type.md -[`typescript/class-name-casing`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/class-name-casing.md -[`typescript/interface-name-prefix`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/interface-name-prefix.md -[`typescript/no-angle-bracket-type-assertion`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-angle-bracket-type-assertion.md -[`typescript/no-parameter-properties`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-parameter-properties.md -[`typescript/member-delimiter-style`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/member-delimiter-style.md -[`typescript/prefer-interface`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/prefer-interface.md -[`typescript/no-array-constructor`]: https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-array-constructor.md + + +[`typescript/adjacent-overload-signatures`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/adjacent-overload-signatures.md +[`typescript/ban-types`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/ban-types.md +[`typescript/explicit-member-accessibility`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/explicit-member-accessibility.md +[`typescript/member-ordering`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/member-ordering.md +[`typescript/no-explicit-any`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-explicit-any.md +[`typescript/no-empty-interface`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-empty-interface.md +[`typescript/no-inferrable-types`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-inferrable-types.md +[`typescript/prefer-namespace-keyword`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/prefer-namespace-keyword.md +[`typescript/no-namespace`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-namespace.md +[`typescript/no-non-null-assertion`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-non-null-assertion.md +[`typescript/no-triple-slash-reference`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-triple-slash-reference.md +[`typescript/no-var-requires`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-var-requires.md +[`typescript/type-annotation-spacing`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/type-annotation-spacing.md +[`typescript/no-misused-new`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-misused-new.md +[`typescript/no-object-literal-type-assertion`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-object-literal-type-assertion.md +[`typescript/no-this-alias`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-this-alias.md +[`typescript/no-extraneous-class`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-extraneous-class.md +[`typescript/no-unused-vars`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-unused-vars.md +[`typescript/no-use-before-define`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-use-before-define.md +[`typescript/indent`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/indent.md +[`typescript/array-type`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/array-type.md +[`typescript/class-name-casing`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/class-name-casing.md +[`typescript/interface-name-prefix`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/interface-name-prefix.md +[`typescript/no-angle-bracket-type-assertion`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-angle-bracket-type-assertion.md +[`typescript/no-parameter-properties`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-parameter-properties.md +[`typescript/member-delimiter-style`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/member-delimiter-style.md +[`typescript/prefer-interface`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/prefer-interface.md +[`typescript/no-array-constructor`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-array-constructor.md diff --git a/packages/eslint-plugin-typescript/docs/rules/adjacent-overload-signatures.md b/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/adjacent-overload-signatures.md rename to packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md diff --git a/packages/eslint-plugin-typescript/docs/rules/array-type.md b/packages/eslint-plugin/docs/rules/array-type.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/array-type.md rename to packages/eslint-plugin/docs/rules/array-type.md diff --git a/packages/eslint-plugin-typescript/docs/rules/ban-types.md b/packages/eslint-plugin/docs/rules/ban-types.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/ban-types.md rename to packages/eslint-plugin/docs/rules/ban-types.md diff --git a/packages/eslint-plugin-typescript/docs/rules/camelcase.md b/packages/eslint-plugin/docs/rules/camelcase.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/camelcase.md rename to packages/eslint-plugin/docs/rules/camelcase.md diff --git a/packages/eslint-plugin-typescript/docs/rules/class-name-casing.md b/packages/eslint-plugin/docs/rules/class-name-casing.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/class-name-casing.md rename to packages/eslint-plugin/docs/rules/class-name-casing.md diff --git a/packages/eslint-plugin-typescript/docs/rules/explicit-function-return-type.md b/packages/eslint-plugin/docs/rules/explicit-function-return-type.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/explicit-function-return-type.md rename to packages/eslint-plugin/docs/rules/explicit-function-return-type.md diff --git a/packages/eslint-plugin-typescript/docs/rules/explicit-member-accessibility.md b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/explicit-member-accessibility.md rename to packages/eslint-plugin/docs/rules/explicit-member-accessibility.md diff --git a/packages/eslint-plugin-typescript/docs/rules/generic-type-naming.md b/packages/eslint-plugin/docs/rules/generic-type-naming.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/generic-type-naming.md rename to packages/eslint-plugin/docs/rules/generic-type-naming.md diff --git a/packages/eslint-plugin-typescript/docs/rules/indent.md b/packages/eslint-plugin/docs/rules/indent.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/indent.md rename to packages/eslint-plugin/docs/rules/indent.md diff --git a/packages/eslint-plugin-typescript/docs/rules/interface-name-prefix.md b/packages/eslint-plugin/docs/rules/interface-name-prefix.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/interface-name-prefix.md rename to packages/eslint-plugin/docs/rules/interface-name-prefix.md diff --git a/packages/eslint-plugin-typescript/docs/rules/member-delimiter-style.md b/packages/eslint-plugin/docs/rules/member-delimiter-style.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/member-delimiter-style.md rename to packages/eslint-plugin/docs/rules/member-delimiter-style.md diff --git a/packages/eslint-plugin-typescript/docs/rules/member-naming.md b/packages/eslint-plugin/docs/rules/member-naming.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/member-naming.md rename to packages/eslint-plugin/docs/rules/member-naming.md diff --git a/packages/eslint-plugin-typescript/docs/rules/member-ordering.md b/packages/eslint-plugin/docs/rules/member-ordering.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/member-ordering.md rename to packages/eslint-plugin/docs/rules/member-ordering.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-angle-bracket-type-assertion.md b/packages/eslint-plugin/docs/rules/no-angle-bracket-type-assertion.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-angle-bracket-type-assertion.md rename to packages/eslint-plugin/docs/rules/no-angle-bracket-type-assertion.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-array-constructor.md b/packages/eslint-plugin/docs/rules/no-array-constructor.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-array-constructor.md rename to packages/eslint-plugin/docs/rules/no-array-constructor.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-empty-interface.md b/packages/eslint-plugin/docs/rules/no-empty-interface.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-empty-interface.md rename to packages/eslint-plugin/docs/rules/no-empty-interface.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-explicit-any.md b/packages/eslint-plugin/docs/rules/no-explicit-any.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-explicit-any.md rename to packages/eslint-plugin/docs/rules/no-explicit-any.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-extraneous-class.md b/packages/eslint-plugin/docs/rules/no-extraneous-class.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-extraneous-class.md rename to packages/eslint-plugin/docs/rules/no-extraneous-class.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-inferrable-types.md b/packages/eslint-plugin/docs/rules/no-inferrable-types.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-inferrable-types.md rename to packages/eslint-plugin/docs/rules/no-inferrable-types.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-misused-new.md b/packages/eslint-plugin/docs/rules/no-misused-new.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-misused-new.md rename to packages/eslint-plugin/docs/rules/no-misused-new.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-namespace.md b/packages/eslint-plugin/docs/rules/no-namespace.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-namespace.md rename to packages/eslint-plugin/docs/rules/no-namespace.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-non-null-assertion.md b/packages/eslint-plugin/docs/rules/no-non-null-assertion.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-non-null-assertion.md rename to packages/eslint-plugin/docs/rules/no-non-null-assertion.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-object-literal-type-assertion.md b/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-object-literal-type-assertion.md rename to packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-parameter-properties.md b/packages/eslint-plugin/docs/rules/no-parameter-properties.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-parameter-properties.md rename to packages/eslint-plugin/docs/rules/no-parameter-properties.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-this-alias.md b/packages/eslint-plugin/docs/rules/no-this-alias.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-this-alias.md rename to packages/eslint-plugin/docs/rules/no-this-alias.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-triple-slash-reference.md b/packages/eslint-plugin/docs/rules/no-triple-slash-reference.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-triple-slash-reference.md rename to packages/eslint-plugin/docs/rules/no-triple-slash-reference.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-type-alias.md b/packages/eslint-plugin/docs/rules/no-type-alias.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-type-alias.md rename to packages/eslint-plugin/docs/rules/no-type-alias.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-unused-vars.md b/packages/eslint-plugin/docs/rules/no-unused-vars.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-unused-vars.md rename to packages/eslint-plugin/docs/rules/no-unused-vars.md diff --git a/packages/eslint-plugin-typescript/docs/rules/no-use-before-define.md b/packages/eslint-plugin/docs/rules/no-use-before-define.md similarity index 98% rename from packages/eslint-plugin-typescript/docs/rules/no-use-before-define.md rename to packages/eslint-plugin/docs/rules/no-use-before-define.md index 553924c9c567..d439d0111a00 100644 --- a/packages/eslint-plugin-typescript/docs/rules/no-use-before-define.md +++ b/packages/eslint-plugin/docs/rules/no-use-before-define.md @@ -88,7 +88,7 @@ let myVar: StringOrNumber; If this is `true`, the rule warns every reference to a variable before the variable declaration. Otherwise, the rule ignores a reference if the declaration is in an upper scope, while still reporting the reference if it's in the same scope as the declaration. Default is `true`. -- `typedefs` (`boolean`, **added** in `eslint-plugin-typescript`) - +- `typedefs` (`boolean`, **added** in `@typescript-eslint/eslint-plugin`) - The flag which shows whether or not this rule checks type declarations. If this is `true`, this rule warns every reference to a type before the type declaration. Otherwise, ignores those references. diff --git a/packages/eslint-plugin-typescript/docs/rules/no-var-requires.md b/packages/eslint-plugin/docs/rules/no-var-requires.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/no-var-requires.md rename to packages/eslint-plugin/docs/rules/no-var-requires.md diff --git a/packages/eslint-plugin-typescript/docs/rules/prefer-interface.md b/packages/eslint-plugin/docs/rules/prefer-interface.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/prefer-interface.md rename to packages/eslint-plugin/docs/rules/prefer-interface.md diff --git a/packages/eslint-plugin-typescript/docs/rules/prefer-namespace-keyword.md b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/prefer-namespace-keyword.md rename to packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md diff --git a/packages/eslint-plugin-typescript/docs/rules/type-annotation-spacing.md b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md similarity index 100% rename from packages/eslint-plugin-typescript/docs/rules/type-annotation-spacing.md rename to packages/eslint-plugin/docs/rules/type-annotation-spacing.md diff --git a/packages/eslint-plugin-typescript/jest.config.js b/packages/eslint-plugin/jest.config.js similarity index 100% rename from packages/eslint-plugin-typescript/jest.config.js rename to packages/eslint-plugin/jest.config.js diff --git a/packages/eslint-plugin/lib/configs/recommended.json b/packages/eslint-plugin/lib/configs/recommended.json new file mode 100644 index 000000000000..77b6e55d31c9 --- /dev/null +++ b/packages/eslint-plugin/lib/configs/recommended.json @@ -0,0 +1,42 @@ +{ + "parser": "@typescript-eslint/eslint-plugin/parser", + "parserOptions": { + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "@typescript-eslint/adjacent-overload-signatures": "error", + "@typescript-eslint/array-type": "error", + "@typescript-eslint/ban-types": "error", + "camelcase": "off", + "@typescript-eslint/camelcase": "error", + "@typescript-eslint/class-name-casing": "error", + "@typescript-eslint/explicit-function-return-type": "warn", + "@typescript-eslint/explicit-member-accessibility": "error", + "indent": "off", + "@typescript-eslint/indent": "error", + "@typescript-eslint/interface-name-prefix": "error", + "@typescript-eslint/member-delimiter-style": "error", + "@typescript-eslint/no-angle-bracket-type-assertion": "error", + "no-array-constructor": "off", + "@typescript-eslint/no-array-constructor": "error", + "@typescript-eslint/no-empty-interface": "error", + "@typescript-eslint/no-explicit-any": "warn", + "@typescript-eslint/no-inferrable-types": "error", + "@typescript-eslint/no-misused-new": "error", + "@typescript-eslint/no-namespace": "error", + "@typescript-eslint/no-non-null-assertion": "error", + "@typescript-eslint/no-object-literal-type-assertion": "error", + "@typescript-eslint/no-parameter-properties": "error", + "@typescript-eslint/no-triple-slash-reference": "error", + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": "warn", + "@typescript-eslint/no-use-before-define": "error", + "@typescript-eslint/no-var-requires": "error", + "@typescript-eslint/prefer-interface": "error", + "@typescript-eslint/prefer-namespace-keyword": "error", + "@typescript-eslint/type-annotation-spacing": "error" + } +} diff --git a/packages/eslint-plugin-typescript/lib/index.js b/packages/eslint-plugin/lib/index.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/index.js rename to packages/eslint-plugin/lib/index.js diff --git a/packages/eslint-plugin-typescript/lib/rules/adjacent-overload-signatures.js b/packages/eslint-plugin/lib/rules/adjacent-overload-signatures.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/adjacent-overload-signatures.js rename to packages/eslint-plugin/lib/rules/adjacent-overload-signatures.js diff --git a/packages/eslint-plugin-typescript/lib/rules/array-type.js b/packages/eslint-plugin/lib/rules/array-type.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/array-type.js rename to packages/eslint-plugin/lib/rules/array-type.js diff --git a/packages/eslint-plugin-typescript/lib/rules/ban-types.js b/packages/eslint-plugin/lib/rules/ban-types.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/ban-types.js rename to packages/eslint-plugin/lib/rules/ban-types.js diff --git a/packages/eslint-plugin-typescript/lib/rules/camelcase.js b/packages/eslint-plugin/lib/rules/camelcase.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/camelcase.js rename to packages/eslint-plugin/lib/rules/camelcase.js diff --git a/packages/eslint-plugin-typescript/lib/rules/class-name-casing.js b/packages/eslint-plugin/lib/rules/class-name-casing.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/class-name-casing.js rename to packages/eslint-plugin/lib/rules/class-name-casing.js diff --git a/packages/eslint-plugin-typescript/lib/rules/explicit-function-return-type.js b/packages/eslint-plugin/lib/rules/explicit-function-return-type.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/explicit-function-return-type.js rename to packages/eslint-plugin/lib/rules/explicit-function-return-type.js diff --git a/packages/eslint-plugin-typescript/lib/rules/explicit-member-accessibility.js b/packages/eslint-plugin/lib/rules/explicit-member-accessibility.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/explicit-member-accessibility.js rename to packages/eslint-plugin/lib/rules/explicit-member-accessibility.js diff --git a/packages/eslint-plugin-typescript/lib/rules/generic-type-naming.js b/packages/eslint-plugin/lib/rules/generic-type-naming.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/generic-type-naming.js rename to packages/eslint-plugin/lib/rules/generic-type-naming.js diff --git a/packages/eslint-plugin-typescript/lib/rules/indent.js b/packages/eslint-plugin/lib/rules/indent.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/indent.js rename to packages/eslint-plugin/lib/rules/indent.js diff --git a/packages/eslint-plugin-typescript/lib/rules/interface-name-prefix.js b/packages/eslint-plugin/lib/rules/interface-name-prefix.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/interface-name-prefix.js rename to packages/eslint-plugin/lib/rules/interface-name-prefix.js diff --git a/packages/eslint-plugin-typescript/lib/rules/member-delimiter-style.js b/packages/eslint-plugin/lib/rules/member-delimiter-style.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/member-delimiter-style.js rename to packages/eslint-plugin/lib/rules/member-delimiter-style.js diff --git a/packages/eslint-plugin-typescript/lib/rules/member-naming.js b/packages/eslint-plugin/lib/rules/member-naming.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/member-naming.js rename to packages/eslint-plugin/lib/rules/member-naming.js diff --git a/packages/eslint-plugin-typescript/lib/rules/member-ordering.js b/packages/eslint-plugin/lib/rules/member-ordering.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/member-ordering.js rename to packages/eslint-plugin/lib/rules/member-ordering.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-angle-bracket-type-assertion.js b/packages/eslint-plugin/lib/rules/no-angle-bracket-type-assertion.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-angle-bracket-type-assertion.js rename to packages/eslint-plugin/lib/rules/no-angle-bracket-type-assertion.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-array-constructor.js b/packages/eslint-plugin/lib/rules/no-array-constructor.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-array-constructor.js rename to packages/eslint-plugin/lib/rules/no-array-constructor.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-empty-interface.js b/packages/eslint-plugin/lib/rules/no-empty-interface.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-empty-interface.js rename to packages/eslint-plugin/lib/rules/no-empty-interface.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-explicit-any.js b/packages/eslint-plugin/lib/rules/no-explicit-any.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-explicit-any.js rename to packages/eslint-plugin/lib/rules/no-explicit-any.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-extraneous-class.js b/packages/eslint-plugin/lib/rules/no-extraneous-class.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-extraneous-class.js rename to packages/eslint-plugin/lib/rules/no-extraneous-class.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-inferrable-types.js b/packages/eslint-plugin/lib/rules/no-inferrable-types.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-inferrable-types.js rename to packages/eslint-plugin/lib/rules/no-inferrable-types.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-misused-new.js b/packages/eslint-plugin/lib/rules/no-misused-new.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-misused-new.js rename to packages/eslint-plugin/lib/rules/no-misused-new.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-namespace.js b/packages/eslint-plugin/lib/rules/no-namespace.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-namespace.js rename to packages/eslint-plugin/lib/rules/no-namespace.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-non-null-assertion.js b/packages/eslint-plugin/lib/rules/no-non-null-assertion.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-non-null-assertion.js rename to packages/eslint-plugin/lib/rules/no-non-null-assertion.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-object-literal-type-assertion.js b/packages/eslint-plugin/lib/rules/no-object-literal-type-assertion.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-object-literal-type-assertion.js rename to packages/eslint-plugin/lib/rules/no-object-literal-type-assertion.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-parameter-properties.js b/packages/eslint-plugin/lib/rules/no-parameter-properties.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-parameter-properties.js rename to packages/eslint-plugin/lib/rules/no-parameter-properties.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-this-alias.js b/packages/eslint-plugin/lib/rules/no-this-alias.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-this-alias.js rename to packages/eslint-plugin/lib/rules/no-this-alias.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-triple-slash-reference.js b/packages/eslint-plugin/lib/rules/no-triple-slash-reference.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-triple-slash-reference.js rename to packages/eslint-plugin/lib/rules/no-triple-slash-reference.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-type-alias.js b/packages/eslint-plugin/lib/rules/no-type-alias.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-type-alias.js rename to packages/eslint-plugin/lib/rules/no-type-alias.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-unused-vars.js b/packages/eslint-plugin/lib/rules/no-unused-vars.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-unused-vars.js rename to packages/eslint-plugin/lib/rules/no-unused-vars.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-use-before-define.js b/packages/eslint-plugin/lib/rules/no-use-before-define.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-use-before-define.js rename to packages/eslint-plugin/lib/rules/no-use-before-define.js diff --git a/packages/eslint-plugin-typescript/lib/rules/no-var-requires.js b/packages/eslint-plugin/lib/rules/no-var-requires.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/no-var-requires.js rename to packages/eslint-plugin/lib/rules/no-var-requires.js diff --git a/packages/eslint-plugin-typescript/lib/rules/prefer-interface.js b/packages/eslint-plugin/lib/rules/prefer-interface.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/prefer-interface.js rename to packages/eslint-plugin/lib/rules/prefer-interface.js diff --git a/packages/eslint-plugin-typescript/lib/rules/prefer-namespace-keyword.js b/packages/eslint-plugin/lib/rules/prefer-namespace-keyword.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/prefer-namespace-keyword.js rename to packages/eslint-plugin/lib/rules/prefer-namespace-keyword.js diff --git a/packages/eslint-plugin-typescript/lib/rules/type-annotation-spacing.js b/packages/eslint-plugin/lib/rules/type-annotation-spacing.js similarity index 100% rename from packages/eslint-plugin-typescript/lib/rules/type-annotation-spacing.js rename to packages/eslint-plugin/lib/rules/type-annotation-spacing.js diff --git a/packages/eslint-plugin-typescript/lib/util.js b/packages/eslint-plugin/lib/util.js similarity index 93% rename from packages/eslint-plugin-typescript/lib/util.js rename to packages/eslint-plugin/lib/util.js index 2578c60aa806..66c6312ea14d 100644 --- a/packages/eslint-plugin-typescript/lib/util.js +++ b/packages/eslint-plugin/lib/util.js @@ -5,7 +5,7 @@ const version = require('../package.json').version; exports.tslintRule = name => `\`${name}\` from TSLint`; exports.metaDocsUrl = name => - `https://github.com/typescript-eslint/typescript-eslint/blob/${version}/packages/eslint-plugin-typescript/docs/rules/${name}.md`; + `https://github.com/typescript-eslint/typescript-eslint/blob/${version}/packages/eslint-plugin/docs/rules/${name}.md`; /** * Check if the context file name is *.ts or *.tsx @@ -117,11 +117,11 @@ exports.getParserServices = context => { !context.parserServices.program || !context.parserServices.esTreeNodeToTSNodeMap ) { - // TODO - the message will require revisiting once the typescript-eslint-parser/typescript-estree finalises + // TODO - the message will require revisiting once the @typescript-eslint/parser work finalises // their work around exposing the parser. They may require that there be a project config field in // the eslint config, in which case we should check and/or report that here appropriately. throw new Error( - 'This rule requires you to use `eslint-plugin-typescript/parser`.' + 'This rule requires you to use `@typescript-eslint/eslint-plugin/parser`.' ); } return context.parserServices; diff --git a/packages/eslint-plugin-typescript/package.json b/packages/eslint-plugin/package.json similarity index 84% rename from packages/eslint-plugin-typescript/package.json rename to packages/eslint-plugin/package.json index ac55100bc692..86c8a1c62193 100644 --- a/packages/eslint-plugin-typescript/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { - "name": "eslint-plugin-typescript", - "version": "1.0.0-rc.3", + "name": "@typescript-eslint/eslint-plugin", + "version": "0.2.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -24,8 +24,8 @@ "recommended:update": "node tools/update-recommended.js" }, "dependencies": { - "requireindex": "^1.2.0", - "typescript-eslint-parser": "21.0.2" + "@typescript-eslint/parser": "0.2.0", + "requireindex": "^1.2.0" }, "devDependencies": { "eslint": "^5.9.0", diff --git a/packages/eslint-plugin-typescript/parser.js b/packages/eslint-plugin/parser.js similarity index 61% rename from packages/eslint-plugin-typescript/parser.js rename to packages/eslint-plugin/parser.js index a2f0433ab12a..44041c4bf2c8 100644 --- a/packages/eslint-plugin-typescript/parser.js +++ b/packages/eslint-plugin/parser.js @@ -5,6 +5,6 @@ 'use strict'; -// export the typescript-eslint-parser. +// export the @typescript-eslint/parser. // this forces the parser to be a direct dependency of the plugin. -module.exports = require('typescript-eslint-parser'); +module.exports = require('@typescript-eslint/parser'); diff --git a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-dupe-args.js b/packages/eslint-plugin/tests/lib/eslint-rules/no-dupe-args.js similarity index 94% rename from packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-dupe-args.js rename to packages/eslint-plugin/tests/lib/eslint-rules/no-dupe-args.js index eda55ccd242c..65d2c88314e0 100644 --- a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-dupe-args.js +++ b/packages/eslint-plugin/tests/lib/eslint-rules/no-dupe-args.js @@ -13,7 +13,7 @@ const ruleTester = new RuleTester({ sourceType: 'module', ecmaFeatures: {} }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-dupe-args', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-implicit-globals.js b/packages/eslint-plugin/tests/lib/eslint-rules/no-implicit-globals.js similarity index 94% rename from packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-implicit-globals.js rename to packages/eslint-plugin/tests/lib/eslint-rules/no-implicit-globals.js index 410f23df03ff..654c3374ca8b 100644 --- a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-implicit-globals.js +++ b/packages/eslint-plugin/tests/lib/eslint-rules/no-implicit-globals.js @@ -12,7 +12,7 @@ const ruleTester = new RuleTester({ ecmaVersion: 6, sourceType: 'module' }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-implicit-globals', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-redeclare.js b/packages/eslint-plugin/tests/lib/eslint-rules/no-redeclare.js similarity index 95% rename from packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-redeclare.js rename to packages/eslint-plugin/tests/lib/eslint-rules/no-redeclare.js index e6bf91facaf6..05b3efa9bb41 100644 --- a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-redeclare.js +++ b/packages/eslint-plugin/tests/lib/eslint-rules/no-redeclare.js @@ -13,7 +13,7 @@ const ruleTester = new RuleTester({ sourceType: 'module', ecmaFeatures: {} }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-redeclare', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-restricted-globals.js b/packages/eslint-plugin/tests/lib/eslint-rules/no-restricted-globals.js similarity index 95% rename from packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-restricted-globals.js rename to packages/eslint-plugin/tests/lib/eslint-rules/no-restricted-globals.js index 2e19c54dc4ab..a88cb359a5df 100644 --- a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-restricted-globals.js +++ b/packages/eslint-plugin/tests/lib/eslint-rules/no-restricted-globals.js @@ -13,7 +13,7 @@ const ruleTester = new RuleTester({ sourceType: 'module', ecmaFeatures: {} }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-restricted-globals', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-shadow.js b/packages/eslint-plugin/tests/lib/eslint-rules/no-shadow.js similarity index 95% rename from packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-shadow.js rename to packages/eslint-plugin/tests/lib/eslint-rules/no-shadow.js index 23bd827e8c81..68901aed4310 100644 --- a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-shadow.js +++ b/packages/eslint-plugin/tests/lib/eslint-rules/no-shadow.js @@ -13,7 +13,7 @@ const ruleTester = new RuleTester({ sourceType: 'module', ecmaFeatures: {} }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-shadow', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-undef.js b/packages/eslint-plugin/tests/lib/eslint-rules/no-undef.js similarity index 97% rename from packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-undef.js rename to packages/eslint-plugin/tests/lib/eslint-rules/no-undef.js index d4bd42a46464..53a148eee9da 100644 --- a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-undef.js +++ b/packages/eslint-plugin/tests/lib/eslint-rules/no-undef.js @@ -17,7 +17,7 @@ const ruleTester = new RuleTester({ sourceType: 'module', ecmaFeatures: {} }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-undef', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-unused-vars.js b/packages/eslint-plugin/tests/lib/eslint-rules/no-unused-vars.js similarity index 95% rename from packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-unused-vars.js rename to packages/eslint-plugin/tests/lib/eslint-rules/no-unused-vars.js index 0dc372bd215f..1e80a0dd6502 100644 --- a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-unused-vars.js +++ b/packages/eslint-plugin/tests/lib/eslint-rules/no-unused-vars.js @@ -13,7 +13,7 @@ const ruleTester = new RuleTester({ sourceType: 'module', ecmaFeatures: {} }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-unused-vars', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-use-before-define.js b/packages/eslint-plugin/tests/lib/eslint-rules/no-use-before-define.js similarity index 95% rename from packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-use-before-define.js rename to packages/eslint-plugin/tests/lib/eslint-rules/no-use-before-define.js index be61759ac52b..4a16ea4c8a03 100644 --- a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-use-before-define.js +++ b/packages/eslint-plugin/tests/lib/eslint-rules/no-use-before-define.js @@ -12,7 +12,7 @@ const ruleTester = new RuleTester({ ecmaVersion: 6, sourceType: 'module' }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-undef', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/strict.js b/packages/eslint-plugin/tests/lib/eslint-rules/strict.js similarity index 84% rename from packages/eslint-plugin-typescript/tests/lib/eslint-rules/strict.js rename to packages/eslint-plugin/tests/lib/eslint-rules/strict.js index 198e6f12b73d..173849371d9f 100644 --- a/packages/eslint-plugin-typescript/tests/lib/eslint-rules/strict.js +++ b/packages/eslint-plugin/tests/lib/eslint-rules/strict.js @@ -12,12 +12,11 @@ const ruleTester = new RuleTester({ ecmaVersion: 6, sourceType: 'module' }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('strict', rule, { valid: [ - // https://github.com/bradzacher/eslint-plugin-typescript/issues/255 // https://github.com/typescript-eslint/typescript-eslint/issues/58 ` window.whatevs = { @@ -29,7 +28,6 @@ window.whatevs = { ], invalid: [ { - // https://github.com/bradzacher/eslint-plugin-typescript/issues/255 // https://github.com/typescript-eslint/typescript-eslint/issues/58 code: ` window.whatevs = { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/adjacent-overload-signatures.js b/packages/eslint-plugin/tests/lib/rules/adjacent-overload-signatures.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/adjacent-overload-signatures.js rename to packages/eslint-plugin/tests/lib/rules/adjacent-overload-signatures.js index a482155f1fc2..161ffd4035e6 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/adjacent-overload-signatures.js +++ b/packages/eslint-plugin/tests/lib/rules/adjacent-overload-signatures.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/adjacent-overload-signatures'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('adjacent-overload-signatures', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/array-type.js b/packages/eslint-plugin/tests/lib/rules/array-type.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/array-type.js rename to packages/eslint-plugin/tests/lib/rules/array-type.js index 12b084b7f1dd..e39796f90c0d 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/array-type.js +++ b/packages/eslint-plugin/tests/lib/rules/array-type.js @@ -18,7 +18,7 @@ const rule = require('../../../lib/rules/array-type'), //------------------------------------------------------------------------------ const ruleTester = new eslint.RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('array-type', rule, { @@ -793,7 +793,7 @@ describe('array-type (nested)', () => { rules: { 'array-type': [2, option] }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }, { fix: true diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/ban-types.js b/packages/eslint-plugin/tests/lib/rules/ban-types.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/ban-types.js rename to packages/eslint-plugin/tests/lib/rules/ban-types.js index 4f6cdcc8fab4..520640cc2063 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/ban-types.js +++ b/packages/eslint-plugin/tests/lib/rules/ban-types.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/ban-types'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); const options = [ diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/camelcase.js b/packages/eslint-plugin/tests/lib/rules/camelcase.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/camelcase.js rename to packages/eslint-plugin/tests/lib/rules/camelcase.js index 5927af4449c3..05efff9af562 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/camelcase.js +++ b/packages/eslint-plugin/tests/lib/rules/camelcase.js @@ -14,7 +14,7 @@ const ruleCamelcase = require('../../../lib/rules/camelcase'); const RuleTester = require('eslint').RuleTester; const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); //------------------------------------------------------------------------------ diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/class-name-casing.js b/packages/eslint-plugin/tests/lib/rules/class-name-casing.js similarity index 98% rename from packages/eslint-plugin-typescript/tests/lib/rules/class-name-casing.js rename to packages/eslint-plugin/tests/lib/rules/class-name-casing.js index e21c4679b522..59c2217ceadf 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/class-name-casing.js +++ b/packages/eslint-plugin/tests/lib/rules/class-name-casing.js @@ -17,7 +17,7 @@ const rule = require('../../../lib/rules/class-name-casing'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('class-name-casing', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/explicit-function-return-type.js b/packages/eslint-plugin/tests/lib/rules/explicit-function-return-type.js similarity index 98% rename from packages/eslint-plugin-typescript/tests/lib/rules/explicit-function-return-type.js rename to packages/eslint-plugin/tests/lib/rules/explicit-function-return-type.js index e4383a39569d..e5454b6ccc78 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/explicit-function-return-type.js +++ b/packages/eslint-plugin/tests/lib/rules/explicit-function-return-type.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/explicit-function-return-type'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('explicit-function-return-type', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/explicit-member-accessibility.js b/packages/eslint-plugin/tests/lib/rules/explicit-member-accessibility.js similarity index 98% rename from packages/eslint-plugin-typescript/tests/lib/rules/explicit-member-accessibility.js rename to packages/eslint-plugin/tests/lib/rules/explicit-member-accessibility.js index f87820f5f8f0..0ec5f048e1fd 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/explicit-member-accessibility.js +++ b/packages/eslint-plugin/tests/lib/rules/explicit-member-accessibility.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/explicit-member-accessibility'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('explicit-member-accessibility', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/generic-type-naming.js b/packages/eslint-plugin/tests/lib/rules/generic-type-naming.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/generic-type-naming.js rename to packages/eslint-plugin/tests/lib/rules/generic-type-naming.js index 1ed16884dfa7..98b0532ec6c8 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/generic-type-naming.js +++ b/packages/eslint-plugin/tests/lib/rules/generic-type-naming.js @@ -15,7 +15,7 @@ const rule = require('../../../lib/rules/generic-type-naming'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('generic-type-naming', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/indent.js b/packages/eslint-plugin/tests/lib/rules/indent.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/indent.js rename to packages/eslint-plugin/tests/lib/rules/indent.js index 612ce758f2d2..c4e069e31f5c 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/indent.js +++ b/packages/eslint-plugin/tests/lib/rules/indent.js @@ -664,7 +664,7 @@ const ruleTester = new RuleTester({ sourceType: 'module', ecmaFeatures: {} }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('indent', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/interface-name-prefix.js b/packages/eslint-plugin/tests/lib/rules/interface-name-prefix.js similarity index 98% rename from packages/eslint-plugin-typescript/tests/lib/rules/interface-name-prefix.js rename to packages/eslint-plugin/tests/lib/rules/interface-name-prefix.js index b72eb7cd6d3c..6243d5a6d11a 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/interface-name-prefix.js +++ b/packages/eslint-plugin/tests/lib/rules/interface-name-prefix.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/interface-name-prefix'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('interface-name-prefix', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/member-delimiter-style.js b/packages/eslint-plugin/tests/lib/rules/member-delimiter-style.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/member-delimiter-style.js rename to packages/eslint-plugin/tests/lib/rules/member-delimiter-style.js index ac4b7721d676..288269243af9 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/member-delimiter-style.js +++ b/packages/eslint-plugin/tests/lib/rules/member-delimiter-style.js @@ -17,7 +17,7 @@ const rule = require('../../../lib/rules/member-delimiter-style'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('member-delimiter-style', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/member-naming.js b/packages/eslint-plugin/tests/lib/rules/member-naming.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/member-naming.js rename to packages/eslint-plugin/tests/lib/rules/member-naming.js index cad66d192367..c3e0d8a69209 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/member-naming.js +++ b/packages/eslint-plugin/tests/lib/rules/member-naming.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/member-naming'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('member-naming', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/member-ordering.js b/packages/eslint-plugin/tests/lib/rules/member-ordering.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/member-ordering.js rename to packages/eslint-plugin/tests/lib/rules/member-ordering.js index f08b8f140d7a..b74bcce32006 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/member-ordering.js +++ b/packages/eslint-plugin/tests/lib/rules/member-ordering.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/member-ordering'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('member-ordering', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-angle-bracket-type-assertion.js b/packages/eslint-plugin/tests/lib/rules/no-angle-bracket-type-assertion.js similarity index 98% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-angle-bracket-type-assertion.js rename to packages/eslint-plugin/tests/lib/rules/no-angle-bracket-type-assertion.js index 9720ab90f704..f4aa7b362740 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-angle-bracket-type-assertion.js +++ b/packages/eslint-plugin/tests/lib/rules/no-angle-bracket-type-assertion.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/no-angle-bracket-type-assertion'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-angle-bracket-type-assertion', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-array-constructor.js b/packages/eslint-plugin/tests/lib/rules/no-array-constructor.js similarity index 98% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-array-constructor.js rename to packages/eslint-plugin/tests/lib/rules/no-array-constructor.js index 7197eac80ccd..90a551722538 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-array-constructor.js +++ b/packages/eslint-plugin/tests/lib/rules/no-array-constructor.js @@ -17,7 +17,7 @@ const rule = require('../../../lib/rules/no-array-constructor'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); const message = 'The array literal notation [] is preferrable.'; diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-empty-interface.js b/packages/eslint-plugin/tests/lib/rules/no-empty-interface.js similarity index 97% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-empty-interface.js rename to packages/eslint-plugin/tests/lib/rules/no-empty-interface.js index d58d6a14674c..a16d875a366c 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-empty-interface.js +++ b/packages/eslint-plugin/tests/lib/rules/no-empty-interface.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/no-empty-interface'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-empty-interface', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-explicit-any.js b/packages/eslint-plugin/tests/lib/rules/no-explicit-any.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-explicit-any.js rename to packages/eslint-plugin/tests/lib/rules/no-explicit-any.js index 6039ea2e74bd..2f6e09350055 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-explicit-any.js +++ b/packages/eslint-plugin/tests/lib/rules/no-explicit-any.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/no-explicit-any'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-explicit-any', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-extraneous-class.js b/packages/eslint-plugin/tests/lib/rules/no-extraneous-class.js similarity index 98% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-extraneous-class.js rename to packages/eslint-plugin/tests/lib/rules/no-extraneous-class.js index d50b7178d859..4243677a8679 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-extraneous-class.js +++ b/packages/eslint-plugin/tests/lib/rules/no-extraneous-class.js @@ -21,7 +21,7 @@ const onlyConstructor = { messageId: 'onlyConstructor', type: 'Identifier' }; //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-extraneous-class', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-inferrable-types.js b/packages/eslint-plugin/tests/lib/rules/no-inferrable-types.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-inferrable-types.js rename to packages/eslint-plugin/tests/lib/rules/no-inferrable-types.js index e2827293cb8c..955647e27f31 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-inferrable-types.js +++ b/packages/eslint-plugin/tests/lib/rules/no-inferrable-types.js @@ -16,7 +16,7 @@ const RuleTester = require('eslint').RuleTester; //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-inferrable-types', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-misused-new.js b/packages/eslint-plugin/tests/lib/rules/no-misused-new.js similarity index 98% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-misused-new.js rename to packages/eslint-plugin/tests/lib/rules/no-misused-new.js index 9a5ac534ef5d..f770f509872a 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-misused-new.js +++ b/packages/eslint-plugin/tests/lib/rules/no-misused-new.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/no-misused-new'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-misused-new', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-namespace.js b/packages/eslint-plugin/tests/lib/rules/no-namespace.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-namespace.js rename to packages/eslint-plugin/tests/lib/rules/no-namespace.js index d3809144034c..cadabf185d06 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-namespace.js +++ b/packages/eslint-plugin/tests/lib/rules/no-namespace.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/no-namespace'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-namespace', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-non-null-assertion.js b/packages/eslint-plugin/tests/lib/rules/no-non-null-assertion.js similarity index 96% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-non-null-assertion.js rename to packages/eslint-plugin/tests/lib/rules/no-non-null-assertion.js index ad3d3dcd78ed..81b79c6972dd 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-non-null-assertion.js +++ b/packages/eslint-plugin/tests/lib/rules/no-non-null-assertion.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/no-non-null-assertion'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-non-null-assertion', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-object-literal-type-assertion.js b/packages/eslint-plugin/tests/lib/rules/no-object-literal-type-assertion.js similarity index 97% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-object-literal-type-assertion.js rename to packages/eslint-plugin/tests/lib/rules/no-object-literal-type-assertion.js index dd073102dc61..2a037390e0b5 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-object-literal-type-assertion.js +++ b/packages/eslint-plugin/tests/lib/rules/no-object-literal-type-assertion.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/no-object-literal-type-assertion'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', parserOptions: { ecmaVersion: 6, sourceType: 'module', diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-parameter-properties.js b/packages/eslint-plugin/tests/lib/rules/no-parameter-properties.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-parameter-properties.js rename to packages/eslint-plugin/tests/lib/rules/no-parameter-properties.js index 43ada16f00f1..80129de18cc6 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-parameter-properties.js +++ b/packages/eslint-plugin/tests/lib/rules/no-parameter-properties.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/no-parameter-properties'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-parameter-properties', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-this-alias.js b/packages/eslint-plugin/tests/lib/rules/no-this-alias.js similarity index 98% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-this-alias.js rename to packages/eslint-plugin/tests/lib/rules/no-this-alias.js index 73c07e3dd748..e2f76005da4d 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-this-alias.js +++ b/packages/eslint-plugin/tests/lib/rules/no-this-alias.js @@ -27,7 +27,7 @@ const arrayDestructureError = { //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-this-alias', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-triple-slash-reference.js b/packages/eslint-plugin/tests/lib/rules/no-triple-slash-reference.js similarity index 94% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-triple-slash-reference.js rename to packages/eslint-plugin/tests/lib/rules/no-triple-slash-reference.js index f38218e663d7..5e61a3736c0c 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-triple-slash-reference.js +++ b/packages/eslint-plugin/tests/lib/rules/no-triple-slash-reference.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/no-triple-slash-reference'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-triple-slash-reference', rule, { @@ -47,7 +47,7 @@ let a /// let a `, - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', errors: [ { messageId: 'tripleSlashReference', diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-type-alias.js b/packages/eslint-plugin/tests/lib/rules/no-type-alias.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-type-alias.js rename to packages/eslint-plugin/tests/lib/rules/no-type-alias.js index dd27c4f4a4aa..fc3c91f7fa1d 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-type-alias.js +++ b/packages/eslint-plugin/tests/lib/rules/no-type-alias.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/no-type-alias'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-type-alias', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-unused-vars.js b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-unused-vars.js rename to packages/eslint-plugin/tests/lib/rules/no-unused-vars.js index cbacd42d0e08..8e7a5a8a7892 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js @@ -17,7 +17,7 @@ const ruleTester = new RuleTester({ sourceType: 'module', ecmaFeatures: {} }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); //------------------------------------------------------------------------------ diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-use-before-define.js b/packages/eslint-plugin/tests/lib/rules/no-use-before-define.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-use-before-define.js rename to packages/eslint-plugin/tests/lib/rules/no-use-before-define.js index b0b8ec21889f..b74645208d6d 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-use-before-define.js +++ b/packages/eslint-plugin/tests/lib/rules/no-use-before-define.js @@ -18,7 +18,7 @@ const rule = require('../../../lib/rules/no-use-before-define'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-use-before-define', rule, { @@ -220,7 +220,7 @@ export namespace Third { } `, parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' } ], invalid: [ diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/no-var-requires.js b/packages/eslint-plugin/tests/lib/rules/no-var-requires.js similarity index 97% rename from packages/eslint-plugin-typescript/tests/lib/rules/no-var-requires.js rename to packages/eslint-plugin/tests/lib/rules/no-var-requires.js index 44d4675506e9..64662f95de2b 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/no-var-requires.js +++ b/packages/eslint-plugin/tests/lib/rules/no-var-requires.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/no-var-requires'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('no-var-requires', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/prefer-interface.js b/packages/eslint-plugin/tests/lib/rules/prefer-interface.js similarity index 97% rename from packages/eslint-plugin-typescript/tests/lib/rules/prefer-interface.js rename to packages/eslint-plugin/tests/lib/rules/prefer-interface.js index b253f2cfb16a..1617cdbe6877 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/prefer-interface.js +++ b/packages/eslint-plugin/tests/lib/rules/prefer-interface.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/prefer-interface'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('interface-over-type-literal', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/prefer-namespace-keyword.js b/packages/eslint-plugin/tests/lib/rules/prefer-namespace-keyword.js similarity index 98% rename from packages/eslint-plugin-typescript/tests/lib/rules/prefer-namespace-keyword.js rename to packages/eslint-plugin/tests/lib/rules/prefer-namespace-keyword.js index 4e090617b017..6107dc0d2ff0 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/prefer-namespace-keyword.js +++ b/packages/eslint-plugin/tests/lib/rules/prefer-namespace-keyword.js @@ -17,7 +17,7 @@ const rule = require('../../../lib/rules/prefer-namespace-keyword'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('prefer-namespace-keyword', rule, { diff --git a/packages/eslint-plugin-typescript/tests/lib/rules/type-annotation-spacing.js b/packages/eslint-plugin/tests/lib/rules/type-annotation-spacing.js similarity index 99% rename from packages/eslint-plugin-typescript/tests/lib/rules/type-annotation-spacing.js rename to packages/eslint-plugin/tests/lib/rules/type-annotation-spacing.js index eca025ba624d..b5826a54e29f 100644 --- a/packages/eslint-plugin-typescript/tests/lib/rules/type-annotation-spacing.js +++ b/packages/eslint-plugin/tests/lib/rules/type-annotation-spacing.js @@ -16,7 +16,7 @@ const rule = require('../../../lib/rules/type-annotation-spacing'), //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }); ruleTester.run('type-annotation-spacing', rule, { @@ -1034,7 +1034,7 @@ type Bar = Record } } ], - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }, 'let resolver: (() => PromiseLike) | PromiseLike;' ], @@ -4219,7 +4219,7 @@ type Bar = Record } } ], - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' } ], invalid: [ diff --git a/packages/eslint-plugin-typescript/tests/lib/util.js b/packages/eslint-plugin/tests/lib/util.js similarity index 100% rename from packages/eslint-plugin-typescript/tests/lib/util.js rename to packages/eslint-plugin/tests/lib/util.js diff --git a/packages/eslint-plugin-typescript/tools/update-recommended.js b/packages/eslint-plugin/tools/update-recommended.js similarity index 96% rename from packages/eslint-plugin-typescript/tools/update-recommended.js rename to packages/eslint-plugin/tools/update-recommended.js index 98c03a4451a0..73b9571eddbe 100644 --- a/packages/eslint-plugin-typescript/tools/update-recommended.js +++ b/packages/eslint-plugin/tools/update-recommended.js @@ -49,7 +49,7 @@ function generate() { const filePath = path.resolve(__dirname, '../lib/configs/recommended.json'); const recommendedConfig = { - parser: 'eslint-plugin-typescript/parser', + parser: '@typescript-eslint/eslint-plugin/parser', parserOptions: { sourceType: 'module' }, diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/typescript-eslint-parser/LICENSE b/packages/parser/LICENSE similarity index 100% rename from packages/typescript-eslint-parser/LICENSE rename to packages/parser/LICENSE diff --git a/packages/typescript-eslint-parser/README.md b/packages/parser/README.md similarity index 84% rename from packages/typescript-eslint-parser/README.md rename to packages/parser/README.md index 49e7a196a2dd..253ed00e4686 100644 --- a/packages/typescript-eslint-parser/README.md +++ b/packages/parser/README.md @@ -5,7 +5,7 @@ An ESLint custom parser which leverages [TypeScript ESTree](https://github.com/t ## Installation: ```sh -npm install --save-dev typescript-eslint-parser +npm install --save-dev @typescript-eslint/parser ``` ## Usage @@ -14,7 +14,7 @@ In your ESLint configuration file, set the `parser` property: ```json { - "parser": "typescript-eslint-parser" + "parser": "@typescript-eslint/parser" } ``` @@ -26,7 +26,7 @@ The core rules built into ESLint, such as `indent` have no knowledge of such con Instead, you also need to make use of one more plugins which will add or extend rules with TypeScript-specific features. -By far the most common case will be installing the [eslint-plugin-typescript](https://github.com/nzakas/eslint-plugin-typescript) plugin, but there are also other relevant options available such a [eslint-plugin-tslint](https://github.com/JamesHenry/eslint-plugin-tslint). +By far the most common case will be installing the [@typescript-eslint/eslint-plugin](https://github.com/nzakas/@typescript-eslint/eslint-plugin) plugin, but there are also other relevant options available such a [@typescript-eslint/eslint-plugin-tslint](https://github.com/JamesHenry/@typescript-eslint/eslint-plugin-tslint). ## Configuration @@ -44,7 +44,7 @@ The following additional configuration options are available by specifying them ```json { - "parser": "typescript-eslint-parser", + "parser": "@typescript-eslint/parser", "parserOptions": { "jsx": true, "useJSXTextNode": true @@ -68,7 +68,7 @@ Please check the current list of open and known issues and ensure the issue has - ESLint Version - TypeScript version -- The `typescript-eslint-parser` version +- The `@typescript-eslint/parser` version - ESLint config or rules and plugins currently enabled ## Integration Tests @@ -93,10 +93,6 @@ If you ever need to change what gets installed when the docker images are built npm run kill-integration-test-containers ``` -## Contributing - -Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the [ESLint Contributor Guidelines](http://eslint.org/docs/developer-guide/contributing), so please be sure to read them before contributing. If you're not sure where to dig in, check out the [issues](https://github.com/eslint/typescript-eslint-parser/issues). - ## Build Commands - `npm test` - run all linting and tests diff --git a/packages/typescript-eslint-parser/jest.config.js b/packages/parser/jest.config.js similarity index 100% rename from packages/typescript-eslint-parser/jest.config.js rename to packages/parser/jest.config.js diff --git a/packages/typescript-eslint-parser/package.json b/packages/parser/package.json similarity index 86% rename from packages/typescript-eslint-parser/package.json rename to packages/parser/package.json index 492e82e150dc..f38199dfa0f2 100644 --- a/packages/typescript-eslint-parser/package.json +++ b/packages/parser/package.json @@ -1,8 +1,8 @@ { - "name": "typescript-eslint-parser", + "name": "@typescript-eslint/parser", + "version": "0.2.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/parser.js", - "version": "21.0.2", "files": [ "dist", "README.md", @@ -36,9 +36,9 @@ "typescript": "*" }, "dependencies": { + "@typescript-eslint/typescript-estree": "0.2.0", "eslint-scope": "^4.0.0", - "eslint-visitor-keys": "^1.0.0", - "typescript-estree": "18.1.0" + "eslint-visitor-keys": "^1.0.0" }, "devDependencies": { "@types/eslint": "^4.16.5", diff --git a/packages/typescript-eslint-parser/src/analyze-scope.ts b/packages/parser/src/analyze-scope.ts similarity index 100% rename from packages/typescript-eslint-parser/src/analyze-scope.ts rename to packages/parser/src/analyze-scope.ts diff --git a/packages/typescript-eslint-parser/src/parser-options.ts b/packages/parser/src/parser-options.ts similarity index 100% rename from packages/typescript-eslint-parser/src/parser-options.ts rename to packages/parser/src/parser-options.ts diff --git a/packages/typescript-eslint-parser/src/parser.ts b/packages/parser/src/parser.ts similarity index 97% rename from packages/typescript-eslint-parser/src/parser.ts rename to packages/parser/src/parser.ts index bdf4fd7d5f46..49aabf26074a 100644 --- a/packages/typescript-eslint-parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -1,5 +1,5 @@ import traverser from 'eslint/lib/util/traverser'; -import * as typescriptESTree from 'typescript-estree'; +import * as typescriptESTree from '@typescript-eslint/typescript-estree'; import { analyzeScope } from './analyze-scope'; import { ParserOptions } from './parser-options'; import { visitorKeys } from './visitor-keys'; diff --git a/packages/typescript-eslint-parser/src/typings.d.ts b/packages/parser/src/typings.d.ts similarity index 100% rename from packages/typescript-eslint-parser/src/typings.d.ts rename to packages/parser/src/typings.d.ts diff --git a/packages/typescript-eslint-parser/src/visitor-keys.ts b/packages/parser/src/visitor-keys.ts similarity index 100% rename from packages/typescript-eslint-parser/src/visitor-keys.ts rename to packages/parser/src/visitor-keys.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/basics/delete-expression.src.js b/packages/parser/tests/fixtures/basics/delete-expression.src.js similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/basics/delete-expression.src.js rename to packages/parser/tests/fixtures/basics/delete-expression.src.js diff --git a/packages/typescript-eslint-parser/tests/fixtures/basics/do-while-statements.src.js b/packages/parser/tests/fixtures/basics/do-while-statements.src.js similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/basics/do-while-statements.src.js rename to packages/parser/tests/fixtures/basics/do-while-statements.src.js diff --git a/packages/typescript-eslint-parser/tests/fixtures/basics/identifiers-double-underscore.src.js b/packages/parser/tests/fixtures/basics/identifiers-double-underscore.src.js similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/basics/identifiers-double-underscore.src.js rename to packages/parser/tests/fixtures/basics/identifiers-double-underscore.src.js diff --git a/packages/typescript-eslint-parser/tests/fixtures/basics/instanceof.src.js b/packages/parser/tests/fixtures/basics/instanceof.src.js similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/basics/instanceof.src.js rename to packages/parser/tests/fixtures/basics/instanceof.src.js diff --git a/packages/typescript-eslint-parser/tests/fixtures/basics/new-with-member-expression.src.js b/packages/parser/tests/fixtures/basics/new-with-member-expression.src.js similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/basics/new-with-member-expression.src.js rename to packages/parser/tests/fixtures/basics/new-with-member-expression.src.js diff --git a/packages/typescript-eslint-parser/tests/fixtures/basics/new-without-parens.src.js b/packages/parser/tests/fixtures/basics/new-without-parens.src.js similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/basics/new-without-parens.src.js rename to packages/parser/tests/fixtures/basics/new-without-parens.src.js diff --git a/packages/typescript-eslint-parser/tests/fixtures/basics/typeof-expression.src.js b/packages/parser/tests/fixtures/basics/typeof-expression.src.js similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/basics/typeof-expression.src.js rename to packages/parser/tests/fixtures/basics/typeof-expression.src.js diff --git a/packages/typescript-eslint-parser/tests/fixtures/basics/update-expression.src.js b/packages/parser/tests/fixtures/basics/update-expression.src.js similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/basics/update-expression.src.js rename to packages/parser/tests/fixtures/basics/update-expression.src.js diff --git a/packages/typescript-eslint-parser/tests/fixtures/basics/void-expression.src.js b/packages/parser/tests/fixtures/basics/void-expression.src.js similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/basics/void-expression.src.js rename to packages/parser/tests/fixtures/basics/void-expression.src.js diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/535.ts b/packages/parser/tests/fixtures/scope-analysis/535.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/535.ts rename to packages/parser/tests/fixtures/scope-analysis/535.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/abstract-class.ts b/packages/parser/tests/fixtures/scope-analysis/abstract-class.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/abstract-class.ts rename to packages/parser/tests/fixtures/scope-analysis/abstract-class.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/class-implements.ts b/packages/parser/tests/fixtures/scope-analysis/class-implements.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/class-implements.ts rename to packages/parser/tests/fixtures/scope-analysis/class-implements.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/class-properties.ts b/packages/parser/tests/fixtures/scope-analysis/class-properties.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/class-properties.ts rename to packages/parser/tests/fixtures/scope-analysis/class-properties.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/class-supper-type.ts b/packages/parser/tests/fixtures/scope-analysis/class-supper-type.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/class-supper-type.ts rename to packages/parser/tests/fixtures/scope-analysis/class-supper-type.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/computed-properties-in-interface.ts b/packages/parser/tests/fixtures/scope-analysis/computed-properties-in-interface.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/computed-properties-in-interface.ts rename to packages/parser/tests/fixtures/scope-analysis/computed-properties-in-interface.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/computed-properties-in-type.ts b/packages/parser/tests/fixtures/scope-analysis/computed-properties-in-type.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/computed-properties-in-type.ts rename to packages/parser/tests/fixtures/scope-analysis/computed-properties-in-type.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/declare-function.ts b/packages/parser/tests/fixtures/scope-analysis/declare-function.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/declare-function.ts rename to packages/parser/tests/fixtures/scope-analysis/declare-function.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/declare-global.ts b/packages/parser/tests/fixtures/scope-analysis/declare-global.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/declare-global.ts rename to packages/parser/tests/fixtures/scope-analysis/declare-global.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/declare-module.ts b/packages/parser/tests/fixtures/scope-analysis/declare-module.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/declare-module.ts rename to packages/parser/tests/fixtures/scope-analysis/declare-module.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/decorators.ts b/packages/parser/tests/fixtures/scope-analysis/decorators.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/decorators.ts rename to packages/parser/tests/fixtures/scope-analysis/decorators.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/enum-string.ts b/packages/parser/tests/fixtures/scope-analysis/enum-string.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/enum-string.ts rename to packages/parser/tests/fixtures/scope-analysis/enum-string.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/enum.ts b/packages/parser/tests/fixtures/scope-analysis/enum.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/enum.ts rename to packages/parser/tests/fixtures/scope-analysis/enum.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/export-as-namespace.ts b/packages/parser/tests/fixtures/scope-analysis/export-as-namespace.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/export-as-namespace.ts rename to packages/parser/tests/fixtures/scope-analysis/export-as-namespace.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/expression-as.ts b/packages/parser/tests/fixtures/scope-analysis/expression-as.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/expression-as.ts rename to packages/parser/tests/fixtures/scope-analysis/expression-as.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/expression-type-parameters.ts b/packages/parser/tests/fixtures/scope-analysis/expression-type-parameters.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/expression-type-parameters.ts rename to packages/parser/tests/fixtures/scope-analysis/expression-type-parameters.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/function-overload-2.ts b/packages/parser/tests/fixtures/scope-analysis/function-overload-2.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/function-overload-2.ts rename to packages/parser/tests/fixtures/scope-analysis/function-overload-2.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/function-overload.ts b/packages/parser/tests/fixtures/scope-analysis/function-overload.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/function-overload.ts rename to packages/parser/tests/fixtures/scope-analysis/function-overload.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/identifier-decorators.ts b/packages/parser/tests/fixtures/scope-analysis/identifier-decorators.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/identifier-decorators.ts rename to packages/parser/tests/fixtures/scope-analysis/identifier-decorators.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/ignore-type-only-stuff.ts b/packages/parser/tests/fixtures/scope-analysis/ignore-type-only-stuff.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/ignore-type-only-stuff.ts rename to packages/parser/tests/fixtures/scope-analysis/ignore-type-only-stuff.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/import-equals.ts b/packages/parser/tests/fixtures/scope-analysis/import-equals.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/import-equals.ts rename to packages/parser/tests/fixtures/scope-analysis/import-equals.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/interface-type.ts b/packages/parser/tests/fixtures/scope-analysis/interface-type.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/interface-type.ts rename to packages/parser/tests/fixtures/scope-analysis/interface-type.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/method-overload.ts b/packages/parser/tests/fixtures/scope-analysis/method-overload.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/method-overload.ts rename to packages/parser/tests/fixtures/scope-analysis/method-overload.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/namespace.ts b/packages/parser/tests/fixtures/scope-analysis/namespace.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/namespace.ts rename to packages/parser/tests/fixtures/scope-analysis/namespace.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/rest-element.ts b/packages/parser/tests/fixtures/scope-analysis/rest-element.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/rest-element.ts rename to packages/parser/tests/fixtures/scope-analysis/rest-element.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/type-alias.ts b/packages/parser/tests/fixtures/scope-analysis/type-alias.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/type-alias.ts rename to packages/parser/tests/fixtures/scope-analysis/type-alias.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/type-annotations.ts b/packages/parser/tests/fixtures/scope-analysis/type-annotations.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/type-annotations.ts rename to packages/parser/tests/fixtures/scope-analysis/type-annotations.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/type-assertions.ts b/packages/parser/tests/fixtures/scope-analysis/type-assertions.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/type-assertions.ts rename to packages/parser/tests/fixtures/scope-analysis/type-assertions.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/type-parameter.ts b/packages/parser/tests/fixtures/scope-analysis/type-parameter.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/type-parameter.ts rename to packages/parser/tests/fixtures/scope-analysis/type-parameter.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/typeof-in-assertions.ts b/packages/parser/tests/fixtures/scope-analysis/typeof-in-assertions.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/typeof-in-assertions.ts rename to packages/parser/tests/fixtures/scope-analysis/typeof-in-assertions.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/typeof-in-call-signature.ts b/packages/parser/tests/fixtures/scope-analysis/typeof-in-call-signature.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/typeof-in-call-signature.ts rename to packages/parser/tests/fixtures/scope-analysis/typeof-in-call-signature.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/typeof-in-return-type.ts b/packages/parser/tests/fixtures/scope-analysis/typeof-in-return-type.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/typeof-in-return-type.ts rename to packages/parser/tests/fixtures/scope-analysis/typeof-in-return-type.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/typeof-in-type-parameters.ts b/packages/parser/tests/fixtures/scope-analysis/typeof-in-type-parameters.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/typeof-in-type-parameters.ts rename to packages/parser/tests/fixtures/scope-analysis/typeof-in-type-parameters.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/typeof-in-var.ts b/packages/parser/tests/fixtures/scope-analysis/typeof-in-var.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/typeof-in-var.ts rename to packages/parser/tests/fixtures/scope-analysis/typeof-in-var.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/typeof.ts b/packages/parser/tests/fixtures/scope-analysis/typeof.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/typeof.ts rename to packages/parser/tests/fixtures/scope-analysis/typeof.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-array-type.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-array-type.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-array-type.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-array-type.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-conditional-with-null.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-conditional-with-null.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-conditional-with-null.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-conditional-with-null.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-conditional.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-conditional.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-conditional.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-conditional.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-indexed.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-indexed.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-indexed.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-indexed.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-infer.ts b/packages/parser/tests/fixtures/scope-analysis/types-infer.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-infer.ts rename to packages/parser/tests/fixtures/scope-analysis/types-infer.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-intersection-type.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-intersection-type.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-intersection-type.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-intersection-type.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-mapped-readonly-minus.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-mapped-readonly-minus.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-mapped-readonly-minus.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-mapped-readonly-minus.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-mapped-readonly-plus.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-mapped-readonly-plus.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-mapped-readonly-plus.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-mapped-readonly-plus.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-mapped-readonly.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-mapped-readonly.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-mapped-readonly.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-mapped-readonly.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-mapped.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-mapped.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-mapped.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-mapped.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-nested-types.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-nested-types.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-nested-types.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-nested-types.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-parenthesized-type.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-parenthesized-type.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-parenthesized-type.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-parenthesized-type.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-reference-generic-nested.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-reference-generic-nested.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-reference-generic-nested.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-reference-generic-nested.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-reference-generic.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-reference-generic.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-reference-generic.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-reference-generic.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-reference.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-reference.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-reference.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-reference.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-tuple-empty.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-tuple-empty.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-tuple-empty.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-tuple-empty.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-tuple-optional.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-tuple-optional.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-tuple-optional.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-tuple-optional.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-tuple-rest.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-tuple-rest.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-tuple-rest.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-tuple-rest.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-tuple-type.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-tuple-type.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-tuple-type.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-tuple-type.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-tuple.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-tuple.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-tuple.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-tuple.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-type-literal.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-type-literal.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-type-literal.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-type-literal.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-type-operator.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-type-operator.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-type-operator.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-type-operator.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-typeof.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-typeof.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-typeof.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-typeof.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-union-intersection.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-union-intersection.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-union-intersection.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-union-intersection.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-union-type.src.ts b/packages/parser/tests/fixtures/scope-analysis/types-union-type.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/scope-analysis/types-union-type.src.ts rename to packages/parser/tests/fixtures/scope-analysis/types-union-type.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/services/isolated-file.src.ts b/packages/parser/tests/fixtures/services/isolated-file.src.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/services/isolated-file.src.ts rename to packages/parser/tests/fixtures/services/isolated-file.src.ts diff --git a/packages/typescript-eslint-parser/tests/fixtures/services/tsconfig.json b/packages/parser/tests/fixtures/services/tsconfig.json similarity index 100% rename from packages/typescript-eslint-parser/tests/fixtures/services/tsconfig.json rename to packages/parser/tests/fixtures/services/tsconfig.json diff --git a/packages/typescript-eslint-parser/tests/lib/__snapshots__/basics.ts.snap b/packages/parser/tests/lib/__snapshots__/basics.ts.snap similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/__snapshots__/basics.ts.snap rename to packages/parser/tests/lib/__snapshots__/basics.ts.snap diff --git a/packages/typescript-eslint-parser/tests/lib/__snapshots__/comments.ts.snap b/packages/parser/tests/lib/__snapshots__/comments.ts.snap similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/__snapshots__/comments.ts.snap rename to packages/parser/tests/lib/__snapshots__/comments.ts.snap diff --git a/packages/typescript-eslint-parser/tests/lib/__snapshots__/javascript.ts.snap b/packages/parser/tests/lib/__snapshots__/javascript.ts.snap similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/__snapshots__/javascript.ts.snap rename to packages/parser/tests/lib/__snapshots__/javascript.ts.snap diff --git a/packages/typescript-eslint-parser/tests/lib/__snapshots__/jsx.ts.snap b/packages/parser/tests/lib/__snapshots__/jsx.ts.snap similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/__snapshots__/jsx.ts.snap rename to packages/parser/tests/lib/__snapshots__/jsx.ts.snap diff --git a/packages/typescript-eslint-parser/tests/lib/__snapshots__/scope-analysis.ts.snap b/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/__snapshots__/scope-analysis.ts.snap rename to packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap diff --git a/packages/typescript-eslint-parser/tests/lib/__snapshots__/services.ts.snap b/packages/parser/tests/lib/__snapshots__/services.ts.snap similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/__snapshots__/services.ts.snap rename to packages/parser/tests/lib/__snapshots__/services.ts.snap diff --git a/packages/typescript-eslint-parser/tests/lib/__snapshots__/tsx.ts.snap b/packages/parser/tests/lib/__snapshots__/tsx.ts.snap similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/__snapshots__/tsx.ts.snap rename to packages/parser/tests/lib/__snapshots__/tsx.ts.snap diff --git a/packages/typescript-eslint-parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/__snapshots__/typescript.ts.snap rename to packages/parser/tests/lib/__snapshots__/typescript.ts.snap diff --git a/packages/typescript-eslint-parser/tests/lib/basics.ts b/packages/parser/tests/lib/basics.ts similarity index 84% rename from packages/typescript-eslint-parser/tests/lib/basics.ts rename to packages/parser/tests/lib/basics.ts index 5dc91decaf69..a433e83ad426 100644 --- a/packages/typescript-eslint-parser/tests/lib/basics.ts +++ b/packages/parser/tests/lib/basics.ts @@ -26,13 +26,13 @@ describe('basics', () => { export const Price: React.SFC = function Price(props) {} `; const config: Linter.Config = { - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', rules: { test: 'error' } }; - linter.defineParser('typescript-eslint-parser', parser); + linter.defineParser('@typescript-eslint/parser', parser); linter.defineRule('test', { create(context: any) { return { @@ -59,9 +59,7 @@ export const Price: React.SFC = function Price(props) {} message: 'called on React.SFC', nodeType: 'TSTypeReference', ruleId: 'test', - severity: 2, - source: - 'export const Price: React.SFC = function Price(props) {}' + severity: 2 }, { column: 31, @@ -71,9 +69,7 @@ export const Price: React.SFC = function Price(props) {} message: 'called on PriceProps', nodeType: 'TSTypeReference', ruleId: 'test', - severity: 2, - source: - 'export const Price: React.SFC = function Price(props) {}' + severity: 2 } ]); }); diff --git a/packages/typescript-eslint-parser/tests/lib/comments.ts b/packages/parser/tests/lib/comments.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/comments.ts rename to packages/parser/tests/lib/comments.ts diff --git a/packages/typescript-eslint-parser/tests/lib/javascript.ts b/packages/parser/tests/lib/javascript.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/javascript.ts rename to packages/parser/tests/lib/javascript.ts diff --git a/packages/typescript-eslint-parser/tests/lib/jsx.ts b/packages/parser/tests/lib/jsx.ts similarity index 93% rename from packages/typescript-eslint-parser/tests/lib/jsx.ts rename to packages/parser/tests/lib/jsx.ts index a986b3c26e9d..55bb4e5f742f 100644 --- a/packages/typescript-eslint-parser/tests/lib/jsx.ts +++ b/packages/parser/tests/lib/jsx.ts @@ -1,6 +1,6 @@ import fs from 'fs'; import glob from 'glob'; -import filesWithKnownIssues from '../../../typescript-eslint-shared-fixtures/jsx-known-issues'; +import filesWithKnownIssues from '../../../shared-fixtures/jsx-known-issues'; import * as testUtils from '../../tools/test-utils'; const JSX_FIXTURES_DIR = diff --git a/packages/typescript-eslint-parser/tests/lib/parser.ts b/packages/parser/tests/lib/parser.ts similarity index 94% rename from packages/typescript-eslint-parser/tests/lib/parser.ts rename to packages/parser/tests/lib/parser.ts index 89ad87638db8..f5b1f7a9ac4a 100644 --- a/packages/typescript-eslint-parser/tests/lib/parser.ts +++ b/packages/parser/tests/lib/parser.ts @@ -1,4 +1,4 @@ -import * as typescriptESTree from 'typescript-estree'; +import * as typescriptESTree from '@typescript-eslint/typescript-estree'; import { parse, parseForESLint, Syntax } from '../../src/parser'; describe('parser', () => { diff --git a/packages/typescript-eslint-parser/tests/lib/scope-analysis.ts b/packages/parser/tests/lib/scope-analysis.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/scope-analysis.ts rename to packages/parser/tests/lib/scope-analysis.ts diff --git a/packages/typescript-eslint-parser/tests/lib/services.ts b/packages/parser/tests/lib/services.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/services.ts rename to packages/parser/tests/lib/services.ts diff --git a/packages/typescript-eslint-parser/tests/lib/tsx.ts b/packages/parser/tests/lib/tsx.ts similarity index 85% rename from packages/typescript-eslint-parser/tests/lib/tsx.ts rename to packages/parser/tests/lib/tsx.ts index d8609ad60659..0872edf307b0 100644 --- a/packages/typescript-eslint-parser/tests/lib/tsx.ts +++ b/packages/parser/tests/lib/tsx.ts @@ -27,12 +27,12 @@ describe('TSX', () => { describe("if the filename ends with '.tsx', enable jsx option automatically.", () => { const linter = new Linter(); - linter.defineParser('typescript-eslint-parser', parser); + linter.defineParser('@typescript-eslint/parser', parser); it('filePath was not provided', () => { const code = 'const element = '; const config = { - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }; const messages = linter.verify(code, config); @@ -43,8 +43,7 @@ describe('TSX', () => { line: 1, message: "Parsing error: '>' expected.", ruleId: null, - severity: 2, - source: 'const element = ' + severity: 2 } ]); }); @@ -52,7 +51,7 @@ describe('TSX', () => { it("filePath was not provided and 'jsx:true' option", () => { const code = 'const element = '; const config = { - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', parserOptions: { jsx: true } @@ -65,7 +64,7 @@ describe('TSX', () => { it('test.ts', () => { const code = 'const element = '; const config = { - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }; const messages = linter.verify(code, config, { filename: 'test.ts' }); @@ -76,8 +75,7 @@ describe('TSX', () => { line: 1, message: "Parsing error: '>' expected.", ruleId: null, - severity: 2, - source: 'const element = ' + severity: 2 } ]); }); @@ -85,7 +83,7 @@ describe('TSX', () => { it("test.ts with 'jsx:true' option", () => { const code = 'const element = '; const config = { - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', parserOptions: { jsx: true } @@ -99,8 +97,7 @@ describe('TSX', () => { line: 1, message: "Parsing error: '>' expected.", ruleId: null, - severity: 2, - source: 'const element = ' + severity: 2 } ]); }); @@ -108,7 +105,7 @@ describe('TSX', () => { it('test.tsx', () => { const code = 'const element = '; const config = { - parser: 'typescript-eslint-parser' + parser: '@typescript-eslint/parser' }; const messages = linter.verify(code, config, { filename: 'test.tsx' }); @@ -118,7 +115,7 @@ describe('TSX', () => { it("test.tsx with 'jsx:false' option", () => { const code = 'const element = '; const config = { - parser: 'typescript-eslint-parser', + parser: '@typescript-eslint/parser', parserOptions: { jsx: false } diff --git a/packages/typescript-eslint-parser/tests/lib/typescript.ts b/packages/parser/tests/lib/typescript.ts similarity index 100% rename from packages/typescript-eslint-parser/tests/lib/typescript.ts rename to packages/parser/tests/lib/typescript.ts diff --git a/packages/typescript-eslint-parser/tools/test-utils.ts b/packages/parser/tools/test-utils.ts similarity index 100% rename from packages/typescript-eslint-parser/tools/test-utils.ts rename to packages/parser/tools/test-utils.ts diff --git a/packages/typescript-eslint-parser/tsconfig.json b/packages/parser/tsconfig.json similarity index 100% rename from packages/typescript-eslint-parser/tsconfig.json rename to packages/parser/tsconfig.json diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/block-trailing-comment.src.js b/packages/shared-fixtures/fixtures/comments/block-trailing-comment.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/block-trailing-comment.src.js rename to packages/shared-fixtures/fixtures/comments/block-trailing-comment.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/comment-within-condition.src.js b/packages/shared-fixtures/fixtures/comments/comment-within-condition.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/comment-within-condition.src.js rename to packages/shared-fixtures/fixtures/comments/comment-within-condition.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/export-default-anonymous-class.src.js b/packages/shared-fixtures/fixtures/comments/export-default-anonymous-class.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/export-default-anonymous-class.src.js rename to packages/shared-fixtures/fixtures/comments/export-default-anonymous-class.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/jsdoc-comment.src.js b/packages/shared-fixtures/fixtures/comments/jsdoc-comment.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/jsdoc-comment.src.js rename to packages/shared-fixtures/fixtures/comments/jsdoc-comment.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-block-comment.src.js b/packages/shared-fixtures/fixtures/comments/jsx-block-comment.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-block-comment.src.js rename to packages/shared-fixtures/fixtures/comments/jsx-block-comment.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-comment-after-jsx.src.js b/packages/shared-fixtures/fixtures/comments/jsx-comment-after-jsx.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-comment-after-jsx.src.js rename to packages/shared-fixtures/fixtures/comments/jsx-comment-after-jsx.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-comment-after-self-closing-jsx.src.js b/packages/shared-fixtures/fixtures/comments/jsx-comment-after-self-closing-jsx.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-comment-after-self-closing-jsx.src.js rename to packages/shared-fixtures/fixtures/comments/jsx-comment-after-self-closing-jsx.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-tag-comments.src.js b/packages/shared-fixtures/fixtures/comments/jsx-tag-comments.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-tag-comments.src.js rename to packages/shared-fixtures/fixtures/comments/jsx-tag-comments.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-text-with-multiline-non-comment.src.js b/packages/shared-fixtures/fixtures/comments/jsx-text-with-multiline-non-comment.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-text-with-multiline-non-comment.src.js rename to packages/shared-fixtures/fixtures/comments/jsx-text-with-multiline-non-comment.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-text-with-url.src.js b/packages/shared-fixtures/fixtures/comments/jsx-text-with-url.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-text-with-url.src.js rename to packages/shared-fixtures/fixtures/comments/jsx-text-with-url.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-with-greather-than.src.js b/packages/shared-fixtures/fixtures/comments/jsx-with-greather-than.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-with-greather-than.src.js rename to packages/shared-fixtures/fixtures/comments/jsx-with-greather-than.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-with-operators.src.js b/packages/shared-fixtures/fixtures/comments/jsx-with-operators.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/jsx-with-operators.src.js rename to packages/shared-fixtures/fixtures/comments/jsx-with-operators.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/line-comment-with-block-syntax.src.js b/packages/shared-fixtures/fixtures/comments/line-comment-with-block-syntax.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/line-comment-with-block-syntax.src.js rename to packages/shared-fixtures/fixtures/comments/line-comment-with-block-syntax.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/mix-line-and-block-comments.src.js b/packages/shared-fixtures/fixtures/comments/mix-line-and-block-comments.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/mix-line-and-block-comments.src.js rename to packages/shared-fixtures/fixtures/comments/mix-line-and-block-comments.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/no-comment-regex.src.js b/packages/shared-fixtures/fixtures/comments/no-comment-regex.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/no-comment-regex.src.js rename to packages/shared-fixtures/fixtures/comments/no-comment-regex.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/no-comment-template.src.js b/packages/shared-fixtures/fixtures/comments/no-comment-template.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/no-comment-template.src.js rename to packages/shared-fixtures/fixtures/comments/no-comment-template.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/surrounding-call-comments.src.js b/packages/shared-fixtures/fixtures/comments/surrounding-call-comments.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/surrounding-call-comments.src.js rename to packages/shared-fixtures/fixtures/comments/surrounding-call-comments.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/surrounding-debugger-comments.src.js b/packages/shared-fixtures/fixtures/comments/surrounding-debugger-comments.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/surrounding-debugger-comments.src.js rename to packages/shared-fixtures/fixtures/comments/surrounding-debugger-comments.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/surrounding-return-comments.src.js b/packages/shared-fixtures/fixtures/comments/surrounding-return-comments.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/surrounding-return-comments.src.js rename to packages/shared-fixtures/fixtures/comments/surrounding-return-comments.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/surrounding-throw-comments.src.js b/packages/shared-fixtures/fixtures/comments/surrounding-throw-comments.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/surrounding-throw-comments.src.js rename to packages/shared-fixtures/fixtures/comments/surrounding-throw-comments.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/surrounding-while-loop-comments.src.js b/packages/shared-fixtures/fixtures/comments/surrounding-while-loop-comments.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/surrounding-while-loop-comments.src.js rename to packages/shared-fixtures/fixtures/comments/surrounding-while-loop-comments.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/switch-fallthrough-comment-in-function.src.js b/packages/shared-fixtures/fixtures/comments/switch-fallthrough-comment-in-function.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/switch-fallthrough-comment-in-function.src.js rename to packages/shared-fixtures/fixtures/comments/switch-fallthrough-comment-in-function.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/switch-fallthrough-comment.src.js b/packages/shared-fixtures/fixtures/comments/switch-fallthrough-comment.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/switch-fallthrough-comment.src.js rename to packages/shared-fixtures/fixtures/comments/switch-fallthrough-comment.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/switch-no-default-comment-in-function.src.js b/packages/shared-fixtures/fixtures/comments/switch-no-default-comment-in-function.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/switch-no-default-comment-in-function.src.js rename to packages/shared-fixtures/fixtures/comments/switch-no-default-comment-in-function.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/switch-no-default-comment-in-nested-functions.src.js b/packages/shared-fixtures/fixtures/comments/switch-no-default-comment-in-nested-functions.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/switch-no-default-comment-in-nested-functions.src.js rename to packages/shared-fixtures/fixtures/comments/switch-no-default-comment-in-nested-functions.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/switch-no-default-comment.src.js b/packages/shared-fixtures/fixtures/comments/switch-no-default-comment.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/switch-no-default-comment.src.js rename to packages/shared-fixtures/fixtures/comments/switch-no-default-comment.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/template-string-block.src.js b/packages/shared-fixtures/fixtures/comments/template-string-block.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/template-string-block.src.js rename to packages/shared-fixtures/fixtures/comments/template-string-block.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/comments/type-assertion-regression-test.src.ts b/packages/shared-fixtures/fixtures/comments/type-assertion-regression-test.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/comments/type-assertion-regression-test.src.ts rename to packages/shared-fixtures/fixtures/comments/type-assertion-regression-test.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrayLiteral/array-literal-in-lhs.src.js b/packages/shared-fixtures/fixtures/javascript/arrayLiteral/array-literal-in-lhs.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrayLiteral/array-literal-in-lhs.src.js rename to packages/shared-fixtures/fixtures/javascript/arrayLiteral/array-literal-in-lhs.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrayLiteral/array-literals-in-binary-expr.src.js b/packages/shared-fixtures/fixtures/javascript/arrayLiteral/array-literals-in-binary-expr.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrayLiteral/array-literals-in-binary-expr.src.js rename to packages/shared-fixtures/fixtures/javascript/arrayLiteral/array-literals-in-binary-expr.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/as-param-with-params.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/as-param-with-params.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/as-param-with-params.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/as-param-with-params.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/as-param.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/as-param.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/as-param.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/as-param.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/basic-in-binary-expression.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/basic-in-binary-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/basic-in-binary-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/basic-in-binary-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/basic.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/basic.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/basic.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/basic.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/block-body-not-object.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/block-body-not-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/block-body-not-object.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/block-body-not-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/block-body.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/block-body.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/block-body.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/block-body.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-dup-params.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-dup-params.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-dup-params.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-dup-params.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-missing-paren.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-missing-paren.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-missing-paren.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-missing-paren.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-not-arrow.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-not-arrow.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-not-arrow.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-not-arrow.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-numeric-param-multi.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-numeric-param-multi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-numeric-param-multi.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-numeric-param-multi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-numeric-param.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-numeric-param.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-numeric-param.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-numeric-param.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-reverse-arrow.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-reverse-arrow.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-reverse-arrow.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-reverse-arrow.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-default-param-eval.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-default-param-eval.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-default-param-eval.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-default-param-eval.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-dup-params.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-dup-params.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-dup-params.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-dup-params.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-eval-return.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-eval-return.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-eval-return.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-eval-return.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-eval.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-eval.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-eval.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-eval.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-octal.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-octal.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-octal.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-octal.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-arguments.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-arguments.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-arguments.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-arguments.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-eval.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-eval.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-eval.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-eval.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-names.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-names.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-names.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-names.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-no-paren-arguments.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-no-paren-arguments.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-no-paren-arguments.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-no-paren-arguments.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-no-paren-eval.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-no-paren-eval.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-no-paren-eval.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-strict-param-no-paren-eval.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-two-lines.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-two-lines.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-two-lines.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-two-lines.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-wrapped-param.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-wrapped-param.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/error-wrapped-param.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/error-wrapped-param.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/expression.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/expression.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/iife.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/iife.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/iife.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/iife.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/multiple-params.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/multiple-params.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/multiple-params.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/multiple-params.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/no-auto-return.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/no-auto-return.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/no-auto-return.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/no-auto-return.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-arguments.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-arguments.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-arguments.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-arguments.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-eval-params.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-eval-params.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-eval-params.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-eval-params.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-eval.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-eval.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-eval.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-eval.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-octal.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-octal.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-octal.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/not-strict-octal.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/return-arrow-function.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/return-arrow-function.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/return-arrow-function.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/return-arrow-function.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/return-sequence.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/return-sequence.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/return-sequence.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/return-sequence.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/single-param-parens.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/single-param-parens.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/single-param-parens.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/single-param-parens.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/single-param-return-identifier.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/single-param-return-identifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/single-param-return-identifier.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/single-param-return-identifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/single-param.src.js b/packages/shared-fixtures/fixtures/javascript/arrowFunctions/single-param.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/arrowFunctions/single-param.src.js rename to packages/shared-fixtures/fixtures/javascript/arrowFunctions/single-param.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/and-operator-array-object.src.js b/packages/shared-fixtures/fixtures/javascript/basics/and-operator-array-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/and-operator-array-object.src.js rename to packages/shared-fixtures/fixtures/javascript/basics/and-operator-array-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/delete-expression.src.js b/packages/shared-fixtures/fixtures/javascript/basics/delete-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/delete-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/basics/delete-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/do-while-statements.src.js b/packages/shared-fixtures/fixtures/javascript/basics/do-while-statements.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/do-while-statements.src.js rename to packages/shared-fixtures/fixtures/javascript/basics/do-while-statements.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/identifiers-double-underscore.src.js b/packages/shared-fixtures/fixtures/javascript/basics/identifiers-double-underscore.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/identifiers-double-underscore.src.js rename to packages/shared-fixtures/fixtures/javascript/basics/identifiers-double-underscore.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/instanceof.src.js b/packages/shared-fixtures/fixtures/javascript/basics/instanceof.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/instanceof.src.js rename to packages/shared-fixtures/fixtures/javascript/basics/instanceof.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/new-with-member-expression.src.js b/packages/shared-fixtures/fixtures/javascript/basics/new-with-member-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/new-with-member-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/basics/new-with-member-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/new-without-parens.src.js b/packages/shared-fixtures/fixtures/javascript/basics/new-without-parens.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/new-without-parens.src.js rename to packages/shared-fixtures/fixtures/javascript/basics/new-without-parens.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/or-operator-array-object.src.js b/packages/shared-fixtures/fixtures/javascript/basics/or-operator-array-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/or-operator-array-object.src.js rename to packages/shared-fixtures/fixtures/javascript/basics/or-operator-array-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/typeof-expression.src.js b/packages/shared-fixtures/fixtures/javascript/basics/typeof-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/typeof-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/basics/typeof-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/update-expression.src.js b/packages/shared-fixtures/fixtures/javascript/basics/update-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/update-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/basics/update-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/void-expression.src.js b/packages/shared-fixtures/fixtures/javascript/basics/void-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/basics/void-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/basics/void-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/bigIntLiterals/binary.src.js b/packages/shared-fixtures/fixtures/javascript/bigIntLiterals/binary.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/bigIntLiterals/binary.src.js rename to packages/shared-fixtures/fixtures/javascript/bigIntLiterals/binary.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/bigIntLiterals/decimal.src.js b/packages/shared-fixtures/fixtures/javascript/bigIntLiterals/decimal.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/bigIntLiterals/decimal.src.js rename to packages/shared-fixtures/fixtures/javascript/bigIntLiterals/decimal.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/bigIntLiterals/hex.src.js b/packages/shared-fixtures/fixtures/javascript/bigIntLiterals/hex.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/bigIntLiterals/hex.src.js rename to packages/shared-fixtures/fixtures/javascript/bigIntLiterals/hex.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/bigIntLiterals/octal.src.js b/packages/shared-fixtures/fixtures/javascript/bigIntLiterals/octal.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/bigIntLiterals/octal.src.js rename to packages/shared-fixtures/fixtures/javascript/bigIntLiterals/octal.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/binaryLiterals/invalid.src.js b/packages/shared-fixtures/fixtures/javascript/binaryLiterals/invalid.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/binaryLiterals/invalid.src.js rename to packages/shared-fixtures/fixtures/javascript/binaryLiterals/invalid.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/binaryLiterals/lowercase.src.js b/packages/shared-fixtures/fixtures/javascript/binaryLiterals/lowercase.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/binaryLiterals/lowercase.src.js rename to packages/shared-fixtures/fixtures/javascript/binaryLiterals/lowercase.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/binaryLiterals/uppercase.src.js b/packages/shared-fixtures/fixtures/javascript/binaryLiterals/uppercase.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/binaryLiterals/uppercase.src.js rename to packages/shared-fixtures/fixtures/javascript/binaryLiterals/uppercase.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/blockBindings/const.src.js b/packages/shared-fixtures/fixtures/javascript/blockBindings/const.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/blockBindings/const.src.js rename to packages/shared-fixtures/fixtures/javascript/blockBindings/const.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/blockBindings/let-in-switchcase.src.js b/packages/shared-fixtures/fixtures/javascript/blockBindings/let-in-switchcase.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/blockBindings/let-in-switchcase.src.js rename to packages/shared-fixtures/fixtures/javascript/blockBindings/let-in-switchcase.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/blockBindings/let.src.js b/packages/shared-fixtures/fixtures/javascript/blockBindings/let.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/blockBindings/let.src.js rename to packages/shared-fixtures/fixtures/javascript/blockBindings/let.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/callExpression/call-expression-with-array.src.js b/packages/shared-fixtures/fixtures/javascript/callExpression/call-expression-with-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/callExpression/call-expression-with-array.src.js rename to packages/shared-fixtures/fixtures/javascript/callExpression/call-expression-with-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/callExpression/call-expression-with-object.src.js b/packages/shared-fixtures/fixtures/javascript/callExpression/call-expression-with-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/callExpression/call-expression-with-object.src.js rename to packages/shared-fixtures/fixtures/javascript/callExpression/call-expression-with-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/callExpression/mixed-expression.src.js b/packages/shared-fixtures/fixtures/javascript/callExpression/mixed-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/callExpression/mixed-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/callExpression/mixed-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/callExpression/new-expression-with-array.src.js b/packages/shared-fixtures/fixtures/javascript/callExpression/new-expression-with-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/callExpression/new-expression-with-array.src.js rename to packages/shared-fixtures/fixtures/javascript/callExpression/new-expression-with-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/callExpression/new-expression-with-object.src.js b/packages/shared-fixtures/fixtures/javascript/callExpression/new-expression-with-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/callExpression/new-expression-with-object.src.js rename to packages/shared-fixtures/fixtures/javascript/callExpression/new-expression-with-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-accessor-properties.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-accessor-properties.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-accessor-properties.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-accessor-properties.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-computed-static-method.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-computed-static-method.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-computed-static-method.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-computed-static-method.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-expression.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-method-named-prototype.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-method-named-prototype.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-method-named-prototype.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-method-named-prototype.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-method-named-static.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-method-named-static.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-method-named-static.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-method-named-static.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-method-named-with-space.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-method-named-with-space.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-method-named-with-space.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-method-named-with-space.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-one-method-super.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-one-method-super.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-one-method-super.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-one-method-super.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-one-method.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-one-method.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-one-method.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-one-method.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-static-method-named-prototype.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-static-method-named-prototype.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-static-method-named-prototype.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-static-method-named-prototype.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-static-method-named-static.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-static-method-named-static.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-static-method-named-static.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-static-method-named-static.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-static-method.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-static-method.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-static-method.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-static-method.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-static-methods-and-accessor-properties.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-static-methods-and-accessor-properties.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-static-methods-and-accessor-properties.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-static-methods-and-accessor-properties.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-computed-static-methods.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-two-computed-static-methods.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-computed-static-methods.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-two-computed-static-methods.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-methods-computed-constructor.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-two-methods-computed-constructor.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-methods-computed-constructor.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-two-methods-computed-constructor.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-methods-semi.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-two-methods-semi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-methods-semi.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-two-methods-semi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-methods-three-semi.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-two-methods-three-semi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-methods-three-semi.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-two-methods-three-semi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-methods-two-semi.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-two-methods-two-semi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-methods-two-semi.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-two-methods-two-semi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-methods.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-two-methods.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-methods.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-two-methods.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-static-methods-named-constructor.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-two-static-methods-named-constructor.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-two-static-methods-named-constructor.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-two-static-methods-named-constructor.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-with-constructor-parameters.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-with-constructor-parameters.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-with-constructor-parameters.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-with-constructor-parameters.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-with-constructor-with-space.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-with-constructor-with-space.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-with-constructor-with-space.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-with-constructor-with-space.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-with-constructor.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-with-constructor.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/class-with-constructor.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/class-with-constructor.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/derived-class-assign-to-var.src.js b/packages/shared-fixtures/fixtures/javascript/classes/derived-class-assign-to-var.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/derived-class-assign-to-var.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/derived-class-assign-to-var.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/derived-class-expression.src.js b/packages/shared-fixtures/fixtures/javascript/classes/derived-class-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/derived-class-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/derived-class-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/empty-class-double-semi.src.js b/packages/shared-fixtures/fixtures/javascript/classes/empty-class-double-semi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/empty-class-double-semi.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/empty-class-double-semi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/empty-class-semi.src.js b/packages/shared-fixtures/fixtures/javascript/classes/empty-class-semi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/empty-class-semi.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/empty-class-semi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/empty-class.src.js b/packages/shared-fixtures/fixtures/javascript/classes/empty-class.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/empty-class.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/empty-class.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/empty-literal-derived-class.src.js b/packages/shared-fixtures/fixtures/javascript/classes/empty-literal-derived-class.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/empty-literal-derived-class.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/empty-literal-derived-class.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/invalid-class-declaration.src.js b/packages/shared-fixtures/fixtures/javascript/classes/invalid-class-declaration.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/invalid-class-declaration.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/invalid-class-declaration.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/invalid-class-setter-declaration.src.js b/packages/shared-fixtures/fixtures/javascript/classes/invalid-class-setter-declaration.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/invalid-class-setter-declaration.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/invalid-class-setter-declaration.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/invalid-class-two-super-classes.src.js b/packages/shared-fixtures/fixtures/javascript/classes/invalid-class-two-super-classes.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/invalid-class-two-super-classes.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/invalid-class-two-super-classes.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/named-class-expression.src.js b/packages/shared-fixtures/fixtures/javascript/classes/named-class-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/named-class-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/named-class-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/named-derived-class-expression.src.js b/packages/shared-fixtures/fixtures/javascript/classes/named-derived-class-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/classes/named-derived-class-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/classes/named-derived-class-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/defaultParams/class-constructor.src.js b/packages/shared-fixtures/fixtures/javascript/defaultParams/class-constructor.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/defaultParams/class-constructor.src.js rename to packages/shared-fixtures/fixtures/javascript/defaultParams/class-constructor.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/defaultParams/class-method.src.js b/packages/shared-fixtures/fixtures/javascript/defaultParams/class-method.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/defaultParams/class-method.src.js rename to packages/shared-fixtures/fixtures/javascript/defaultParams/class-method.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/defaultParams/declaration.src.js b/packages/shared-fixtures/fixtures/javascript/defaultParams/declaration.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/defaultParams/declaration.src.js rename to packages/shared-fixtures/fixtures/javascript/defaultParams/declaration.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/defaultParams/expression.src.js b/packages/shared-fixtures/fixtures/javascript/defaultParams/expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/defaultParams/expression.src.js rename to packages/shared-fixtures/fixtures/javascript/defaultParams/expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/defaultParams/method.src.js b/packages/shared-fixtures/fixtures/javascript/defaultParams/method.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/defaultParams/method.src.js rename to packages/shared-fixtures/fixtures/javascript/defaultParams/method.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/defaultParams/not-all-params.src.js b/packages/shared-fixtures/fixtures/javascript/defaultParams/not-all-params.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/defaultParams/not-all-params.src.js rename to packages/shared-fixtures/fixtures/javascript/defaultParams/not-all-params.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-object-named.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-object-named.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-object-named.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-object-named.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-nested-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/arrow-param-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-object-nested.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-object-nested.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-object-nested.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-object-nested.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-arrowFunctions/param-defaults-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/array-const-undefined.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/array-const-undefined.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/array-const-undefined.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/array-const-undefined.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/array-let-undefined.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/array-let-undefined.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/array-let-undefined.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/array-let-undefined.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-const-named.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-const-named.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-const-named.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-const-named.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-const-undefined.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-const-undefined.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-const-undefined.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-const-undefined.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-let-named.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-let-named.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-let-named.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-let-named.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-let-undefined.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-let-undefined.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-let-undefined.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-blockBindings/object-let-undefined.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-object-short.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-object-short.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-object-short.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-object-short.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-object-wrapped.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-object-wrapped.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-object-wrapped.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-object-wrapped.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-defaultParams/param-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-forOf/loop.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-forOf/loop.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-forOf/loop.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-forOf/loop.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/complex-destructured.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/complex-destructured.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/complex-destructured.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/complex-destructured.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/destructured-array-literal.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/destructured-array-literal.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/destructured-array-literal.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/destructured-array-literal.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/destructuring-param.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/destructuring-param.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/destructuring-param.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/destructuring-param.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/error-complex-destructured-spread-first.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/error-complex-destructured-spread-first.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/error-complex-destructured-spread-first.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/error-complex-destructured-spread-first.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/invalid-not-final-array-empty.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/invalid-not-final-array-empty.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/invalid-not-final-array-empty.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/invalid-not-final-array-empty.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/multi-destructured.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/multi-destructured.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/multi-destructured.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/multi-destructured.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/not-final-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/not-final-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/not-final-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/not-final-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/single-destructured.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/single-destructured.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/single-destructured.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/single-destructured.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/var-complex-destructured.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/var-complex-destructured.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/var-complex-destructured.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/var-complex-destructured.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/var-destructured-array-literal.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/var-destructured-array-literal.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/var-destructured-array-literal.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/var-destructured-array-literal.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/var-multi-destructured.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/var-multi-destructured.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/var-multi-destructured.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/var-multi-destructured.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/var-single-destructured.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/var-single-destructured.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring-and-spread/var-single-destructured.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring-and-spread/var-single-destructured.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/array-member.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/array-member.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/array-member.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/array-member.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/array-to-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/array-to-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/array-to-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/array-to-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/array-var-undefined.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/array-var-undefined.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/array-var-undefined.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/array-var-undefined.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/call-expression-destruction-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/call-expression-destruction-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/call-expression-destruction-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/call-expression-destruction-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/call-expression-destruction-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/call-expression-destruction-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/call-expression-destruction-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/call-expression-destruction-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-defaults-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-defaults-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-defaults-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-defaults-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-defaults-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-defaults-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-defaults-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-defaults-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/class-constructor-params-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-method-params-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/class-method-params-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-method-params-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/class-method-params-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-method-params-defaults-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/class-method-params-defaults-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-method-params-defaults-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/class-method-params-defaults-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-method-params-defaults-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/class-method-params-defaults-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-method-params-defaults-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/class-method-params-defaults-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-method-params-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/class-method-params-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/class-method-params-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/class-method-params-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-array-all.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-array-all.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-array-all.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-array-all.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-array-longform-nested-multi.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-array-longform-nested-multi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-array-longform-nested-multi.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-array-longform-nested-multi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-array-multi.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-array-multi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-array-multi.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-array-multi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-array-nested-all.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-array-nested-all.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-array-nested-all.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-array-nested-all.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-array-nested-multi.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-array-nested-multi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-array-nested-multi.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-array-nested-multi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-all.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-all.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-all.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-all.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-assign.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-assign.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-assign.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-assign.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-longform-all.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-longform-all.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-longform-all.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-longform-all.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-longform-multi.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-longform-multi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-longform-multi.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-longform-multi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-longform.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-longform.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-longform.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-longform.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-mixed-multi.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-mixed-multi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-mixed-multi.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-mixed-multi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-multi.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-multi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-multi.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-multi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-nested-all.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-nested-all.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-nested-all.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-nested-all.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-nested-multi.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-nested-multi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object-nested-multi.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object-nested-multi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/defaults-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/defaults-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/destructured-array-catch.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/destructured-array-catch.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/destructured-array-catch.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/destructured-array-catch.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/destructured-object-catch.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/destructured-object-catch.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/destructured-object-catch.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/destructured-object-catch.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/invalid-defaults-object-assign.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/invalid-defaults-object-assign.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/invalid-defaults-object-assign.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/invalid-defaults-object-assign.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/named-param.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/named-param.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/named-param.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/named-param.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/nested-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/nested-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/nested-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/nested-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/nested-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/nested-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/nested-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/nested-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/object-var-named.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/object-var-named.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/object-var-named.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/object-var-named.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/object-var-undefined.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/object-var-undefined.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/object-var-undefined.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/object-var-undefined.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/param-defaults-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/param-defaults-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/param-defaults-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/param-defaults-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/param-defaults-object-nested.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/param-defaults-object-nested.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/param-defaults-object-nested.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/param-defaults-object-nested.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/param-defaults-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/param-defaults-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/param-defaults-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/param-defaults-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-array-wrapped.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/params-array-wrapped.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-array-wrapped.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/params-array-wrapped.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/params-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/params-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-multi-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/params-multi-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-multi-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/params-multi-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-nested-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/params-nested-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-nested-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/params-nested-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-nested-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/params-nested-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-nested-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/params-nested-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-object-wrapped.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/params-object-wrapped.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-object-wrapped.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/params-object-wrapped.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-object.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/params-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/params-object.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/params-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/sparse-array.src.js b/packages/shared-fixtures/fixtures/javascript/destructuring/sparse-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/destructuring/sparse-array.src.js rename to packages/shared-fixtures/fixtures/javascript/destructuring/sparse-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/block.src.js b/packages/shared-fixtures/fixtures/javascript/directives/block.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/block.src.js rename to packages/shared-fixtures/fixtures/javascript/directives/block.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/directive-in-class.src.js b/packages/shared-fixtures/fixtures/javascript/directives/directive-in-class.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/directive-in-class.src.js rename to packages/shared-fixtures/fixtures/javascript/directives/directive-in-class.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/first-expression.src.js b/packages/shared-fixtures/fixtures/javascript/directives/first-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/first-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/directives/first-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/function-non-strict.src.js b/packages/shared-fixtures/fixtures/javascript/directives/function-non-strict.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/function-non-strict.src.js rename to packages/shared-fixtures/fixtures/javascript/directives/function-non-strict.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/non-directive-string.src.js b/packages/shared-fixtures/fixtures/javascript/directives/non-directive-string.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/non-directive-string.src.js rename to packages/shared-fixtures/fixtures/javascript/directives/non-directive-string.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/non-unique-directive.src.js b/packages/shared-fixtures/fixtures/javascript/directives/non-unique-directive.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/non-unique-directive.src.js rename to packages/shared-fixtures/fixtures/javascript/directives/non-unique-directive.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/program-order.src.js b/packages/shared-fixtures/fixtures/javascript/directives/program-order.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/program-order.src.js rename to packages/shared-fixtures/fixtures/javascript/directives/program-order.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/program.src.js b/packages/shared-fixtures/fixtures/javascript/directives/program.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/program.src.js rename to packages/shared-fixtures/fixtures/javascript/directives/program.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/raw.src.js b/packages/shared-fixtures/fixtures/javascript/directives/raw.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/directives/raw.src.js rename to packages/shared-fixtures/fixtures/javascript/directives/raw.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalAsyncIteration/async-generators.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalAsyncIteration/async-generators.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalAsyncIteration/async-generators.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalAsyncIteration/async-generators.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalAsyncIteration/async-iterator.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalAsyncIteration/async-iterator.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalAsyncIteration/async-iterator.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalAsyncIteration/async-iterator.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalDynamicImport/dynamic-import.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalDynamicImport/dynamic-import.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalDynamicImport/dynamic-import.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalDynamicImport/dynamic-import.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/arg-spread.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/arg-spread.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/arg-spread.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/arg-spread.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/destructuring-assign-mirror.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/destructuring-assign-mirror.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/destructuring-assign-mirror.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/destructuring-assign-mirror.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/function-parameter-object-spread.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/function-parameter-object-spread.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/function-parameter-object-spread.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/function-parameter-object-spread.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/invalid-rest-trailing-comma.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/invalid-rest-trailing-comma.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/invalid-rest-trailing-comma.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/invalid-rest-trailing-comma.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/invalid-rest.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/invalid-rest.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/invalid-rest.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/invalid-rest.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/object-rest.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/object-rest.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/object-rest.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/object-rest.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/property-spread.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/property-spread.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/property-spread.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/property-spread.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/shorthand-method-args.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/shorthand-method-args.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/shorthand-method-args.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/shorthand-method-args.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/shorthand-methods.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/shorthand-methods.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/shorthand-methods.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/shorthand-methods.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/shorthand-properties.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/shorthand-properties.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/shorthand-properties.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/shorthand-properties.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/single-spread.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/single-spread.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/single-spread.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/single-spread.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/spread-trailing-comma.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/spread-trailing-comma.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/spread-trailing-comma.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/spread-trailing-comma.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/two-spread.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/two-spread.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/two-spread.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalObjectRestSpread/two-spread.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalOptionalCatchBinding/optional-catch-binding-finally.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalOptionalCatchBinding/optional-catch-binding-finally.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalOptionalCatchBinding/optional-catch-binding-finally.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalOptionalCatchBinding/optional-catch-binding-finally.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalOptionalCatchBinding/optional-catch-binding.src.js b/packages/shared-fixtures/fixtures/javascript/experimentalOptionalCatchBinding/optional-catch-binding.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/experimentalOptionalCatchBinding/optional-catch-binding.src.js rename to packages/shared-fixtures/fixtures/javascript/experimentalOptionalCatchBinding/optional-catch-binding.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/exponentiationOperators/exponential-operators.src.js b/packages/shared-fixtures/fixtures/javascript/exponentiationOperators/exponential-operators.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/exponentiationOperators/exponential-operators.src.js rename to packages/shared-fixtures/fixtures/javascript/exponentiationOperators/exponential-operators.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/for/for-empty.src.js b/packages/shared-fixtures/fixtures/javascript/for/for-empty.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/for/for-empty.src.js rename to packages/shared-fixtures/fixtures/javascript/for/for-empty.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/for/for-loop.src.js b/packages/shared-fixtures/fixtures/javascript/for/for-loop.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/for/for-loop.src.js rename to packages/shared-fixtures/fixtures/javascript/for/for-loop.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/for/for-with-coma.src.js b/packages/shared-fixtures/fixtures/javascript/for/for-with-coma.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/for/for-with-coma.src.js rename to packages/shared-fixtures/fixtures/javascript/for/for-with-coma.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/for/for-with-const.src.js b/packages/shared-fixtures/fixtures/javascript/for/for-with-const.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/for/for-with-const.src.js rename to packages/shared-fixtures/fixtures/javascript/for/for-with-const.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/for/for-with-function.src.js b/packages/shared-fixtures/fixtures/javascript/for/for-with-function.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/for/for-with-function.src.js rename to packages/shared-fixtures/fixtures/javascript/for/for-with-function.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/for/for-with-let.src.js b/packages/shared-fixtures/fixtures/javascript/for/for-with-let.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/for/for-with-let.src.js rename to packages/shared-fixtures/fixtures/javascript/for/for-with-let.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-array.src.js b/packages/shared-fixtures/fixtures/javascript/forIn/for-in-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-array.src.js rename to packages/shared-fixtures/fixtures/javascript/forIn/for-in-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-bare-nonstrict.src.js b/packages/shared-fixtures/fixtures/javascript/forIn/for-in-bare-nonstrict.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-bare-nonstrict.src.js rename to packages/shared-fixtures/fixtures/javascript/forIn/for-in-bare-nonstrict.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-destruction-object.src.js b/packages/shared-fixtures/fixtures/javascript/forIn/for-in-destruction-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-destruction-object.src.js rename to packages/shared-fixtures/fixtures/javascript/forIn/for-in-destruction-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-destruction.src.js b/packages/shared-fixtures/fixtures/javascript/forIn/for-in-destruction.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-destruction.src.js rename to packages/shared-fixtures/fixtures/javascript/forIn/for-in-destruction.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-object-with-body.src.js b/packages/shared-fixtures/fixtures/javascript/forIn/for-in-object-with-body.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-object-with-body.src.js rename to packages/shared-fixtures/fixtures/javascript/forIn/for-in-object-with-body.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-object.src.js b/packages/shared-fixtures/fixtures/javascript/forIn/for-in-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-object.src.js rename to packages/shared-fixtures/fixtures/javascript/forIn/for-in-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-with-assigment.src.js b/packages/shared-fixtures/fixtures/javascript/forIn/for-in-with-assigment.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-with-assigment.src.js rename to packages/shared-fixtures/fixtures/javascript/forIn/for-in-with-assigment.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-with-bare-assigment.src.js b/packages/shared-fixtures/fixtures/javascript/forIn/for-in-with-bare-assigment.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-with-bare-assigment.src.js rename to packages/shared-fixtures/fixtures/javascript/forIn/for-in-with-bare-assigment.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-with-const.src.js b/packages/shared-fixtures/fixtures/javascript/forIn/for-in-with-const.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-with-const.src.js rename to packages/shared-fixtures/fixtures/javascript/forIn/for-in-with-const.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-with-milti-asigment.src.js b/packages/shared-fixtures/fixtures/javascript/forIn/for-in-with-milti-asigment.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-with-milti-asigment.src.js rename to packages/shared-fixtures/fixtures/javascript/forIn/for-in-with-milti-asigment.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-with-rest.src.js b/packages/shared-fixtures/fixtures/javascript/forIn/for-in-with-rest.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-with-rest.src.js rename to packages/shared-fixtures/fixtures/javascript/forIn/for-in-with-rest.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-with-var.src.js b/packages/shared-fixtures/fixtures/javascript/forIn/for-in-with-var.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forIn/for-in-with-var.src.js rename to packages/shared-fixtures/fixtures/javascript/forIn/for-in-with-var.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-array.src.js b/packages/shared-fixtures/fixtures/javascript/forOf/for-of-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-array.src.js rename to packages/shared-fixtures/fixtures/javascript/forOf/for-of-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-destruction-object.src.js b/packages/shared-fixtures/fixtures/javascript/forOf/for-of-destruction-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-destruction-object.src.js rename to packages/shared-fixtures/fixtures/javascript/forOf/for-of-destruction-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-destruction.src.js b/packages/shared-fixtures/fixtures/javascript/forOf/for-of-destruction.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-destruction.src.js rename to packages/shared-fixtures/fixtures/javascript/forOf/for-of-destruction.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-object.src.js b/packages/shared-fixtures/fixtures/javascript/forOf/for-of-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-object.src.js rename to packages/shared-fixtures/fixtures/javascript/forOf/for-of-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-with-function-initializer.src.js b/packages/shared-fixtures/fixtures/javascript/forOf/for-of-with-function-initializer.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-with-function-initializer.src.js rename to packages/shared-fixtures/fixtures/javascript/forOf/for-of-with-function-initializer.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-with-rest.src.js b/packages/shared-fixtures/fixtures/javascript/forOf/for-of-with-rest.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-with-rest.src.js rename to packages/shared-fixtures/fixtures/javascript/forOf/for-of-with-rest.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-with-var-and-braces.src.js b/packages/shared-fixtures/fixtures/javascript/forOf/for-of-with-var-and-braces.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-with-var-and-braces.src.js rename to packages/shared-fixtures/fixtures/javascript/forOf/for-of-with-var-and-braces.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-with-var-and-no-braces.src.js b/packages/shared-fixtures/fixtures/javascript/forOf/for-of-with-var-and-no-braces.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/for-of-with-var-and-no-braces.src.js rename to packages/shared-fixtures/fixtures/javascript/forOf/for-of-with-var-and-no-braces.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/invalid-for-of-with-const-and-no-braces.src.js b/packages/shared-fixtures/fixtures/javascript/forOf/invalid-for-of-with-const-and-no-braces.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/invalid-for-of-with-const-and-no-braces.src.js rename to packages/shared-fixtures/fixtures/javascript/forOf/invalid-for-of-with-const-and-no-braces.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/invalid-for-of-with-let-and-no-braces.src.js b/packages/shared-fixtures/fixtures/javascript/forOf/invalid-for-of-with-let-and-no-braces.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/forOf/invalid-for-of-with-let-and-no-braces.src.js rename to packages/shared-fixtures/fixtures/javascript/forOf/invalid-for-of-with-let-and-no-braces.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/anonymous-generator.src.js b/packages/shared-fixtures/fixtures/javascript/generators/anonymous-generator.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/anonymous-generator.src.js rename to packages/shared-fixtures/fixtures/javascript/generators/anonymous-generator.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/async-generator-function.src.js b/packages/shared-fixtures/fixtures/javascript/generators/async-generator-function.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/async-generator-function.src.js rename to packages/shared-fixtures/fixtures/javascript/generators/async-generator-function.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/async-generator-method.src.js b/packages/shared-fixtures/fixtures/javascript/generators/async-generator-method.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/async-generator-method.src.js rename to packages/shared-fixtures/fixtures/javascript/generators/async-generator-method.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/double-yield.src.js b/packages/shared-fixtures/fixtures/javascript/generators/double-yield.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/double-yield.src.js rename to packages/shared-fixtures/fixtures/javascript/generators/double-yield.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/empty-generator-declaration.src.js b/packages/shared-fixtures/fixtures/javascript/generators/empty-generator-declaration.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/empty-generator-declaration.src.js rename to packages/shared-fixtures/fixtures/javascript/generators/empty-generator-declaration.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/generator-declaration.src.js b/packages/shared-fixtures/fixtures/javascript/generators/generator-declaration.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/generator-declaration.src.js rename to packages/shared-fixtures/fixtures/javascript/generators/generator-declaration.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/yield-delegation.src.js b/packages/shared-fixtures/fixtures/javascript/generators/yield-delegation.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/yield-delegation.src.js rename to packages/shared-fixtures/fixtures/javascript/generators/yield-delegation.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/yield-without-value-in-call.src.js b/packages/shared-fixtures/fixtures/javascript/generators/yield-without-value-in-call.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/yield-without-value-in-call.src.js rename to packages/shared-fixtures/fixtures/javascript/generators/yield-without-value-in-call.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/yield-without-value-no-semi.src.js b/packages/shared-fixtures/fixtures/javascript/generators/yield-without-value-no-semi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/yield-without-value-no-semi.src.js rename to packages/shared-fixtures/fixtures/javascript/generators/yield-without-value-no-semi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/yield-without-value.src.js b/packages/shared-fixtures/fixtures/javascript/generators/yield-without-value.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/generators/yield-without-value.src.js rename to packages/shared-fixtures/fixtures/javascript/generators/yield-without-value.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/globalReturn/return-identifier.src.js b/packages/shared-fixtures/fixtures/javascript/globalReturn/return-identifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/globalReturn/return-identifier.src.js rename to packages/shared-fixtures/fixtures/javascript/globalReturn/return-identifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/globalReturn/return-no-arg.src.js b/packages/shared-fixtures/fixtures/javascript/globalReturn/return-no-arg.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/globalReturn/return-no-arg.src.js rename to packages/shared-fixtures/fixtures/javascript/globalReturn/return-no-arg.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/globalReturn/return-true.src.js b/packages/shared-fixtures/fixtures/javascript/globalReturn/return-true.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/globalReturn/return-true.src.js rename to packages/shared-fixtures/fixtures/javascript/globalReturn/return-true.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/hexLiterals/invalid.src.js b/packages/shared-fixtures/fixtures/javascript/hexLiterals/invalid.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/hexLiterals/invalid.src.js rename to packages/shared-fixtures/fixtures/javascript/hexLiterals/invalid.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/hexLiterals/lowercase.src.js b/packages/shared-fixtures/fixtures/javascript/hexLiterals/lowercase.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/hexLiterals/lowercase.src.js rename to packages/shared-fixtures/fixtures/javascript/hexLiterals/lowercase.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/hexLiterals/uppercase.src.js b/packages/shared-fixtures/fixtures/javascript/hexLiterals/uppercase.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/hexLiterals/uppercase.src.js rename to packages/shared-fixtures/fixtures/javascript/hexLiterals/uppercase.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/importMeta/simple-import-meta.src.js b/packages/shared-fixtures/fixtures/javascript/importMeta/simple-import-meta.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/importMeta/simple-import-meta.src.js rename to packages/shared-fixtures/fixtures/javascript/importMeta/simple-import-meta.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/labels/label-break.src.js b/packages/shared-fixtures/fixtures/javascript/labels/label-break.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/labels/label-break.src.js rename to packages/shared-fixtures/fixtures/javascript/labels/label-break.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/labels/label-continue.src.js b/packages/shared-fixtures/fixtures/javascript/labels/label-continue.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/labels/label-continue.src.js rename to packages/shared-fixtures/fixtures/javascript/labels/label-continue.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/error-delete.src.js b/packages/shared-fixtures/fixtures/javascript/modules/error-delete.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/error-delete.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/error-delete.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/error-function.src.js b/packages/shared-fixtures/fixtures/javascript/modules/error-function.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/error-function.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/error-function.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/error-strict.src.js b/packages/shared-fixtures/fixtures/javascript/modules/error-strict.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/error-strict.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/error-strict.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-array.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-default-array.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-array.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-default-array.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-class.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-default-class.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-class.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-default-class.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-expression.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-default-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-default-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-function.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-default-function.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-function.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-default-function.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-named-class.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-default-named-class.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-named-class.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-default-named-class.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-named-function.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-default-named-function.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-named-function.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-default-named-function.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-number.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-default-number.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-number.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-default-number.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-object.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-default-object.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-object.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-default-object.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-value.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-default-value.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-default-value.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-default-value.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-batch.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-from-batch.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-batch.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-from-batch.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-default.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-from-default.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-default.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-from-default.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-named-as-default.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-from-named-as-default.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-named-as-default.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-from-named-as-default.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-named-as-specifier.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-from-named-as-specifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-named-as-specifier.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-from-named-as-specifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-named-as-specifiers.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-from-named-as-specifiers.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-named-as-specifiers.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-from-named-as-specifiers.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-specifier.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-from-specifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-specifier.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-from-specifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-specifiers.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-from-specifiers.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-from-specifiers.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-from-specifiers.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-function.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-function.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-function.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-function.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-as-default.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-named-as-default.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-as-default.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-named-as-default.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-as-specifier.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-named-as-specifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-as-specifier.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-named-as-specifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-as-specifiers.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-named-as-specifiers.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-as-specifiers.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-named-as-specifiers.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-class.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-named-class.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-class.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-named-class.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-empty.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-named-empty.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-empty.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-named-empty.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-specifier.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-named-specifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-specifier.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-named-specifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-specifiers-comma.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-named-specifiers-comma.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-specifiers-comma.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-named-specifiers-comma.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-specifiers.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-named-specifiers.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-named-specifiers.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-named-specifiers.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-var-anonymous-function.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-var-anonymous-function.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-var-anonymous-function.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-var-anonymous-function.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-var-number.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-var-number.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-var-number.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-var-number.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-var.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-var.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/export-var.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/export-var.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-default-and-named-specifiers.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-default-and-named-specifiers.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-default-and-named-specifiers.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-default-and-named-specifiers.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-default-and-namespace-specifiers.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-default-and-namespace-specifiers.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-default-and-namespace-specifiers.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-default-and-namespace-specifiers.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-default-as.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-default-as.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-default-as.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-default-as.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-default.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-default.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-default.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-default.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-jquery.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-jquery.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-jquery.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-jquery.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-module.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-module.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-module.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-module.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-named-as-specifier.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-named-as-specifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-named-as-specifier.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-named-as-specifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-named-as-specifiers.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-named-as-specifiers.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-named-as-specifiers.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-named-as-specifiers.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-named-empty.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-named-empty.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-named-empty.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-named-empty.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-named-specifier.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-named-specifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-named-specifier.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-named-specifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-named-specifiers-comma.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-named-specifiers-comma.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-named-specifiers-comma.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-named-specifiers-comma.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-named-specifiers.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-named-specifiers.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-named-specifiers.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-named-specifiers.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-namespace-specifier.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-namespace-specifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-namespace-specifier.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-namespace-specifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-null-as-nil.src.js b/packages/shared-fixtures/fixtures/javascript/modules/import-null-as-nil.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/import-null-as-nil.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/import-null-as-nil.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-await.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-await.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-await.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-await.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-class.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-class.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-class.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-class.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-batch-missing-from-clause.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-export-batch-missing-from-clause.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-batch-missing-from-clause.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-export-batch-missing-from-clause.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-batch-token.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-export-batch-token.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-batch-token.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-export-batch-token.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-default-equal.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-export-default-equal.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-default-equal.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-export-default-equal.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-default-token.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-export-default-token.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-default-token.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-export-default-token.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-default.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-export-default.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-default.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-export-default.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-named-default.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-export-named-default.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-named-default.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-export-named-default.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-named-extra-comma.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-export-named-extra-comma.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-named-extra-comma.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-export-named-extra-comma.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-named-middle-comma.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-export-named-middle-comma.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-export-named-middle-comma.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-export-named-middle-comma.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-default-after-named-after-default.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-default-after-named-after-default.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-default-after-named-after-default.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-default-after-named-after-default.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-default-after-named.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-default-after-named.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-default-after-named.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-default-after-named.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-default-missing-module-specifier.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-default-missing-module-specifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-default-missing-module-specifier.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-default-missing-module-specifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-default-module-specifier.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-default-module-specifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-default-module-specifier.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-default-module-specifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-default.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-default.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-default.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-default.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-missing-module-specifier.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-missing-module-specifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-missing-module-specifier.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-missing-module-specifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-module-specifier.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-module-specifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-module-specifier.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-module-specifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-named-after-named.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-named-after-named.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-named-after-named.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-named-after-named.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-named-after-namespace.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-named-after-namespace.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-named-after-namespace.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-named-after-namespace.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-named-as-missing-from.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-named-as-missing-from.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-named-as-missing-from.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-named-as-missing-from.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-named-extra-comma.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-named-extra-comma.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-named-extra-comma.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-named-extra-comma.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-named-middle-comma.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-named-middle-comma.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-named-middle-comma.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-named-middle-comma.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-namespace-after-named.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-namespace-after-named.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-namespace-after-named.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-namespace-after-named.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-namespace-missing-as.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-import-namespace-missing-as.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/modules/invalid-import-namespace-missing-as.src.js rename to packages/shared-fixtures/fixtures/javascript/modules/invalid-import-namespace-missing-as.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/newTarget/invalid-new-target.src.js b/packages/shared-fixtures/fixtures/javascript/newTarget/invalid-new-target.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/newTarget/invalid-new-target.src.js rename to packages/shared-fixtures/fixtures/javascript/newTarget/invalid-new-target.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/newTarget/invalid-unknown-property.src.js b/packages/shared-fixtures/fixtures/javascript/newTarget/invalid-unknown-property.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/newTarget/invalid-unknown-property.src.js rename to packages/shared-fixtures/fixtures/javascript/newTarget/invalid-unknown-property.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/newTarget/simple-new-target.src.js b/packages/shared-fixtures/fixtures/javascript/newTarget/simple-new-target.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/newTarget/simple-new-target.src.js rename to packages/shared-fixtures/fixtures/javascript/newTarget/simple-new-target.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteral/object-literal-in-lhs.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteral/object-literal-in-lhs.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteral/object-literal-in-lhs.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteral/object-literal-in-lhs.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-addition-property.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-addition-property.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-addition-property.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-addition-property.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-and-identifier.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-and-identifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-and-identifier.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-and-identifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-getter-and-setter.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-getter-and-setter.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-getter-and-setter.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-getter-and-setter.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-string-property.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-string-property.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-string-property.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-string-property.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-variable-property.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-variable-property.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-variable-property.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/computed-variable-property.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/invalid-computed-variable-property.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/invalid-computed-variable-property.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/invalid-computed-variable-property.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/invalid-computed-variable-property.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/invalid-standalone-computed-variable-property.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/invalid-standalone-computed-variable-property.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/invalid-standalone-computed-variable-property.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/invalid-standalone-computed-variable-property.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/standalone-expression-with-addition.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/standalone-expression-with-addition.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/standalone-expression-with-addition.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/standalone-expression-with-addition.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/standalone-expression-with-method.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/standalone-expression-with-method.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/standalone-expression-with-method.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/standalone-expression-with-method.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/standalone-expression.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/standalone-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/standalone-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralComputedProperties/standalone-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/error-proto-property.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/error-proto-property.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/error-proto-property.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/error-proto-property.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/error-proto-string-property.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/error-proto-string-property.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/error-proto-string-property.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/error-proto-string-property.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/strict-duplicate-properties.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/strict-duplicate-properties.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/strict-duplicate-properties.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/strict-duplicate-properties.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/strict-duplicate-string-properties.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/strict-duplicate-string-properties.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/strict-duplicate-string-properties.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralDuplicateProperties/strict-duplicate-string-properties.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/invalid-method-no-braces.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/invalid-method-no-braces.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/invalid-method-no-braces.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/invalid-method-no-braces.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/method-property.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/method-property.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/method-property.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/method-property.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-named-get.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-named-get.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-named-get.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-named-get.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-named-set.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-named-set.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-named-set.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-named-set.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-with-argument.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-with-argument.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-with-argument.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-with-argument.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-with-string-name.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-with-string-name.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-with-string-name.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method-with-string-name.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/simple-method.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/string-name-method-property.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/string-name-method-property.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/string-name-method-property.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandMethods/string-name-method-property.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandProperties/shorthand-properties.src.js b/packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandProperties/shorthand-properties.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/objectLiteralShorthandProperties/shorthand-properties.src.js rename to packages/shared-fixtures/fixtures/javascript/objectLiteralShorthandProperties/shorthand-properties.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/octalLiterals/invalid.src.js b/packages/shared-fixtures/fixtures/javascript/octalLiterals/invalid.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/octalLiterals/invalid.src.js rename to packages/shared-fixtures/fixtures/javascript/octalLiterals/invalid.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/octalLiterals/legacy.src.js b/packages/shared-fixtures/fixtures/javascript/octalLiterals/legacy.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/octalLiterals/legacy.src.js rename to packages/shared-fixtures/fixtures/javascript/octalLiterals/legacy.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/octalLiterals/lowercase.src.js b/packages/shared-fixtures/fixtures/javascript/octalLiterals/lowercase.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/octalLiterals/lowercase.src.js rename to packages/shared-fixtures/fixtures/javascript/octalLiterals/lowercase.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/octalLiterals/strict-uppercase.src.js b/packages/shared-fixtures/fixtures/javascript/octalLiterals/strict-uppercase.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/octalLiterals/strict-uppercase.src.js rename to packages/shared-fixtures/fixtures/javascript/octalLiterals/strict-uppercase.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/octalLiterals/uppercase.src.js b/packages/shared-fixtures/fixtures/javascript/octalLiterals/uppercase.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/octalLiterals/uppercase.src.js rename to packages/shared-fixtures/fixtures/javascript/octalLiterals/uppercase.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/regex/regexp-simple.src.js b/packages/shared-fixtures/fixtures/javascript/regex/regexp-simple.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/regex/regexp-simple.src.js rename to packages/shared-fixtures/fixtures/javascript/regex/regexp-simple.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/regexUFlag/regex-u-extended-escape.src.js b/packages/shared-fixtures/fixtures/javascript/regexUFlag/regex-u-extended-escape.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/regexUFlag/regex-u-extended-escape.src.js rename to packages/shared-fixtures/fixtures/javascript/regexUFlag/regex-u-extended-escape.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/regexUFlag/regex-u-invalid-extended-escape.src.js b/packages/shared-fixtures/fixtures/javascript/regexUFlag/regex-u-invalid-extended-escape.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/regexUFlag/regex-u-invalid-extended-escape.src.js rename to packages/shared-fixtures/fixtures/javascript/regexUFlag/regex-u-invalid-extended-escape.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/regexUFlag/regex-u-simple.src.js b/packages/shared-fixtures/fixtures/javascript/regexUFlag/regex-u-simple.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/regexUFlag/regex-u-simple.src.js rename to packages/shared-fixtures/fixtures/javascript/regexUFlag/regex-u-simple.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/regexYFlag/regexp-y-simple.src.js b/packages/shared-fixtures/fixtures/javascript/regexYFlag/regexp-y-simple.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/regexYFlag/regexp-y-simple.src.js rename to packages/shared-fixtures/fixtures/javascript/regexYFlag/regexp-y-simple.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/basic-rest.src.js b/packages/shared-fixtures/fixtures/javascript/restParams/basic-rest.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/basic-rest.src.js rename to packages/shared-fixtures/fixtures/javascript/restParams/basic-rest.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/class-constructor.src.js b/packages/shared-fixtures/fixtures/javascript/restParams/class-constructor.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/class-constructor.src.js rename to packages/shared-fixtures/fixtures/javascript/restParams/class-constructor.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/class-method.src.js b/packages/shared-fixtures/fixtures/javascript/restParams/class-method.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/class-method.src.js rename to packages/shared-fixtures/fixtures/javascript/restParams/class-method.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/error-no-default.src.js b/packages/shared-fixtures/fixtures/javascript/restParams/error-no-default.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/error-no-default.src.js rename to packages/shared-fixtures/fixtures/javascript/restParams/error-no-default.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/error-not-last.src.js b/packages/shared-fixtures/fixtures/javascript/restParams/error-not-last.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/error-not-last.src.js rename to packages/shared-fixtures/fixtures/javascript/restParams/error-not-last.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/func-expression-multi.src.js b/packages/shared-fixtures/fixtures/javascript/restParams/func-expression-multi.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/func-expression-multi.src.js rename to packages/shared-fixtures/fixtures/javascript/restParams/func-expression-multi.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/func-expression.src.js b/packages/shared-fixtures/fixtures/javascript/restParams/func-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/func-expression.src.js rename to packages/shared-fixtures/fixtures/javascript/restParams/func-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/invalid-rest-param.src.js b/packages/shared-fixtures/fixtures/javascript/restParams/invalid-rest-param.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/invalid-rest-param.src.js rename to packages/shared-fixtures/fixtures/javascript/restParams/invalid-rest-param.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/single-rest.src.js b/packages/shared-fixtures/fixtures/javascript/restParams/single-rest.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/restParams/single-rest.src.js rename to packages/shared-fixtures/fixtures/javascript/restParams/single-rest.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-float-negative.src.js b/packages/shared-fixtures/fixtures/javascript/simple-literals/literal-float-negative.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-float-negative.src.js rename to packages/shared-fixtures/fixtures/javascript/simple-literals/literal-float-negative.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-float.src.js b/packages/shared-fixtures/fixtures/javascript/simple-literals/literal-float.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-float.src.js rename to packages/shared-fixtures/fixtures/javascript/simple-literals/literal-float.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-null.src.js b/packages/shared-fixtures/fixtures/javascript/simple-literals/literal-null.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-null.src.js rename to packages/shared-fixtures/fixtures/javascript/simple-literals/literal-null.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-number-negative.src.js b/packages/shared-fixtures/fixtures/javascript/simple-literals/literal-number-negative.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-number-negative.src.js rename to packages/shared-fixtures/fixtures/javascript/simple-literals/literal-number-negative.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-number.src.js b/packages/shared-fixtures/fixtures/javascript/simple-literals/literal-number.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-number.src.js rename to packages/shared-fixtures/fixtures/javascript/simple-literals/literal-number.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-string.src.js b/packages/shared-fixtures/fixtures/javascript/simple-literals/literal-string.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-string.src.js rename to packages/shared-fixtures/fixtures/javascript/simple-literals/literal-string.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-undefined.src.js b/packages/shared-fixtures/fixtures/javascript/simple-literals/literal-undefined.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/simple-literals/literal-undefined.src.js rename to packages/shared-fixtures/fixtures/javascript/simple-literals/literal-undefined.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/spread/complex-spread.src.js b/packages/shared-fixtures/fixtures/javascript/spread/complex-spread.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/spread/complex-spread.src.js rename to packages/shared-fixtures/fixtures/javascript/spread/complex-spread.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/spread/error-invalid-if.src.js b/packages/shared-fixtures/fixtures/javascript/spread/error-invalid-if.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/spread/error-invalid-if.src.js rename to packages/shared-fixtures/fixtures/javascript/spread/error-invalid-if.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/spread/error-invalid-sequence.src.js b/packages/shared-fixtures/fixtures/javascript/spread/error-invalid-sequence.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/spread/error-invalid-sequence.src.js rename to packages/shared-fixtures/fixtures/javascript/spread/error-invalid-sequence.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/spread/multi-function-call.src.js b/packages/shared-fixtures/fixtures/javascript/spread/multi-function-call.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/spread/multi-function-call.src.js rename to packages/shared-fixtures/fixtures/javascript/spread/multi-function-call.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/spread/not-final-param.src.js b/packages/shared-fixtures/fixtures/javascript/spread/not-final-param.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/spread/not-final-param.src.js rename to packages/shared-fixtures/fixtures/javascript/spread/not-final-param.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/spread/simple-function-call.src.js b/packages/shared-fixtures/fixtures/javascript/spread/simple-function-call.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/spread/simple-function-call.src.js rename to packages/shared-fixtures/fixtures/javascript/spread/simple-function-call.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/deeply-nested.src.js b/packages/shared-fixtures/fixtures/javascript/templateStrings/deeply-nested.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/deeply-nested.src.js rename to packages/shared-fixtures/fixtures/javascript/templateStrings/deeply-nested.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/error-octal-literal.src.js b/packages/shared-fixtures/fixtures/javascript/templateStrings/error-octal-literal.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/error-octal-literal.src.js rename to packages/shared-fixtures/fixtures/javascript/templateStrings/error-octal-literal.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/escape-characters.src.js b/packages/shared-fixtures/fixtures/javascript/templateStrings/escape-characters.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/escape-characters.src.js rename to packages/shared-fixtures/fixtures/javascript/templateStrings/escape-characters.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/expressions.src.js b/packages/shared-fixtures/fixtures/javascript/templateStrings/expressions.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/expressions.src.js rename to packages/shared-fixtures/fixtures/javascript/templateStrings/expressions.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/multi-line-template-string.src.js b/packages/shared-fixtures/fixtures/javascript/templateStrings/multi-line-template-string.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/multi-line-template-string.src.js rename to packages/shared-fixtures/fixtures/javascript/templateStrings/multi-line-template-string.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/simple-template-string.src.js b/packages/shared-fixtures/fixtures/javascript/templateStrings/simple-template-string.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/simple-template-string.src.js rename to packages/shared-fixtures/fixtures/javascript/templateStrings/simple-template-string.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/single-dollar-sign.src.js b/packages/shared-fixtures/fixtures/javascript/templateStrings/single-dollar-sign.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/single-dollar-sign.src.js rename to packages/shared-fixtures/fixtures/javascript/templateStrings/single-dollar-sign.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/tagged-no-placeholders.src.js b/packages/shared-fixtures/fixtures/javascript/templateStrings/tagged-no-placeholders.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/tagged-no-placeholders.src.js rename to packages/shared-fixtures/fixtures/javascript/templateStrings/tagged-no-placeholders.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/tagged-template-string.src.js b/packages/shared-fixtures/fixtures/javascript/templateStrings/tagged-template-string.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/templateStrings/tagged-template-string.src.js rename to packages/shared-fixtures/fixtures/javascript/templateStrings/tagged-template-string.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/basic-string-literal.src.js b/packages/shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/basic-string-literal.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/basic-string-literal.src.js rename to packages/shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/basic-string-literal.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/complex-string-literal.src.js b/packages/shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/complex-string-literal.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/complex-string-literal.src.js rename to packages/shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/complex-string-literal.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/invalid-empty-escape.src.js b/packages/shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/invalid-empty-escape.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/invalid-empty-escape.src.js rename to packages/shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/invalid-empty-escape.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/invalid-too-large-escape.src.js b/packages/shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/invalid-too-large-escape.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/invalid-too-large-escape.src.js rename to packages/shared-fixtures/fixtures/javascript/unicodeCodePointEscapes/invalid-too-large-escape.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx-useJSXTextNode/self-closing-tag-inside-tag.src.js b/packages/shared-fixtures/fixtures/jsx-useJSXTextNode/self-closing-tag-inside-tag.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx-useJSXTextNode/self-closing-tag-inside-tag.src.js rename to packages/shared-fixtures/fixtures/jsx-useJSXTextNode/self-closing-tag-inside-tag.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx-useJSXTextNode/test-content.src.js b/packages/shared-fixtures/fixtures/jsx-useJSXTextNode/test-content.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx-useJSXTextNode/test-content.src.js rename to packages/shared-fixtures/fixtures/jsx-useJSXTextNode/test-content.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/attributes.src.js b/packages/shared-fixtures/fixtures/jsx/attributes.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/attributes.src.js rename to packages/shared-fixtures/fixtures/jsx/attributes.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/element-keyword-name.src.js b/packages/shared-fixtures/fixtures/jsx/element-keyword-name.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/element-keyword-name.src.js rename to packages/shared-fixtures/fixtures/jsx/element-keyword-name.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/embedded-comment.src.js b/packages/shared-fixtures/fixtures/jsx/embedded-comment.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/embedded-comment.src.js rename to packages/shared-fixtures/fixtures/jsx/embedded-comment.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/embedded-conditional.src.js b/packages/shared-fixtures/fixtures/jsx/embedded-conditional.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/embedded-conditional.src.js rename to packages/shared-fixtures/fixtures/jsx/embedded-conditional.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/embedded-invalid-js-identifier.src.js b/packages/shared-fixtures/fixtures/jsx/embedded-invalid-js-identifier.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/embedded-invalid-js-identifier.src.js rename to packages/shared-fixtures/fixtures/jsx/embedded-invalid-js-identifier.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/embedded-tags.src.js b/packages/shared-fixtures/fixtures/jsx/embedded-tags.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/embedded-tags.src.js rename to packages/shared-fixtures/fixtures/jsx/embedded-tags.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/empty-placeholder.src.js b/packages/shared-fixtures/fixtures/jsx/empty-placeholder.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/empty-placeholder.src.js rename to packages/shared-fixtures/fixtures/jsx/empty-placeholder.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/escape-patterns.src.js b/packages/shared-fixtures/fixtures/jsx/escape-patterns.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/escape-patterns.src.js rename to packages/shared-fixtures/fixtures/jsx/escape-patterns.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-attribute-missing-equals.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-attribute-missing-equals.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-attribute-missing-equals.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-attribute-missing-equals.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-attribute.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-attribute.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-attribute.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-attribute.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-broken-tag.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-broken-tag.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-broken-tag.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-broken-tag.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-computed-end-tag-name.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-computed-end-tag-name.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-computed-end-tag-name.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-computed-end-tag-name.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-computed-string-end-tag-name.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-computed-string-end-tag-name.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-computed-string-end-tag-name.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-computed-string-end-tag-name.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-embedded-expression.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-embedded-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-embedded-expression.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-embedded-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-leading-dot-tag-name.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-leading-dot-tag-name.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-leading-dot-tag-name.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-leading-dot-tag-name.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-matching-placeholder-in-closing-tag.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-matching-placeholder-in-closing-tag.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-matching-placeholder-in-closing-tag.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-matching-placeholder-in-closing-tag.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-mismatched-closing-tag.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-mismatched-closing-tag.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-mismatched-closing-tag.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-mismatched-closing-tag.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-mismatched-closing-tags.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-mismatched-closing-tags.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-mismatched-closing-tags.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-mismatched-closing-tags.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-mismatched-dot-tag-name.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-mismatched-dot-tag-name.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-mismatched-dot-tag-name.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-mismatched-dot-tag-name.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-mismatched-namespace-tag.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-mismatched-namespace-tag.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-mismatched-namespace-tag.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-mismatched-namespace-tag.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-missing-closing-tag-attribute-placeholder.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-missing-closing-tag-attribute-placeholder.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-missing-closing-tag-attribute-placeholder.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-missing-closing-tag-attribute-placeholder.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-missing-closing-tag.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-missing-closing-tag.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-missing-closing-tag.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-missing-closing-tag.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-missing-namespace-name.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-missing-namespace-name.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-missing-namespace-name.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-missing-namespace-name.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-missing-namespace-value.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-missing-namespace-value.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-missing-namespace-value.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-missing-namespace-value.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-missing-spread-operator.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-missing-spread-operator.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-missing-spread-operator.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-missing-spread-operator.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-namespace-name-with-docts.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-namespace-name-with-docts.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-namespace-name-with-docts.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-namespace-name-with-docts.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-namespace-value-with-dots.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-namespace-value-with-dots.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-namespace-value-with-dots.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-namespace-value-with-dots.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-no-common-parent-with-comment.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-no-common-parent-with-comment.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-no-common-parent-with-comment.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-no-common-parent-with-comment.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-no-common-parent.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-no-common-parent.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-no-common-parent.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-no-common-parent.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-no-tag-name.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-no-tag-name.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-no-tag-name.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-no-tag-name.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-placeholder-in-closing-tag.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-placeholder-in-closing-tag.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-placeholder-in-closing-tag.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-placeholder-in-closing-tag.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-shorthand-fragment-no-closing.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-shorthand-fragment-no-closing.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-shorthand-fragment-no-closing.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-shorthand-fragment-no-closing.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-trailing-dot-tag-name.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-trailing-dot-tag-name.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-trailing-dot-tag-name.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-trailing-dot-tag-name.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-unexpected-comma.src.js b/packages/shared-fixtures/fixtures/jsx/invalid-unexpected-comma.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/invalid-unexpected-comma.src.js rename to packages/shared-fixtures/fixtures/jsx/invalid-unexpected-comma.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/japanese-characters.src.js b/packages/shared-fixtures/fixtures/jsx/japanese-characters.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/japanese-characters.src.js rename to packages/shared-fixtures/fixtures/jsx/japanese-characters.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/less-than-operator.src.js b/packages/shared-fixtures/fixtures/jsx/less-than-operator.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/less-than-operator.src.js rename to packages/shared-fixtures/fixtures/jsx/less-than-operator.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/member-expression-this.src.js b/packages/shared-fixtures/fixtures/jsx/member-expression-this.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/member-expression-this.src.js rename to packages/shared-fixtures/fixtures/jsx/member-expression-this.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/member-expression.src.js b/packages/shared-fixtures/fixtures/jsx/member-expression.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/member-expression.src.js rename to packages/shared-fixtures/fixtures/jsx/member-expression.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/multiple-blank-spaces.src.js b/packages/shared-fixtures/fixtures/jsx/multiple-blank-spaces.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/multiple-blank-spaces.src.js rename to packages/shared-fixtures/fixtures/jsx/multiple-blank-spaces.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/namespaced-attribute-and-value-inserted.src.js b/packages/shared-fixtures/fixtures/jsx/namespaced-attribute-and-value-inserted.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/namespaced-attribute-and-value-inserted.src.js rename to packages/shared-fixtures/fixtures/jsx/namespaced-attribute-and-value-inserted.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/namespaced-name-and-attribute.src.js b/packages/shared-fixtures/fixtures/jsx/namespaced-name-and-attribute.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/namespaced-name-and-attribute.src.js rename to packages/shared-fixtures/fixtures/jsx/namespaced-name-and-attribute.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/newslines-and-entities.src.js b/packages/shared-fixtures/fixtures/jsx/newslines-and-entities.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/newslines-and-entities.src.js rename to packages/shared-fixtures/fixtures/jsx/newslines-and-entities.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/self-closing-tag-inside-tag.src.js b/packages/shared-fixtures/fixtures/jsx/self-closing-tag-inside-tag.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/self-closing-tag-inside-tag.src.js rename to packages/shared-fixtures/fixtures/jsx/self-closing-tag-inside-tag.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/self-closing-tag-with-newline.src.js b/packages/shared-fixtures/fixtures/jsx/self-closing-tag-with-newline.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/self-closing-tag-with-newline.src.js rename to packages/shared-fixtures/fixtures/jsx/self-closing-tag-with-newline.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/self-closing-tag.src.js b/packages/shared-fixtures/fixtures/jsx/self-closing-tag.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/self-closing-tag.src.js rename to packages/shared-fixtures/fixtures/jsx/self-closing-tag.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/shorthand-fragment-with-child.src.js b/packages/shared-fixtures/fixtures/jsx/shorthand-fragment-with-child.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/shorthand-fragment-with-child.src.js rename to packages/shared-fixtures/fixtures/jsx/shorthand-fragment-with-child.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/shorthand-fragment.src.js b/packages/shared-fixtures/fixtures/jsx/shorthand-fragment.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/shorthand-fragment.src.js rename to packages/shared-fixtures/fixtures/jsx/shorthand-fragment.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/spread-child.src.js b/packages/shared-fixtures/fixtures/jsx/spread-child.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/spread-child.src.js rename to packages/shared-fixtures/fixtures/jsx/spread-child.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/spread-operator-attribute-and-regular-attribute.src.js b/packages/shared-fixtures/fixtures/jsx/spread-operator-attribute-and-regular-attribute.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/spread-operator-attribute-and-regular-attribute.src.js rename to packages/shared-fixtures/fixtures/jsx/spread-operator-attribute-and-regular-attribute.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/spread-operator-attributes.src.js b/packages/shared-fixtures/fixtures/jsx/spread-operator-attributes.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/spread-operator-attributes.src.js rename to packages/shared-fixtures/fixtures/jsx/spread-operator-attributes.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/tag-names-with-dots.src.js b/packages/shared-fixtures/fixtures/jsx/tag-names-with-dots.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/tag-names-with-dots.src.js rename to packages/shared-fixtures/fixtures/jsx/tag-names-with-dots.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/tag-names-with-multi-dots.src.js b/packages/shared-fixtures/fixtures/jsx/tag-names-with-multi-dots.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/tag-names-with-multi-dots.src.js rename to packages/shared-fixtures/fixtures/jsx/tag-names-with-multi-dots.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/test-content.src.js b/packages/shared-fixtures/fixtures/jsx/test-content.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/test-content.src.js rename to packages/shared-fixtures/fixtures/jsx/test-content.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/trailing-spread-operator-attribute.src.js b/packages/shared-fixtures/fixtures/jsx/trailing-spread-operator-attribute.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/trailing-spread-operator-attribute.src.js rename to packages/shared-fixtures/fixtures/jsx/trailing-spread-operator-attribute.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/jsx/unknown-escape-pattern.src.js b/packages/shared-fixtures/fixtures/jsx/unknown-escape-pattern.src.js similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/jsx/unknown-escape-pattern.src.js rename to packages/shared-fixtures/fixtures/jsx/unknown-escape-pattern.src.js diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/tsx/generic-jsx-element.src.tsx b/packages/shared-fixtures/fixtures/tsx/generic-jsx-element.src.tsx similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/tsx/generic-jsx-element.src.tsx rename to packages/shared-fixtures/fixtures/tsx/generic-jsx-element.src.tsx diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/tsx/react-typed-props.src.tsx b/packages/shared-fixtures/fixtures/tsx/react-typed-props.src.tsx similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/tsx/react-typed-props.src.tsx rename to packages/shared-fixtures/fixtures/tsx/react-typed-props.src.tsx diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/babylon-convergence/type-parameter-whitespace-loc.src.ts b/packages/shared-fixtures/fixtures/typescript/babylon-convergence/type-parameter-whitespace-loc.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/babylon-convergence/type-parameter-whitespace-loc.src.ts rename to packages/shared-fixtures/fixtures/typescript/babylon-convergence/type-parameter-whitespace-loc.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/babylon-convergence/type-parameters.src.ts b/packages/shared-fixtures/fixtures/typescript/babylon-convergence/type-parameters.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/babylon-convergence/type-parameters.src.ts rename to packages/shared-fixtures/fixtures/typescript/babylon-convergence/type-parameters.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-constructor.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-constructor.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-constructor.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-constructor.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-method.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-method.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-method.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-method.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-properties.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-properties.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-properties.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/abstract-class-with-optional-method.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-optional-method.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/abstract-class-with-optional-method.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-optional-method.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/abstract-interface.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/abstract-interface.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/abstract-interface.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/abstract-interface.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/arrow-function-with-type-parameters.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/arrow-function-with-type-parameters.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/arrow-function-with-type-parameters.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/arrow-function-with-type-parameters.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/async-function-expression.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/async-function-expression.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/async-function-expression.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/async-function-expression.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/async-function-with-var-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/async-function-with-var-declaration.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/async-function-with-var-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/async-function-with-var-declaration.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/call-signatures-with-generics.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/call-signatures-with-generics.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/call-signatures-with-generics.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/call-signatures-with-generics.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/call-signatures.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/call-signatures.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/call-signatures.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/call-signatures.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/cast-as-expression.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/cast-as-expression.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/cast-as-expression.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/cast-as-expression.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/cast-as-multi-assign.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/cast-as-multi-assign.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/cast-as-multi-assign.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/cast-as-multi-assign.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/cast-as-multi.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/cast-as-multi.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/cast-as-multi.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/cast-as-multi.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/cast-as-operator.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/cast-as-operator.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/cast-as-operator.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/cast-as-operator.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/cast-as-simple.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/cast-as-simple.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/cast-as-simple.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/cast-as-simple.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-multi-line-keyword-abstract.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-multi-line-keyword-abstract.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-multi-line-keyword-abstract.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-multi-line-keyword-abstract.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-multi-line-keyword-declare.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-multi-line-keyword-declare.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-multi-line-keyword-declare.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-multi-line-keyword-declare.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-accessibility-modifiers.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-accessibility-modifiers.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-accessibility-modifiers.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-accessibility-modifiers.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-constructor-and-modifier.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-constructor-and-modifier.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-constructor-and-modifier.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-constructor-and-modifier.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-constructor-and-return-type.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-constructor-and-return-type.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-constructor-and-return-type.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-constructor-and-return-type.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-constructor-and-type-parameters.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-constructor-and-type-parameters.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-constructor-and-type-parameters.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-constructor-and-type-parameters.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-definite-assignment.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-definite-assignment.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-definite-assignment.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-definite-assignment.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-export-parameter-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-export-parameter-properties.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-export-parameter-properties.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-export-parameter-properties.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-extends-and-implements.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-extends-and-implements.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-extends-and-implements.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-extends-and-implements.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-extends-generic-multiple.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-extends-generic-multiple.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-extends-generic-multiple.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-extends-generic-multiple.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-extends-generic.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-extends-generic.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-extends-generic.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-extends-generic.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-generic-method-default.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-generic-method-default.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-generic-method-default.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-generic-method-default.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-generic-method.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-generic-method.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-generic-method.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-generic-method.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-implements-and-extends.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-implements-and-extends.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-implements-and-extends.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-implements-and-extends.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-implements-generic-multiple.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-implements-generic-multiple.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-implements-generic-multiple.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-implements-generic-multiple.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-implements-generic.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-implements-generic.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-implements-generic.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-implements-generic.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-implements.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-implements.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-implements.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-implements.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-method.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-method.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-method.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-method.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-mixin-reference.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-mixin-reference.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-mixin-reference.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-mixin-reference.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-mixin.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-mixin.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-mixin.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-mixin.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-optional-computed-property.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-optional-computed-property.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-optional-computed-property.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-optional-computed-property.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-optional-methods.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-optional-methods.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-optional-methods.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-optional-methods.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-optional-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-optional-properties.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-optional-properties.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-optional-properties.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-optional-property-undefined.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-optional-property-undefined.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-optional-property-undefined.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-optional-property-undefined.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-private-parameter-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-private-parameter-properties.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-private-parameter-properties.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-private-parameter-properties.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-property-function.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-property-function.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-property-function.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-property-function.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-property-values.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-property-values.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-property-values.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-property-values.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-protected-parameter-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-protected-parameter-properties.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-protected-parameter-properties.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-protected-parameter-properties.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-public-parameter-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-public-parameter-properties.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-public-parameter-properties.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-public-parameter-properties.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-readonly-parameter-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-readonly-parameter-properties.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-readonly-parameter-properties.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-readonly-parameter-properties.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-readonly-property.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-readonly-property.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-readonly-property.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-readonly-property.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-static-parameter-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-static-parameter-properties.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-static-parameter-properties.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-static-parameter-properties.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-two-methods-computed-constructor.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-two-methods-computed-constructor.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-two-methods-computed-constructor.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-two-methods-computed-constructor.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-type-parameter-default.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-type-parameter-default.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-type-parameter-default.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-type-parameter-default.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-type-parameter-underscore.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-type-parameter-underscore.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-type-parameter-underscore.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-type-parameter-underscore.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-type-parameter.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-type-parameter.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/class-with-type-parameter.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/class-with-type-parameter.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/const-enum.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/const-enum.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/const-enum.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/const-enum.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/declare-class-with-optional-method.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/declare-class-with-optional-method.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/declare-class-with-optional-method.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/declare-class-with-optional-method.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/declare-function.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/declare-function.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/declare-function.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/declare-function.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/destructuring-assignment-nested.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/destructuring-assignment-nested.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/destructuring-assignment-nested.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/destructuring-assignment-nested.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/destructuring-assignment-object.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/destructuring-assignment-object.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/destructuring-assignment-object.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/destructuring-assignment-object.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/destructuring-assignment-property.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/destructuring-assignment-property.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/destructuring-assignment-property.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/destructuring-assignment-property.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/destructuring-assignment.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/destructuring-assignment.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/destructuring-assignment.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/destructuring-assignment.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/directive-in-module.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/directive-in-module.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/directive-in-module.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/directive-in-module.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/directive-in-namespace.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/directive-in-namespace.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/directive-in-namespace.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/directive-in-namespace.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-as-namespace.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-as-namespace.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-as-namespace.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/export-as-namespace.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-assignment.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-assignment.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-assignment.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/export-assignment.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-declare-const-named-enum.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-declare-const-named-enum.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-declare-const-named-enum.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/export-declare-const-named-enum.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-declare-named-enum.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-declare-named-enum.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-declare-named-enum.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/export-declare-named-enum.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-default-class-with-generic.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-default-class-with-generic.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-default-class-with-generic.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/export-default-class-with-generic.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-default-class-with-multiple-generics.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-default-class-with-multiple-generics.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-default-class-with-multiple-generics.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/export-default-class-with-multiple-generics.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-named-class-with-generic.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-named-class-with-generic.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-named-class-with-generic.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/export-named-class-with-generic.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-named-class-with-multiple-generics.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-named-class-with-multiple-generics.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-named-class-with-multiple-generics.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/export-named-class-with-multiple-generics.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-named-enum.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-named-enum.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-named-enum.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/export-named-enum.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-type-alias-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-type-alias-declaration.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-type-alias-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/export-type-alias-declaration.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-type-class-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-type-class-declaration.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-type-class-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/export-type-class-declaration.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-type-function-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-type-function-declaration.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/export-type-function-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/export-type-function-declaration.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-overloads.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/function-overloads.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-overloads.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/function-overloads.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-await.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/function-with-await.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-await.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/function-with-await.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-object-type-with-optional-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/function-with-object-type-with-optional-properties.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-object-type-with-optional-properties.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/function-with-object-type-with-optional-properties.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-object-type-without-annotation.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/function-with-object-type-without-annotation.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-object-type-without-annotation.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/function-with-object-type-without-annotation.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-type-parameters-that-have-comments.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/function-with-type-parameters-that-have-comments.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-type-parameters-that-have-comments.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/function-with-type-parameters-that-have-comments.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-type-parameters-with-constraint.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/function-with-type-parameters-with-constraint.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-type-parameters-with-constraint.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/function-with-type-parameters-with-constraint.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-type-parameters.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/function-with-type-parameters.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-type-parameters.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/function-with-type-parameters.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-types-assignation.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/function-with-types-assignation.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-types-assignation.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/function-with-types-assignation.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-types.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/function-with-types.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/function-with-types.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/function-with-types.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/import-equal-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/import-equal-declaration.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/import-equal-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/import-equal-declaration.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/import-export-equal-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/import-export-equal-declaration.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/import-export-equal-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/import-export-equal-declaration.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/import-type-with-type-parameters-in-type-reference.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/import-type-with-type-parameters-in-type-reference.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/import-type-with-type-parameters-in-type-reference.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/import-type-with-type-parameters-in-type-reference.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/import-type.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/import-type.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/import-type.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/import-type.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-extends-multiple.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/interface-extends-multiple.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-extends-multiple.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/interface-extends-multiple.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-extends.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/interface-extends.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-extends.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/interface-extends.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-type-parameters.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/interface-type-parameters.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-type-parameters.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/interface-type-parameters.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-all-property-types.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/interface-with-all-property-types.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-all-property-types.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/interface-with-all-property-types.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-construct-signature-with-parameter-accessibility.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/interface-with-construct-signature-with-parameter-accessibility.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-construct-signature-with-parameter-accessibility.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/interface-with-construct-signature-with-parameter-accessibility.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-extends-member-expression.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/interface-with-extends-member-expression.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-extends-member-expression.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/interface-with-extends-member-expression.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-extends-type-parameters.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/interface-with-extends-type-parameters.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-extends-type-parameters.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/interface-with-extends-type-parameters.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-generic.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/interface-with-generic.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-generic.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/interface-with-generic.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-jsdoc.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/interface-with-jsdoc.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-jsdoc.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/interface-with-jsdoc.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-method.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/interface-with-method.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-method.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/interface-with-method.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-optional-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/interface-with-optional-properties.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-with-optional-properties.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/interface-with-optional-properties.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-without-type-annotation.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/interface-without-type-annotation.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/interface-without-type-annotation.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/interface-without-type-annotation.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/keyof-operator.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/keyof-operator.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/keyof-operator.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/keyof-operator.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/nested-type-arguments.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/nested-type-arguments.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/nested-type-arguments.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/nested-type-arguments.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/never-type-param.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/never-type-param.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/never-type-param.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/never-type-param.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/non-null-assertion-operator.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/non-null-assertion-operator.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/non-null-assertion-operator.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/non-null-assertion-operator.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/null-and-undefined-type-annotations.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/null-and-undefined-type-annotations.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/null-and-undefined-type-annotations.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/null-and-undefined-type-annotations.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/object-with-escaped-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/object-with-escaped-properties.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/object-with-escaped-properties.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/object-with-escaped-properties.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/object-with-typed-methods.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/object-with-typed-methods.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/object-with-typed-methods.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/object-with-typed-methods.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/parenthesized-use-strict.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/parenthesized-use-strict.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/parenthesized-use-strict.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/parenthesized-use-strict.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/symbol-type-param.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/symbol-type-param.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/symbol-type-param.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/symbol-type-param.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-alias-declaration-with-constrained-type-parameter.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-alias-declaration-with-constrained-type-parameter.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-alias-declaration-with-constrained-type-parameter.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-alias-declaration-with-constrained-type-parameter.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-alias-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-alias-declaration.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-alias-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-alias-declaration.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-alias-object-without-annotation.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-alias-object-without-annotation.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-alias-object-without-annotation.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-alias-object-without-annotation.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-assertion-arrow-function.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-assertion-arrow-function.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-assertion-arrow-function.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-assertion-arrow-function.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-assertion.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-assertion.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-assertion.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-assertion.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-guard-in-arrow-function.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-guard-in-arrow-function.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-guard-in-arrow-function.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-guard-in-arrow-function.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-guard-in-function.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-guard-in-function.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-guard-in-function.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-guard-in-function.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-guard-in-interface.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-guard-in-interface.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-guard-in-interface.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-guard-in-interface.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-guard-in-method.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-guard-in-method.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-guard-in-method.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-guard-in-method.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-parameters-comments.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-parameters-comments.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-parameters-comments.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-parameters-comments.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-reference-comments.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-reference-comments.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/type-reference-comments.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-reference-comments.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-bigint.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-bigint.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-bigint.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-bigint.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-boolean.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-boolean.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-boolean.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-boolean.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-false.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-false.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-false.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-false.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-never.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-never.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-never.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-never.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-null.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-null.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-null.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-null.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-number.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-number.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-number.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-number.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-object.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-object.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-object.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-object.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-string.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-string.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-string.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-string.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-symbol.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-symbol.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-symbol.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-symbol.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-true.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-true.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-true.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-true.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-undefined.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-undefined.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-undefined.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-undefined.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-unknown.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-unknown.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-unknown.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-unknown.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-void.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-void.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-keyword-void.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-keyword-void.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-method-signature.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-method-signature.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-method-signature.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-method-signature.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-this.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/typed-this.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/typed-this.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/typed-this.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/unique-symbol.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/unique-symbol.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/unique-symbol.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/unique-symbol.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/unknown-type-annotation.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/unknown-type-annotation.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/unknown-type-annotation.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/unknown-type-annotation.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/var-with-definite-assignment.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/var-with-definite-assignment.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/var-with-definite-assignment.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/var-with-definite-assignment.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/var-with-dotted-type.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/var-with-dotted-type.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/var-with-dotted-type.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/var-with-dotted-type.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/var-with-type.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/var-with-type.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/var-with-type.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/var-with-type.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/variable-declaration-type-annotation-spacing.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/variable-declaration-type-annotation-spacing.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/basics/variable-declaration-type-annotation-spacing.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/variable-declaration-type-annotation-spacing.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/abstract-class.src.ts b/packages/shared-fixtures/fixtures/typescript/declare/abstract-class.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/abstract-class.src.ts rename to packages/shared-fixtures/fixtures/typescript/declare/abstract-class.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/class.src.ts b/packages/shared-fixtures/fixtures/typescript/declare/class.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/class.src.ts rename to packages/shared-fixtures/fixtures/typescript/declare/class.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/enum.src.ts b/packages/shared-fixtures/fixtures/typescript/declare/enum.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/enum.src.ts rename to packages/shared-fixtures/fixtures/typescript/declare/enum.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/function.src.ts b/packages/shared-fixtures/fixtures/typescript/declare/function.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/function.src.ts rename to packages/shared-fixtures/fixtures/typescript/declare/function.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/interface.src.ts b/packages/shared-fixtures/fixtures/typescript/declare/interface.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/interface.src.ts rename to packages/shared-fixtures/fixtures/typescript/declare/interface.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/module.src.ts b/packages/shared-fixtures/fixtures/typescript/declare/module.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/module.src.ts rename to packages/shared-fixtures/fixtures/typescript/declare/module.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/namespace.src.ts b/packages/shared-fixtures/fixtures/typescript/declare/namespace.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/namespace.src.ts rename to packages/shared-fixtures/fixtures/typescript/declare/namespace.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/type-alias.src.ts b/packages/shared-fixtures/fixtures/typescript/declare/type-alias.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/type-alias.src.ts rename to packages/shared-fixtures/fixtures/typescript/declare/type-alias.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/variable.src.ts b/packages/shared-fixtures/fixtures/typescript/declare/variable.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/declare/variable.src.ts rename to packages/shared-fixtures/fixtures/typescript/declare/variable.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-factory-instance-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-factory-instance-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-factory-instance-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-factory-instance-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-factory-static-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-factory-static-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-factory-static-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-factory-static-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-instance-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-instance-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-instance-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-instance-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-static-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-static-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-static-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/accessor-decorators/accessor-decorator-static-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/class-decorators/class-decorator-factory.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/class-decorators/class-decorator-factory.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/class-decorators/class-decorator-factory.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/class-decorators/class-decorator-factory.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/class-decorators/class-decorator.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/class-decorators/class-decorator.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/class-decorators/class-decorator.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/class-decorators/class-decorator.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-factory-instance-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-factory-instance-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-factory-instance-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-factory-instance-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-factory-static-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-factory-static-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-factory-static-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-factory-static-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-instance-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-instance-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-instance-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-instance-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-static-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-static-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-static-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/method-decorators/method-decorator-static-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-constructor.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-constructor.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-constructor.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-constructor.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-instance-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-instance-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-instance-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-instance-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-static-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-static-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-static-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-decorator-static-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-factory-instance-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-factory-instance-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-factory-instance-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-factory-instance-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-factory-static-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-factory-static-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-factory-static-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-factory-static-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-instance-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-instance-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-instance-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-instance-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-static-member.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-static-member.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-static-member.src.ts rename to packages/shared-fixtures/fixtures/typescript/decorators/property-decorators/property-decorator-static-member.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/class-empty-extends-implements.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/class-empty-extends-implements.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/class-empty-extends-implements.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/class-empty-extends-implements.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/class-empty-extends.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/class-empty-extends.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/class-empty-extends.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/class-empty-extends.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/class-extends-empty-implements.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/class-extends-empty-implements.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/class-extends-empty-implements.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/class-extends-empty-implements.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/class-multiple-implements.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/class-multiple-implements.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/class-multiple-implements.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/class-multiple-implements.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-enum-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-enum-declaration.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-enum-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-enum-declaration.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-interface-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-interface-declaration.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-interface-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-interface-declaration.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/empty-type-arguments.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-arguments.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/empty-type-arguments.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-arguments.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/enum-with-keywords.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/enum-with-keywords.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/enum-with-keywords.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/enum-with-keywords.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/index-signature-parameters.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/index-signature-parameters.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/index-signature-parameters.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/index-signature-parameters.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-empty-extends.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-empty-extends.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-empty-extends.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-empty-extends.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-implements.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-implements.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-implements.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-implements.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-export.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-export.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-export.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-export.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-private.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-private.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-private.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-private.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-protected.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-protected.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-protected.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-protected.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-public.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-public.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-public.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-public.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-static.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-static.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-static.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-index-signature-static.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-method-export.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-method-export.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-method-export.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-method-export.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-method-private.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-method-private.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-method-private.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-method-private.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-method-protected.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-method-protected.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-method-protected.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-method-protected.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-method-public.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-method-public.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-method-public.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-method-public.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-method-static.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-method-static.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-method-static.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-method-static.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-multiple-extends.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-multiple-extends.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-multiple-extends.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-multiple-extends.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-property-export.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-property-export.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-property-export.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-property-export.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-property-private.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-property-private.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-property-private.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-property-private.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-property-protected.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-property-protected.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-property-protected.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-property-protected.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-property-public.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-property-public.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-property-public.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-property-public.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-property-static.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-property-static.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-property-static.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-property-static.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-property-with-default-value.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-property-with-default-value.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/interface-property-with-default-value.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-property-with-default-value.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/object-assertion-not-allowed.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/object-assertion-not-allowed.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/object-assertion-not-allowed.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/object-assertion-not-allowed.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/object-optional-not-allowed.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/object-optional-not-allowed.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/object-optional-not-allowed.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/object-optional-not-allowed.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/solo-const.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/solo-const.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/errorRecovery/solo-const.src.ts rename to packages/shared-fixtures/fixtures/typescript/errorRecovery/solo-const.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/expressions/call-expression-type-arguments.src.ts b/packages/shared-fixtures/fixtures/typescript/expressions/call-expression-type-arguments.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/expressions/call-expression-type-arguments.src.ts rename to packages/shared-fixtures/fixtures/typescript/expressions/call-expression-type-arguments.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/expressions/new-expression-type-arguments.src.ts b/packages/shared-fixtures/fixtures/typescript/expressions/new-expression-type-arguments.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/expressions/new-expression-type-arguments.src.ts rename to packages/shared-fixtures/fixtures/typescript/expressions/new-expression-type-arguments.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/expressions/tagged-template-expression-type-arguments.src.ts b/packages/shared-fixtures/fixtures/typescript/expressions/tagged-template-expression-type-arguments.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/expressions/tagged-template-expression-type-arguments.src.ts rename to packages/shared-fixtures/fixtures/typescript/expressions/tagged-template-expression-type-arguments.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/namespaces-and-modules/ambient-module-declaration-with-import.src.ts b/packages/shared-fixtures/fixtures/typescript/namespaces-and-modules/ambient-module-declaration-with-import.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/namespaces-and-modules/ambient-module-declaration-with-import.src.ts rename to packages/shared-fixtures/fixtures/typescript/namespaces-and-modules/ambient-module-declaration-with-import.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/namespaces-and-modules/declare-namespace-with-exported-function.src.ts b/packages/shared-fixtures/fixtures/typescript/namespaces-and-modules/declare-namespace-with-exported-function.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/namespaces-and-modules/declare-namespace-with-exported-function.src.ts rename to packages/shared-fixtures/fixtures/typescript/namespaces-and-modules/declare-namespace-with-exported-function.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/namespaces-and-modules/global-module-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/namespaces-and-modules/global-module-declaration.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/namespaces-and-modules/global-module-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/namespaces-and-modules/global-module-declaration.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/namespaces-and-modules/module-with-default-exports.src.ts b/packages/shared-fixtures/fixtures/typescript/namespaces-and-modules/module-with-default-exports.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/namespaces-and-modules/module-with-default-exports.src.ts rename to packages/shared-fixtures/fixtures/typescript/namespaces-and-modules/module-with-default-exports.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/namespaces-and-modules/nested-internal-module.src.ts b/packages/shared-fixtures/fixtures/typescript/namespaces-and-modules/nested-internal-module.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/namespaces-and-modules/nested-internal-module.src.ts rename to packages/shared-fixtures/fixtures/typescript/namespaces-and-modules/nested-internal-module.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/namespaces-and-modules/shorthand-ambient-module-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/namespaces-and-modules/shorthand-ambient-module-declaration.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/namespaces-and-modules/shorthand-ambient-module-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/namespaces-and-modules/shorthand-ambient-module-declaration.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/array-type.src.ts b/packages/shared-fixtures/fixtures/typescript/types/array-type.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/array-type.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/array-type.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/conditional-infer-nested.src.ts b/packages/shared-fixtures/fixtures/typescript/types/conditional-infer-nested.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/conditional-infer-nested.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/conditional-infer-nested.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/conditional-infer-simple.src.ts b/packages/shared-fixtures/fixtures/typescript/types/conditional-infer-simple.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/conditional-infer-simple.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/conditional-infer-simple.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/conditional-infer.src.ts b/packages/shared-fixtures/fixtures/typescript/types/conditional-infer.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/conditional-infer.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/conditional-infer.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/conditional-with-null.src.ts b/packages/shared-fixtures/fixtures/typescript/types/conditional-with-null.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/conditional-with-null.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/conditional-with-null.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/conditional.src.ts b/packages/shared-fixtures/fixtures/typescript/types/conditional.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/conditional.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/conditional.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/constructor-generic.src.ts b/packages/shared-fixtures/fixtures/typescript/types/constructor-generic.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/constructor-generic.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/constructor-generic.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/constructor-in-generic.src.ts b/packages/shared-fixtures/fixtures/typescript/types/constructor-in-generic.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/constructor-in-generic.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/constructor-in-generic.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/constructor-with-rest.src.ts b/packages/shared-fixtures/fixtures/typescript/types/constructor-with-rest.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/constructor-with-rest.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/constructor-with-rest.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/constructor.src.ts b/packages/shared-fixtures/fixtures/typescript/types/constructor.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/constructor.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/constructor.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/function-generic.src.ts b/packages/shared-fixtures/fixtures/typescript/types/function-generic.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/function-generic.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/function-generic.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/function-in-generic.src.ts b/packages/shared-fixtures/fixtures/typescript/types/function-in-generic.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/function-in-generic.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/function-in-generic.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/function-with-rest.src.ts b/packages/shared-fixtures/fixtures/typescript/types/function-with-rest.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/function-with-rest.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/function-with-rest.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/function-with-this.src.ts b/packages/shared-fixtures/fixtures/typescript/types/function-with-this.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/function-with-this.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/function-with-this.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/function.src.ts b/packages/shared-fixtures/fixtures/typescript/types/function.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/function.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/function.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/index-signature-readonly.src.ts b/packages/shared-fixtures/fixtures/typescript/types/index-signature-readonly.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/index-signature-readonly.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/index-signature-readonly.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/index-signature-without-type.src.ts b/packages/shared-fixtures/fixtures/typescript/types/index-signature-without-type.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/index-signature-without-type.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/index-signature-without-type.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/index-signature.src.ts b/packages/shared-fixtures/fixtures/typescript/types/index-signature.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/index-signature.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/index-signature.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/indexed.src.ts b/packages/shared-fixtures/fixtures/typescript/types/indexed.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/indexed.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/indexed.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/intersection-type.src.ts b/packages/shared-fixtures/fixtures/typescript/types/intersection-type.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/intersection-type.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/intersection-type.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/literal-number-negative.src.ts b/packages/shared-fixtures/fixtures/typescript/types/literal-number-negative.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/literal-number-negative.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/literal-number-negative.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/literal-number.src.ts b/packages/shared-fixtures/fixtures/typescript/types/literal-number.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/literal-number.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/literal-number.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/literal-string.src.ts b/packages/shared-fixtures/fixtures/typescript/types/literal-string.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/literal-string.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/literal-string.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/mapped-readonly-minus.src.ts b/packages/shared-fixtures/fixtures/typescript/types/mapped-readonly-minus.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/mapped-readonly-minus.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/mapped-readonly-minus.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/mapped-readonly-plus.src.ts b/packages/shared-fixtures/fixtures/typescript/types/mapped-readonly-plus.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/mapped-readonly-plus.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/mapped-readonly-plus.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/mapped-readonly.src.ts b/packages/shared-fixtures/fixtures/typescript/types/mapped-readonly.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/mapped-readonly.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/mapped-readonly.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/mapped.src.ts b/packages/shared-fixtures/fixtures/typescript/types/mapped.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/mapped.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/mapped.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/nested-types.src.ts b/packages/shared-fixtures/fixtures/typescript/types/nested-types.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/nested-types.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/nested-types.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/parenthesized-type.src.ts b/packages/shared-fixtures/fixtures/typescript/types/parenthesized-type.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/parenthesized-type.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/parenthesized-type.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/reference-generic-nested.src.ts b/packages/shared-fixtures/fixtures/typescript/types/reference-generic-nested.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/reference-generic-nested.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/reference-generic-nested.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/reference-generic.src.ts b/packages/shared-fixtures/fixtures/typescript/types/reference-generic.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/reference-generic.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/reference-generic.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/reference.src.ts b/packages/shared-fixtures/fixtures/typescript/types/reference.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/reference.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/reference.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/this-type-expanded.src.ts b/packages/shared-fixtures/fixtures/typescript/types/this-type-expanded.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/this-type-expanded.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/this-type-expanded.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/this-type.src.ts b/packages/shared-fixtures/fixtures/typescript/types/this-type.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/this-type.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/this-type.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/tuple-empty.src.ts b/packages/shared-fixtures/fixtures/typescript/types/tuple-empty.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/tuple-empty.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/tuple-empty.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/tuple-optional.src.ts b/packages/shared-fixtures/fixtures/typescript/types/tuple-optional.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/tuple-optional.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/tuple-optional.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/tuple-rest.src.ts b/packages/shared-fixtures/fixtures/typescript/types/tuple-rest.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/tuple-rest.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/tuple-rest.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/tuple-type.src.ts b/packages/shared-fixtures/fixtures/typescript/types/tuple-type.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/tuple-type.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/tuple-type.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/tuple.src.ts b/packages/shared-fixtures/fixtures/typescript/types/tuple.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/tuple.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/tuple.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/type-literal.src.ts b/packages/shared-fixtures/fixtures/typescript/types/type-literal.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/type-literal.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/type-literal.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/type-operator.src.ts b/packages/shared-fixtures/fixtures/typescript/types/type-operator.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/type-operator.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/type-operator.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/typeof.src.ts b/packages/shared-fixtures/fixtures/typescript/types/typeof.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/typeof.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/typeof.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/union-intersection.src.ts b/packages/shared-fixtures/fixtures/typescript/types/union-intersection.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/union-intersection.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/union-intersection.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/union-type.src.ts b/packages/shared-fixtures/fixtures/typescript/types/union-type.src.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/fixtures/typescript/types/union-type.src.ts rename to packages/shared-fixtures/fixtures/typescript/types/union-type.src.ts diff --git a/packages/typescript-eslint-shared-fixtures/jsx-known-issues.ts b/packages/shared-fixtures/jsx-known-issues.ts similarity index 100% rename from packages/typescript-eslint-shared-fixtures/jsx-known-issues.ts rename to packages/shared-fixtures/jsx-known-issues.ts diff --git a/packages/typescript-eslint-shared-fixtures/package.json b/packages/shared-fixtures/package.json similarity index 100% rename from packages/typescript-eslint-shared-fixtures/package.json rename to packages/shared-fixtures/package.json diff --git a/packages/typescript-eslint-parser/CHANGELOG.md b/packages/typescript-eslint-parser/CHANGELOG.md deleted file mode 100644 index 15510d3fb820..000000000000 --- a/packages/typescript-eslint-parser/CHANGELOG.md +++ /dev/null @@ -1,368 +0,0 @@ -v21.0.2 - December 3, 2018 - -- [`fed0a5a`](https://github.com/eslint/typescript-eslint-parser/commit/fed0a5a4bc7b3c6a242081adf91af50e848fcf62) Docs: Update README.md (#567) (dudiharush) -- [`47abd82`](https://github.com/eslint/typescript-eslint-parser/commit/47abd8282384617793d800209b5eb5d71d0c5730) Fix: issue with global augmentation when tokens are not present (#574) (Armano) -- [`c5ffad3`](https://github.com/eslint/typescript-eslint-parser/commit/c5ffad3ecafdc9596174d1a2de5fd978d386035a) Fix: scope for TSImportEqualsDeclaration (#571) (Armano) -- [`8ff0ad1`](https://github.com/eslint/typescript-eslint-parser/commit/8ff0ad153cf66b873c21624b7af31d33ce9d7073) Fix: missing implements in classes (#562) (Armano) -- [`cc92044`](https://github.com/eslint/typescript-eslint-parser/commit/cc920441093356a7a47ff5fdb752643b6c42cff8) Fix: visiting superTypeParameters in classes (#561) (Armano) -- [`83dbabb`](https://github.com/eslint/typescript-eslint-parser/commit/83dbabb626e5592c07085743a44586378956a153) Fix: visiting typeParameters in expressions (#565) (Armano) -- [`c19e479`](https://github.com/eslint/typescript-eslint-parser/commit/c19e4798ae6067daf9994b90fabcdf2d1953d70c) Fix: visitor-keys for TSAbstractClassProperty (#560) (Armano) -- [`491ebca`](https://github.com/eslint/typescript-eslint-parser/commit/491ebcaff9815071d4194584e3d94d0edf601e3b) Fix: crash in no-unused-vars when using enum (#556) (Armano) -- [`ae7c4e6`](https://github.com/eslint/typescript-eslint-parser/commit/ae7c4e661737b0db8cb0f7b612f58a94e1cced7c) Fix: missing visitor-keys (#554) (Armano) - -v21.0.1 - November 15, 2018 - -- [`3715584`](https://github.com/eslint/typescript-eslint-parser/commit/3715584404de566c9b6db975328122e819993768) Fix: wrong reference on TSQualifiedName (fixes #550) (#551) (Toru Nagashima) -- [`15b32d0`](https://github.com/eslint/typescript-eslint-parser/commit/15b32d0c9430111cdcdc7d187dfdc00b049bf3fb) Upgrade: eslint-release v1.2.0 (#549) (Kai Cataldo) - -v21.0.0 - November 13, 2018 - -- eb23b26 Update: add proper scope analysis (fixes #535) (#540) (Toru Nagashima) -- 150ffe8 Breaking: make 'useJSXTextNode:true' by default (#544) (Toru Nagashima) -- 2d22321 Breaking: switch 'jsx' option by filename (fixes #517) (#543) (Toru Nagashima) -- 3b1ed17 Breaking: make eslint a peerDep/devDep (#541) (Kai Cataldo) -- 1d54346 Chore: test Node v11 in CI (#542) (Kai Cataldo) -- a9d932a Breaking: typescript-estree v5 (#538) (Kai Cataldo) -- 6a9b629 Docs: add options to README (#530) (Joe Pea) - -v20.1.1 - October 31, 2018 - -- 1683169 Revert "Chore: Make ESLint a devDependency/peerDependency (fixes #523)" (#537) (Kevin Partington) - -v20.1.0 - October 30, 2018 - -- 075d243 Chore: Make ESLint a devDependency/peerDependency (fixes #523) (#526) (Kevin Partington) -- 4310aac Chore: Force LF for tsx files (#520) (Benjamin Lichtman) -- bacac5f New: Add visitor keys (#516) (Michał Sajnóg) -- 4172933 Upgrade: eslint-release@1.0.0 (#527) (Teddy Katz) - -v20.0.0 - October 8, 2018 - -- f4b9893 Breaking: Support TypeScript 3.1 (fixes #524) (#525) (James Henry) - -v19.0.2 - September 29, 2018 - -- aa0fe13 Fix: Re-expose parse method (fixes #519) (#521) (Kevin Partington) -- 655359f Chore: Makefile tweaks (#522) (Kevin Partington) - -v19.0.1 - September 25, 2018 - -- 7a367c7 Fix: Remove lib from package.json files (#518) (James Henry) - -v19.0.0 - September 25, 2018 - -- 3d3ab2f Breaking: Use typescript-estree for parsing (#515) (James Henry) - -v18.0.0 - August 6, 2018 - -- 16d1a78 Breaking: Support TypeScript 3.0 (#504) (James Henry) -- 7461462 Fix: remove unnecessary TypeRef wrapper for ImportType (fixes #507) (#508) (Ika) - -v17.0.1 - July 26, 2018 - -- f1d7de3 Chore: Replace removed API with public flags (fixes #498) (#505) (Texas Toland) - -v17.0.0 - July 26, 2018 - -- 117800d Fix: support JSXSpreadChild (fixes #500) (#501) (Ika) -- 6eec85b Breaking: Remove "Experimental" from rest and spread (fixes #428) (#429) (Lucas Duailibe) -- 42f29a1 Fix: error on multiple super classes (fixes #493) (#494) (Ika) -- 11d9169 Breaking: always set optional on ClassProperty (fixes #472) (#491) (Ika) - -v16.0.1 - June 27, 2018 - -- bc83c6a Chore: Do not run integration tests within npm test (James Henry) -- db62d63 Fix: Snapshot all ecma-features fixtures (#495) (James Henry) -- 3c1fab0 Fix: support ImportMeta (fixes #489) (#490) (Ika) -- 6611535 Chore: Loosen node version requirement in package.json (fixes #482) (#484) (James Henry) -- 27f39cc Chore: Powerful integration tests and improved README (#483) (James Henry) - -v16.0.0 - June 3, 2018 - -- 009336d Breaking: Set minimum node version to 6 (#481) (James Henry) -- 9316b23 Breaking: Support TypeScript 2.9 (#480) (James Henry) - -v15.0.1 - June 3, 2018 - -- 891cee9 Fix: decorators removed on interface declarations (fixes #478) (#479) (Muhanad Rabie) - -v15.0.0 - April 17, 2018 - -- e572416 Breaking: Support TypeScript 2.8 (fixes #453) (#454) (James Henry) - -v14.0.0 - February 21, 2018 - -- 439ea24 New: Support Definite Assignment (fixes #424) (#432) (Lucas Azzola) -- adc0b1b Breaking: Remove all tokens inside comments from tokens array (fixes #422) (#423) (Kai Cataldo) - -v13.0.0 - February 9, 2018 - -- fb5e4c4 Breaking: Support TypeScript 2.7 (fixes #442,#426) (#447) (James Henry) -- bd9c12f Docs: Update Known Issues section of README (#440) (Kepler Sticka-Jones) - -v12.0.0 - January 16, 2018 - -- 6ce4cd8 Breaking: Properly categorize constructors with no body (#427) (Jed Fox) -- e94ede3 Docs: Sets default code block language in issue template to "ts" (#421) (Marius Schulz) - -v11.0.0 - December 13, 2017 - -- 6698042 Breaking: No prefix on FnDec within namespace (fixes #127) (#413) (James Henry) -- aec31cb Breaking: Implement parseForESLint() function (#412) (James Henry) - -v10.0.0 - December 11, 2017 - -- 59a37f4 Breaking: Updates to AST node types of some TSNodes (fixes #386) (#388) (James Henry) -- 627355e Chore: Introduce integration tests (#411) (James Henry) -- b4d22e7 Chore: No package-lock like other ESLint repos (#409) (James Henry) - -v9.0.1 - November 29, 2017 - -- 153cdb8 Fix: Calculate end position of TypeInstantiation (fixes #406) (#405) (Lucas Duailibe) -- 678907b Fix: Explicitly convert AbstractKeyword (fixes #407) (#408) (James Henry) - -v9.0.0 - November 10, 2017 - -- 46479e8 Breaking: Support TypeScript 2.6 (fixes #394) (#397) (James Henry) - -v8.0.1 - October 22, 2017 - -- 0401ffc Fix: Calculate typeArguments loc data correctly if empty (fixes #395) (#396) (James Henry) -- a214f71 Chore: Add a way to test TSX specific issues (fixes #376) (#398) (James Henry) -- 9c71a62 Fix: add missing TSSymbolKeyword type (#385) (Ika) -- e10aab8 Chore: Refactor alignment tests, now on by default (#387) (James Henry) -- 9e17d0b Chore: Minor cleanup, fix jQuery foundation copyright (#383) (James Henry) - -v8.0.0 - September 5, 2017 - -- 9877e98 Breaking: Support TypeScript 2.5 (fixes #368) (#369) (#370) (James Henry) -- 5b49870 Fix: Location data for typeAnnotations (#378) (James Henry) - -v7.0.0 - August 22, 2017 - -- 01c34f4 Fix: Ensure exports applied to TSModuleDeclaration (#375) (James Henry) -- 38bd1ae Breaking: Check for isTypeKeyword in type params (fixes #373) (#374) (James Henry) -- 3727956 Breaking: Handle TSModuleDeclaration and refactor (fixes #371) (#372) (James Henry) -- d67ee6c Fix: Typo in TSExportAssignment node type (#367) (James Henry) - -v6.0.1 - August 19, 2017 - -- 7bcc0d6 Fix: Ensure modifiers are applied to enums (fixes #365) (#366) (James Henry) - -v6.0.0 - August 19, 2017 - -- 32c0cc8 Breaking: Explicitly handle TSEnumDeclaration (fixes #345) (#364) (James Henry) -- 5f741a9 Fix: Allow other orderings of implements/extends clauses (fixes #361) (#363) (Jed Fox) -- f5bd145 Chore: Breakout and label TS-specific AST comparison tests (#360) (James Henry) -- f6e56b3 Chore: Build out AST comparison tests and categorize issues (#358) (James Henry) -- ab4e05e Breaking: Only add .implements/.accessibility/.decorators if truthy (#354) (James Henry) -- 275897b Fix: Location data for methods and constructors (#357) (James Henry) -- 5fce5e7 Fix: Exp. operator assignment is AssignmentExpression (fixes #355) (#356) (James Henry) -- 67971de Fix: Include newlines at the end of source in AST (fixes #352) (#353) (James Henry) -- 8406209 Fix: Remove start and end values from JSX tokens (fixes #341) (#351) (James Henry) - -v5.0.1 - August 9, 2017 - -- 81e20c0 Fix: Only warn about an unsupported TypeScript version once (#347) (Jed Fox) -- 5e22fac Chore: AST alignment testing against Babylon (#342) (James Henry) - -v5.0.0 - August 6, 2017 - -- 271b4f1 New: Support TypeScript 2.4 (fixes #321) (#322) (#326) (James Henry) -- ea6c3bb Breaking: Use TSTypeReference for TypeParameters (#340) (James Henry) -- a9ca775 Fix: Use name 'this' in JSXMemberExpression (fixes #337) (#338) (Reyad Attiyat) -- ef2687b Fix: Handle assignment within property destructuring (fixes #332) (#336) (James Henry) - -v4.0.0 - July 10, 2017 - -- 6a612cd Breaking: Include type annotation range for Identifiers (fixes #314) (#319) (Reyad Attiyat) -- 074a64f Fix: Arrow function body should be ObjectExpression (fixes #331) (#334) (Reyad Attiyat) -- fb66f61 Fix: Unescape string literal identifiers (fixes #328) (#330) (Lucas Azzola) -- 9cab9d3 Breaking: Remove TypeAnnotation wrapper from constraint (#325) (James Henry) -- b255499 New: Provider loggerFn option to configure logging (fixes #323) (#324) (James Henry) -- 0540298 Fix: Calculate correct type parameter range (fixes #316) (#320) (Reyad Attiyat) -- 4938c2c Fix: Ensure JSX tag names are JSXIdentifiers (fixes #315) (#318) (Reyad Attiyat) -- 1f20557 Fix: Use TSExportAssignment node type (fixes #304) (#317) (Reyad Attiyat) -- b26cda1 Fix: Use TSNullKeyword for null type instead of Literal (#313) (James Henry) -- 9037dc5 Chore: Add node 8 to .travis.yml (#312) (James Henry) -- 8062515 Chore: Refactor tests to assert snapshots not JSON (#311) (James Henry) -- 2ad791b Fix: Add name to JSXIdentifier when converting ThisKeyword (fixes #307) (#310) (Reyad Attiyat) -- 519907e Breaking: Use ESTree export node types in modules (fixes# 263) (#265) (Reyad Attiyat) -- c4b0b64 Fix: Label readonly class properties (fixes #302) (#303) (Reyad Attiyat) -- bffd6cc Fix: Add more tests for destructuring and spread (fixes #306) (#308) (Reyad Attiyat) -- f7c9246 Chore: Fix typo in comment (#305) (Jeremy Attali) -- 3dcba7d Breaking: Change isReadonly to readonly (fixes #284) (#285) (James Henry) -- bc9225f Chore: Replace mocha (istanbul, chai, leche) with Jest (#300) (James Henry) -- 8744577 Breaking: Decorator ESTree compliance, always convert (fixes #250) (#293) (James Henry) -- dd6404a Breaking: Convert Signature types to be more ESTree like (fixes #262) (#264) (Reyad Attiyat) -- 379dcaf Fix: Only set optional property on certain node property (fixes #289) (#292) (Reyad Attiyat) -- 89f8561 Fix: Label static and export in TSParameterProperty (fixes #286) (#301) (Reyad Attiyat) -- 992f1fa Fix: Unescape type parameter names (fixes #296) (#298) (Reyad Attiyat) -- 5ed8573 Fix: Async generator method should be labeled (fixes #297) (#299) (Reyad Attiyat) -- 31ad3c4 Fix: Create RegExp object for RegExp literals (fixes #287) (#291) (Reyad Attiyat) -- 525a544 Fix: Set node type to ExperimentalRestProperty (fixes #276) (#279) (Reyad Attiyat) -- eb32fed Fix: Convert type guards (fixes #282) (#283) (James Henry) -- b7220fd New: Create option to enable JSXText node type (fixes #266) (#272) (Reyad Attiyat) -- 6dd3696 Fix: Add exponentiation operators (fixes #280) (#281) (Lucas Azzola) -- 3491b4b Fix: Replace JSXMemberExpression with TSQualifiedName (fixes #257) (#258) (Lucas Azzola) -- b4eb0b5 Fix: Convert range and line number corretly in JSX literals (#277) (Reyad Attiyat) -- 3f9f41c Fix: wrap interface in ExportNamedDeclaration if necessary (fixes #269) (#270) (Danny Martini) - -v3.0.0 - May 17, 2017 - -- 6b56bfe Fix: Use correct starting range and loc for JSXText tokens (fixes #227) (#271) (Reyad Attiyat) -- f5fcc87 Breaking: Allow comment scanner to rescan tokens (fixes #216) (#219) (Reyad Attiyat) -- f836bb9 Chore: Refactor the codebase (fixes #220) (#261) (James Henry) -- aade6bd Chore: Update README with list of known issues (#247) (Reyad Attiyat) -- c8e881a Breaking: Normalize type parameters (fixes #197) (#196) (Rasmus Eneman) -- d37bf04 Fix: Type parameter start location calculation (fixes #260) (#259) (Igor Oleinikov) -- 1a97650 Fix: Handle case where class has extends but no super class (fixes #249) (#254) (Reyad Attiyat) -- 00ad71d Fix: add `instanceof` to ast-converter (fixes #252) (#251) (Danny Arnold) -- 2989f8b Upgrade: Update semver package (#246) (Simen Bekkhus) -- b1efe69 Breaking: Change how interface node gets converted (fixes #201) (#241) (Reyad Attiyat) -- e311620 Fix: Set await property on async iterators (for await) (fixes #236) (#239) (Reyad Attiyat) -- a294afa Fix: Set async on async FunctionExpressions (fixes #244) (#245) (Lucas Azzola) -- 7c00f16 Chore: Add tests for object spread and async generator (refs #236) (#237) (Reyad Attiyat) -- 7b69bc9 Fix: Label abstract class properties (fixes #234) (#238) (Reyad Attiyat) -- a330ec6 New: Add support for default type parameters (fixes #235) (#240) (Reyad Attiyat) -- e1ef800 Fix: Support superTypeParameters (fixes #242) (#243) (Lucas Azzola) -- 65c2e0a Breaking: Support TypeScript 2.3 (fixes #232) (#233) (Lucas Azzola) -- 15f1173 Fix: Use TSAbsractMethodDefinition for abstract constructor (fixes #228) (#229) (Lucas Azzola) -- 8fb71d2 Breaking: Add .body to TSModuleBlock nodes (fixes #217) (#218) (Philipp A) -- 471f403 Chore: Remove before_script from .travis.yml (fixes #231) (#230) (James Henry) -- 9397c5c Chore: Cleanup Makefile (#221) (Reyad Attiyat) -- dd57f81 Update: Open TS peerDependency, warn non-supported version (fixes #167) (#193) (James Henry) -- a37d5ed Fix: Wrap any parameter with modifiers, not just in constructors (#214) (Rasmus Eneman) - -v2.1.0 - April 4, 2017 - -- d709fd8 Fix: Set root to true in eslintrc (fixes #211) (#212) (Reyad Attiyat) -- 1e73711 Fix: Optional methods are not marked as optional (fixes #206) (#207) (Rasmus Eneman) -- 1cee2e3 Fix: Nested type arguments are not preserved (fixes #204) (#205) (Rasmus Eneman) -- 5a324a3 Fix: Preserve type parameters for methods (fixes #202) (#203) (Rasmus Eneman) -- bfb1506 New: Add type parameters to more AST nodes (fixes #184) (#183) (Rasmus Eneman) -- 0fadfc3 Fix: Convert MetaProperty (new.target) nodes correcly (fixes #194) (#195) (Reyad Attiyat) -- 4d755ed New: Store type parameter constraints (fixes #188) (#189) (Rasmus Eneman) -- 29d848c Fix: Updated broken class-with-optional-properties test result (#192) (James Henry) -- 04f6556 New: Mark optional parameters and properties (fixes #186) (#187) (Rasmus Eneman) -- cc9d4b3 Fix: Add missing typeAnnotation to class properties (fixes #190) (#191) (Rasmus Eneman) -- 215a012 Fix: Change DoWhileStatement to DoStatement to match TS (fixes #180) (#181) (James Henry) -- 581a7a5 Fix: Missing parameter properties info in constructors (fixes #143) (#168) (patricio trevino) -- 69d2537 Chore: Add test for constructor and methods with parameters (refs #168) (#178) (Reyad Attiyat) -- c2a0b71 Fix: Add start and end property to tokens (fixes #172) (#176) (Reyad Attiyat) -- 2640d81 Fix: Remove jsdoc node property from ts nodes (fixes #164) (#177) (Reyad Attiyat) -- 701e2c5 Fix: Set name to type JSXIdentifier and fix selfClosing (fixes #172) (#175) (Reyad Attiyat) -- 8b4e548 Fix: Convert Void and Delete expressions to UnaryExpression (fixes #171) (#174) (Reyad Attiyat) - -v2.0.0 - February 24, 2017 - -- 38aef53 Breaking: Updated supported TypeScript version to ~2.2.1 (fixes #149) (#169) (James Henry) -- 25207e0 Fix: Optimize convertTokens, treat JsxText as token (fixes #70) (#158) (James Henry) -- 76c33f8 Fix: Await node should have argument property (fixes #160) (#161) (Reyad Attiyat) -- 2f86bef Fix: Unescape identifiers typescript may prepend underscore (fixes #145) (#159) (Reyad Attiyat) - -v1.0.3 - February 10, 2017 - -- 19e7f15 Docs: Show currently supported TypeScript version (#157) (James Henry) -- e96ba1f Fix: Calculate range correctly for exported generic class (fixes #152) (#155) (Reyad Attiyat) -- 11d5a7d Fix: Handle object types without annotations (fixes #148) (#154) (Reyad Attiyat) -- fc1e6bb Fix: Parameter with assignation provide type annotations (fixes #146) (#147) (patricio trevino) -- e5f378f Fix: Calculate range correctly when class is exported (fixes #152) (#153) (Reyad Attiyat) -- 6312383 Fix: Calculate constructor range using node.parameters.pos (fixes #139) (#140) (Reyad Attiyat) - -v1.0.2 - January 12, 2017 - -- d53f1f8 Fix: Use ts utilities determine variable declaration type (fixes #136) (#138) (Reyad Attiyat) -- 918190d Fix: export type alias ExportNamedDeclaration node generation (fixes #134) (#135) (patricio trevino) - -v1.0.1 - January 4, 2017 - -- 9882a8e Fix: Add missing async property (#133) (James Henry) -- 60843ad Fix: Handle async/await (fixes #119) (#129) (Philipp A) -- 0ff19dd Fix: Exception thrown when space occurs after function name (fixes #123) (#124) (Reyad Attiyat) -- ff283aa Fix: Allow running without options (fixes #121) (#120) (Philipp A) -- dd03b2f Docs: Changed --save to --save-dev in readme (#132) (Amila Welihinda) -- 41ccef5 Build: Add TS as dev-dep, only support minor range (#131) (James Henry) - -v1.0.0 - November 11, 2016 - -- c60f216 Chore: Normalize .yml line endings (fixes #113) (#115) (James Henry) -- 9521396 Breaking: Updated to TypeScript 2.x (fixes #105) (#112) (James Henry) -- a7320df Docs: Update license copyright (Nicholas C. Zakas) -- 51ec64d Fix: Exclude TSNode.flags when deeplyCopy fallback is used (refs #105) (#107) (James Henry) -- 7ebf4d5 Fix: Rename decorator example to avoid issue in TS 2.x (refs #105) (#106) (James Henry) -- 45b9874 Fix: Added missing yml lf gitattribute (#104) (James Henry) -- 4dd3439 Build: Add Node 6.x to Travis (fixes #99) (#98) (Danny Fritz) - -v0.4.0 - September 23, 2016 - -- eb1ad9b Fix: Add loc and range data to generated VariableDeclarator node (#100) (James Henry) -- 5dae849 New: Accessibility Modifiers (fixes #87) (#88) (Danny Fritz) -- 68992eb Fix: Tests break with Windows line-endings (fixes #93) (#97) (Danny Fritz) - -v0.3.1 - September 20, 2016 - -- e36d800 Fix: Convert TypeAliasDeclaration into VariableDeclarator (fixes #89) (#91) (James Henry) -- ac0c95d Fix: Prefix function declarations in TS namespaces (fixes #78) (#82) (James Henry) -- 7cc865e Fix: Support abstract classes and methods (fixes #80) (#81) (James Henry) - -v0.3.0 - September 13, 2016 - -- e76f3b9 New: Convert type alias into variable declaration (refs #77) (#83) (James Henry) -- 5c47ad5 Fix: Convert TSTypeOfExpression to UnaryExpression (fixes #85) (#86) (James Henry) -- 799fd63 Fix: Distinguish between DeclareFunction and FunctionDeclaration (#79) (James Henry) - -v0.2.0 - August 29, 2016 - -- 138495f New: Add accessor decorators to AST (fixes #63) (#73) (James Henry) -- f6a8e71 New: Add property decorators to AST (fixes #71) (#72) (James Henry) -- 328259f New: Add param decorators to the AST (fixes #68) (#69) (James Henry) -- 8b97fe7 New: Add class decorators to AST (fixes #66) (#67) (James Henry) -- 7364cb9 New: Add method decorators to AST (fixes #65) (#64) (James Henry) - -v0.1.3 - August 22, 2016 - -- da984bf Fix: manually update package.json after build failure (Nicholas C. Zakas) -- 5bfb9bf Fix: Check for arguments property on NewExpression (fixes #60) (#62) (James Henry) -- d323ee7 Docs: Add issue template (Nicholas C. Zakas) -- 8f4964c Fix: UpdateExpression detection and operator format (fixes #58) (#59) (James Henry) -- e09ebb3 Fix: Add function type parameters (fixes #52) (#56) (James Henry) - -v0.1.1 - August 10, 2016 - -- 62d14b4 Fix: Class implements generic syntax (fixes #44) (#53) (James Henry) - -v0.1.0 - August 9, 2016 - -- d49b5f1 Build: Add CI build scripts (Nicholas C. Zakas) -- 32a46b3 New: Attaches comments to the ESTree AST (fixes #31) (#49) (James Henry) -- f4856f9 Fix: Class implements conversion (fixes #39) (#43) (Nicholas C. Zakas) -- 795a418 Build: Add linting to npm test (Nicholas C. Zakas) -- d26fec4 New: Automatically generate TS-specific nodes (#40) (Nicholas C. Zakas) -- 46b9c87 Docs: Update README to have the correct phase order. (#35) (Dean Taub) -- a8b00fe Chore: Add jQuery Foundation copyright (Nicholas C. Zakas) -- 560bb99 Fix: Remove console logging of node.kind (fixes #29) (Tom X. Tobin) - -v0.1.0-alpha.1 - March 18, 2016 - -- 0eddb71 New: Implements JSX syntax (fixes #18) (James Henry) -- e890743 Docs: PR validation check (Nicholas C. Zakas) -- c314f77 Build: Don't test Node 0.10 (Nicholas C. Zakas) -- bc05e1a Fix: Ensure true, false and null values are not stringifed (fixes #1) (James Henry) - -v0.1.0-alpha.0 - March 4, 2016 - -- c05b5da Build: Add release tool (Nicholas C. Zakas) -- 091973b Fix: SyntaxKind code checks, update TS peerDependency ^1.7.3 (fixes #15) (James Henry) -- e34f6b4 Fix: Use YAML file for ESLint config (Nicholas C. Zakas) -- e19b29d Update: TypeScript to be a peer dependency (fixes #12) (Nicholas C. Zakas) -- bdb1e3a Fix: Make tests actually work (fixes #6) (Nicholas C. Zakas) -- c61cc81 Docs: Improved detail and accuracy of JSDoc blocks (James Henry) -- 918a9cc Fix: Fixes linting errors (fixes #10) (James Henry) -- 1721dde Fix: Bumped lint script dependencies (fixes #8) (James Henry) -- 2f04e92 Fix: Removed unused reference to acorn-jsx/inject (fixes #2) (James Henry) -- 0e9d61e Docs: Update README with plans (Nicholas C. Zakas) -- c88e3ab New: Finished up ES6 features (Nicholas C. Zakas) -- 0ea1e32 Build: Tag as alpha release (Nicholas C. Zakas) -- 08702b8 Docs: Update README (Nicholas C. Zakas) -- c88ba98 New: First commit (Nicholas C. Zakas) diff --git a/packages/typescript-estree/README.md b/packages/typescript-estree/README.md index 922a49f766bc..110521f37616 100644 --- a/packages/typescript-estree/README.md +++ b/packages/typescript-estree/README.md @@ -20,13 +20,12 @@ This parser is somewhat generic and robust, and could be used to power any use-c In fact, it is already used within these hyper-popular open-source projects to power their TypeScript support: - [ESLint](https://eslint.org), the pluggable linting utility for JavaScript and JSX - - See [typescript-eslint-parser](https://github.com/eslint/typescript-eslint-parser) for more details - [Prettier](https://prettier.io), an opinionated code formatter ## Installation ``` -npm install --save typescript-estree +npm install --save @typescript-eslint/typescript-estree ``` ## API @@ -75,7 +74,7 @@ Parses the given string of code with the options provided and returns an ESTree- Example usage: ```javascript -const parser = require('typescript-estree'); +const parser = require('@typescript-eslint/typescript-estree'); const code = `const hello: string = 'world';`; const ast = parser.parse(code, { range: true, @@ -90,7 +89,7 @@ Exposes the current version of typescript-estree as specified in package.json. Example usage: ```javascript -const parser = require('typescript-estree'); +const parser = require('@typescript-eslint/typescript-estree'); const version = parser.version; ``` @@ -101,7 +100,7 @@ Exposes an object that contains the AST node types produced by the parser. Example usage: ```javascript -const parser = require('typescript-estree'); +const parser = require('@typescript-eslint/typescript-estree'); const astNodeTypes = parser.AST_NODE_TYPES; ``` diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 2c0f3f5173e9..e24209daebea 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,8 +1,8 @@ { - "name": "typescript-estree", + "name": "@typescript-eslint/typescript-estree", + "version": "0.2.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/parser.js", - "version": "18.1.0", "files": [ "dist", "README.md", 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 59210d587f95..22bddf6b7baf 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -2,7 +2,7 @@ import glob from 'glob'; import fs from 'fs'; import path from 'path'; -import jsxKnownIssues from '../../../typescript-eslint-shared-fixtures/jsx-known-issues'; +import jsxKnownIssues from '../../../shared-fixtures/jsx-known-issues'; interface Fixture { filename: string; @@ -26,7 +26,7 @@ interface CreateFixturePatternConfig { const fixturesDirPath = path.join(__dirname, '../fixtures'); const sharedFixturesDirPath = path.join( __dirname, - '../../../typescript-eslint-shared-fixtures/fixtures' + '../../../shared-fixtures/fixtures' ); class FixturesTester { diff --git a/packages/typescript-estree/tests/ast-alignment/parse.ts b/packages/typescript-estree/tests/ast-alignment/parse.ts index 407346455311..ec6123c03995 100644 --- a/packages/typescript-estree/tests/ast-alignment/parse.ts +++ b/packages/typescript-estree/tests/ast-alignment/parse.ts @@ -80,7 +80,7 @@ export function parse(text: string, opts: ASTComparisonParseOptions) { try { switch (opts.parser) { - case 'typescript-estree': + case '@typescript-eslint/typescript-estree': result.ast = parseUtils.normalizeNodeTypes( parseWithTypeScriptESTree(text, opts.jsx) ); diff --git a/packages/typescript-estree/tests/ast-alignment/spec.ts b/packages/typescript-estree/tests/ast-alignment/spec.ts index 777e0b704b41..0f3a91966dc7 100644 --- a/packages/typescript-estree/tests/ast-alignment/spec.ts +++ b/packages/typescript-estree/tests/ast-alignment/spec.ts @@ -11,7 +11,7 @@ fixturesToTest.forEach(fixture => { * Parse with typescript-estree */ const typeScriptESTreeResult = parse(source, { - parser: 'typescript-estree', + parser: '@typescript-eslint/typescript-estree', jsx: fixture.jsx }); diff --git a/packages/typescript-estree/tests/lib/jsx.ts b/packages/typescript-estree/tests/lib/jsx.ts index 4f2963fa04ff..8b2f9f2c19de 100644 --- a/packages/typescript-estree/tests/lib/jsx.ts +++ b/packages/typescript-estree/tests/lib/jsx.ts @@ -12,7 +12,7 @@ import { createSnapshotTestBlock, formatSnapshotName } from '../../tools/test-utils'; -import filesWithKnownIssues from '../../../typescript-eslint-shared-fixtures/jsx-known-issues'; +import filesWithKnownIssues from '../../../shared-fixtures/jsx-known-issues'; //------------------------------------------------------------------------------ // Setup diff --git a/tests/integration/docker-compose.yml b/tests/integration/docker-compose.yml index 2c2e4c241db5..086f3e76485d 100644 --- a/tests/integration/docker-compose.yml +++ b/tests/integration/docker-compose.yml @@ -9,11 +9,11 @@ services: # but apply an empty volume for the package tests, we don't need those. - ../../package.json/:/usr/root-package.json - ./utils/:/usr/utils - - ../../packages/typescript-eslint-parser/dist/:/usr/parser + - ../../packages/parser/:/usr/parser - /usr/parser/tests - ../../packages/typescript-estree/:/usr/typescript-estree - /usr/typescript-estree/tests - - ../../packages/eslint-plugin-typescript/:/usr/eslint-plugin + - ../../packages/eslint-plugin/:/usr/eslint-plugin - /usr/eslint-plugin/tests - ../../packages/eslint-plugin-tslint/:/usr/eslint-plugin-tslint - /usr/eslint-plugin-tslint/tests diff --git a/tests/integration/fixtures/typescript-and-tslint-plugins-together/.eslintrc.yml b/tests/integration/fixtures/typescript-and-tslint-plugins-together/.eslintrc.yml index 90a1f7a0acf8..1e7fd8888744 100644 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/.eslintrc.yml +++ b/tests/integration/fixtures/typescript-and-tslint-plugins-together/.eslintrc.yml @@ -1,25 +1,25 @@ root: true -# Local version of typescript-eslint-parser -parser: /usr/parser/parser.js +# Local version of @typescript-eslint/parser +parser: '@typescript-eslint/parser' plugins: -# Should resolve local version of @typescript-eslint/eslint-plugin -- typescript -# Should resolve local version of @typescript-eslint/eslint-plugin-tslint -- tslint +# Local version of @typescript-eslint/eslint-plugin +- '@typescript-eslint' +# Local version of @typescript-eslint/eslint-plugin-tslint +- '@typescript-eslint/tslint' env: es6: true node: true extends: -- plugin:typescript/recommended +- plugin:@typescript-eslint/recommended parserOptions: sourceType: module ecmaFeatures: jsx: false project: /usr/linked/tsconfig.json rules: - tslint/config: + '@typescript-eslint/tslint/config': - error - rules: semicolon: [true, 'always'] diff --git a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.js.snap b/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.js.snap index 331ae0c462d6..a4df7d29fe6d 100644 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.js.snap +++ b/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.js.snap @@ -15,9 +15,8 @@ Array [ "line": 1, "message": "'noSemi' is assigned a value but never used.", "nodeType": "Identifier", - "ruleId": "typescript/no-unused-vars", + "ruleId": "@typescript-eslint/no-unused-vars", "severity": 1, - "source": "const noSemi = true", }, Object { "column": 20, @@ -26,9 +25,8 @@ Array [ "line": 1, "message": "Missing semicolon (tslint:semicolon)", "nodeType": null, - "ruleId": "tslint/config", + "ruleId": "@typescript-eslint/tslint/config", "severity": 2, - "source": "const noSemi = true", }, ], "source": "const noSemi = true diff --git a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh b/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh index f9804fa8767f..dbd94edf768b 100755 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh +++ b/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh @@ -6,6 +6,12 @@ node /usr/utils/generate-package-json.js # Install dependencies npm install +# Use the local volumes for our own packages +npm install $(npm pack /usr/typescript-estree | tail -1) +npm install $(npm pack /usr/parser | tail -1) +npm install $(npm pack /usr/eslint-plugin-tslint | tail -1) +npm install $(npm pack /usr/eslint-plugin | tail -1) + # Run the linting # (the "|| true" helps make sure that we run our tests on failed linting runs as well) npx eslint --format json --output-file /usr/lint-output.json --config /usr/linked/.eslintrc.yml /usr/linked/**/*.ts || true diff --git a/tests/integration/utils/generate-package-json.js b/tests/integration/utils/generate-package-json.js index 03dd6a55c386..1f08f53b1ea5 100644 --- a/tests/integration/utils/generate-package-json.js +++ b/tests/integration/utils/generate-package-json.js @@ -10,19 +10,13 @@ const testPackageJSON = { devDependencies: { eslint: rootPackageJSON.devDependencies.eslint, typescript: rootPackageJSON.devDependencies.typescript, - tslint: '^5.11.0', + tslint: rootPackageJSON.devDependencies.tslint, /** * TEMP: Bump jest to ahead of our stable usage in the monorepo, * we need the bleeding edge snapshotResolver option */ // jest: rootPackageJSON.devDependencies.jest, - jest: '24.0.0-alpha.12', - /** - * Use the local volumes for our own packages - */ - 'eslint-plugin-typescript': 'file:/usr/eslint-plugin', - 'eslint-plugin-tslint': 'file:/usr/eslint-plugin-tslint', - 'typescript-estree': 'file:/usr/typescript-estree' + jest: '24.0.0-alpha.12' } }; diff --git a/yarn.lock b/yarn.lock index 1597cb6dbb27..c2cc9db7f6a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -898,13 +898,6 @@ acorn-globals@^4.1.0: acorn "^6.0.1" acorn-walk "^6.0.1" -acorn-jsx@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" - integrity sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s= - dependencies: - acorn "^3.0.4" - acorn-jsx@^5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.0.1.tgz#32a064fd925429216a09b141102bfdd185fae40e" @@ -915,12 +908,7 @@ acorn-walk@^6.0.1: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-6.1.1.tgz#d363b66f5fac5f018ff9c3a1e7b6f8e310cc3913" integrity sha512-OtUw6JUTgxA2QoqqmrmQ7F2NYqiBPi/L2jqHyFtllhOUvXYQXf0Z1CYUinIfyT4bTCGmrA7gX9FvHA81uzCoVw== -acorn@^3.0.4: - version "3.3.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" - integrity sha1-ReN/s56No/JbruP/U2niu18iAXo= - -acorn@^5.5.0, acorn@^5.5.3: +acorn@^5.5.3: version "5.7.3" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279" integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw== @@ -944,21 +932,6 @@ agentkeepalive@^3.4.1: dependencies: humanize-ms "^1.2.1" -ajv-keywords@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" - integrity sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I= - -ajv@^5.2.3, ajv@^5.3.0: - version "5.5.2" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" - integrity sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU= - dependencies: - co "^4.6.0" - fast-deep-equal "^1.0.0" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.3.0" - ajv@^6.5.3, ajv@^6.5.5, ajv@^6.6.1: version "6.7.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.7.0.tgz#e3ce7bb372d6577bb1839f1dfdfcbf5ad2948d96" @@ -1630,11 +1603,6 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.3.1, chalk@^2.4 escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chardet@^0.4.0: - version "0.4.2" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" - integrity sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I= - chardet@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" @@ -1971,7 +1939,7 @@ cosmiconfig@^5.0.2: js-yaml "^3.9.0" parse-json "^4.0.0" -cross-spawn@^5.0.1, cross-spawn@^5.1.0: +cross-spawn@^5.0.1: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" integrity sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk= @@ -2365,14 +2333,6 @@ eslint-docs@^0.2.6: ora "^3.0.0" read-pkg-up "^4.0.0" -eslint-scope@^3.7.1: - version "3.7.3" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.3.tgz#bb507200d3d17f60247636160b4826284b108535" - integrity sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA== - dependencies: - esrecurse "^4.1.0" - estraverse "^4.1.1" - eslint-scope@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.0.tgz#50bf3071e9338bcdc43331794a0cb533f0136172" @@ -2391,49 +2351,48 @@ eslint-visitor-keys@^1.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" integrity sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ== -eslint@^4.19.1: - version "4.19.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.19.1.tgz#32d1d653e1d90408854bfb296f076ec7e186a300" - integrity sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ== +eslint@^5.12.1: + version "5.12.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.12.1.tgz#5ca9931fb9029d04e7be92b03ce3b58edfac7e3b" + integrity sha512-54NV+JkTpTu0d8+UYSA8mMKAG4XAsaOrozA9rCW7tgneg1mevcL7wIotPC+fZ0SkWwdhNqoXoxnQCTBp7UvTsg== dependencies: - ajv "^5.3.0" - babel-code-frame "^6.22.0" + "@babel/code-frame" "^7.0.0" + ajv "^6.5.3" chalk "^2.1.0" - concat-stream "^1.6.0" - cross-spawn "^5.1.0" - debug "^3.1.0" + cross-spawn "^6.0.5" + debug "^4.0.1" doctrine "^2.1.0" - eslint-scope "^3.7.1" + eslint-scope "^4.0.0" + eslint-utils "^1.3.1" eslint-visitor-keys "^1.0.0" - espree "^3.5.4" - esquery "^1.0.0" + espree "^5.0.0" + esquery "^1.0.1" esutils "^2.0.2" file-entry-cache "^2.0.0" functional-red-black-tree "^1.0.1" glob "^7.1.2" - globals "^11.0.1" - ignore "^3.3.3" + globals "^11.7.0" + ignore "^4.0.6" + import-fresh "^3.0.0" imurmurhash "^0.1.4" - inquirer "^3.0.6" - is-resolvable "^1.0.0" - js-yaml "^3.9.1" + inquirer "^6.1.0" + js-yaml "^3.12.0" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.3.0" - lodash "^4.17.4" - minimatch "^3.0.2" + lodash "^4.17.5" + minimatch "^3.0.4" mkdirp "^0.5.1" natural-compare "^1.4.0" optionator "^0.8.2" path-is-inside "^1.0.2" pluralize "^7.0.0" progress "^2.0.0" - regexpp "^1.0.1" - require-uncached "^1.0.3" - semver "^5.3.0" + regexpp "^2.0.1" + semver "^5.5.1" strip-ansi "^4.0.0" - strip-json-comments "~2.0.1" - table "4.0.2" - text-table "~0.2.0" + strip-json-comments "^2.0.1" + table "^5.0.2" + text-table "^0.2.0" eslint@^5.9.0: version "5.12.0" @@ -2478,14 +2437,6 @@ eslint@^5.9.0: table "^5.0.2" text-table "^0.2.0" -espree@^3.5.4: - version "3.5.4" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7" - integrity sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A== - dependencies: - acorn "^5.5.0" - acorn-jsx "^3.0.0" - espree@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/espree/-/espree-5.0.0.tgz#fc7f984b62b36a0f543b13fb9cd7b9f4a7f5b65c" @@ -2505,7 +2456,7 @@ esprima@^4.0.0: resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.0.0, esquery@^1.0.1: +esquery@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" integrity sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA== @@ -2639,15 +2590,6 @@ extend@~3.0.2: resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== -external-editor@^2.0.4: - version "2.2.0" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.2.0.tgz#045511cfd8d133f3846673d1047c154e214ad3d5" - integrity sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A== - dependencies: - chardet "^0.4.0" - iconv-lite "^0.4.17" - tmp "^0.0.33" - external-editor@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.0.3.tgz#5866db29a97826dbe4bf3afd24070ead9ea43a27" @@ -2688,11 +2630,6 @@ extsprintf@^1.2.0: resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= -fast-deep-equal@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614" - integrity sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ= - fast-deep-equal@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" @@ -3145,7 +3082,7 @@ global-dirs@^0.1.0: dependencies: ini "^1.3.4" -globals@^11.0.1, globals@^11.7.0: +globals@^11.7.0: version "11.10.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.10.0.tgz#1e09776dffda5e01816b3bb4077c8b59c24eaa50" integrity sha512-0GZF1RiPKU97IHUO5TORo9w1PwrH/NBPl+fS7oMLdaTRiYmYbwK4NWoZWrAdd0/abG9R2BU+OiwyQpTpE6pdfQ== @@ -3333,7 +3270,7 @@ husky@0.14.3: normalize-path "^1.0.0" strip-indent "^2.0.0" -iconv-lite@0.4.24, iconv-lite@^0.4.17, iconv-lite@^0.4.24, iconv-lite@^0.4.4, iconv-lite@~0.4.13: +iconv-lite@0.4.24, iconv-lite@^0.4.24, iconv-lite@^0.4.4, iconv-lite@~0.4.13: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -3352,7 +3289,7 @@ ignore-walk@^3.0.1: dependencies: minimatch "^3.0.4" -ignore@^3.3.3, ignore@^3.3.5: +ignore@^3.3.5: version "3.3.10" resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043" integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug== @@ -3435,26 +3372,6 @@ init-package-json@^1.10.3: validate-npm-package-license "^3.0.1" validate-npm-package-name "^3.0.0" -inquirer@^3.0.6: - version "3.3.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" - integrity sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ== - dependencies: - ansi-escapes "^3.0.0" - chalk "^2.0.0" - cli-cursor "^2.1.0" - cli-width "^2.0.0" - external-editor "^2.0.4" - figures "^2.0.0" - lodash "^4.3.0" - mute-stream "0.0.7" - run-async "^2.2.0" - rx-lite "^4.0.8" - rx-lite-aggregates "^4.0.8" - string-width "^2.1.0" - strip-ansi "^4.0.0" - through "^2.3.6" - inquirer@^6.1.0, inquirer@^6.2.0: version "6.2.1" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.2.1.tgz#9943fc4882161bdb0b0c9276769c75b32dbfcd52" @@ -3735,11 +3652,6 @@ is-regexp@^1.0.0: resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069" integrity sha1-/S2INUXEa6xaYz57mgnof6LLUGk= -is-resolvable@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88" - integrity sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg== - is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" @@ -4203,7 +4115,7 @@ js-tokens@^3.0.2: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= -js-yaml@^3.12.0, js-yaml@^3.7.0, js-yaml@^3.9.0, js-yaml@^3.9.1: +js-yaml@^3.12.0, js-yaml@^3.7.0, js-yaml@^3.9.0: version "3.12.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.1.tgz#295c8632a18a23e054cf5c9d3cecafe678167600" integrity sha512-um46hB9wNOKlwkHgiuyEVAybXBjwFUV0Z/RaHJblRd9DXltue9FTYvzCr9ErQrK9Adz5MU4gHWVaNUfdmrC8qA== @@ -4258,11 +4170,6 @@ json-parse-better-errors@^1.0.0, json-parse-better-errors@^1.0.1: resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== -json-schema-traverse@^0.3.0: - version "0.3.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" - integrity sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A= - json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -4667,7 +4574,7 @@ lodash.unescape@4.0.1: resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c" integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw= -lodash@4.17.11, lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.1, lodash@^4.3.0: +lodash@4.17.11, lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.1: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== @@ -4934,7 +4841,7 @@ mimic-fn@^1.0.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== -minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4: +minimatch@^3.0.0, minimatch@^3.0.3, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== @@ -6045,11 +5952,6 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexpp@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-1.1.0.tgz#0e3516dd0b7904f413d2d4193dce4618c3a689ab" - integrity sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw== - regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -6242,18 +6144,6 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" -rx-lite-aggregates@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" - integrity sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74= - dependencies: - rx-lite "*" - -rx-lite@*, rx-lite@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" - integrity sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ= - rxjs@^6.1.0, rxjs@^6.3.3: version "6.3.3" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz#3c6a7fa420e844a81390fb1158a9ec614f4bad55" @@ -6381,13 +6271,6 @@ slice-ansi@0.0.4: resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" integrity sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU= -slice-ansi@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" - integrity sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg== - dependencies: - is-fullwidth-code-point "^2.0.0" - slice-ansi@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.0.0.tgz#5373bdb8559b45676e8541c66916cdd6251612e7" @@ -6755,18 +6638,6 @@ symbol-tree@^3.2.2: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6" integrity sha1-rifbOPZgp64uHDt9G8KQgZuFGeY= -table@4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36" - integrity sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA== - dependencies: - ajv "^5.2.3" - ajv-keywords "^2.1.0" - chalk "^2.1.0" - lodash "^4.17.4" - slice-ansi "1.0.0" - string-width "^2.1.1" - table@^5.0.2: version "5.2.1" resolved "https://registry.yarnpkg.com/table/-/table-5.2.1.tgz#e78463702b1be9f7131c39860bcfb1b81114c2a1" @@ -6832,7 +6703,7 @@ text-extensions@^1.0.0: resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.9.0.tgz#1853e45fee39c945ce6f6c36b2d659b5aabc2a26" integrity sha512-wiBrwC1EhBelW12Zy26JeOUkQ5mRu+5o8rpsJk5+2t+Y5vE7e842qtZDQ2g1NpX/29HdyFeJ4nSIhI47ENSxlQ== -text-table@^0.2.0, text-table@~0.2.0: +text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= From 27a3b754a73d51f352737e5a9b6308de7cb6b5db Mon Sep 17 00:00:00 2001 From: James Henry Date: Sat, 19 Jan 2019 18:40:45 -0500 Subject: [PATCH 02/88] build: use travis-deploy-once for now --- .travis.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 10d7a2a909e6..40e20ff3f481 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,12 +27,8 @@ script: - yarn global add codecov after_success: - codecov + - npm install -g travis-deploy-once + - travis-deploy-once "npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN && npx lerna publish --canary --force-publish --yes" branches: only: - master -deploy: - on: - branch: master - provider: script - script: npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN && npx lerna publish --canary --force-publish --yes - skip_cleanup: true From 33d0e53cdcdb46fc813edd687c071a31c75cc510 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sat, 19 Jan 2019 18:52:46 -0500 Subject: [PATCH 03/88] build: revert use travis-deploy-once for now --- .travis.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 40e20ff3f481..10d7a2a909e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,12 @@ script: - yarn global add codecov after_success: - codecov - - npm install -g travis-deploy-once - - travis-deploy-once "npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN && npx lerna publish --canary --force-publish --yes" branches: only: - master +deploy: + on: + branch: master + provider: script + script: npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN && npx lerna publish --canary --force-publish --yes + skip_cleanup: true From 5ab031a48295daed37336597693863f80ef5d071 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sat, 19 Jan 2019 19:11:09 -0500 Subject: [PATCH 04/88] chore: publish v0.2.1 --- CHANGELOG.md | 8 ++++++++ lerna.json | 2 +- packages/eslint-plugin-tslint/CHANGELOG.md | 8 ++++++++ packages/eslint-plugin-tslint/package.json | 4 ++-- packages/eslint-plugin/CHANGELOG.md | 8 ++++++++ packages/eslint-plugin/package.json | 4 ++-- packages/parser/CHANGELOG.md | 8 ++++++++ packages/parser/package.json | 8 ++++---- packages/shared-fixtures/CHANGELOG.md | 8 ++++++++ packages/shared-fixtures/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 8 ++++++++ packages/typescript-estree/package.json | 4 ++-- 12 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 packages/eslint-plugin/CHANGELOG.md create mode 100644 packages/shared-fixtures/CHANGELOG.md create mode 100644 packages/typescript-estree/CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000000..d0706cb69e05 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) + +**Note:** Version bump only for package @typescript-eslint/typescript-eslint diff --git a/lerna.json b/lerna.json index c5fbf20147b6..d51f69375e6d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.2.0", + "version": "0.2.1", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index e69de29bb2d1..241c8cd24624 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -0,0 +1,8 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 8fe4231573e1..e6f13409db21 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "0.2.0", + "version": "0.2.1", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -33,6 +33,6 @@ "devDependencies": { "@types/eslint": "^4.16.3", "@types/lodash.memoize": "^4.1.4", - "@typescript-eslint/parser": "0.2.0" + "@typescript-eslint/parser": "0.2.1" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md new file mode 100644 index 000000000000..d0f9e7a9b350 --- /dev/null +++ b/packages/eslint-plugin/CHANGELOG.md @@ -0,0 +1,8 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 86c8a1c62193..a8f81d0eab0b 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "0.2.0", + "version": "0.2.1", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -24,7 +24,7 @@ "recommended:update": "node tools/update-recommended.js" }, "dependencies": { - "@typescript-eslint/parser": "0.2.0", + "@typescript-eslint/parser": "0.2.1", "requireindex": "^1.2.0" }, "devDependencies": { diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index e69de29bb2d1..eec382e512e0 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -0,0 +1,8 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) + +**Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index f38199dfa0f2..b4271605c7b9 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "0.2.0", + "version": "0.2.1", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/parser.js", "files": [ @@ -36,14 +36,14 @@ "typescript": "*" }, "dependencies": { - "@typescript-eslint/typescript-estree": "0.2.0", + "@typescript-eslint/typescript-estree": "0.2.1", "eslint-scope": "^4.0.0", "eslint-visitor-keys": "^1.0.0" }, "devDependencies": { "@types/eslint": "^4.16.5", - "@types/estree": "^0.0.39", "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/shared-fixtures": "*" + "@types/estree": "^0.0.39", + "@typescript-eslint/shared-fixtures": "0.2.1" } } diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md new file mode 100644 index 000000000000..aebf69abe3ec --- /dev/null +++ b/packages/shared-fixtures/CHANGELOG.md @@ -0,0 +1,8 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index dfb21239d0cf..fe6193c18596 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "0.0.0", + "version": "0.2.1", "private": true } diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md new file mode 100644 index 000000000000..2ee862165041 --- /dev/null +++ b/packages/typescript-estree/CHANGELOG.md @@ -0,0 +1,8 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) + +**Note:** Version bump only for package @typescript-eslint/typescript-estree diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index e24209daebea..770cf0a1da51 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "0.2.0", + "version": "0.2.1", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/parser.js", "files": [ @@ -41,7 +41,7 @@ "typescript": "*" }, "devDependencies": { - "@typescript-eslint/shared-fixtures": "*", + "@typescript-eslint/shared-fixtures": "0.2.1", "typescript": "~3.2.1" } } From dbd27c585d324fc1e875c4b5cf6209c39080d347 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sat, 19 Jan 2019 19:26:10 -0500 Subject: [PATCH 05/88] build: remove deploy job for now --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 10d7a2a909e6..6c53fba944cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,3 @@ after_success: branches: only: - master -deploy: - on: - branch: master - provider: script - script: npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN && npx lerna publish --canary --force-publish --yes - skip_cleanup: true From cbb7ffefc18da6647edb0322bd6f0058580b6944 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 15:19:52 +0100 Subject: [PATCH 06/88] test(plugin-tslint): update tslint tests (#83) --- .../eslint-plugin-tslint/tests/index.spec.ts | 39 +++++++------------ .../tests/ast-alignment/fixtures-to-test.ts | 5 +-- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/packages/eslint-plugin-tslint/tests/index.spec.ts b/packages/eslint-plugin-tslint/tests/index.spec.ts index 1b78c3943f85..8232a16ec21c 100644 --- a/packages/eslint-plugin-tslint/tests/index.spec.ts +++ b/packages/eslint-plugin-tslint/tests/index.spec.ts @@ -2,18 +2,19 @@ import { rules } from '../src/index'; import { RuleTester } from 'eslint'; import { readFileSync } from 'fs'; -const ruleTester = new RuleTester(); - -const parserOptions: any = { - ecmaVersion: 6, - sourceType: 'module', - ecmaFeatures: {}, - /** - * Project is needed to generate the parserServices - * within @typescript-eslint/parser - */ - project: './tests/tsconfig.json' -}; +const ruleTester = new RuleTester({ + parserOptions: { + ecmaVersion: 6, + sourceType: 'module', + ecmaFeatures: {}, + /** + * Project is needed to generate the parserServices + * within @typescript-eslint/parser + */ + project: './tests/tsconfig.json' + }, + parser: '@typescript-eslint/parser' +}); /** * Inline rules should be supported @@ -40,8 +41,6 @@ ruleTester.run('tslint/config', rules.config, { valid: [ { code: 'var foo = true;', - parser: '@typescript-eslint/parser', - parserOptions, options: [tslintRulesConfig] }, { @@ -50,9 +49,7 @@ ruleTester.run('tslint/config', rules.config, { /\n/g, ' ' ), - parser: '@typescript-eslint/parser', parserOptions: { - ...parserOptions, project: `${__dirname}/test-project/tsconfig.json` }, options: [ @@ -63,8 +60,6 @@ ruleTester.run('tslint/config', rules.config, { }, { code: 'throw "should be ok because rule is not loaded";', - parser: '@typescript-eslint/parser', - parserOptions, options: [tslintRulesConfig] } ], @@ -72,8 +67,6 @@ ruleTester.run('tslint/config', rules.config, { invalid: [ { options: [{ lintFile: './tests/test-project/tslint.json' }], - parser: '@typescript-eslint/parser', - parserOptions, code: 'throw "err" // no-string-throw', errors: [ { @@ -84,8 +77,6 @@ ruleTester.run('tslint/config', rules.config, { }, { code: 'var foo = true // semicolon', - parser: '@typescript-eslint/parser', - parserOptions, options: [tslintRulesConfig], output: 'var foo = true // semicolon', errors: [ @@ -98,8 +89,6 @@ ruleTester.run('tslint/config', rules.config, { }, { code: 'var foo = true // fail', - parser: '@typescript-eslint/parser', - parserOptions, options: [tslintRulesDirectoryConfig], output: 'var foo = true // fail', errors: [ @@ -116,9 +105,7 @@ ruleTester.run('tslint/config', rules.config, { /\n/g, ' ' ), - parser: '@typescript-eslint/parser', parserOptions: { - ...parserOptions, project: `${__dirname}/test-project/tsconfig.json` }, options: [ 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 22bddf6b7baf..178b86573537 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -352,9 +352,8 @@ tester.addFixturePatternConfig('typescript/basics', { */ 'interface-with-extends-member-expression', /** - * Babel bug for parsing exported abstract interface - * https://github.com/babel/babel/issues/9304 - * PR: https://github.com/babel/babel/pull/9336 + * PR for parsing exported abstract interface has been merged into Babel: https://github.com/babel/babel/pull/9336 + * TODO: remove me in next babel > 7.2.3 */ 'abstract-interface', /** From 590064966a13d6de719ce29bece1d2cf1a6fc2f5 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Sun, 20 Jan 2019 09:28:14 -0500 Subject: [PATCH 07/88] chore: update .codecov.yml comment config (#84) --- .codecov.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.codecov.yml b/.codecov.yml index 119f1a50499c..750d876773d3 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -7,3 +7,7 @@ coverage: default: target: auto threshold: 2% +comment: + layout: diff, flags, files + require_changes: true + From c13b21a74d4fc68ae9c5577bdb07eff5a27b4809 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 15:28:42 +0100 Subject: [PATCH 08/88] docs: align readme across packages (#86) --- README.md | 4 +- packages/eslint-plugin-tslint/README.md | 48 ++++++---- packages/eslint-plugin/README.md | 90 +++++++++--------- .../eslint-plugin/docs/rules/ban-types.md | 4 +- .../eslint-plugin/docs/rules/camelcase.md | 18 ++-- packages/eslint-plugin/docs/rules/indent.md | 92 +++++++++---------- .../docs/rules/no-misused-new.md | 2 +- .../rules/no-object-literal-type-assertion.md | 2 +- .../eslint-plugin/docs/rules/no-this-alias.md | 2 +- .../docs/rules/no-unused-vars.md | 14 ++- packages/parser/README.md | 14 ++- packages/typescript-estree/README.md | 87 +++++++++--------- 12 files changed, 200 insertions(+), 177 deletions(-) diff --git a/README.md b/README.md index 47493a417b0e..2d6dda93ecb3 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@

Travis GitHub license - NPM Version - NPM Downloads + NPM Downloads + Codecov Commitizen friendly

diff --git a/packages/eslint-plugin-tslint/README.md b/packages/eslint-plugin-tslint/README.md index 09cc6e4c0b71..8ecccbd1001a 100644 --- a/packages/eslint-plugin-tslint/README.md +++ b/packages/eslint-plugin-tslint/README.md @@ -1,41 +1,49 @@ -# ESLint Plugin TSLint +

ESLint Plugin TSLint

-[![Travis](https://img.shields.io/travis/@typescript-eslint/eslint-plugin-tslint.svg?style=flat-square)](https://travis-ci.org/@typescript-eslint/eslint-plugin-tslint) -[![GitHub license](https://img.shields.io/npm/l/@typescript-eslint/eslint-plugin-tslint.svg?style=flat-square)](https://github.com/@typescript-eslint/eslint-plugin-tslint/blob/master/LICENSE) -[![NPM Version](https://img.shields.io/npm/v/@typescript-eslint/eslint-plugin-tslint.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin-tslint) -[![NPM Downloads](https://img.shields.io/npm/dt/@typescript-eslint/eslint-plugin-tslint.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin-tslint) -[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) +

ESLint plugin wraps a TSLint configuration and lints the whole source using TSLint.

-ESLint plugin wraps a TSLint configuration and lints the whole source using TSLint. +

+ Travis + GitHub license + NPM Version + NPM Downloads + Commitizen friendly +

-## INSTALL +## Installation -``` -npm i -D @typescript-eslint/eslint-plugin-tslint +```sh +npm i @typescript-eslint/eslint-plugin-tslint --save-dev ``` -## USAGE +## Usage Configure in your eslint config file: -``` -"plugins": [ +```js +{ + "plugins": [ "tslint" -], -"rules": { + ], + "rules": { "tslint/config": ["warn", { - lintFile: '/* path to tslint.json of your project */', - rules: { /* tslint rules (will be used if `lintFile` is not specified) */ }, - rulesDirectory: [ /* array of paths to directories with rules, e.g. 'node_modules/tslint/lib/rules' (will be used if `lintFile` is not specified) */ ] + "lintFile": '', // path to tslint.json of your project + "rules": { + // tslint rules (will be used if `lintFile` is not specified) + }, + "rulesDirectory": [ + // array of paths to directories with rules, e.g. 'node_modules/tslint/lib/rules' (will be used if `lintFile` is not specified) + ] }], + } } ``` -## RULES +## Rules Plugin contains only single rule `tslint/config`. -## EXAMPLES +## Examples - [unlight/node-package-starter/.eslintrc.js](https://github.com/unlight/node-package-starter/blob/master/.eslintrc.js) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 82e116951b03..c9ee4a63bb0e 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -1,27 +1,31 @@ -# @typescript-eslint/eslint-plugin +

ESLint Plugin TypeScript

-[![NPM version](https://img.shields.io/npm/v/@typescript-eslint/eslint-plugin.svg)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) -[![NPM downloads](https://img.shields.io/npm/dm/@typescript-eslint/eslint-plugin.svg)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) -[![TravisCI](https://img.shields.io/travis/@typescript-eslint/eslint-plugin.svg)](https://travis-ci.com/@typescript-eslint/eslint-plugin) +

+ Travis + GitHub license + NPM Version + NPM Downloads + Commitizen friendly +

## Installation You'll first need to install [ESLint](http://eslint.org): -```shellsession -$ npm i eslint --save-dev +```sh +npm i eslint --save-dev ``` Next, install `typescript` if you haven’t already: -```shellsession -$ npm i typescript@~3.1.1 --save-dev +```sh +npm i typescript@~3.1.1 --save-dev ``` Last, install `@typescript-eslint/eslint-plugin`: -```shellsession -$ npm install @typescript-eslint/eslint-plugin --save-dev +```sh +npm i @typescript-eslint/eslint-plugin --save-dev ``` **Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `@typescript-eslint/eslint-plugin` globally. @@ -70,38 +74,38 @@ You can also enable all the recommended rules at once. Add `plugin:typescript/re | Name | Description | :heavy_check_mark: | :wrench: | | ---- | ----------- | ------------------ | -------- | -| [`typescript/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) | :heavy_check_mark: | | -| [`typescript/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array` for arrays (`array-type` from TSLint) | :heavy_check_mark: | :wrench: | -| [`typescript/ban-types`](./docs/rules/ban-types.md) | Enforces that types will not to be used (`ban-types` from TSLint) | :heavy_check_mark: | :wrench: | -| [`typescript/camelcase`](./docs/rules/camelcase.md) | Enforce camelCase naming convention | :heavy_check_mark: | | -| [`typescript/class-name-casing`](./docs/rules/class-name-casing.md) | Require PascalCased class and interface names (`class-name` from TSLint) | :heavy_check_mark: | | -| [`typescript/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | :heavy_check_mark: | | -| [`typescript/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods (`member-access` from TSLint) | :heavy_check_mark: | | -| [`typescript/generic-type-naming`](./docs/rules/generic-type-naming.md) | Enforces naming of generic type variables | | | -| [`typescript/indent`](./docs/rules/indent.md) | Enforce consistent indentation (`indent` from TSLint) | :heavy_check_mark: | :wrench: | -| [`typescript/interface-name-prefix`](./docs/rules/interface-name-prefix.md) | Require that interface names be prefixed with `I` (`interface-name` from TSLint) | :heavy_check_mark: | | -| [`typescript/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | :heavy_check_mark: | :wrench: | -| [`typescript/member-naming`](./docs/rules/member-naming.md) | Enforces naming conventions for class members by visibility. | | | -| [`typescript/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order (`member-ordering` from TSLint) | | | -| [`typescript/no-angle-bracket-type-assertion`](./docs/rules/no-angle-bracket-type-assertion.md) | Enforces the use of `as Type` assertions instead of `` assertions (`no-angle-bracket-type-assertion` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :heavy_check_mark: | :wrench: | -| [`typescript/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type (`no-any` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) | | | -| [`typescript/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (`no-inferrable-types` from TSLint) | :heavy_check_mark: | :wrench: | -| [`typescript/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md) | Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-parameter-properties`](./docs/rules/no-parameter-properties.md) | Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | | -| [`typescript/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// ` comments (`no-reference` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | | -| [`typescript/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | | -| [`typescript/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | | -| [`typescript/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: | -| [`typescript/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: | -| [`typescript/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array` for arrays (`array-type` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Enforces that types will not to be used (`ban-types` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/camelcase`](./docs/rules/camelcase.md) | Enforce camelCase naming convention | :heavy_check_mark: | | +| [`@typescript-eslint/class-name-casing`](./docs/rules/class-name-casing.md) | Require PascalCased class and interface names (`class-name` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | :heavy_check_mark: | | +| [`@typescript-eslint/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods (`member-access` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/generic-type-naming`](./docs/rules/generic-type-naming.md) | Enforces naming of generic type variables | | | +| [`@typescript-eslint/indent`](./docs/rules/indent.md) | Enforce consistent indentation (`indent` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/interface-name-prefix`](./docs/rules/interface-name-prefix.md) | Require that interface names be prefixed with `I` (`interface-name` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/member-naming`](./docs/rules/member-naming.md) | Enforces naming conventions for class members by visibility. | | | +| [`@typescript-eslint/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order (`member-ordering` from TSLint) | | | +| [`@typescript-eslint/no-angle-bracket-type-assertion`](./docs/rules/no-angle-bracket-type-assertion.md) | Enforces the use of `as Type` assertions instead of `` assertions (`no-angle-bracket-type-assertion` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type (`no-any` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) | | | +| [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (`no-inferrable-types` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md) | Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-parameter-properties`](./docs/rules/no-parameter-properties.md) | Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | | +| [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// ` comments (`no-reference` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | | +| [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | | +| [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: | diff --git a/packages/eslint-plugin/docs/rules/ban-types.md b/packages/eslint-plugin/docs/rules/ban-types.md index 64eaa018df9f..5ab5e6e96e76 100644 --- a/packages/eslint-plugin/docs/rules/ban-types.md +++ b/packages/eslint-plugin/docs/rules/ban-types.md @@ -32,7 +32,7 @@ class Foo extends Bar implements Baz { ```CJSON { - "typescript/ban-types": ["error", { + "@typescript-eslint/ban-types": ["error", { "types": { // report usages of the type using the default error message "Foo": null, @@ -54,7 +54,7 @@ class Foo extends Bar implements Baz { ```json { - "typescript/ban-types": [ + "@typescript-eslint/ban-types": [ "error", { "types": { diff --git a/packages/eslint-plugin/docs/rules/camelcase.md b/packages/eslint-plugin/docs/rules/camelcase.md index ab624c2f9931..203a3885ed43 100644 --- a/packages/eslint-plugin/docs/rules/camelcase.md +++ b/packages/eslint-plugin/docs/rules/camelcase.md @@ -24,7 +24,7 @@ variable that will be imported into the local module scope. { // note you must disable the base rule as it can report incorrect errors "camelcase": "off", - "typescript/camelcase": ["error", { "properties": "always" }] + "@typescript-eslint/camelcase": ["error", { "properties": "always" }] } ``` @@ -41,7 +41,7 @@ This rule has an object option: Examples of **incorrect** code for this rule with the default `{ "properties": "always" }` option: ```js -/*eslint typescript/camelcase: "error"*/ +/*eslint @typescript-eslint/camelcase: "error"*/ import { no_camelcased } from 'external-module'; @@ -81,7 +81,7 @@ var { foo: bar_baz = 1 } = quz; Examples of **correct** code for this rule with the default `{ "properties": "always" }` option: ```js -/*eslint typescript/camelcase: "error"*/ +/*eslint @typescript-eslint/camelcase: "error"*/ import { no_camelcased as camelCased } from 'external-module'; @@ -122,7 +122,7 @@ var { foo: isCamelCased = 1 } = quz; Examples of **correct** code for this rule with the `{ "properties": "never" }` option: ```js -/*eslint typescript/camelcase: ["error", {properties: "never"}]*/ +/*eslint @typescript-eslint/camelcase: ["error", {properties: "never"}]*/ var obj = { my_pref: 1 @@ -134,7 +134,7 @@ var obj = { Examples of **incorrect** code for this rule with the default `{ "ignoreDestructuring": false }` option: ```js -/*eslint typescript/camelcase: "error"*/ +/*eslint @typescript-eslint/camelcase: "error"*/ var { category_id } = query; @@ -152,7 +152,7 @@ var { category_id: categoryId, ...other_props } = query; Examples of **incorrect** code for this rule with the `{ "ignoreDestructuring": true }` option: ```js -/*eslint typescript/camelcase: ["error", {ignoreDestructuring: true}]*/ +/*eslint @typescript-eslint/camelcase: ["error", {ignoreDestructuring: true}]*/ var { category_id: category_alias } = query; @@ -162,7 +162,7 @@ var { category_id, ...other_props } = query; Examples of **correct** code for this rule with the `{ "ignoreDestructuring": true }` option: ```js -/*eslint typescript/camelcase: ["error", {ignoreDestructuring: true}]*/ +/*eslint @typescript-eslint/camelcase: ["error", {ignoreDestructuring: true}]*/ var { category_id } = query; @@ -176,7 +176,7 @@ var { category_id: category_id } = query; Examples of **correct** code for this rule with the `allow` option: ```js -/*eslint typescript/camelcase: ["error", {allow: ["UNSAFE_componentWillMount"]}]*/ +/*eslint @typescript-eslint/camelcase: ["error", {allow: ["UNSAFE_componentWillMount"]}]*/ function UNSAFE_componentWillMount() { // ... @@ -184,7 +184,7 @@ function UNSAFE_componentWillMount() { ``` ```js -/*eslint typescript/camelcase: ["error", {allow: ["^UNSAFE_"]}]*/ +/*eslint @typescript-eslint/camelcase: ["error", {allow: ["^UNSAFE_"]}]*/ function UNSAFE_componentWillMount() { // ... diff --git a/packages/eslint-plugin/docs/rules/indent.md b/packages/eslint-plugin/docs/rules/indent.md index 1ef6595a8ad8..5678ba291da2 100644 --- a/packages/eslint-plugin/docs/rules/indent.md +++ b/packages/eslint-plugin/docs/rules/indent.md @@ -30,7 +30,7 @@ For example, for 2-space indentation: { // note you must disable the base rule as it can report incorrect errors "indent": "off", - "typescript/indent": ["error", 2] + "@typescript-eslint/indent": ["error", 2] } ``` @@ -40,7 +40,7 @@ Or for tabbed indentation: { // note you must disable the base rule as it can report incorrect errors "indent": "off", - "typescript/indent": ["error", "tab"] + "@typescript-eslint/indent": ["error", "tab"] } ``` @@ -48,7 +48,7 @@ Examples of **incorrect** code for this rule with the default options: ```js -/*eslint typescript/indent: "error"*/ +/*eslint @typescript-eslint/indent: "error"*/ if (a) { b=c; @@ -62,7 +62,7 @@ Examples of **correct** code for this rule with the default options: ```js -/*eslint typescript/indent: "error"*/ +/*eslint @typescript-eslint/indent: "error"*/ if (a) { b=c; @@ -116,7 +116,7 @@ Examples of **incorrect** code for this rule with the `"tab"` option: ```js -/*eslint typescript/indent: ["error", "tab"]*/ +/*eslint @typescript-eslint/indent: ["error", "tab"]*/ if (a) { b=c; @@ -130,7 +130,7 @@ Examples of **correct** code for this rule with the `"tab"` option: ```js -/*eslint typescript/indent: ["error", "tab"]*/ +/*eslint @typescript-eslint/indent: ["error", "tab"]*/ if (a) { /*tab*/b=c; @@ -146,7 +146,7 @@ Examples of **incorrect** code for this rule with the `2, { "SwitchCase": 1 }` o ```js -/*eslint typescript/indent: ["error", 2, { "SwitchCase": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "SwitchCase": 1 }]*/ switch(a){ case "a": @@ -160,7 +160,7 @@ Examples of **correct** code for this rule with the `2, { "SwitchCase": 1 }` opt ```js -/*eslint typescript/indent: ["error", 2, { "SwitchCase": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "SwitchCase": 1 }]*/ switch(a){ case "a": @@ -176,7 +176,7 @@ Examples of **incorrect** code for this rule with the `2, { "VariableDeclarator" ```js -/*eslint typescript/indent: ["error", 2, { "VariableDeclarator": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "VariableDeclarator": 1 }]*/ /*eslint-env es6*/ var a, @@ -194,7 +194,7 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": ```js -/*eslint typescript/indent: ["error", 2, { "VariableDeclarator": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "VariableDeclarator": 1 }]*/ /*eslint-env es6*/ var a, @@ -212,7 +212,7 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": ```js -/*eslint typescript/indent: ["error", 2, { "VariableDeclarator": 2 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "VariableDeclarator": 2 }]*/ /*eslint-env es6*/ var a, @@ -230,7 +230,7 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": ```js -/*eslint typescript/indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/ /*eslint-env es6*/ var a, @@ -250,7 +250,7 @@ Examples of **incorrect** code for this rule with the options `2, { "outerIIFEBo ```js -/*eslint typescript/indent: ["error", 2, { "outerIIFEBody": 0 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "outerIIFEBody": 0 }]*/ (function() { @@ -270,7 +270,7 @@ Examples of **correct** code for this rule with the options `2, {"outerIIFEBody" ```js -/*eslint typescript/indent: ["error", 2, { "outerIIFEBody": 0 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "outerIIFEBody": 0 }]*/ (function() { @@ -292,7 +292,7 @@ Examples of **incorrect** code for this rule with the `2, { "MemberExpression": ```js -/*eslint typescript/indent: ["error", 2, { "MemberExpression": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "MemberExpression": 1 }]*/ foo .bar @@ -303,7 +303,7 @@ Examples of **correct** code for this rule with the `2, { "MemberExpression": 1 ```js -/*eslint typescript/indent: ["error", 2, { "MemberExpression": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "MemberExpression": 1 }]*/ foo .bar @@ -316,7 +316,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionDeclaration ```js -/*eslint typescript/indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/ function foo(bar, baz, @@ -329,7 +329,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionDeclaration": ```js -/*eslint typescript/indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/ function foo(bar, baz, @@ -342,7 +342,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionDeclaration ```js -/*eslint typescript/indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/ function foo(bar, baz, qux, boop) { @@ -354,7 +354,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionDeclaration": ```js -/*eslint typescript/indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/ function foo(bar, baz, qux, boop) { @@ -368,7 +368,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionExpression" ```js -/*eslint typescript/indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/ var foo = function(bar, baz, @@ -381,7 +381,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionExpression": ```js -/*eslint typescript/indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/ var foo = function(bar, baz, @@ -394,7 +394,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionExpression" ```js -/*eslint typescript/indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/ var foo = function(bar, baz, qux, boop) { @@ -406,7 +406,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionExpression": ```js -/*eslint typescript/indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/ var foo = function(bar, baz, qux, boop) { @@ -420,7 +420,7 @@ Examples of **incorrect** code for this rule with the `2, { "CallExpression": {" ```js -/*eslint typescript/indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/ foo(bar, baz, @@ -432,7 +432,7 @@ Examples of **correct** code for this rule with the `2, { "CallExpression": {"ar ```js -/*eslint typescript/indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/ foo(bar, baz, @@ -444,7 +444,7 @@ Examples of **incorrect** code for this rule with the `2, { "CallExpression": {" ```js -/*eslint typescript/indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/ foo(bar, baz, baz, boop, beep); @@ -454,7 +454,7 @@ Examples of **correct** code for this rule with the `2, { "CallExpression": {"ar ```js -/*eslint typescript/indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/ foo(bar, baz, baz, boop, beep); @@ -466,7 +466,7 @@ Examples of **incorrect** code for this rule with the `2, { "ArrayExpression": 1 ```js -/*eslint typescript/indent: ["error", 2, { "ArrayExpression": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "ArrayExpression": 1 }]*/ var foo = [ bar, @@ -479,7 +479,7 @@ Examples of **correct** code for this rule with the `2, { "ArrayExpression": 1 } ```js -/*eslint typescript/indent: ["error", 2, { "ArrayExpression": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "ArrayExpression": 1 }]*/ var foo = [ bar, @@ -492,7 +492,7 @@ Examples of **incorrect** code for this rule with the `2, { "ArrayExpression": " ```js -/*eslint typescript/indent: ["error", 2, {"ArrayExpression": "first"}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"ArrayExpression": "first"}]*/ var foo = [bar, baz, @@ -504,7 +504,7 @@ Examples of **correct** code for this rule with the `2, { "ArrayExpression": "fi ```js -/*eslint typescript/indent: ["error", 2, {"ArrayExpression": "first"}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"ArrayExpression": "first"}]*/ var foo = [bar, baz, @@ -518,7 +518,7 @@ Examples of **incorrect** code for this rule with the `2, { "ObjectExpression": ```js -/*eslint typescript/indent: ["error", 2, { "ObjectExpression": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "ObjectExpression": 1 }]*/ var foo = { bar: 1, @@ -531,7 +531,7 @@ Examples of **correct** code for this rule with the `2, { "ObjectExpression": 1 ```js -/*eslint typescript/indent: ["error", 2, { "ObjectExpression": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "ObjectExpression": 1 }]*/ var foo = { bar: 1, @@ -544,7 +544,7 @@ Examples of **incorrect** code for this rule with the `2, { "ObjectExpression": ```js -/*eslint typescript/indent: ["error", 2, {"ObjectExpression": "first"}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"ObjectExpression": "first"}]*/ var foo = { bar: 1, baz: 2 }; @@ -554,7 +554,7 @@ Examples of **correct** code for this rule with the `2, { "ObjectExpression": "f ```js -/*eslint typescript/indent: ["error", 2, {"ObjectExpression": "first"}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"ObjectExpression": "first"}]*/ var foo = { bar: 1, baz: 2 }; @@ -566,7 +566,7 @@ Examples of **correct** code for this rule with the `4, { "ImportDeclaration": 1 ```js -/*eslint typescript/indent: ["error", 4, { ImportDeclaration: 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { ImportDeclaration: 1 }]*/ import { foo, bar, @@ -584,7 +584,7 @@ Examples of **incorrect** code for this rule with the `4, { ImportDeclaration: " ```js -/*eslint typescript/indent: ["error", 4, { ImportDeclaration: "first" }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { ImportDeclaration: "first" }]*/ import { foo, bar, @@ -596,7 +596,7 @@ Examples of **correct** code for this rule with the `4, { ImportDeclaration: "fi ```js -/*eslint typescript/indent: ["error", 4, { ImportDeclaration: "first" }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { ImportDeclaration: "first" }]*/ import { foo, bar, @@ -610,7 +610,7 @@ Examples of **incorrect** code for this rule with the default `4, { "flatTernary ```js -/*eslint typescript/indent: ["error", 4, { "flatTernaryExpressions": false }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { "flatTernaryExpressions": false }]*/ var a = foo ? bar : @@ -622,7 +622,7 @@ Examples of **correct** code for this rule with the default `4, { "flatTernaryEx ```js -/*eslint typescript/indent: ["error", 4, { "flatTernaryExpressions": false }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { "flatTernaryExpressions": false }]*/ var a = foo ? bar : @@ -634,7 +634,7 @@ Examples of **incorrect** code for this rule with the `4, { "flatTernaryExpressi ```js -/*eslint typescript/indent: ["error", 4, { "flatTernaryExpressions": true }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { "flatTernaryExpressions": true }]*/ var a = foo ? bar : @@ -646,7 +646,7 @@ Examples of **correct** code for this rule with the `4, { "flatTernaryExpression ```js -/*eslint typescript/indent: ["error", 4, { "flatTernaryExpressions": true }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { "flatTernaryExpressions": true }]*/ var a = foo ? bar : @@ -662,7 +662,7 @@ Examples of **correct** code for this rule with the `4, { "ignoredNodes": ["Cond ```js -/*eslint typescript/indent: ["error", 4, { "ignoredNodes": ["ConditionalExpression"] }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { "ignoredNodes": ["ConditionalExpression"] }]*/ var a = foo ? bar @@ -679,7 +679,7 @@ Examples of **correct** code for this rule with the `4, { "ignoredNodes": ["Call ```js -/*eslint typescript/indent: ["error", 4, { "ignoredNodes": ["CallExpression > FunctionExpression.callee > BlockStatement.body"] }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { "ignoredNodes": ["CallExpression > FunctionExpression.callee > BlockStatement.body"] }]*/ (function() { @@ -695,7 +695,7 @@ Examples of additional **correct** code for this rule with the `4, { "ignoreComm ```js -/*eslint typescript/indent: ["error", 4, { "ignoreComments": true }] */ +/*eslint @typescript-eslint/indent: ["error", 4, { "ignoreComments": true }] */ if (foo) { doSomething(); diff --git a/packages/eslint-plugin/docs/rules/no-misused-new.md b/packages/eslint-plugin/docs/rules/no-misused-new.md index ea588fd5ec29..df1aec7ad605 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-new.md +++ b/packages/eslint-plugin/docs/rules/no-misused-new.md @@ -32,7 +32,7 @@ interface I { ```json { - "typescript/no-misused-new": "error" + "@typescript-eslint/no-misused-new": "error" } ``` diff --git a/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md b/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md index c833fe9fbbbd..fe25f8f64107 100644 --- a/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md @@ -22,7 +22,7 @@ const z = { ... } as unknown; ```json { - "typescript/no-object-literal-type-assertion": "error" + "@typescript-eslint/no-object-literal-type-assertion": "error" } ``` diff --git a/packages/eslint-plugin/docs/rules/no-this-alias.md b/packages/eslint-plugin/docs/rules/no-this-alias.md index ea747805e0ee..b40c165b3db7 100644 --- a/packages/eslint-plugin/docs/rules/no-this-alias.md +++ b/packages/eslint-plugin/docs/rules/no-this-alias.md @@ -41,7 +41,7 @@ You can pass an object option: ```json5 { - 'typescript/no-this-alias': [ + '@typescript-eslint/no-this-alias': [ 'error', { allowDestructuring: true, // Allow `const { props, state } = this`; false by default diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars.md b/packages/eslint-plugin/docs/rules/no-unused-vars.md index 58dcc78f1ee0..63f148f7a3f4 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-vars.md +++ b/packages/eslint-plugin/docs/rules/no-unused-vars.md @@ -110,11 +110,15 @@ By default this rule is enabled with `all` option for variables and `after-used` ```CJSON { - "rules": { - // note you must disable the base rule as it can report incorrect errors - "no-unused-vars": "off", - "typescript/no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }] - } + "rules": { + // note you must disable the base rule as it can report incorrect errors + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": ["error", { + "vars": "all", + "args": "after-used", + "ignoreRestSiblings": false + }] + } } ``` diff --git a/packages/parser/README.md b/packages/parser/README.md index 253ed00e4686..bcf4d941c7f4 100644 --- a/packages/parser/README.md +++ b/packages/parser/README.md @@ -1,11 +1,19 @@ -# TypeScript ESLint Parser +

TypeScript ESLint Parser

-An ESLint custom parser which leverages [TypeScript ESTree](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/typescript-estree) to allow for ESLint to lint TypeScript source code. +

An ESLint custom parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.

+ +

+ Travis + GitHub license + NPM Version + NPM Downloads + Commitizen friendly +

## Installation: ```sh -npm install --save-dev @typescript-eslint/parser +npm install @typescript-eslint/parser --save-dev ``` ## Usage diff --git a/packages/typescript-estree/README.md b/packages/typescript-estree/README.md index 110521f37616..910002f4fae0 100644 --- a/packages/typescript-estree/README.md +++ b/packages/typescript-estree/README.md @@ -3,12 +3,11 @@

A parser that converts TypeScript source code into an ESTree-compatible form

- Travis - GitHub license - NPM Version - NPM Downloads - Commitizen friendly - semantic-release + Travis + GitHub license + NPM Version + NPM Downloads + Commitizen friendly


@@ -24,8 +23,8 @@ In fact, it is already used within these hyper-popular open-source projects to p ## Installation -``` -npm install --save @typescript-eslint/typescript-estree +```sh +npm install @typescript-eslint/typescript-estree --save-dev ``` ## API @@ -34,46 +33,46 @@ npm install --save @typescript-eslint/typescript-estree Parses the given string of code with the options provided and returns an ESTree-compatible AST. The options object has the following properties: -```javascript +```js { - // attach range information to each node - range: false, - - // attach line/column location information to each node - loc: false, - - // create a top-level tokens array containing all tokens - tokens: false, - - // create a top-level comments array containing all comments - comment: false, - - // enable parsing JSX. For more details, see https://www.typescriptlang.org/docs/handbook/jsx.html - jsx: false, - - /* - * The JSX AST changed the node type for string literals - * inside a JSX Element from `Literal` to `JSXText`. - * When value is `true`, these nodes will be parsed as type `JSXText`. - * When value is `false`, these nodes will be parsed as type `Literal`. - */ - useJSXTextNode: false, - - // Cause the parser to error if it encounters an unknown AST node type (useful for testing) - errorOnUnknownASTType: false, - - /* - * Allows overriding of function used for logging. - * When value is `false`, no logging will occur. - * When value is not provided, `console.log()` will be used. - */ - loggerFn: undefined + // attach range information to each node + range: false, + + // attach line/column location information to each node + loc: false, + + // create a top-level tokens array containing all tokens + tokens: false, + + // create a top-level comments array containing all comments + comment: false, + + // enable parsing JSX. For more details, see https://www.typescriptlang.org/docs/handbook/jsx.html + jsx: false, + + /* + * The JSX AST changed the node type for string literals + * inside a JSX Element from `Literal` to `JSXText`. + * When value is `true`, these nodes will be parsed as type `JSXText`. + * When value is `false`, these nodes will be parsed as type `Literal`. + */ + useJSXTextNode: false, + + // Cause the parser to error if it encounters an unknown AST node type (useful for testing) + errorOnUnknownASTType: false, + + /* + * Allows overriding of function used for logging. + * When value is `false`, no logging will occur. + * When value is not provided, `console.log()` will be used. + */ + loggerFn: undefined } ``` Example usage: -```javascript +```js const parser = require('@typescript-eslint/typescript-estree'); const code = `const hello: string = 'world';`; const ast = parser.parse(code, { @@ -88,7 +87,7 @@ Exposes the current version of typescript-estree as specified in package.json. Example usage: -```javascript +```js const parser = require('@typescript-eslint/typescript-estree'); const version = parser.version; ``` @@ -99,7 +98,7 @@ Exposes an object that contains the AST node types produced by the parser. Example usage: -```javascript +```js const parser = require('@typescript-eslint/typescript-estree'); const astNodeTypes = parser.AST_NODE_TYPES; ``` From c5aabf7515fe80a8a1de208b7dbf75f18e87432e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Sun, 20 Jan 2019 15:28:58 +0100 Subject: [PATCH 09/88] docs(plugin-typescript): fix readme instructions (#91) --- packages/eslint-plugin/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index c9ee4a63bb0e..6f649ef0ada6 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -37,7 +37,7 @@ Add `@typescript-eslint/eslint-plugin/parser` to the `parser` field and `typescr ```json { "parser": "@typescript-eslint/eslint-plugin/parser", - "plugins": ["typescript"] + "plugins": ["@typescript-eslint"] } ``` @@ -49,9 +49,9 @@ Then configure the rules you want to use under the rules section. ```json { "parser": "@typescript-eslint/eslint-plugin/parser", - "plugins": ["typescript"], + "plugins": ["@typescript-eslint"], "rules": { - "typescript/rule-name": "error" + "@typescript-eslint/rule-name": "error" } } ``` @@ -60,7 +60,7 @@ You can also enable all the recommended rules at once. Add `plugin:typescript/re ```json { - "extends": ["plugin:typescript/recommended"] + "extends": ["plugin:@typescript-eslint/recommended"] } ``` From b321736a837c6c335a2bef91f7cda5d0d972826e Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 15:29:32 +0100 Subject: [PATCH 10/88] feat(parser): support ecmaFeatures.jsx flag and tests (#85) --- packages/parser/README.md | 6 ++- packages/parser/src/parser-options.ts | 23 ++++---- packages/parser/src/parser.ts | 69 +++++++++++++++--------- packages/parser/tests/lib/comments.ts | 6 ++- packages/parser/tests/lib/jsx.ts | 4 +- packages/parser/tests/lib/parser.ts | 54 +++++++++++++++++++ packages/parser/tests/lib/tsx.ts | 16 ++++-- packages/typescript-estree/src/parser.ts | 8 +-- 8 files changed, 138 insertions(+), 48 deletions(-) diff --git a/packages/parser/README.md b/packages/parser/README.md index bcf4d941c7f4..3a18f79735e6 100644 --- a/packages/parser/README.md +++ b/packages/parser/README.md @@ -40,7 +40,7 @@ By far the most common case will be installing the [@typescript-eslint/eslint-pl The following additional configuration options are available by specifying them in [`parserOptions`](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) in your ESLint configuration file. -- **`jsx`** - default `false`. Enable parsing JSX when `true`. More details can be found [here](https://www.typescriptlang.org/docs/handbook/jsx.html). +- **`ecmaFeatures.jsx`** - default `false`. Enable parsing JSX when `true`. More details can be found [here](https://www.typescriptlang.org/docs/handbook/jsx.html). - It's `false` on `*.ts` files regardless of this option. - It's `true` on `*.tsx` files regardless of this option. @@ -54,7 +54,9 @@ The following additional configuration options are available by specifying them { "parser": "@typescript-eslint/parser", "parserOptions": { - "jsx": true, + "ecmaFeatures": { + "jsx": true + }, "useJSXTextNode": true } } diff --git a/packages/parser/src/parser-options.ts b/packages/parser/src/parser-options.ts index 6bb6b160bca7..95d6e54c182c 100644 --- a/packages/parser/src/parser-options.ts +++ b/packages/parser/src/parser-options.ts @@ -1,17 +1,20 @@ export interface ParserOptions { - useJSXTextNode?: boolean; - loc?: true; - range?: true; - tokens?: true; - filePath?: string; + loc?: boolean; + comment?: boolean; + range?: boolean; + tokens?: boolean; sourceType?: 'script' | 'module'; ecmaVersion?: number; ecmaFeatures?: { globalReturn?: boolean; + jsx?: boolean; }; - /** - * @deprecated We should finalize the work from - * https://github.com/eslint/typescript-eslint-parser#595 - */ - jsx?: boolean; + // ts-estree specific + filePath?: string; + project?: string | string[]; + useJSXTextNode?: boolean; + errorOnUnknownASTType?: boolean; + errorOnTypeScriptSyntacticAndSemanticIssues?: boolean; + tsconfigRootDir?: string; + extraFileExtensions?: string[]; } diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 49aabf26074a..2dd32b383625 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -1,5 +1,9 @@ import traverser from 'eslint/lib/util/traverser'; -import * as typescriptESTree from '@typescript-eslint/typescript-estree'; +import { + AST_NODE_TYPES, + parseAndGenerateServices, + ParserOptions as ParserOptionsTsESTree +} from '@typescript-eslint/typescript-estree'; import { analyzeScope } from './analyze-scope'; import { ParserOptions } from './parser-options'; import { visitorKeys } from './visitor-keys'; @@ -20,52 +24,67 @@ interface ParseForESLintResult { scopeManager: ReturnType; } +function validateBoolean( + value: boolean | undefined, + fallback: boolean = false +): boolean { + if (typeof value !== 'boolean') { + return fallback; + } + return value; +} + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + export const version = packageJSON.version; +export const Syntax = Object.freeze(AST_NODE_TYPES); + export function parse(code: string, options?: ParserOptions) { return parseForESLint(code, options).ast; } -export const Syntax = Object.freeze(typescriptESTree.AST_NODE_TYPES); - -export function parseForESLint( +export function parseForESLint( code: string, - options?: T | null + options?: ParserOptions | null ): ParseForESLintResult { - if (typeof options !== 'object' || options === null) { - options = { useJSXTextNode: true } as T; - } else if (typeof options.useJSXTextNode !== 'boolean') { - options = Object.assign({}, options, { useJSXTextNode: true }); - } - if (typeof options.filePath === 'string') { - const tsx = options.filePath.endsWith('.tsx'); - if (tsx || options.filePath.endsWith('.ts')) { - options = Object.assign({}, options, { jsx: tsx }); - } + if (!options || typeof options !== 'object') { + options = {}; } - // https://eslint.org/docs/user-guide/configuring#specifying-parser-options // if sourceType is not provided by default eslint expect that it will be set to "script" - options.sourceType = options.sourceType || 'script'; if (options.sourceType !== 'module' && options.sourceType !== 'script') { options.sourceType = 'script'; } + if (typeof options.ecmaFeatures !== 'object') { + options.ecmaFeatures = {}; + } + + const parserOptions: ParserOptionsTsESTree = {}; + Object.assign(parserOptions, options, { + useJSXTextNode: validateBoolean(options.useJSXTextNode, true), + jsx: validateBoolean(options.ecmaFeatures.jsx) + }); + + if (typeof options.filePath === 'string') { + const tsx = options.filePath.endsWith('.tsx'); + if (tsx || options.filePath.endsWith('.ts')) { + parserOptions.jsx = tsx; + } + } - const { ast, services } = typescriptESTree.parseAndGenerateServices( - code, - options - ); + const { ast, services } = parseAndGenerateServices(code, parserOptions); ast.sourceType = options.sourceType; traverser.traverse(ast, { - enter: (node: any) => { + enter(node: any) { switch (node.type) { // Function#body cannot be null in ESTree spec. case 'FunctionExpression': if (!node.body) { - node.type = `TSEmptyBody${ - node.type - }` as typescriptESTree.AST_NODE_TYPES; + node.type = `TSEmptyBody${node.type}` as AST_NODE_TYPES; } break; // no default diff --git a/packages/parser/tests/lib/comments.ts b/packages/parser/tests/lib/comments.ts index bdf3356f3a4b..f2bb2260d651 100644 --- a/packages/parser/tests/lib/comments.ts +++ b/packages/parser/tests/lib/comments.ts @@ -15,8 +15,10 @@ describe('Comments', () => { testFiles.forEach(filename => { const code = fs.readFileSync(filename, 'utf8'); const config: ParserOptions = { - jsx: true, - sourceType: 'module' + sourceType: 'module', + ecmaFeatures: { + jsx: true + } }; it( testUtils.formatSnapshotName(filename, FIXTURES_DIR), diff --git a/packages/parser/tests/lib/jsx.ts b/packages/parser/tests/lib/jsx.ts index 55bb4e5f742f..05adef987f6f 100644 --- a/packages/parser/tests/lib/jsx.ts +++ b/packages/parser/tests/lib/jsx.ts @@ -28,7 +28,9 @@ describe('JSX', () => { const code = fs.readFileSync(filename, 'utf8'); const config = { useJSXTextNode, - jsx: true + ecmaFeatures: { + jsx: true + } }; it( testUtils.formatSnapshotName(filename, fixturesDir), diff --git a/packages/parser/tests/lib/parser.ts b/packages/parser/tests/lib/parser.ts index f5b1f7a9ac4a..bfc23bac5abb 100644 --- a/packages/parser/tests/lib/parser.ts +++ b/packages/parser/tests/lib/parser.ts @@ -1,5 +1,6 @@ import * as typescriptESTree from '@typescript-eslint/typescript-estree'; import { parse, parseForESLint, Syntax } from '../../src/parser'; +import * as scope from '../../src/analyze-scope'; describe('parser', () => { it('parse() should return just the AST from parseForESLint()', () => { @@ -15,11 +16,64 @@ describe('parser', () => { it('parseForESLint() should set the sourceType to script, if an invalid one is provided', () => { const code = 'const valid = true;'; const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices'); + const spyScope = jest.spyOn(scope, 'analyzeScope'); parseForESLint(code, { sourceType: 'foo' as any }); expect(spy).toHaveBeenCalledWith(code, { + ecmaFeatures: {}, + jsx: false, sourceType: 'script', useJSXTextNode: true }); + expect(spyScope).toHaveBeenCalledWith(jasmine.any(Object), { + ecmaFeatures: {}, + sourceType: 'script' + }); + }); + + it('parseAndGenerateServices() should be called with options', () => { + const code = 'const valid = true;'; + const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices'); + parseForESLint(code, { + loc: false, + comment: false, + range: false, + tokens: false, + sourceType: 'module', + ecmaVersion: 10, + ecmaFeatures: { + globalReturn: false, + jsx: false + }, + // ts-estree specific + filePath: 'test/foo', + project: 'tsconfig.json', + useJSXTextNode: false, + errorOnUnknownASTType: false, + errorOnTypeScriptSyntacticAndSemanticIssues: false, + tsconfigRootDir: '../../', + extraFileExtensions: ['foo'] + }); + expect(spy).toHaveBeenCalledWith(code, { + jsx: false, + loc: false, + comment: false, + range: false, + tokens: false, + sourceType: 'module', + ecmaVersion: 10, + ecmaFeatures: { + globalReturn: false, + jsx: false + }, + // ts-estree specific + filePath: 'test/foo', + project: 'tsconfig.json', + useJSXTextNode: false, + errorOnUnknownASTType: false, + errorOnTypeScriptSyntacticAndSemanticIssues: false, + tsconfigRootDir: '../../', + extraFileExtensions: ['foo'] + }); }); it('Syntax should contain a frozen object of typescriptESTree.AST_NODE_TYPES', () => { diff --git a/packages/parser/tests/lib/tsx.ts b/packages/parser/tests/lib/tsx.ts index 0872edf307b0..a18278e80458 100644 --- a/packages/parser/tests/lib/tsx.ts +++ b/packages/parser/tests/lib/tsx.ts @@ -17,7 +17,9 @@ describe('TSX', () => { const code = fs.readFileSync(filename, 'utf8'); const config = { useJSXTextNode: true, - jsx: true + ecmaFeatures: { + jsx: true + } }; it( testUtils.formatSnapshotName(filename, FIXTURES_DIR, '.tsx'), @@ -53,7 +55,9 @@ describe('TSX', () => { const config = { parser: '@typescript-eslint/parser', parserOptions: { - jsx: true + ecmaFeatures: { + jsx: true + } } }; const messages = linter.verify(code, config); @@ -85,7 +89,9 @@ describe('TSX', () => { const config = { parser: '@typescript-eslint/parser', parserOptions: { - jsx: true + ecmaFeatures: { + jsx: true + } } }; const messages = linter.verify(code, config, { filename: 'test.ts' }); @@ -117,7 +123,9 @@ describe('TSX', () => { const config = { parser: '@typescript-eslint/parser', parserOptions: { - jsx: false + ecmaFeatures: { + jsx: false + } } }; const messages = linter.verify(code, config, { filename: 'test.tsx' }); diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index 1a39cfd2f31f..2f6347e0a7a2 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -350,10 +350,7 @@ function generateAST( // Public //------------------------------------------------------------------------------ -export { AST_NODE_TYPES } from './ast-node-types'; -export { version }; - -const version = packageJSON.version; +export const version: string = packageJSON.version; export function parse( code: string, @@ -378,3 +375,6 @@ export function parseAndGenerateServices(code: string, options: ParserOptions) { } }; } + +export { AST_NODE_TYPES } from './ast-node-types'; +export { ParserOptions }; From 2df5e0c039d3a5c558c164f8b748c6e2da447436 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 15:29:46 +0100 Subject: [PATCH 11/88] fix(eslint-plugin): no-unused-vars: mark declared statements as used (#88) --- .../eslint-plugin/lib/rules/no-unused-vars.js | 3 +++ .../tests/lib/rules/no-unused-vars.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/packages/eslint-plugin/lib/rules/no-unused-vars.js b/packages/eslint-plugin/lib/rules/no-unused-vars.js index eef6ddb2310f..ecf62b154002 100644 --- a/packages/eslint-plugin/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/lib/rules/no-unused-vars.js @@ -62,6 +62,9 @@ module.exports = Object.assign({}, baseRule, { }, 'TSEnumMember Identifier'(node) { context.markVariableAsUsed(node.name); + }, + '*[declare=true] Identifier'(node) { + context.markVariableAsUsed(node.name); } }); } diff --git a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js index 8e7a5a8a7892..25410bbf2701 100644 --- a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js @@ -525,6 +525,22 @@ import * as fastify from 'fastify' import { Server, IncomingMessage, ServerResponse } from 'http' const server: fastify.FastifyInstance = fastify({}) server.get('/ping') + `, + // https://github.com/typescript-eslint/typescript-eslint/issues/61 + `declare function foo();`, + // https://github.com/typescript-eslint/typescript-eslint/issues/61 + ` +declare namespace Foo { + function bar(line: string, index: number | null, tabSize: number): number; + var baz: string; +} + `, + // https://github.com/typescript-eslint/typescript-eslint/issues/61 + ` +declare var Foo: { + new (value?: any): Object, + foo(): string +} ` ], From 3f51d51f93a0f3b415394ac3309d3becfdf5009c Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 15:30:11 +0100 Subject: [PATCH 12/88] fix(eslint-plugin): fix crash in rule indent for eslint 5.12.1 (#89) --- packages/eslint-plugin/lib/rules/indent.js | 3 ++- packages/eslint-plugin/lib/rules/no-unused-vars.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/lib/rules/indent.js b/packages/eslint-plugin/lib/rules/indent.js index a8024145a1c4..84144219faff 100644 --- a/packages/eslint-plugin/lib/rules/indent.js +++ b/packages/eslint-plugin/lib/rules/indent.js @@ -101,7 +101,8 @@ module.exports = Object.assign({}, baseRule, { url: util.metaDocsUrl('indent') }, fixable: 'whitespace', - schema: baseRule.meta.schema + schema: baseRule.meta.schema, + messages: baseRule.meta.messages }, create(context) { diff --git a/packages/eslint-plugin/lib/rules/no-unused-vars.js b/packages/eslint-plugin/lib/rules/no-unused-vars.js index ecf62b154002..d7f32f15a5c1 100644 --- a/packages/eslint-plugin/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/lib/rules/no-unused-vars.js @@ -21,7 +21,8 @@ module.exports = Object.assign({}, baseRule, { url: util.metaDocsUrl('no-unused-vars'), recommended: 'warn' }, - schema: baseRule.meta.schema + schema: baseRule.meta.schema, + messages: baseRule.meta.messages }, create(context) { From 7d178a96887742808b1730c6017b2c4081571667 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 20 Jan 2019 10:06:30 -0500 Subject: [PATCH 13/88] build: separate job for integration tests (#93) --- .travis.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6c53fba944cd..c18b22b64cb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,22 +11,28 @@ notifications: node_js: - '11' - '10' - - '9' - '8' - '6' install: - - yarn --ignore-engines + # This also runs a build as part of the postinstall + # bootstrap + - yarn --ignore-engines --frozen-lockfile script: - - commitlint-travis - - yarn check-format # TODO: Fix this check # - yarn workspace eslint-plugin docs:check - - yarn build - yarn test - - yarn integration-tests - yarn global add codecov after_success: - codecov branches: only: - master + +jobs: + include: + - stage: Code and Commit Formatting and Integration Tests + node_js: "11" + script: + - commitlint-travis + - yarn check-format + - yarn integration-tests From 0ddb93c56b3dce1610b8c4d79d20b764d1665bb2 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 20 Jan 2019 10:36:19 -0500 Subject: [PATCH 14/88] feat(eslint-plugin): remove exported parser (#94) --- packages/eslint-plugin/README.md | 27 +++++++-------------------- packages/eslint-plugin/parser.js | 10 ---------- 2 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 packages/eslint-plugin/parser.js diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 6f649ef0ada6..b9366b302b31 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -10,45 +10,32 @@ ## Installation -You'll first need to install [ESLint](http://eslint.org): - -```sh -npm i eslint --save-dev -``` - -Next, install `typescript` if you haven’t already: - -```sh -npm i typescript@~3.1.1 --save-dev -``` - -Last, install `@typescript-eslint/eslint-plugin`: +Make sure you have TypeScript and @typescript-eslint/parser installed, then install the plugin: ```sh npm i @typescript-eslint/eslint-plugin --save-dev ``` +It is important that you use the same version number for `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin`. + **Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `@typescript-eslint/eslint-plugin` globally. ## Usage -Add `@typescript-eslint/eslint-plugin/parser` to the `parser` field and `typescript` to the plugins section of your `.eslintrc` configuration file: +Add `@typescript-eslint/parser` to the `parser` field and `@typescript-eslint` to the plugins section of your `.eslintrc` configuration file: ```json { - "parser": "@typescript-eslint/eslint-plugin/parser", + "parser": "@typescript-eslint/parser", "plugins": ["@typescript-eslint"] } ``` -Note: The plugin provides its own version of the `@typescript-eslint/parser` via `@typescript-eslint/eslint-plugin/parser`. -This helps us guarantee 100% compatibility between the plugin and the parser. - Then configure the rules you want to use under the rules section. ```json { - "parser": "@typescript-eslint/eslint-plugin/parser", + "parser": "@typescript-eslint/parser", "plugins": ["@typescript-eslint"], "rules": { "@typescript-eslint/rule-name": "error" @@ -56,7 +43,7 @@ Then configure the rules you want to use under the rules section. } ``` -You can also enable all the recommended rules at once. Add `plugin:typescript/recommended` in extends: +You can also enable all the recommended rules at once. Add `plugin:@typescript-eslint/recommended` in extends: ```json { diff --git a/packages/eslint-plugin/parser.js b/packages/eslint-plugin/parser.js deleted file mode 100644 index 44041c4bf2c8..000000000000 --- a/packages/eslint-plugin/parser.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @fileoverview Internal parser - * @author Patricio Trevino - */ - -'use strict'; - -// export the @typescript-eslint/parser. -// this forces the parser to be a direct dependency of the plugin. -module.exports = require('@typescript-eslint/parser'); From f0e4d1d26542944b4ff6c5ccf8b8a4cc1572b38b Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 20 Jan 2019 10:59:15 -0500 Subject: [PATCH 15/88] docs: some fixes and consistency (#95) --- packages/eslint-plugin-tslint/README.md | 6 ++-- packages/parser/README.md | 43 ++----------------------- 2 files changed, 6 insertions(+), 43 deletions(-) diff --git a/packages/eslint-plugin-tslint/README.md b/packages/eslint-plugin-tslint/README.md index 8ecccbd1001a..7a1cdf297aa4 100644 --- a/packages/eslint-plugin-tslint/README.md +++ b/packages/eslint-plugin-tslint/README.md @@ -23,10 +23,10 @@ Configure in your eslint config file: ```js { "plugins": [ - "tslint" + "@typescript-eslint/tslint" ], "rules": { - "tslint/config": ["warn", { + "@typescript-eslint/tslint/config": ["warn", { "lintFile": '', // path to tslint.json of your project "rules": { // tslint rules (will be used if `lintFile` is not specified) @@ -41,7 +41,7 @@ Configure in your eslint config file: ## Rules -Plugin contains only single rule `tslint/config`. +Plugin contains only single rule `@typescript-eslint/tslint/config`. ## Examples diff --git a/packages/parser/README.md b/packages/parser/README.md index 3a18f79735e6..77359a790f34 100644 --- a/packages/parser/README.md +++ b/packages/parser/README.md @@ -34,7 +34,7 @@ The core rules built into ESLint, such as `indent` have no knowledge of such con Instead, you also need to make use of one more plugins which will add or extend rules with TypeScript-specific features. -By far the most common case will be installing the [@typescript-eslint/eslint-plugin](https://github.com/nzakas/@typescript-eslint/eslint-plugin) plugin, but there are also other relevant options available such a [@typescript-eslint/eslint-plugin-tslint](https://github.com/JamesHenry/@typescript-eslint/eslint-plugin-tslint). +By far the most common case will be installing the [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin) plugin, but there are also other relevant options available such a [@typescript-eslint/eslint-plugin-tslint](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin-tslint). ## Configuration @@ -64,50 +64,13 @@ The following additional configuration options are available by specifying them ## Supported TypeScript Version -We will always endeavor to support the latest stable version of TypeScript. - -The version of TypeScript currently supported by this parser is `~3.2.1`. This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript. - -If you use a non-supported version of TypeScript, the parser will log a warning to the console. +Please see https://github.com/typescript-eslint/typescript-eslint for the supported TypeScript version. **Please ensure that you are using a supported version before submitting any issues/bug reports.** ## Reporting Issues -Please check the current list of open and known issues and ensure the issue has not been reported before. When creating a new issue provide as much information about your environment as possible. This includes: - -- ESLint Version -- TypeScript version -- The `@typescript-eslint/parser` version -- ESLint config or rules and plugins currently enabled - -## Integration Tests - -We have a very flexible way of running integration tests which connects all of the moving parts of the usage of this parser in the ESLint ecosystem. - -We run each test within its own docker container, and so each one has complete autonomy over what dependencies/plugins are installed and what versions are used. This also has the benefit of not bloating the `package.json` and `node_modules` of the parser project itself. - -> If you are going to submit an issue related to the usage of this parser with ESLint, please consider creating a failing integration test which clearly demonstrates the behavior. It's honestly super quick! - -You just need to duplicate one of the existing test sub-directories found in `tests/integration/`, tweak the dependencies and ESLint config to match what you need, and add a new entry to the docker-compose.yml file which matches the format of the existing ones. - -Then run: - -```sh -npm run integration-tests -``` - -If you ever need to change what gets installed when the docker images are built by docker-compose, you will first need to kill the existing containers by running: - -```sh -npm run kill-integration-test-containers -``` - -## Build Commands - -- `npm test` - run all linting and tests -- `npm run lint` - run all linting -- `npm run integration-tests` - run only integration tests +Please use the @typescript-eslint/parser issue template when creating your issue and fill out the information requested as best you can. This will really help us when looking into your issue. ## License From c51d4e0ffd7497d285b48cc271b3be6edcac6ecb Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 20 Jan 2019 15:28:48 -0500 Subject: [PATCH 16/88] chore: versions on issue templates --- .../ISSUE_TEMPLATE/eslint-plugin-tslint.md | 23 +++++++++---------- .../eslint-plugin-typescript.md | 5 +++- .../typescript-eslint-parser.md | 21 ++++++++--------- .github/ISSUE_TEMPLATE/typescript-estree.md | 13 +++++++---- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md b/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md index d78e999d908e..313c1880a1ab 100644 --- a/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md +++ b/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md @@ -6,18 +6,6 @@ labels: 'package: @typescript-eslint/eslint-plugin-tslint, triage' assignees: '' --- -**What version of Node.js and npm are you using?** - -- Node: -- npm: - -**What version of the following packages are you using?** - -- @typescript-eslint/eslint-plugin-tslint: -- @typescript-eslint/parser: -- TypeScript: -- ESLint: - **What code were you trying to parse?** ```ts @@ -27,3 +15,14 @@ assignees: '' **What did you expect to happen?** **What actually happened?** + +**Versions** + +| package | version | +| ----------------------------------------- | ------- | +| `@typescript-eslint/eslint-plugin-tslint` | `X.Y.Z` | +| `@typescript-eslint/parser` | `X.Y.Z` | +| `TypeScript` | `X.Y.Z` | +| `ESLint` | `X.Y.Z` | +| `node` | `X.Y.Z` | +| `npm` | `X.Y.Z` | diff --git a/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md b/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md index b7566c0069ca..ddae219da635 100644 --- a/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md +++ b/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md @@ -42,4 +42,7 @@ Please try to avoid code that isn't directly related to the bug, as it makes it | ---------------------------------- | ------- | | `@typescript-eslint/eslint-plugin` | `X.Y.Z` | | `@typescript-eslint/parser` | `X.Y.Z` | -| `typescript` | `X.Y.Z` | +| `TypeScript` | `X.Y.Z` | +| `ESLint` | `X.Y.Z` | +| `node` | `X.Y.Z` | +| `npm` | `X.Y.Z` | diff --git a/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md b/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md index 601087f77e82..f0cfe5a1e158 100644 --- a/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md +++ b/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md @@ -6,17 +6,6 @@ labels: 'package: parser, triage' assignees: '' --- -**What version of Node.js and npm are you using?** - -- Node: -- npm: - -**What version of the following packages are you using?** - -- @typescript-eslint/parser: -- TypeScript: -- ESLint: - **What code were you trying to parse?** ```ts @@ -26,3 +15,13 @@ assignees: '' **What did you expect to happen?** **What actually happened?** + +**Versions** + +| package | version | +| --------------------------- | ------- | +| `@typescript-eslint/parser` | `X.Y.Z` | +| `TypeScript` | `X.Y.Z` | +| `ESLint` | `X.Y.Z` | +| `node` | `X.Y.Z` | +| `npm` | `X.Y.Z` | diff --git a/.github/ISSUE_TEMPLATE/typescript-estree.md b/.github/ISSUE_TEMPLATE/typescript-estree.md index f6b12ebafe9e..fc8cca3d9a39 100644 --- a/.github/ISSUE_TEMPLATE/typescript-estree.md +++ b/.github/ISSUE_TEMPLATE/typescript-estree.md @@ -6,10 +6,6 @@ labels: 'package: typescript-estree, triage' assignees: '' --- -**What version of TypeScript are you using?** - -**What version of `@typescript-eslint/typescript-estree` are you using?** - **What code were you trying to parse?** ```ts @@ -19,3 +15,12 @@ assignees: '' **What did you expect to happen?** **What actually happened?** + +**Versions** + +| package | version | +| -------------------------------------- | ------- | +| `@typescript-eslint/typescript-estree` | `X.Y.Z` | +| `TypeScript` | `X.Y.Z` | +| `node` | `X.Y.Z` | +| `npm` | `X.Y.Z` | From 055c3fcddb86189aae7056e51a10cd774156cabb Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 20 Jan 2019 17:46:20 -0500 Subject: [PATCH 17/88] fix(eslint-plugin): update remaining parser refs (#97) --- packages/eslint-plugin/lib/configs/recommended.json | 2 +- packages/eslint-plugin/lib/util.js | 5 +---- packages/eslint-plugin/tools/update-recommended.js | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/eslint-plugin/lib/configs/recommended.json b/packages/eslint-plugin/lib/configs/recommended.json index 77b6e55d31c9..cd21778bfff1 100644 --- a/packages/eslint-plugin/lib/configs/recommended.json +++ b/packages/eslint-plugin/lib/configs/recommended.json @@ -1,5 +1,5 @@ { - "parser": "@typescript-eslint/eslint-plugin/parser", + "parser": "@typescript-eslint/parser", "parserOptions": { "sourceType": "module" }, diff --git a/packages/eslint-plugin/lib/util.js b/packages/eslint-plugin/lib/util.js index 66c6312ea14d..1df02bfb9e8e 100644 --- a/packages/eslint-plugin/lib/util.js +++ b/packages/eslint-plugin/lib/util.js @@ -117,11 +117,8 @@ exports.getParserServices = context => { !context.parserServices.program || !context.parserServices.esTreeNodeToTSNodeMap ) { - // TODO - the message will require revisiting once the @typescript-eslint/parser work finalises - // their work around exposing the parser. They may require that there be a project config field in - // the eslint config, in which case we should check and/or report that here appropriately. throw new Error( - 'This rule requires you to use `@typescript-eslint/eslint-plugin/parser`.' + 'This rule requires you to use `@typescript-eslint/parser`.' ); } return context.parserServices; diff --git a/packages/eslint-plugin/tools/update-recommended.js b/packages/eslint-plugin/tools/update-recommended.js index 73b9571eddbe..ce402c3933be 100644 --- a/packages/eslint-plugin/tools/update-recommended.js +++ b/packages/eslint-plugin/tools/update-recommended.js @@ -49,7 +49,7 @@ function generate() { const filePath = path.resolve(__dirname, '../lib/configs/recommended.json'); const recommendedConfig = { - parser: '@typescript-eslint/eslint-plugin/parser', + parser: '@typescript-eslint/parser', parserOptions: { sourceType: 'module' }, From af460d4ad0c4646ed2c6e1de25629c4a2e8fd0f8 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 20 Jan 2019 17:49:02 -0500 Subject: [PATCH 18/88] chore: publish v1.0.0 --- CHANGELOG.md | 13 +++++++++++++ lerna.json | 2 +- packages/eslint-plugin-tslint/CHANGELOG.md | 4 ++++ packages/eslint-plugin-tslint/package.json | 4 ++-- packages/eslint-plugin/CHANGELOG.md | 12 ++++++++++++ packages/eslint-plugin/package.json | 4 ++-- packages/parser/CHANGELOG.md | 6 ++++++ packages/parser/package.json | 6 +++--- packages/shared-fixtures/CHANGELOG.md | 8 ++++++++ packages/shared-fixtures/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 6 ++++++ packages/typescript-estree/package.json | 4 ++-- 12 files changed, 60 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0706cb69e05..c87104215644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) + +### Bug Fixes + +- **eslint-plugin:** fix crash in rule indent for eslint 5.12.1 ([#89](https://github.com/typescript-eslint/typescript-eslint/issues/89)) ([3f51d51](https://github.com/typescript-eslint/typescript-eslint/commit/3f51d51)) +- **eslint-plugin:** no-unused-vars: mark declared statements as used ([#88](https://github.com/typescript-eslint/typescript-eslint/issues/88)) ([2df5e0c](https://github.com/typescript-eslint/typescript-eslint/commit/2df5e0c)) +- **eslint-plugin:** update remaining parser refs ([#97](https://github.com/typescript-eslint/typescript-eslint/issues/97)) ([055c3fc](https://github.com/typescript-eslint/typescript-eslint/commit/055c3fc)) + +### Features + +- **eslint-plugin:** remove exported parser ([#94](https://github.com/typescript-eslint/typescript-eslint/issues/94)) ([0ddb93c](https://github.com/typescript-eslint/typescript-eslint/commit/0ddb93c)) +- **parser:** support ecmaFeatures.jsx flag and tests ([#85](https://github.com/typescript-eslint/typescript-eslint/issues/85)) ([b321736](https://github.com/typescript-eslint/typescript-eslint/commit/b321736)) + ## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/typescript-eslint diff --git a/lerna.json b/lerna.json index d51f69375e6d..c416cf72769b 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.2.1", + "version": "1.0.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index 241c8cd24624..a95c7b88cb36 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + ## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index e6f13409db21..9c0668115ecc 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "0.2.1", + "version": "1.0.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -33,6 +33,6 @@ "devDependencies": { "@types/eslint": "^4.16.3", "@types/lodash.memoize": "^4.1.4", - "@typescript-eslint/parser": "0.2.1" + "@typescript-eslint/parser": "1.0.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index d0f9e7a9b350..188e6b07bec3 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) + +### Bug Fixes + +- **eslint-plugin:** fix crash in rule indent for eslint 5.12.1 ([#89](https://github.com/typescript-eslint/typescript-eslint/issues/89)) ([3f51d51](https://github.com/typescript-eslint/typescript-eslint/commit/3f51d51)) +- **eslint-plugin:** no-unused-vars: mark declared statements as used ([#88](https://github.com/typescript-eslint/typescript-eslint/issues/88)) ([2df5e0c](https://github.com/typescript-eslint/typescript-eslint/commit/2df5e0c)) +- **eslint-plugin:** update remaining parser refs ([#97](https://github.com/typescript-eslint/typescript-eslint/issues/97)) ([055c3fc](https://github.com/typescript-eslint/typescript-eslint/commit/055c3fc)) + +### Features + +- **eslint-plugin:** remove exported parser ([#94](https://github.com/typescript-eslint/typescript-eslint/issues/94)) ([0ddb93c](https://github.com/typescript-eslint/typescript-eslint/commit/0ddb93c)) + ## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/eslint-plugin diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index a8f81d0eab0b..34d125380e4c 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "0.2.1", + "version": "1.0.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -24,7 +24,7 @@ "recommended:update": "node tools/update-recommended.js" }, "dependencies": { - "@typescript-eslint/parser": "0.2.1", + "@typescript-eslint/parser": "1.0.0", "requireindex": "^1.2.0" }, "devDependencies": { diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index eec382e512e0..1e519885b94a 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) + +### Features + +- **parser:** support ecmaFeatures.jsx flag and tests ([#85](https://github.com/typescript-eslint/typescript-eslint/issues/85)) ([b321736](https://github.com/typescript-eslint/typescript-eslint/commit/b321736)) + ## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index b4271605c7b9..be34576e324c 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "0.2.1", + "version": "1.0.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/parser.js", "files": [ @@ -36,7 +36,7 @@ "typescript": "*" }, "dependencies": { - "@typescript-eslint/typescript-estree": "0.2.1", + "@typescript-eslint/typescript-estree": "1.0.0", "eslint-scope": "^4.0.0", "eslint-visitor-keys": "^1.0.0" }, @@ -44,6 +44,6 @@ "@types/eslint": "^4.16.5", "@types/eslint-visitor-keys": "^1.0.0", "@types/estree": "^0.0.39", - "@typescript-eslint/shared-fixtures": "0.2.1" + "@typescript-eslint/shared-fixtures": "1.0.0" } } diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index aebf69abe3ec..2b7402f262e4 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + + + + + ## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index fe6193c18596..4478df0606e9 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "0.2.1", + "version": "1.0.0", "private": true } diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index 2ee862165041..39323d365fd7 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) + +### Features + +- **parser:** support ecmaFeatures.jsx flag and tests ([#85](https://github.com/typescript-eslint/typescript-eslint/issues/85)) ([b321736](https://github.com/typescript-eslint/typescript-eslint/commit/b321736)) + ## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/typescript-estree diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 770cf0a1da51..10d0639be1f4 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "0.2.1", + "version": "1.0.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/parser.js", "files": [ @@ -41,7 +41,7 @@ "typescript": "*" }, "devDependencies": { - "@typescript-eslint/shared-fixtures": "0.2.1", + "@typescript-eslint/shared-fixtures": "1.0.0", "typescript": "~3.2.1" } } From 09f67ffac728cb90242833b6ac96a22a996ec286 Mon Sep 17 00:00:00 2001 From: "azure-pipelines[bot]" Date: Sun, 20 Jan 2019 20:05:01 -0500 Subject: [PATCH 19/88] chore: set up CI with Azure Pipelines (#98) --- .travis.yml | 38 --------------------------- azure-pipelines.yml | 62 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 38 deletions(-) delete mode 100644 .travis.yml create mode 100644 azure-pipelines.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c18b22b64cb0..000000000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -sudo: required -services: - - docker -language: node_js -cache: - yarn: true - directories: - - node_modules -notifications: - email: false -node_js: - - '11' - - '10' - - '8' - - '6' -install: - # This also runs a build as part of the postinstall - # bootstrap - - yarn --ignore-engines --frozen-lockfile -script: - # TODO: Fix this check - # - yarn workspace eslint-plugin docs:check - - yarn test - - yarn global add codecov -after_success: - - codecov -branches: - only: - - master - -jobs: - include: - - stage: Code and Commit Formatting and Integration Tests - node_js: "11" - script: - - commitlint-travis - - yarn check-format - - yarn integration-tests diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000000..63512b1f85ad --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,62 @@ +trigger: + - master + +jobs: + - job: primary_code_validation_and_tests + displayName: Primary code validation and tests + pool: + vmImage: 'Ubuntu-16.04' + steps: + - task: NodeTool@0 + inputs: + versionSpec: 11 + displayName: 'Install Node.js 11' + + - script: | + # This also runs a build as part of the postinstall + # bootstrap + yarn --ignore-engines --frozen-lockfile + + - script: | + yarn check-format + displayName: 'Check code formatting' + + - script: | + yarn test + displayName: 'Run unit tests' + + - script: | + yarn integration-tests + displayName: 'Run integrations tests' + + - script: | + npx codecov -t $(CODECOV_TOKEN) + displayName: 'Publish code coverage report' + + - job: unit_tests_on_other_node_versions + displayName: Run unit tests on other Node.js versions + pool: + vmImage: 'Ubuntu-16.04' + strategy: + maxParallel: 3 + matrix: + node_10_x: + node_version: 10.x + node_8_x: + node_version: 8.x + node_6_x: + node_version: 6.x + steps: + - task: NodeTool@0 + inputs: + versionSpec: $(node_version) + displayName: 'Install Node.js $(node_version)' + + - script: | + # This also runs a build as part of the postinstall + # bootstrap + yarn --ignore-engines --frozen-lockfile + + - script: | + yarn test + displayName: 'Run unit tests' From 378fbe59ed1126532420c0a65b0d2f5e93410a1d Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 21 Jan 2019 04:21:43 +0100 Subject: [PATCH 20/88] build: enable eslint checks for ci builds (#67) --- .eslintignore | 8 +++ .eslintrc.json | 68 +++++++++++++++++++ README.md | 2 +- azure-pipelines.yml | 4 ++ package.json | 4 ++ packages/eslint-plugin-tslint/README.md | 2 +- packages/eslint-plugin/README.md | 2 +- packages/parser/README.md | 2 +- packages/typescript-estree/README.md | 2 +- .../tests/ast-alignment/utils.ts | 2 +- yarn.lock | 10 +++ 11 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000000..58fa04212589 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,8 @@ +node_modules +dist +jest.config.js +fixtures +coverage + +packages/typescript-estree/src/estree +packages/eslint-plugin-tslint/tests diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000000..6c87aaec59ad --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,68 @@ +{ + "root": true, + "plugins": ["eslint-plugin", "@typescript-eslint", "jest"], + "env": { + "es6": true, + "node": true + }, + "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], + "rules": { + "no-mixed-operators": "error", + "no-console": "off", + "no-undef": "off", + "@typescript-eslint/indent": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/explicit-member-accessibility": "off", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-use-before-define": "off", + "@typescript-eslint/no-object-literal-type-assertion": "off", + "@typescript-eslint/no-parameter-properties": "off" + }, + "parserOptions": { + "sourceType": "module", + "ecmaFeatures": { + "jsx": false + } + }, + "overrides": [ + { + "files": [ + "packages/eslint-plugin-tslint/**/*.ts", + "packages/eslint-plugin-typescript/**/*.js", + "packages/typescript-eslint-parser/**/*.ts", + "packages/typescript-estree/**/*.ts" + ], + "env": { + "jest/globals": true + }, + "rules": { + "jest/no-disabled-tests": "warn", + "jest/no-focused-tests": "error", + "jest/no-identical-title": "error", + "jest/prefer-to-have-length": "warn", + "jest/valid-expect": "error" + } + }, + { + "files": ["packages/eslint-plugin-typescript/**/*.js"], + "rules": { + "eslint-plugin/fixer-return": "error", + "eslint-plugin/no-identical-tests": "error", + "eslint-plugin/no-missing-placeholders": "error", + "eslint-plugin/no-unused-placeholders": "error", + "eslint-plugin/no-useless-token-range": "error", + "eslint-plugin/require-meta-fixable": "error", + "eslint-plugin/prefer-placeholders": "error", + "eslint-plugin/prefer-replace-text": "error", + "eslint-plugin/no-deprecated-report-api": "error", + "eslint-plugin/report-message-format": ["error", "^[A-Z'{].*[\\.}]$"], + "eslint-plugin/no-deprecated-context-methods": "error", + "eslint-plugin/prefer-output-null": "error", + "eslint-plugin/test-case-shorthand-strings": "error", + "eslint-plugin/require-meta-type": "error" + } + } + ] +} diff --git a/README.md b/README.md index 2d6dda93ecb3..de2fdd5da6ae 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

Monorepo for all the tooling which enables ESLint to support TypeScript

- Travis + Azure Pipelines GitHub license NPM Downloads Codecov diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 63512b1f85ad..a34eaea0062d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,6 +21,10 @@ jobs: yarn check-format displayName: 'Check code formatting' + - script: | + yarn lint + displayName: 'Run linting' + - script: | yarn test displayName: 'Run unit tests' diff --git a/package.json b/package.json index 5cb4261cb79a..ed6bbf422c9e 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,8 @@ "build": "lerna run build", "clean": "lerna clean && lerna run clean", "precommit": "yarn test && lint-staged", + "lint": "eslint . --ext .js,.ts", + "lint-fix": "eslint . --ext .js,.ts --fix", "cz": "git-cz", "commitmsg": "commitlint -E GIT_PARAMS", "check-format": "prettier --list-different \"./**/*.{ts,js,json,md}\"", @@ -63,6 +65,8 @@ "@types/semver": "^5.5.0", "cz-conventional-changelog": "2.1.0", "eslint": "^5.12.1", + "eslint-plugin-jest": "^22.1.3", + "eslint-plugin-eslint-plugin": "^2.0.1", "glob": "7.1.2", "husky": "0.14.3", "jest": "23.6.0", diff --git a/packages/eslint-plugin-tslint/README.md b/packages/eslint-plugin-tslint/README.md index 7a1cdf297aa4..7eed5033dfbb 100644 --- a/packages/eslint-plugin-tslint/README.md +++ b/packages/eslint-plugin-tslint/README.md @@ -3,7 +3,7 @@

ESLint plugin wraps a TSLint configuration and lints the whole source using TSLint.

- Travis + Azure Pipelines GitHub license NPM Version NPM Downloads diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index b9366b302b31..ec96819a455f 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -1,7 +1,7 @@

ESLint Plugin TypeScript

- Travis + Azure Pipelines GitHub license NPM Version NPM Downloads diff --git a/packages/parser/README.md b/packages/parser/README.md index 77359a790f34..f348ae4617dc 100644 --- a/packages/parser/README.md +++ b/packages/parser/README.md @@ -3,7 +3,7 @@

An ESLint custom parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.

- Travis + Azure Pipelines GitHub license NPM Version NPM Downloads diff --git a/packages/typescript-estree/README.md b/packages/typescript-estree/README.md index 910002f4fae0..6769f0fca20b 100644 --- a/packages/typescript-estree/README.md +++ b/packages/typescript-estree/README.md @@ -3,7 +3,7 @@

A parser that converts TypeScript source code into an ESTree-compatible form

- Travis + Azure Pipelines GitHub license NPM Version NPM Downloads diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index 77336ee7b5f4..ee0a2b7d72f9 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -236,7 +236,7 @@ export function preprocessBabylonAST(ast: any): any { * Babel: ClassProperty + abstract: true * ts-estree: TSAbstractClassProperty */ - ClassProperty(node: any, parent: any) { + ClassProperty(node: any) { if (node.abstract) { node.type = 'TSAbstractClassProperty'; delete node.abstract; diff --git a/yarn.lock b/yarn.lock index c2cc9db7f6a2..a80ac0413712 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2333,6 +2333,16 @@ eslint-docs@^0.2.6: ora "^3.0.0" read-pkg-up "^4.0.0" +eslint-plugin-eslint-plugin@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-plugin/-/eslint-plugin-eslint-plugin-2.0.1.tgz#d275434969dbde3da1d4cb7a121dc8d88457c786" + integrity sha512-kJ5TZsRJH/xYstG07v3YeOy/W5SDAEzV+bvvoL0aiG1HtqDmg4mJvNPnn/JngANMmsx8oXlJrIcBTCpJzm+9kg== + +eslint-plugin-jest@^22.1.3: + version "22.1.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.1.3.tgz#4444108dfcddc5d2117ed6dc551f529d7e73a99e" + integrity sha512-JTZTI6WQoNruAugNyCO8fXfTONVcDd5i6dMRFA5g3rUFn1UDDLILY1bTL6alvNXbW2U7Sc2OSpi8m08pInnq0A== + eslint-scope@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.0.tgz#50bf3071e9338bcdc43331794a0cb533f0136172" From 193b434e5adc442ac4876f5aa8eda6d001cc72b6 Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 21 Jan 2019 15:12:06 +0100 Subject: [PATCH 21/88] fix(eslint-plugin): improve detection of used vars in heritage (#102) --- .../eslint-plugin/lib/rules/no-unused-vars.js | 30 ++++++++- .../tests/lib/rules/no-unused-vars.js | 65 +++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/lib/rules/no-unused-vars.js b/packages/eslint-plugin/lib/rules/no-unused-vars.js index d7f32f15a5c1..bb09d6abd271 100644 --- a/packages/eslint-plugin/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/lib/rules/no-unused-vars.js @@ -45,6 +45,25 @@ module.exports = Object.assign({}, baseRule, { } } + /** + * Mark heritage clause as used + * @param node The node currently being traversed + * @returns {void} + */ + function markHeritageAsUsed(node) { + switch (node.type) { + case 'Identifier': + context.markVariableAsUsed(node.name); + break; + case 'MemberExpression': + markHeritageAsUsed(node.object); + break; + case 'CallExpression': + markHeritageAsUsed(node.callee); + break; + } + } + //---------------------------------------------------------------------- // Public //---------------------------------------------------------------------- @@ -54,8 +73,15 @@ module.exports = Object.assign({}, baseRule, { 'TSTypeReference Identifier'(node) { context.markVariableAsUsed(node.name); }, - 'TSClassImplements Identifier'(node) { - context.markVariableAsUsed(node.name); + TSInterfaceHeritage(node) { + if (node.expression) { + markHeritageAsUsed(node.expression); + } + }, + TSClassImplements(node) { + if (node.expression) { + markHeritageAsUsed(node.expression); + } }, 'TSParameterProperty Identifier'(node) { // just assume parameter properties are used diff --git a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js index 25410bbf2701..c197adff8ee1 100644 --- a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js @@ -541,6 +541,15 @@ declare var Foo: { new (value?: any): Object, foo(): string } + `, + ` +import foo from 'foo'; +export interface Bar extends foo.i18n {} + `, + ` +import foo from 'foo'; +import bar from 'foo'; +export interface Bar extends foo.i18n {} ` ], @@ -763,6 +772,62 @@ enum FormFieldIds { column: 6 } ] + }, + { + code: ` +import test from 'test'; +import baz from 'baz'; +export interface Bar extends baz.test {} + `, + errors: [ + { + message: "'test' is defined but never used.", + line: 2, + column: 8 + } + ] + }, + { + code: ` +import test from 'test'; +import baz from 'baz'; +export interface Bar extends baz().test {} + `, + errors: [ + { + message: "'test' is defined but never used.", + line: 2, + column: 8 + } + ] + }, + { + code: ` +import test from 'test'; +import baz from 'baz'; +export class Bar implements baz.test {} + `, + errors: [ + { + message: "'test' is defined but never used.", + line: 2, + column: 8 + } + ] + }, + { + code: ` +import test from 'test'; +import baz from 'baz'; +export class Bar implements baz().test {} + `, + errors: [ + { + message: "'test' is defined but never used.", + line: 2, + column: 8 + } + ] } ] }); From d12b63460d067ead3d9afa9d4f74dcada4b91196 Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 21 Jan 2019 10:20:30 -0500 Subject: [PATCH 22/88] chore: fix package names (#105) --- .eslintrc.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 6c87aaec59ad..f44790c843c8 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -30,8 +30,8 @@ { "files": [ "packages/eslint-plugin-tslint/**/*.ts", - "packages/eslint-plugin-typescript/**/*.js", - "packages/typescript-eslint-parser/**/*.ts", + "packages/eslint-plugin/**/*.js", + "packages/parser/**/*.ts", "packages/typescript-estree/**/*.ts" ], "env": { @@ -46,7 +46,7 @@ } }, { - "files": ["packages/eslint-plugin-typescript/**/*.js"], + "files": ["packages/eslint-plugin/**/*.js"], "rules": { "eslint-plugin/fixer-return": "error", "eslint-plugin/no-identical-tests": "error", From 34fbe628a78ece28eac75ef1c665de4c99505add Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 21 Jan 2019 18:41:14 -0500 Subject: [PATCH 23/88] test(typescript-estree): enable more alignment tests (#114) --- package.json | 2 +- .../typescript-estree/src/semantic-errors.ts | 1 + .../tests/ast-alignment/fixtures-to-test.ts | 69 +++---------------- .../semantic-diagnostics-enabled.ts.snap | 18 ++++- yarn.lock | 8 +-- 5 files changed, 31 insertions(+), 67 deletions(-) diff --git a/package.json b/package.json index ed6bbf422c9e..c7a27e9a643d 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ }, "devDependencies": { "@babel/code-frame": "7.0.0", - "@babel/parser": "7.2.3", + "@babel/parser": "7.3.0", "@commitlint/cli": "^7.1.2", "@commitlint/config-conventional": "^7.1.2", "@commitlint/travis-cli": "^7.1.2", diff --git a/packages/typescript-estree/src/semantic-errors.ts b/packages/typescript-estree/src/semantic-errors.ts index 22e8210ba55d..169031947d3f 100644 --- a/packages/typescript-estree/src/semantic-errors.ts +++ b/packages/typescript-estree/src/semantic-errors.ts @@ -54,6 +54,7 @@ function whitelistSupportedDiagnostics( ): ReadonlyArray { return diagnostics.filter(diagnostic => { switch (diagnostic.code) { + case 1013: // ts 3.2 "A rest parameter or binding pattern may not have a trailing comma." case 1014: // ts 3.2 "A rest parameter must be last in a parameter list." case 1044: // ts 3.2 "'{0}' modifier cannot appear on a module or namespace element." case 1045: // ts 3.2 "A '{0}' modifier cannot be used with an interface declaration." 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 178b86573537..2e478b0fb1b1 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -147,14 +147,7 @@ tester.addFixturePatternConfig('javascript/simple-literals'); tester.addFixturePatternConfig('javascript/directives'); -tester.addFixturePatternConfig('javascript/experimentalObjectRestSpread', { - ignore: [ - /** - * Trailing comma is not permitted after a "RestElement" in Babel - */ - 'invalid-rest-trailing-comma' - ] -}); +tester.addFixturePatternConfig('javascript/experimentalObjectRestSpread'); tester.addFixturePatternConfig('javascript/arrowFunctions', { ignore: [ @@ -330,16 +323,6 @@ tester.addFixturePatternConfig('typescript/basics', { * TODO: Investigate in more depth, potentially split up different parts of the interface */ 'interface-with-all-property-types', // babel parse errors - /** - * PR for generic ArrowFunctionExpression ranges has been merged into Babel: https://github.com/babel/babel/pull/9295 - * TODO: remove me in next babel > 7.2.3 - */ - 'arrow-function-with-type-parameters', - /** - * PR for this type predicate ranges has been merged into Babel: https://github.com/babel/babel/pull/9339 - * TODO: remove me in next babel > 7.2.3 - */ - 'type-guard-in-method', /** * there is difference in range between babel and ts-estree */ @@ -351,11 +334,6 @@ tester.addFixturePatternConfig('typescript/basics', { * TODO: report it to babel */ 'interface-with-extends-member-expression', - /** - * PR for parsing exported abstract interface has been merged into Babel: https://github.com/babel/babel/pull/9336 - * TODO: remove me in next babel > 7.2.3 - */ - 'abstract-interface', /** * Babel bug for optional or abstract methods * https://github.com/babel/babel/issues/9305 @@ -364,46 +342,32 @@ tester.addFixturePatternConfig('typescript/basics', { 'abstract-class-with-optional-method', // babel parse errors 'declare-class-with-optional-method', // babel parse errors /** - * PR for parameter property ranges has been merged into Babel: https://github.com/babel/babel/pull/9284 - * TODO: remove me in next babel > 7.2.3 + * Was expected to be fixed by PR into Babel: https://github.com/babel/babel/pull/9284 + * But not fixed in Babel 7.3 + * TODO: Investigate differences */ 'class-with-private-parameter-properties', 'class-with-protected-parameter-properties', 'class-with-public-parameter-properties', 'class-with-readonly-parameter-properties', /** - * PR for type import has been merged into Babel: https://github.com/babel/babel/pull/9302 - * TODO: remove me in next babel > 7.2.3 + * Was expected to be fixed by PR into Babel: https://github.com/babel/babel/pull/9302 + * But not fixed in Babel 7.3 + * TODO: Investigate differences */ 'import-type', 'import-type-with-type-parameters-in-type-reference', - /** - * PR for BigInt support has been merged into Babel: https://github.com/babel/babel/pull/9230 - * TODO: remove me in next babel > 7.2.3 - */ - 'typed-keyword-bigint', /** * Not yet supported in Babel https://github.com/babel/babel/issues/9228 * Directive field is not added to module and namespace */ 'directive-in-module', 'directive-in-namespace', - /** - * PR for type assertions ranges has been merged into Babel: https://github.com/babel/babel/pull/9284 - * TODO: remove me in next babel > 7.2.3 - */ - 'type-assertion', /** * Babel parses this incorrectly * https://github.com/babel/babel/issues/9324 */ - 'type-assertion-arrow-function', - /** - * PR for type parsing declare and abstract classes has been merged into Babel: https://github.com/babel/babel/pull/9328 - * TODO: remove me in next babel > 7.2.3 - */ - 'class-multi-line-keyword-declare', - 'class-multi-line-keyword-abstract' + 'type-assertion-arrow-function' ], ignoreSourceType: [ /** @@ -443,27 +407,12 @@ tester.addFixturePatternConfig('typescript/expressions', { }); tester.addFixturePatternConfig('typescript/errorRecovery', { - fileType: 'ts', - ignore: [ - /** - * PR with errors in empty extends and implements has been merged into Babel: https://github.com/babel/babel/pull/9292 - * TODO: remove me in next babel > 7.2.3 - */ - 'interface-empty-extends', - 'class-extends-empty-implements' - ] + fileType: 'ts' }); tester.addFixturePatternConfig('typescript/types', { fileType: 'ts', ignore: [ - /** - * PR for type Identifier in TSIndexSignature ranges has been merged into Babel: https://github.com/babel/babel/pull/9335 - * TODO: remove me in next babel > 7.2.3 - */ - 'index-signature', - 'index-signature-readonly', - 'index-signature-without-type', /** * AST difference */ diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index 3407f292ace2..dfd7dbf783d0 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -560,7 +560,14 @@ Object { } `; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/destructuring-and-spread/invalid-not-final-array-empty.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/destructuring-and-spread/invalid-not-final-array-empty.src 1`] = ` +Object { + "column": 5, + "index": 5, + "lineNumber": 1, + "message": "A rest parameter or binding pattern may not have a trailing comma.", +} +`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/destructuring-and-spread/multi-destructured.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -622,7 +629,14 @@ Object { } `; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/experimentalObjectRestSpread/invalid-rest-trailing-comma.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/experimentalObjectRestSpread/invalid-rest-trailing-comma.src 1`] = ` +Object { + "column": 16, + "index": 16, + "lineNumber": 1, + "message": "A rest parameter or binding pattern may not have a trailing comma.", +} +`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/experimentalObjectRestSpread/object-rest.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; diff --git a/yarn.lock b/yarn.lock index a80ac0413712..e2d917cdc557 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18,10 +18,10 @@ esutils "^2.0.2" js-tokens "^4.0.0" -"@babel/parser@7.2.3": - version "7.2.3" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.2.3.tgz#32f5df65744b70888d17872ec106b02434ba1489" - integrity sha512-0LyEcVlfCoFmci8mXx8A5oIkpkOgyo8dRHtxBnK9RRBwxO2+JZPNsqtVEZQ7mJFPxnXF9lfmU24mHOPI0qnlkA== +"@babel/parser@7.3.0": + version "7.3.0" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.3.0.tgz#930251fe6714df47ce540a919ccdf6dcfb652b61" + integrity sha512-8M30TzMpLHGmuthHZStm4F+az5wxyYeh8U+LWK7+b2qnlQ0anXBmOQ1I8DCMV1K981wPY3C3kWZ4SA1lR3Y3xQ== "@commitlint/cli@^7.1.2", "@commitlint/cli@^7.3.2": version "7.3.2" From 857cdc004da8851ce8c634d6e1d02eb0cdf82b37 Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 22 Jan 2019 01:09:17 +0100 Subject: [PATCH 24/88] refactor(typescript-estree): correct warnings reported by sonarlint (#100) --- .../typescript-estree/src/ast-converter.ts | 6 +- packages/typescript-estree/src/convert.ts | 8 +- packages/typescript-estree/src/parser.ts | 4 +- .../tests/lib/__snapshots__/parse.ts.snap | 80 +++++++++++++++++++ packages/typescript-estree/tests/lib/parse.ts | 62 +++++++++++++- .../typescript-estree/tools/test-utils.ts | 1 + 6 files changed, 147 insertions(+), 14 deletions(-) diff --git a/packages/typescript-estree/src/ast-converter.ts b/packages/typescript-estree/src/ast-converter.ts index ce6f14b63f71..13d2212c5c4f 100644 --- a/packages/typescript-estree/src/ast-converter.ts +++ b/packages/typescript-estree/src/ast-converter.ts @@ -11,11 +11,11 @@ import { convertTokens } from './node-utils'; import ts from 'typescript'; import { Extra } from './temp-types-based-on-js-source'; -export default ( +export default function astConverter( ast: ts.SourceFile, extra: Extra, shouldProvideParserServices: boolean -) => { +) { /** * The TypeScript compiler produced fundamental parse errors when parsing the * source. @@ -59,4 +59,4 @@ export default ( } return { estree, astMaps }; -}; +} diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index f75547953df8..5d3c4df99734 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -694,8 +694,8 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { } if (node.type) { - (result as any).id.typeAnnotation = convertTypeAnnotation(node.type); - fixTypeAnnotationParentLocation((result as any).id); + result.id!.typeAnnotation = convertTypeAnnotation(node.type); + fixTypeAnnotationParentLocation(result.id!); } break; } @@ -1249,7 +1249,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { expressions: [] }); - node.templateSpans.forEach((templateSpan: any) => { + node.templateSpans.forEach(templateSpan => { (result as any).expressions.push(convertChild(templateSpan.expression)); (result as any).quasis.push(convertChild(templateSpan.literal)); }); @@ -1333,7 +1333,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { } if (node.questionToken) { - (parameter as any).optional = true; + parameter.optional = true; } if (node.modifiers) { diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index 2f6347e0a7a2..ff2784aa9963 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -213,10 +213,8 @@ function generateAST( tsNodeToESTreeNodeMap?: WeakMap; }; } { - const toString = String; - if (typeof code !== 'string' && !((code as any) instanceof String)) { - code = toString(code); + code = String(code); } resetExtra(); diff --git a/packages/typescript-estree/tests/lib/__snapshots__/parse.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/parse.ts.snap index ae6a9a339e17..4509f7441037 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/parse.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/parse.ts.snap @@ -188,3 +188,83 @@ Object { "type": "Program", } `; + +exports[`parse() non string code should correctly convert code to string 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "raw": "12345", + "type": "Literal", + "value": 12345, + }, + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "ExpressionStatement", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Numeric", + "value": "12345", + }, + ], + "type": "Program", +} +`; diff --git a/packages/typescript-estree/tests/lib/parse.ts b/packages/typescript-estree/tests/lib/parse.ts index cbb9bebfd052..74f02d03792c 100644 --- a/packages/typescript-estree/tests/lib/parse.ts +++ b/packages/typescript-estree/tests/lib/parse.ts @@ -6,6 +6,7 @@ * MIT License */ import * as parser from '../../src/parser'; +import * as astConverter from '../../src/ast-converter'; import { ParserOptions } from '../../src/temp-types-based-on-js-source'; import { createSnapshotTestBlock } from '../../tools/test-utils'; @@ -16,8 +17,8 @@ import { createSnapshotTestBlock } from '../../tools/test-utils'; describe('parse()', () => { describe('basic functionality', () => { it('should parse an empty string', () => { - expect((parser as any).parse('').body).toEqual([]); - expect(parser.parse('', {} as any).body).toEqual([]); + expect(parser.parse('').body).toEqual([]); + expect(parser.parse('', {}).body).toEqual([]); }); }); @@ -33,7 +34,7 @@ describe('parse()', () => { describe('general', () => { const code = 'let foo = bar;'; - const config = { + const config: ParserOptions = { comment: true, tokens: true, range: true, @@ -42,7 +43,60 @@ describe('parse()', () => { it( 'output tokens, comments, locs, and ranges when called with those options', - createSnapshotTestBlock(code, config as ParserOptions) + createSnapshotTestBlock(code, config) ); }); + + describe('non string code', () => { + const code = (12345 as any) as string; + const config: ParserOptions = { + comment: true, + tokens: true, + range: true, + loc: true + }; + + it( + 'should correctly convert code to string', + createSnapshotTestBlock(code, config) + ); + }); + + describe('loggerFn should be propagated to ast-converter', () => { + it('output tokens, comments, locs, and ranges when called with those options', () => { + const spy = jest.spyOn(astConverter, 'default'); + + const loggerFn = jest.fn(() => true); + + parser.parse('let foo = bar;', { + loggerFn, + comment: true, + tokens: true, + range: true, + loc: true + }); + + expect(spy).toHaveBeenCalledWith( + jasmine.any(Object), + { + code: 'let foo = bar;', + comment: true, + comments: [], + errorOnTypeScriptSyntacticAndSemanticIssues: false, + errorOnUnknownASTType: false, + extraFileExtensions: [], + jsx: false, + loc: true, + log: loggerFn, + projects: [], + range: true, + strict: false, + tokens: jasmine.any(Array), + tsconfigRootDir: jasmine.any(String), + useJSXTextNode: false + }, + false + ); + }); + }); }); diff --git a/packages/typescript-estree/tools/test-utils.ts b/packages/typescript-estree/tools/test-utils.ts index dc507d78e1e8..9191ae5e518a 100644 --- a/packages/typescript-estree/tools/test-utils.ts +++ b/packages/typescript-estree/tools/test-utils.ts @@ -36,6 +36,7 @@ export function parseCodeAndGenerateServices( * and which performs an assertion on the snapshot for the given code and config. * @param {string} code The source code to parse * @param {ParserOptions} config the parser configuration + * @param {boolean} generateServices Flag determining whether to generate ast maps and program or not * @returns {jest.ProvidesCallback} callback for Jest it() block */ export function createSnapshotTestBlock( From e0f409390cbedc57aa1ed38ce8118979cd8db35b Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 21 Jan 2019 19:26:38 -0500 Subject: [PATCH 25/88] build: try example canary conditional job (#116) --- azure-pipelines.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a34eaea0062d..11634775f519 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -64,3 +64,20 @@ jobs: - script: | yarn test displayName: 'Run unit tests' + + - job: publish_canary_version + displayName: Publish the latest code as a canary version + dependsOn: + - primary_code_validation_and_tests + - unit_tests_on_other_node_versions + condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'), ne(variables['Build.Reason'], 'PullRequest')) + pool: + vmImage: 'Ubuntu-16.04' + steps: + - task: NodeTool@0 + inputs: + versionSpec: 11 + displayName: 'Install Node.js 11' + + - script: | + echo "canary" From 33ac99fbc60ee80774f0d7a415015d33e764bec3 Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 21 Jan 2019 19:41:10 -0500 Subject: [PATCH 26/88] build: publish all packages in canary job (#117) --- azure-pipelines.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 11634775f519..c933f0827920 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -80,4 +80,10 @@ jobs: displayName: 'Install Node.js 11' - script: | - echo "canary" + # This also runs a build as part of the postinstall + # bootstrap + yarn --ignore-engines --frozen-lockfile + + - script: | + npx lerna publish --canary --exact --force-publish --yes + displayName: 'Publish all packages to npm' From 819b640559bb41d43467dd473ee15eaf227247ba Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 21 Jan 2019 19:55:45 -0500 Subject: [PATCH 27/88] build: npm auth --- azure-pipelines.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c933f0827920..805b5c0a1ee9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -84,6 +84,9 @@ jobs: # bootstrap yarn --ignore-engines --frozen-lockfile + - script: | + npm config set //registry.npmjs.org/:_authToken=$(NPM_TOKEN) + - script: | npx lerna publish --canary --exact --force-publish --yes displayName: 'Publish all packages to npm' From 5841cd2eca6a2b2a4fc018fa71b5f7ef121c4dab Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Tue, 22 Jan 2019 07:38:55 -0500 Subject: [PATCH 28/88] =?UTF-8?q?fix(eslint-plugin):=20don=E2=80=99t=20mar?= =?UTF-8?q?k=20`declare=20class`=20as=20unused=20(#110)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #106 --- packages/eslint-plugin/lib/rules/no-unused-vars.js | 6 ++++++ packages/eslint-plugin/tests/lib/rules/no-unused-vars.js | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/packages/eslint-plugin/lib/rules/no-unused-vars.js b/packages/eslint-plugin/lib/rules/no-unused-vars.js index bb09d6abd271..79c60d437c24 100644 --- a/packages/eslint-plugin/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/lib/rules/no-unused-vars.js @@ -92,6 +92,12 @@ module.exports = Object.assign({}, baseRule, { }, '*[declare=true] Identifier'(node) { context.markVariableAsUsed(node.name); + const scope = context.getScope(); + const { variableScope } = scope; + if (variableScope !== scope) { + const superVar = variableScope.set.get(node.name); + if (superVar) superVar.eslintUsed = true; + } } }); } diff --git a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js index c197adff8ee1..726f755c3956 100644 --- a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js @@ -540,6 +540,13 @@ declare namespace Foo { declare var Foo: { new (value?: any): Object, foo(): string +} + `, + // https://github.com/typescript-eslint/typescript-eslint/issues/106 + ` +declare class Foo { + constructor(value?: any): Object; + foo(): string; } `, ` From 4e781f1844acb3c74b093b1380cc37172cac2bfe Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 22 Jan 2019 16:28:56 +0100 Subject: [PATCH 29/88] fix(typescript-estree): fix range of assignment in parameter (#115) --- .../lib/__snapshots__/typescript.ts.snap | 28 +++++++++---------- packages/typescript-estree/src/convert.ts | 6 ++++ packages/typescript-estree/src/node-utils.ts | 2 +- .../tests/ast-alignment/fixtures-to-test.ts | 9 ------ .../lib/__snapshots__/typescript.ts.snap | 28 +++++++++---------- 5 files changed, 35 insertions(+), 38 deletions(-) diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index b1013b958c11..046f4e2081a2 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -21333,12 +21333,12 @@ Object { "line": 4, }, "start": Object { - "column": 14, + "column": 22, "line": 4, }, }, "range": Array [ - 116, + 124, 140, ], "right": Object { @@ -21439,12 +21439,12 @@ Object { "line": 5, }, "start": Object { - "column": 14, + "column": 31, "line": 5, }, }, "range": Array [ - 156, + 173, 197, ], "right": Object { @@ -24453,12 +24453,12 @@ Object { "line": 4, }, "start": Object { - "column": 14, + "column": 24, "line": 4, }, }, "range": Array [ - 120, + 130, 146, ], "right": Object { @@ -24559,12 +24559,12 @@ Object { "line": 5, }, "start": Object { - "column": 14, + "column": 33, "line": 5, }, }, "range": Array [ - 162, + 181, 205, ], "right": Object { @@ -25579,12 +25579,12 @@ Object { "line": 4, }, "start": Object { - "column": 14, + "column": 21, "line": 4, }, }, "range": Array [ - 114, + 121, 137, ], "right": Object { @@ -25685,12 +25685,12 @@ Object { "line": 5, }, "start": Object { - "column": 14, + "column": 30, "line": 5, }, }, "range": Array [ - 153, + 169, 193, ], "right": Object { @@ -26633,12 +26633,12 @@ Object { "line": 3, }, "start": Object { - "column": 14, + "column": 23, "line": 3, }, }, "range": Array [ - 68, + 77, 103, ], "right": Object { diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 5d3c4df99734..c02a2eece24a 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -1318,6 +1318,12 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { left: parameter, right: convertChild(node.initializer) }); + + if (node.modifiers) { + // AssignmentPattern should not contain modifiers in range + result.range[0] = parameter.range[0]; + result.loc = getLocFor(result.range[0], result.range[1], ast); + } } else { parameter = result = convert({ node: node.name, diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index 678c97215fa0..fa780cfe8e97 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -161,7 +161,7 @@ export function hasModifier( * @param node TypeScript AST node * @returns returns last modifier if present or null */ -export function getLastModifier(node: ts.Node): ts.Node | null { +export function getLastModifier(node: ts.Node): ts.Modifier | null { return ( (!!node.modifiers && !!node.modifiers.length && 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 2e478b0fb1b1..3b1a21e43d80 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -341,15 +341,6 @@ tester.addFixturePatternConfig('typescript/basics', { 'abstract-class-with-abstract-method', // babel parse errors 'abstract-class-with-optional-method', // babel parse errors 'declare-class-with-optional-method', // babel parse errors - /** - * Was expected to be fixed by PR into Babel: https://github.com/babel/babel/pull/9284 - * But not fixed in Babel 7.3 - * TODO: Investigate differences - */ - 'class-with-private-parameter-properties', - 'class-with-protected-parameter-properties', - 'class-with-public-parameter-properties', - 'class-with-readonly-parameter-properties', /** * Was expected to be fixed by PR into Babel: https://github.com/babel/babel/pull/9302 * But not fixed in Babel 7.3 diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index 5ad5989309a8..6341ffcd7d74 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -21291,12 +21291,12 @@ Object { "line": 4, }, "start": Object { - "column": 14, + "column": 22, "line": 4, }, }, "range": Array [ - 116, + 124, 140, ], "right": Object { @@ -21397,12 +21397,12 @@ Object { "line": 5, }, "start": Object { - "column": 14, + "column": 31, "line": 5, }, }, "range": Array [ - 156, + 173, 197, ], "right": Object { @@ -24408,12 +24408,12 @@ Object { "line": 4, }, "start": Object { - "column": 14, + "column": 24, "line": 4, }, }, "range": Array [ - 120, + 130, 146, ], "right": Object { @@ -24514,12 +24514,12 @@ Object { "line": 5, }, "start": Object { - "column": 14, + "column": 33, "line": 5, }, }, "range": Array [ - 162, + 181, 205, ], "right": Object { @@ -25533,12 +25533,12 @@ Object { "line": 4, }, "start": Object { - "column": 14, + "column": 21, "line": 4, }, }, "range": Array [ - 114, + 121, 137, ], "right": Object { @@ -25639,12 +25639,12 @@ Object { "line": 5, }, "start": Object { - "column": 14, + "column": 30, "line": 5, }, }, "range": Array [ - 153, + 169, 193, ], "right": Object { @@ -26586,12 +26586,12 @@ Object { "line": 3, }, "start": Object { - "column": 14, + "column": 23, "line": 3, }, }, "range": Array [ - 68, + 77, 103, ], "right": Object { From c541edec85372e1d3e9f424365569f12f6b5690d Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 22 Jan 2019 17:38:44 +0100 Subject: [PATCH 30/88] feat(eslint-plugin): add new rule restrict-plus-operands (#70) --- packages/eslint-plugin/README.md | 1 + .../docs/rules/restrict-plus-operands.md | 25 ++ .../lib/rules/restrict-plus-operands.js | 104 +++++++ .../tests/fixtures/tsconfig.json | 9 + .../tests/lib/rules/restrict-plus-operands.js | 282 ++++++++++++++++++ 5 files changed, 421 insertions(+) create mode 100644 packages/eslint-plugin/docs/rules/restrict-plus-operands.md create mode 100644 packages/eslint-plugin/lib/rules/restrict-plus-operands.js create mode 100644 packages/eslint-plugin/tests/fixtures/tsconfig.json create mode 100644 packages/eslint-plugin/tests/lib/rules/restrict-plus-operands.js diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index ec96819a455f..108dd0f994be 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -93,6 +93,7 @@ You can also enable all the recommended rules at once. Add `plugin:@typescript-e | [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: | | [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string. (`restrict-plus-operands` from TSLint) | | | | [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: | diff --git a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md new file mode 100644 index 000000000000..a1436daf7695 --- /dev/null +++ b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md @@ -0,0 +1,25 @@ +# When adding two variables, operands must both be of type number or of type string. (restrict-plus-operands) + +Examples of **correct** code: + +```ts +var foo = parseInt('5.5', 10) + 10; +``` + +Examples of **incorrect** code: + +```ts +var foo = '5.5' + 5; +``` + +## Options + +```json +{ + "@typescript-eslint/restrict-plus-operands": "error" +} +``` + +## Compatibility + +- TSLint: [restrict-plus-operands](https://palantir.github.io/tslint/rules/restrict-plus-operands/) diff --git a/packages/eslint-plugin/lib/rules/restrict-plus-operands.js b/packages/eslint-plugin/lib/rules/restrict-plus-operands.js new file mode 100644 index 000000000000..222f51e5c8af --- /dev/null +++ b/packages/eslint-plugin/lib/rules/restrict-plus-operands.js @@ -0,0 +1,104 @@ +/** + * @fileoverview When adding two variables, operands must both be of type number or of type string. + * @author James Henry + * @author Armano + */ +'use strict'; + +const util = require('../util'); + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + type: 'problem', + docs: { + description: + 'When adding two variables, operands must both be of type number or of type string.', + extraDescription: [util.tslintRule('restrict-plus-operands')], + category: 'TypeScript', + url: util.metaDocsUrl('restrict-plus-operands') + }, + messages: { + notNumbers: + "Operands of '+' operation must either be both strings or both numbers.", + notStrings: + "Operands of '+' operation must either be both strings or both numbers. Consider using a template literal." + }, + schema: [] + }, + + create(context) { + const service = util.getParserServices(context); + + const typeChecker = service.program.getTypeChecker(); + + /** + * Helper function to get base type of node + * @param {ts.Type} type type to be evaluated + * @returns {*} string, number or invalid + */ + function getBaseTypeOfLiteralType(type) { + if (type.isNumberLiteral()) { + return 'number'; + } + if (type.isStringLiteral()) { + return 'string'; + } + if (type.isUnion()) { + const types = type.types.map(getBaseTypeOfLiteralType); + + return types.every(value => value === types[0]) ? types[0] : 'invalid'; + } + + const stringType = typeChecker.typeToString(type); + + if (stringType === 'number' || stringType === 'string') { + return stringType; + } + return 'invalid'; + } + + /** + * Helper function to get base type of node + * @param {ASTNode} node the node to be evaluated. + * @returns {*} string, number or invalid + */ + function getNodeType(node) { + const tsNode = service.esTreeNodeToTSNodeMap.get(node); + const type = typeChecker.getTypeAtLocation(tsNode); + + return getBaseTypeOfLiteralType(type); + } + + //---------------------------------------------------------------------- + // Public + //---------------------------------------------------------------------- + return { + "BinaryExpression[operator='+']"(node) { + const leftType = getNodeType(node.left); + const rightType = getNodeType(node.right); + + if ( + leftType === 'invalid' || + rightType === 'invalid' || + leftType !== rightType + ) { + if (leftType === 'string' || rightType === 'string') { + context.report({ + node, + messageId: 'notStrings' + }); + } else { + context.report({ + node, + messageId: 'notNumbers' + }); + } + } + } + }; + } +}; diff --git a/packages/eslint-plugin/tests/fixtures/tsconfig.json b/packages/eslint-plugin/tests/fixtures/tsconfig.json new file mode 100644 index 000000000000..8702b63472ba --- /dev/null +++ b/packages/eslint-plugin/tests/fixtures/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "lib": ["es2015", "es2017"] + } +} diff --git a/packages/eslint-plugin/tests/lib/rules/restrict-plus-operands.js b/packages/eslint-plugin/tests/lib/rules/restrict-plus-operands.js new file mode 100644 index 000000000000..a13b7cea3e47 --- /dev/null +++ b/packages/eslint-plugin/tests/lib/rules/restrict-plus-operands.js @@ -0,0 +1,282 @@ +/** + * @fileoverview When adding two variables, operands must both be of type number or of type string. + * @author James Henry + * @author Armano + */ +'use strict'; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ +const path = require('path'); + +const rule = require('../../../lib/rules/restrict-plus-operands'), + RuleTester = require('eslint').RuleTester; + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +const rootPath = path.join(process.cwd(), 'tests/fixtures/'); + +const ruleTester = new RuleTester({ + parser: '@typescript-eslint/parser', + parserOptions: { + generateServices: true, + tsconfigRootDir: rootPath, + project: './tsconfig.json' + } +}); + +ruleTester.run('restrict-plus-operands', rule, { + valid: [ + `var x = 5;`, + `var y = "10";`, + `var z = 8.2;`, + `var w = "6.5";`, + `var foo = 5 + 10;`, + `var foo = "5.5" + "10";`, + `var foo = parseInt("5.5", 10) + 10;`, + `var foo = parseFloat("5.5", 10) + 10;`, + ` +function test () : number { return 2; } +var foo = test("5.5", 10) + 10; + `, + ` +var x = 5; +var z = 8.2; +var foo = x + z; + `, + ` +var w = "6.5"; +var y = "10"; +var foo = y + w; + `, + 'var foo = 1 + 1;', + "var foo = '1' + '1';", + ` +var pair: { first: number, second: string } = { first: 5, second: "10" }; +var foo = pair.first + 10; + `, + ` +var pair: { first: number, second: string } = { first: 5, second: "10" }; +var foo = pair.first + (10 as number); + `, + ` +var pair: { first: number, second: string } = { first: 5, second: "10" }; +var foo = "5.5" + pair.second; + `, + ` +var pair: { first: number, second: string } = { first: 5, second: "10" }; +var foo = ("5.5" as string) + pair.second; + `, + `const foo = 'hello' + (someBoolean ? 'a' : 'b') + (() => someBoolean ? 'c' : 'd')() + 'e';`, + `const balls = true;`, + `balls === true;` + ], + invalid: [ + { + code: "var foo = '1' + 1;", + errors: [ + { + messageId: 'notStrings', + line: 1, + column: 11 + } + ] + }, + { + code: 'var foo = [] + {};', + errors: [ + { + messageId: 'notNumbers', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = 5 + "10";`, + errors: [ + { + messageId: 'notStrings', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = [] + 5;`, + errors: [ + { + messageId: 'notNumbers', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = [] + {};`, + errors: [ + { + messageId: 'notNumbers', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = [] + [];`, + errors: [ + { + messageId: 'notNumbers', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = 5 + [];`, + errors: [ + { + messageId: 'notNumbers', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = "5" + {};`, + errors: [ + { + messageId: 'notStrings', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = 5.5 + "5";`, + errors: [ + { + messageId: 'notStrings', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = "5.5" + 5;`, + errors: [ + { + messageId: 'notStrings', + line: 1, + column: 11 + } + ] + }, + { + code: ` +var x = 5; +var y = "10"; +var foo = x + y; + `, + errors: [ + { + messageId: 'notStrings', + line: 4, + column: 11 + } + ] + }, + { + code: ` +var x = 5; +var y = "10"; +var foo = y + x; + `, + errors: [ + { + messageId: 'notStrings', + line: 4, + column: 11 + } + ] + }, + { + code: ` +var x = 5; +var foo = x + {}; + `, + errors: [ + { + messageId: 'notNumbers', + line: 3, + column: 11 + } + ] + }, + { + code: ` +var y = "10"; +var foo = [] + y; + `, + errors: [ + { + messageId: 'notStrings', + line: 3, + column: 11 + } + ] + }, + { + code: ` +var pair: { first: number, second: string } = { first: 5, second: "10" }; +var foo = pair.first + "10"; + `, + errors: [ + { + messageId: 'notStrings', + line: 3, + column: 11 + } + ] + }, + { + code: ` +var pair: { first: number, second: string } = { first: 5, second: "10" }; +var foo = 5 + pair.second; + `, + errors: [ + { + messageId: 'notStrings', + line: 3, + column: 11 + } + ] + }, + { + code: `var foo = parseInt("5.5", 10) + "10";`, + errors: [ + { + messageId: 'notStrings', + line: 1, + column: 11 + } + ] + }, + { + code: ` +var pair = { first: 5, second: "10" }; +var foo = pair + pair; + `, + errors: [ + { + messageId: 'notNumbers', + line: 3, + column: 11 + } + ] + } + ] +}); From 74802b1b9b051c94a220fc5859b64211c7c71d7c Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 23 Jan 2019 00:28:07 +0100 Subject: [PATCH 31/88] refactor(typescript-estree): simplify range calculation for body nodes (#127) --- .../lib/__snapshots__/javascript.ts.snap | 2 + .../lib/__snapshots__/typescript.ts.snap | 2 + .../classes/class-with-no-body.src.js | 1 + .../interface-with-no-body.src.ts | 1 + packages/typescript-estree/src/convert.ts | 69 +++---------------- packages/typescript-estree/src/node-utils.ts | 4 +- .../lib/__snapshots__/javascript.ts.snap | 2 + .../semantic-diagnostics-enabled.ts.snap | 18 +++++ .../lib/__snapshots__/typescript.ts.snap | 2 + 9 files changed, 41 insertions(+), 60 deletions(-) create mode 100644 packages/shared-fixtures/fixtures/javascript/classes/class-with-no-body.src.js create mode 100644 packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-with-no-body.src.ts diff --git a/packages/parser/tests/lib/__snapshots__/javascript.ts.snap b/packages/parser/tests/lib/__snapshots__/javascript.ts.snap index fcbb463e5ee9..b31c5e710a2b 100644 --- a/packages/parser/tests/lib/__snapshots__/javascript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/javascript.ts.snap @@ -30326,6 +30326,8 @@ Object { } `; +exports[`javascript fixtures/classes/class-with-no-body.src 1`] = `"'{' expected."`; + exports[`javascript fixtures/classes/derived-class-assign-to-var.src 1`] = ` Object { "body": Array [ diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index 046f4e2081a2..cd9460af3e32 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -95244,6 +95244,8 @@ Object { } `; +exports[`typescript fixtures/errorRecovery/interface-with-no-body.src 1`] = `"'{' expected."`; + exports[`typescript fixtures/errorRecovery/object-assertion-not-allowed.src 1`] = ` Object { "body": Array [ diff --git a/packages/shared-fixtures/fixtures/javascript/classes/class-with-no-body.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-with-no-body.src.js new file mode 100644 index 000000000000..c389887ee5aa --- /dev/null +++ b/packages/shared-fixtures/fixtures/javascript/classes/class-with-no-body.src.js @@ -0,0 +1 @@ +class Foo diff --git a/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-with-no-body.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-with-no-body.src.ts new file mode 100644 index 000000000000..3f943170b49e --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/errorRecovery/interface-with-no-body.src.ts @@ -0,0 +1 @@ +interface Foo diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index c02a2eece24a..e5656e828934 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -1363,40 +1363,14 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: { const heritageClauses = node.heritageClauses || []; - let classNodeType = SyntaxKind[node.kind]; - let lastClassToken: any = heritageClauses.length - ? heritageClauses[heritageClauses.length - 1] - : node.name; if (node.typeParameters && node.typeParameters.length) { - const lastTypeParameter = - node.typeParameters[node.typeParameters.length - 1]; - - if (!lastClassToken || lastTypeParameter.pos > lastClassToken.pos) { - lastClassToken = findNextToken(lastTypeParameter, ast, ast); - } result.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( node.typeParameters ); } - if (node.modifiers && node.modifiers.length) { - /** - * We need check for modifiers, and use the last one, as there - * could be multiple before the open brace - */ - const lastModifier = node.modifiers![node.modifiers!.length - 1]; - - if (!lastClassToken || lastModifier.pos > lastClassToken.pos) { - lastClassToken = findNextToken(lastModifier, ast, ast); - } - } else if (!lastClassToken) { - // no name - lastClassToken = node.getFirstToken(); - } - - const openBrace = findNextToken(lastClassToken, ast, ast)!; const superClass = heritageClauses.find( clause => clause.token === SyntaxKind.ExtendsKeyword ); @@ -1421,14 +1395,16 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { clause => clause.token === SyntaxKind.ImplementsKeyword ); + const classBodyRange = [node.members.pos - 1, node.end]; + Object.assign(result, { type: classNodeType, id: convertChild(node.name), body: { type: AST_NODE_TYPES.ClassBody, body: [], - range: [openBrace.getStart(ast), node.end], - loc: getLocFor(openBrace.getStart(ast), node.end, ast) + range: classBodyRange, + loc: getLocFor(classBodyRange[0], classBodyRange[1], ast) }, superClass: superClass && superClass.types[0] @@ -2335,45 +2311,22 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { case SyntaxKind.InterfaceDeclaration: { const interfaceHeritageClauses = node.heritageClauses || []; - let interfaceLastClassToken = interfaceHeritageClauses.length - ? interfaceHeritageClauses[interfaceHeritageClauses.length - 1] - : node.name; - if (node.typeParameters && node.typeParameters.length) { - const interfaceLastTypeParameter = - node.typeParameters[node.typeParameters.length - 1]; - - if ( - !interfaceLastClassToken || - interfaceLastTypeParameter.pos > interfaceLastClassToken.pos - ) { - interfaceLastClassToken = findNextToken( - interfaceLastTypeParameter, - ast, - ast - ) as any; - } result.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( node.typeParameters ); } - const interfaceOpenBrace = findNextToken( - interfaceLastClassToken, - ast, - ast - )!; - - const interfaceBody = { - type: AST_NODE_TYPES.TSInterfaceBody, - body: node.members.map(member => convertChild(member)), - range: [interfaceOpenBrace.getStart(ast), node.end], - loc: getLocFor(interfaceOpenBrace.getStart(ast), node.end, ast) - }; + const interfaceBodyRange = [node.members.pos - 1, node.end]; Object.assign(result, { type: AST_NODE_TYPES.TSInterfaceDeclaration, - body: interfaceBody, + body: { + type: AST_NODE_TYPES.TSInterfaceBody, + body: node.members.map(member => convertChild(member)), + range: interfaceBodyRange, + loc: getLocFor(interfaceBodyRange[0], interfaceBodyRange[1], ast) + }, id: convertChild(node.name) }); diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index fa780cfe8e97..240c4d1c9f71 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -359,13 +359,13 @@ export function getTSNodeAccessibility( /** * Finds the next token based on the previous one and its parent * Had to copy this from TS instead of using TS's version because theirs doesn't pass the ast to getChildren - * @param {ts.Node} previousToken The previous TSToken + * @param {ts.TextRange} previousToken The previous TSToken * @param {ts.Node} parent The parent TSNode * @param {ts.SourceFile} ast The TS AST * @returns {ts.Node|undefined} the next TSToken */ export function findNextToken( - previousToken: ts.Node, + previousToken: ts.TextRange, parent: ts.Node, ast: ts.SourceFile ): ts.Node | undefined { diff --git a/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap index eb2eb8f6f916..8d02532b8d7f 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap @@ -30246,6 +30246,8 @@ Object { } `; +exports[`javascript fixtures/classes/class-with-no-body.src 1`] = `"'{' expected."`; + exports[`javascript fixtures/classes/derived-class-assign-to-var.src 1`] = ` Object { "body": Array [ diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index dfd7dbf783d0..e1186e5638a5 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -349,6 +349,15 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/classes/class-with-constructor-with-space.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/classes/class-with-no-body.src 1`] = ` +Object { + "column": 0, + "index": 10, + "lineNumber": 2, + "message": "'{' expected.", +} +`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/classes/derived-class-assign-to-var.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/classes/derived-class-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -2465,6 +2474,15 @@ Object { } `; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/interface-with-no-body.src 1`] = ` +Object { + "column": 0, + "index": 14, + "lineNumber": 2, + "message": "'{' expected.", +} +`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/object-assertion-not-allowed.src 1`] = ` Object { "column": 3, diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index 6341ffcd7d74..c374e397a6e8 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -94859,6 +94859,8 @@ Object { } `; +exports[`typescript fixtures/errorRecovery/interface-with-no-body.src 1`] = `"'{' expected."`; + exports[`typescript fixtures/errorRecovery/object-assertion-not-allowed.src 1`] = ` Object { "body": Array [ From 91eedf20f3bd3940ba4576e8a8a48ad9fca01f15 Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 23 Jan 2019 00:33:56 +0100 Subject: [PATCH 32/88] fix(typescript-estree): correct range of parameters with comments (#128) --- .../lib/__snapshots__/typescript.ts.snap | 2113 +++++++++++++++++ .../type-parameters-comments-heritage.src.ts | 4 + packages/typescript-estree/src/convert.ts | 42 +- .../semantic-diagnostics-enabled.ts.snap | 2 + .../lib/__snapshots__/typescript.ts.snap | 1787 ++++++++++++++ 5 files changed, 3915 insertions(+), 33 deletions(-) create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/type-parameters-comments-heritage.src.ts diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index cd9460af3e32..39c74ab7586d 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -66551,6 +66551,2119 @@ Object { } `; +exports[`typescript fixtures/basics/type-parameters-comments-heritage.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 72, + "line": 1, + }, + }, + "range": Array [ + 72, + 74, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 74, + ], + "superClass": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "name": "bar", + "range": Array [ + 43, + 46, + ], + "type": "Identifier", + }, + "superTypeParameters": Object { + "loc": Object { + "end": Object { + "column": 71, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 60, + "line": 1, + }, + "start": Object { + "column": 59, + "line": 1, + }, + }, + "range": Array [ + 59, + 60, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 60, + "line": 1, + }, + "start": Object { + "column": 59, + "line": 1, + }, + }, + "name": "A", + "range": Array [ + 59, + 60, + ], + "type": "Identifier", + }, + }, + ], + "range": Array [ + 47, + 71, + ], + "type": "TSTypeParameterInstantiation", + }, + "type": "ClassDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "name": "A", + "range": Array [ + 22, + 23, + ], + "type": "Identifier", + }, + "range": Array [ + 22, + 23, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 10, + 34, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + Object { + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 89, + "line": 2, + }, + "start": Object { + "column": 87, + "line": 2, + }, + }, + "range": Array [ + 162, + 164, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "name": "foo2", + "range": Array [ + 81, + 85, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 89, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 75, + 164, + ], + "superClass": Object { + "loc": Object { + "end": Object { + "column": 61, + "line": 2, + }, + "start": Object { + "column": 58, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 133, + 136, + ], + "type": "Identifier", + }, + "superTypeParameters": Object { + "loc": Object { + "end": Object { + "column": 86, + "line": 2, + }, + "start": Object { + "column": 62, + "line": 2, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 75, + "line": 2, + }, + "start": Object { + "column": 74, + "line": 2, + }, + }, + "range": Array [ + 149, + 150, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 75, + "line": 2, + }, + "start": Object { + "column": 74, + "line": 2, + }, + }, + "name": "A", + "range": Array [ + 149, + 150, + ], + "type": "Identifier", + }, + }, + ], + "range": Array [ + 137, + 161, + ], + "type": "TSTypeParameterInstantiation", + }, + "type": "ClassDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 49, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "params": Array [ + Object { + "default": Object { + "literal": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 37, + "line": 2, + }, + }, + "range": Array [ + 112, + 113, + ], + "raw": "2", + "type": "Literal", + "value": 2, + }, + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 37, + "line": 2, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "TSLiteralType", + }, + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "A", + "range": Array [ + 98, + 99, + ], + "type": "Identifier", + }, + "range": Array [ + 98, + 113, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 86, + 124, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + Object { + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 79, + "line": 3, + }, + "start": Object { + "column": 77, + "line": 3, + }, + }, + "range": Array [ + 242, + 244, + ], + "type": "TSInterfaceBody", + }, + "extends": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 51, + "line": 3, + }, + "start": Object { + "column": 47, + "line": 3, + }, + }, + "name": "bar2", + "range": Array [ + 212, + 216, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 76, + "line": 3, + }, + "start": Object { + "column": 47, + "line": 3, + }, + }, + "range": Array [ + 212, + 241, + ], + "type": "TSInterfaceHeritage", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 76, + "line": 3, + }, + "start": Object { + "column": 52, + "line": 3, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 65, + "line": 3, + }, + "start": Object { + "column": 64, + "line": 3, + }, + }, + "range": Array [ + 229, + 230, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 65, + "line": 3, + }, + "start": Object { + "column": 64, + "line": 3, + }, + }, + "name": "A", + "range": Array [ + 229, + 230, + ], + "type": "Identifier", + }, + }, + ], + "range": Array [ + 217, + 241, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + ], + "id": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "name": "bar", + "range": Array [ + 175, + 178, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 79, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 165, + 244, + ], + "type": "TSInterfaceDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 3, + }, + "start": Object { + "column": 14, + "line": 3, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "name": "A", + "range": Array [ + 191, + 192, + ], + "type": "Identifier", + }, + "range": Array [ + 191, + 192, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 179, + 203, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + Object { + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 93, + "line": 4, + }, + "start": Object { + "column": 91, + "line": 4, + }, + }, + "range": Array [ + 336, + 338, + ], + "type": "TSInterfaceBody", + }, + "extends": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 65, + "line": 4, + }, + "start": Object { + "column": 62, + "line": 4, + }, + }, + "name": "bar", + "range": Array [ + 307, + 310, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 90, + "line": 4, + }, + "start": Object { + "column": 62, + "line": 4, + }, + }, + "range": Array [ + 307, + 335, + ], + "type": "TSInterfaceHeritage", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 90, + "line": 4, + }, + "start": Object { + "column": 66, + "line": 4, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 79, + "line": 4, + }, + "start": Object { + "column": 78, + "line": 4, + }, + }, + "range": Array [ + 323, + 324, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 79, + "line": 4, + }, + "start": Object { + "column": 78, + "line": 4, + }, + }, + "name": "A", + "range": Array [ + 323, + 324, + ], + "type": "Identifier", + }, + }, + ], + "range": Array [ + 311, + 335, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + ], + "id": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 4, + }, + "start": Object { + "column": 10, + "line": 4, + }, + }, + "name": "bar2", + "range": Array [ + 255, + 259, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 93, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 4, + }, + }, + "range": Array [ + 245, + 338, + ], + "type": "TSInterfaceDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 4, + }, + "start": Object { + "column": 15, + "line": 4, + }, + }, + "params": Array [ + Object { + "default": Object { + "literal": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 41, + "line": 4, + }, + }, + "range": Array [ + 286, + 287, + ], + "raw": "2", + "type": "Literal", + "value": 2, + }, + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 41, + "line": 4, + }, + }, + "range": Array [ + 286, + 287, + ], + "type": "TSLiteralType", + }, + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 27, + "line": 4, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 4, + }, + "start": Object { + "column": 27, + "line": 4, + }, + }, + "name": "A", + "range": Array [ + 272, + 273, + ], + "type": "Identifier", + }, + "range": Array [ + 272, + 287, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 260, + 298, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + ], + "comments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 21, + ], + "type": "Block", + "value": " aaa ", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 33, + ], + "type": "Block", + "value": " bbb ", + }, + Object { + "loc": Object { + "end": Object { + "column": 58, + "line": 1, + }, + "start": Object { + "column": 49, + "line": 1, + }, + }, + "range": Array [ + 49, + 58, + ], + "type": "Block", + "value": " aaa ", + }, + Object { + "loc": Object { + "end": Object { + "column": 70, + "line": 1, + }, + "start": Object { + "column": 61, + "line": 1, + }, + }, + "range": Array [ + 61, + 70, + ], + "type": "Block", + "value": " bbb ", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "range": Array [ + 88, + 97, + ], + "type": "Block", + "value": " aaa ", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 25, + "line": 2, + }, + }, + "range": Array [ + 100, + 109, + ], + "type": "Block", + "value": " bbb ", + }, + Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 2, + }, + "start": Object { + "column": 39, + "line": 2, + }, + }, + "range": Array [ + 114, + 123, + ], + "type": "Block", + "value": " bbb ", + }, + Object { + "loc": Object { + "end": Object { + "column": 73, + "line": 2, + }, + "start": Object { + "column": 64, + "line": 2, + }, + }, + "range": Array [ + 139, + 148, + ], + "type": "Block", + "value": " aaa ", + }, + Object { + "loc": Object { + "end": Object { + "column": 85, + "line": 2, + }, + "start": Object { + "column": 76, + "line": 2, + }, + }, + "range": Array [ + 151, + 160, + ], + "type": "Block", + "value": " bbb ", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 3, + }, + }, + "range": Array [ + 181, + 190, + ], + "type": "Block", + "value": " aaa ", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 28, + "line": 3, + }, + }, + "range": Array [ + 193, + 202, + ], + "type": "Block", + "value": " bbb ", + }, + Object { + "loc": Object { + "end": Object { + "column": 63, + "line": 3, + }, + "start": Object { + "column": 54, + "line": 3, + }, + }, + "range": Array [ + 219, + 228, + ], + "type": "Block", + "value": " aaa ", + }, + Object { + "loc": Object { + "end": Object { + "column": 75, + "line": 3, + }, + "start": Object { + "column": 66, + "line": 3, + }, + }, + "range": Array [ + 231, + 240, + ], + "type": "Block", + "value": " bbb ", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 4, + }, + "start": Object { + "column": 17, + "line": 4, + }, + }, + "range": Array [ + 262, + 271, + ], + "type": "Block", + "value": " aaa ", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 4, + }, + "start": Object { + "column": 29, + "line": 4, + }, + }, + "range": Array [ + 274, + 283, + ], + "type": "Block", + "value": " bbb ", + }, + Object { + "loc": Object { + "end": Object { + "column": 52, + "line": 4, + }, + "start": Object { + "column": 43, + "line": 4, + }, + }, + "range": Array [ + 288, + 297, + ], + "type": "Block", + "value": " bbb ", + }, + Object { + "loc": Object { + "end": Object { + "column": 77, + "line": 4, + }, + "start": Object { + "column": 68, + "line": 4, + }, + }, + "range": Array [ + 313, + 322, + ], + "type": "Block", + "value": " aaa ", + }, + Object { + "loc": Object { + "end": Object { + "column": 89, + "line": 4, + }, + "start": Object { + "column": 80, + "line": 4, + }, + }, + "range": Array [ + 325, + 334, + ], + "type": "Block", + "value": " bbb ", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 339, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 42, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "range": Array [ + 43, + 46, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 60, + "line": 1, + }, + "start": Object { + "column": 59, + "line": 1, + }, + }, + "range": Array [ + 59, + 60, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 71, + "line": 1, + }, + "start": Object { + "column": 70, + "line": 1, + }, + }, + "range": Array [ + 70, + 71, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 73, + "line": 1, + }, + "start": Object { + "column": 72, + "line": 1, + }, + }, + "range": Array [ + 72, + 73, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 73, + "line": 1, + }, + }, + "range": Array [ + 73, + 74, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 75, + 80, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 81, + 85, + ], + "type": "Identifier", + "value": "foo2", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 86, + 87, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 98, + 99, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 2, + }, + "start": Object { + "column": 35, + "line": 2, + }, + }, + "range": Array [ + 110, + 111, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 37, + "line": 2, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "Numeric", + "value": "2", + }, + Object { + "loc": Object { + "end": Object { + "column": 49, + "line": 2, + }, + "start": Object { + "column": 48, + "line": 2, + }, + }, + "range": Array [ + 123, + 124, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 57, + "line": 2, + }, + "start": Object { + "column": 50, + "line": 2, + }, + }, + "range": Array [ + 125, + 132, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 61, + "line": 2, + }, + "start": Object { + "column": 58, + "line": 2, + }, + }, + "range": Array [ + 133, + 136, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 63, + "line": 2, + }, + "start": Object { + "column": 62, + "line": 2, + }, + }, + "range": Array [ + 137, + 138, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 75, + "line": 2, + }, + "start": Object { + "column": 74, + "line": 2, + }, + }, + "range": Array [ + 149, + 150, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 86, + "line": 2, + }, + "start": Object { + "column": 85, + "line": 2, + }, + }, + "range": Array [ + 160, + 161, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 88, + "line": 2, + }, + "start": Object { + "column": 87, + "line": 2, + }, + }, + "range": Array [ + 162, + 163, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 89, + "line": 2, + }, + "start": Object { + "column": 88, + "line": 2, + }, + }, + "range": Array [ + 163, + 164, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 165, + 174, + ], + "type": "Keyword", + "value": "interface", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 175, + 178, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 3, + }, + "start": Object { + "column": 14, + "line": 3, + }, + }, + "range": Array [ + 179, + 180, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "range": Array [ + 191, + 192, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 3, + }, + "start": Object { + "column": 37, + "line": 3, + }, + }, + "range": Array [ + 202, + 203, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 3, + }, + "start": Object { + "column": 39, + "line": 3, + }, + }, + "range": Array [ + 204, + 211, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 51, + "line": 3, + }, + "start": Object { + "column": 47, + "line": 3, + }, + }, + "range": Array [ + 212, + 216, + ], + "type": "Identifier", + "value": "bar2", + }, + Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 3, + }, + "start": Object { + "column": 52, + "line": 3, + }, + }, + "range": Array [ + 217, + 218, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 65, + "line": 3, + }, + "start": Object { + "column": 64, + "line": 3, + }, + }, + "range": Array [ + 229, + 230, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 76, + "line": 3, + }, + "start": Object { + "column": 75, + "line": 3, + }, + }, + "range": Array [ + 240, + 241, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 78, + "line": 3, + }, + "start": Object { + "column": 77, + "line": 3, + }, + }, + "range": Array [ + 242, + 243, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 79, + "line": 3, + }, + "start": Object { + "column": 78, + "line": 3, + }, + }, + "range": Array [ + 243, + 244, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 4, + }, + }, + "range": Array [ + 245, + 254, + ], + "type": "Keyword", + "value": "interface", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 4, + }, + "start": Object { + "column": 10, + "line": 4, + }, + }, + "range": Array [ + 255, + 259, + ], + "type": "Identifier", + "value": "bar2", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 4, + }, + "start": Object { + "column": 15, + "line": 4, + }, + }, + "range": Array [ + 260, + 261, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 4, + }, + "start": Object { + "column": 27, + "line": 4, + }, + }, + "range": Array [ + 272, + 273, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 40, + "line": 4, + }, + "start": Object { + "column": 39, + "line": 4, + }, + }, + "range": Array [ + 284, + 285, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 41, + "line": 4, + }, + }, + "range": Array [ + 286, + 287, + ], + "type": "Numeric", + "value": "2", + }, + Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 4, + }, + "start": Object { + "column": 52, + "line": 4, + }, + }, + "range": Array [ + 297, + 298, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 61, + "line": 4, + }, + "start": Object { + "column": 54, + "line": 4, + }, + }, + "range": Array [ + 299, + 306, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 65, + "line": 4, + }, + "start": Object { + "column": 62, + "line": 4, + }, + }, + "range": Array [ + 307, + 310, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 67, + "line": 4, + }, + "start": Object { + "column": 66, + "line": 4, + }, + }, + "range": Array [ + 311, + 312, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 79, + "line": 4, + }, + "start": Object { + "column": 78, + "line": 4, + }, + }, + "range": Array [ + 323, + 324, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 90, + "line": 4, + }, + "start": Object { + "column": 89, + "line": 4, + }, + }, + "range": Array [ + 334, + 335, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 92, + "line": 4, + }, + "start": Object { + "column": 91, + "line": 4, + }, + }, + "range": Array [ + 336, + 337, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 93, + "line": 4, + }, + "start": Object { + "column": 92, + "line": 4, + }, + }, + "range": Array [ + 337, + 338, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/type-reference-comments.src 1`] = ` Object { "body": Array [ diff --git a/packages/shared-fixtures/fixtures/typescript/basics/type-parameters-comments-heritage.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-parameters-comments-heritage.src.ts new file mode 100644 index 000000000000..986f4826089f --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/type-parameters-comments-heritage.src.ts @@ -0,0 +1,4 @@ +class foo < /* aaa */ A /* bbb */> extends bar < /* aaa */ A /* bbb */> {} +class foo2 < /* aaa */ A /* bbb */ = 2 /* bbb */> extends bar < /* aaa */ A /* bbb */> {} +interface bar < /* aaa */ A /* bbb */> extends bar2 < /* aaa */ A /* bbb */> {} +interface bar2 < /* aaa */ A /* bbb */ = 2 /* bbb */> extends bar < /* aaa */ A /* bbb */> {} diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index e5656e828934..64120d6a8d85 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -211,61 +211,37 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { } /** - * Converts a ts.Node's typeArguments ts.NodeArray to a flow-like typeParameters node + * Converts a ts.Node's typeArguments to TSTypeParameterInstantiation node * @param {ts.NodeArray} typeArguments ts.Node typeArguments * @returns {ESTreeNode} TypeParameterInstantiation node */ function convertTypeArgumentsToTypeParameters( typeArguments: ts.NodeArray ): ESTreeNode { - /** - * Even if typeArguments is an empty array, TypeScript sets a `pos` and `end` - * property on the array object so we can safely read the values here - */ - const start = typeArguments.pos - 1; - let end = typeArguments.end + 1; - if (typeArguments && typeArguments.length) { - const firstTypeArgument = typeArguments[0]; - const typeArgumentsParent = firstTypeArgument.parent; - /** - * In the case of the parent being a CallExpression or a TypeReference we have to use - * slightly different logic to calculate the correct end position - */ - if ( - typeArgumentsParent && - (typeArgumentsParent.kind === SyntaxKind.CallExpression || - typeArgumentsParent.kind === SyntaxKind.TypeReference) - ) { - const lastTypeArgument = typeArguments[typeArguments.length - 1]; - const greaterThanToken = findNextToken(lastTypeArgument, ast, ast); - end = greaterThanToken!.end; - } - } + const greaterThanToken = findNextToken(typeArguments, ast, ast)!; + return { type: AST_NODE_TYPES.TSTypeParameterInstantiation, - range: [start, end], - loc: getLocFor(start, end, ast), + range: [typeArguments.pos - 1, greaterThanToken.end], + loc: getLocFor(typeArguments.pos - 1, greaterThanToken.end, ast), params: typeArguments.map(typeArgument => convertChildType(typeArgument)) }; } /** - * Converts a ts.Node's typeParameters ts.ts.NodeArray to a flow-like TypeParameterDeclaration node + * Converts a ts.Node's typeParameters to TSTypeParameterDeclaration node * @param {ts.NodeArray} typeParameters ts.Node typeParameters * @returns {ESTreeNode} TypeParameterDeclaration node */ function convertTSTypeParametersToTypeParametersDeclaration( typeParameters: ts.NodeArray ): ESTreeNode { - const firstTypeParameter = typeParameters[0]; - const lastTypeParameter = typeParameters[typeParameters.length - 1]; - - const greaterThanToken = findNextToken(lastTypeParameter, ast, ast); + const greaterThanToken = findNextToken(typeParameters, ast, ast)!; return { type: AST_NODE_TYPES.TSTypeParameterDeclaration, - range: [firstTypeParameter.pos - 1, greaterThanToken!.end], - loc: getLocFor(firstTypeParameter.pos - 1, greaterThanToken!.end, ast), + range: [typeParameters.pos - 1, greaterThanToken.end], + loc: getLocFor(typeParameters.pos - 1, greaterThanToken.end, ast), params: typeParameters.map(typeParameter => convertChildType(typeParameter) ) diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index e1186e5638a5..768b79a8fd31 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -2129,6 +2129,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-parameters-comments.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-parameters-comments-heritage.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-reference-comments.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/typed-keyword-bigint.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index c374e397a6e8..90ebe3e137e0 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -66263,6 +66263,1793 @@ Object { } `; +exports[`typescript fixtures/basics/type-parameters-comments-heritage.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 72, + "line": 1, + }, + }, + "range": Array [ + 72, + 74, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 74, + ], + "superClass": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "name": "bar", + "range": Array [ + 43, + 46, + ], + "type": "Identifier", + }, + "superTypeParameters": Object { + "loc": Object { + "end": Object { + "column": 71, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 60, + "line": 1, + }, + "start": Object { + "column": 59, + "line": 1, + }, + }, + "range": Array [ + 59, + 60, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 60, + "line": 1, + }, + "start": Object { + "column": 59, + "line": 1, + }, + }, + "name": "A", + "range": Array [ + 59, + 60, + ], + "type": "Identifier", + }, + }, + ], + "range": Array [ + 47, + 71, + ], + "type": "TSTypeParameterInstantiation", + }, + "type": "ClassDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "name": "A", + "range": Array [ + 22, + 23, + ], + "type": "Identifier", + }, + "range": Array [ + 22, + 23, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 10, + 34, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + Object { + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 89, + "line": 2, + }, + "start": Object { + "column": 87, + "line": 2, + }, + }, + "range": Array [ + 162, + 164, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "name": "foo2", + "range": Array [ + 81, + 85, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 89, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 75, + 164, + ], + "superClass": Object { + "loc": Object { + "end": Object { + "column": 61, + "line": 2, + }, + "start": Object { + "column": 58, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 133, + 136, + ], + "type": "Identifier", + }, + "superTypeParameters": Object { + "loc": Object { + "end": Object { + "column": 86, + "line": 2, + }, + "start": Object { + "column": 62, + "line": 2, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 75, + "line": 2, + }, + "start": Object { + "column": 74, + "line": 2, + }, + }, + "range": Array [ + 149, + 150, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 75, + "line": 2, + }, + "start": Object { + "column": 74, + "line": 2, + }, + }, + "name": "A", + "range": Array [ + 149, + 150, + ], + "type": "Identifier", + }, + }, + ], + "range": Array [ + 137, + 161, + ], + "type": "TSTypeParameterInstantiation", + }, + "type": "ClassDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 49, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "params": Array [ + Object { + "default": Object { + "literal": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 37, + "line": 2, + }, + }, + "range": Array [ + 112, + 113, + ], + "raw": "2", + "type": "Literal", + "value": 2, + }, + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 37, + "line": 2, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "TSLiteralType", + }, + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "A", + "range": Array [ + 98, + 99, + ], + "type": "Identifier", + }, + "range": Array [ + 98, + 113, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 86, + 124, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + Object { + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 79, + "line": 3, + }, + "start": Object { + "column": 77, + "line": 3, + }, + }, + "range": Array [ + 242, + 244, + ], + "type": "TSInterfaceBody", + }, + "extends": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 51, + "line": 3, + }, + "start": Object { + "column": 47, + "line": 3, + }, + }, + "name": "bar2", + "range": Array [ + 212, + 216, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 76, + "line": 3, + }, + "start": Object { + "column": 47, + "line": 3, + }, + }, + "range": Array [ + 212, + 241, + ], + "type": "TSInterfaceHeritage", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 76, + "line": 3, + }, + "start": Object { + "column": 52, + "line": 3, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 65, + "line": 3, + }, + "start": Object { + "column": 64, + "line": 3, + }, + }, + "range": Array [ + 229, + 230, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 65, + "line": 3, + }, + "start": Object { + "column": 64, + "line": 3, + }, + }, + "name": "A", + "range": Array [ + 229, + 230, + ], + "type": "Identifier", + }, + }, + ], + "range": Array [ + 217, + 241, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + ], + "id": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "name": "bar", + "range": Array [ + 175, + 178, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 79, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 165, + 244, + ], + "type": "TSInterfaceDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 3, + }, + "start": Object { + "column": 14, + "line": 3, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "name": "A", + "range": Array [ + 191, + 192, + ], + "type": "Identifier", + }, + "range": Array [ + 191, + 192, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 179, + 203, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + Object { + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 93, + "line": 4, + }, + "start": Object { + "column": 91, + "line": 4, + }, + }, + "range": Array [ + 336, + 338, + ], + "type": "TSInterfaceBody", + }, + "extends": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 65, + "line": 4, + }, + "start": Object { + "column": 62, + "line": 4, + }, + }, + "name": "bar", + "range": Array [ + 307, + 310, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 90, + "line": 4, + }, + "start": Object { + "column": 62, + "line": 4, + }, + }, + "range": Array [ + 307, + 335, + ], + "type": "TSInterfaceHeritage", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 90, + "line": 4, + }, + "start": Object { + "column": 66, + "line": 4, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 79, + "line": 4, + }, + "start": Object { + "column": 78, + "line": 4, + }, + }, + "range": Array [ + 323, + 324, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 79, + "line": 4, + }, + "start": Object { + "column": 78, + "line": 4, + }, + }, + "name": "A", + "range": Array [ + 323, + 324, + ], + "type": "Identifier", + }, + }, + ], + "range": Array [ + 311, + 335, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + ], + "id": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 4, + }, + "start": Object { + "column": 10, + "line": 4, + }, + }, + "name": "bar2", + "range": Array [ + 255, + 259, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 93, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 4, + }, + }, + "range": Array [ + 245, + 338, + ], + "type": "TSInterfaceDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 4, + }, + "start": Object { + "column": 15, + "line": 4, + }, + }, + "params": Array [ + Object { + "default": Object { + "literal": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 41, + "line": 4, + }, + }, + "range": Array [ + 286, + 287, + ], + "raw": "2", + "type": "Literal", + "value": 2, + }, + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 41, + "line": 4, + }, + }, + "range": Array [ + 286, + 287, + ], + "type": "TSLiteralType", + }, + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 27, + "line": 4, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 4, + }, + "start": Object { + "column": 27, + "line": 4, + }, + }, + "name": "A", + "range": Array [ + 272, + 273, + ], + "type": "Identifier", + }, + "range": Array [ + 272, + 287, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 260, + 298, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 339, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 42, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "range": Array [ + 43, + 46, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 60, + "line": 1, + }, + "start": Object { + "column": 59, + "line": 1, + }, + }, + "range": Array [ + 59, + 60, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 71, + "line": 1, + }, + "start": Object { + "column": 70, + "line": 1, + }, + }, + "range": Array [ + 70, + 71, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 73, + "line": 1, + }, + "start": Object { + "column": 72, + "line": 1, + }, + }, + "range": Array [ + 72, + 73, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 73, + "line": 1, + }, + }, + "range": Array [ + 73, + 74, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 75, + 80, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 81, + 85, + ], + "type": "Identifier", + "value": "foo2", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 86, + 87, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 98, + 99, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 2, + }, + "start": Object { + "column": 35, + "line": 2, + }, + }, + "range": Array [ + 110, + 111, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 37, + "line": 2, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "Numeric", + "value": "2", + }, + Object { + "loc": Object { + "end": Object { + "column": 49, + "line": 2, + }, + "start": Object { + "column": 48, + "line": 2, + }, + }, + "range": Array [ + 123, + 124, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 57, + "line": 2, + }, + "start": Object { + "column": 50, + "line": 2, + }, + }, + "range": Array [ + 125, + 132, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 61, + "line": 2, + }, + "start": Object { + "column": 58, + "line": 2, + }, + }, + "range": Array [ + 133, + 136, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 63, + "line": 2, + }, + "start": Object { + "column": 62, + "line": 2, + }, + }, + "range": Array [ + 137, + 138, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 75, + "line": 2, + }, + "start": Object { + "column": 74, + "line": 2, + }, + }, + "range": Array [ + 149, + 150, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 86, + "line": 2, + }, + "start": Object { + "column": 85, + "line": 2, + }, + }, + "range": Array [ + 160, + 161, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 88, + "line": 2, + }, + "start": Object { + "column": 87, + "line": 2, + }, + }, + "range": Array [ + 162, + 163, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 89, + "line": 2, + }, + "start": Object { + "column": 88, + "line": 2, + }, + }, + "range": Array [ + 163, + 164, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 165, + 174, + ], + "type": "Keyword", + "value": "interface", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 175, + 178, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 3, + }, + "start": Object { + "column": 14, + "line": 3, + }, + }, + "range": Array [ + 179, + 180, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "range": Array [ + 191, + 192, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 3, + }, + "start": Object { + "column": 37, + "line": 3, + }, + }, + "range": Array [ + 202, + 203, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 3, + }, + "start": Object { + "column": 39, + "line": 3, + }, + }, + "range": Array [ + 204, + 211, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 51, + "line": 3, + }, + "start": Object { + "column": 47, + "line": 3, + }, + }, + "range": Array [ + 212, + 216, + ], + "type": "Identifier", + "value": "bar2", + }, + Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 3, + }, + "start": Object { + "column": 52, + "line": 3, + }, + }, + "range": Array [ + 217, + 218, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 65, + "line": 3, + }, + "start": Object { + "column": 64, + "line": 3, + }, + }, + "range": Array [ + 229, + 230, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 76, + "line": 3, + }, + "start": Object { + "column": 75, + "line": 3, + }, + }, + "range": Array [ + 240, + 241, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 78, + "line": 3, + }, + "start": Object { + "column": 77, + "line": 3, + }, + }, + "range": Array [ + 242, + 243, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 79, + "line": 3, + }, + "start": Object { + "column": 78, + "line": 3, + }, + }, + "range": Array [ + 243, + 244, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 4, + }, + }, + "range": Array [ + 245, + 254, + ], + "type": "Keyword", + "value": "interface", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 4, + }, + "start": Object { + "column": 10, + "line": 4, + }, + }, + "range": Array [ + 255, + 259, + ], + "type": "Identifier", + "value": "bar2", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 4, + }, + "start": Object { + "column": 15, + "line": 4, + }, + }, + "range": Array [ + 260, + 261, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 4, + }, + "start": Object { + "column": 27, + "line": 4, + }, + }, + "range": Array [ + 272, + 273, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 40, + "line": 4, + }, + "start": Object { + "column": 39, + "line": 4, + }, + }, + "range": Array [ + 284, + 285, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 41, + "line": 4, + }, + }, + "range": Array [ + 286, + 287, + ], + "type": "Numeric", + "value": "2", + }, + Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 4, + }, + "start": Object { + "column": 52, + "line": 4, + }, + }, + "range": Array [ + 297, + 298, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 61, + "line": 4, + }, + "start": Object { + "column": 54, + "line": 4, + }, + }, + "range": Array [ + 299, + 306, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 65, + "line": 4, + }, + "start": Object { + "column": 62, + "line": 4, + }, + }, + "range": Array [ + 307, + 310, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 67, + "line": 4, + }, + "start": Object { + "column": 66, + "line": 4, + }, + }, + "range": Array [ + 311, + 312, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 79, + "line": 4, + }, + "start": Object { + "column": 78, + "line": 4, + }, + }, + "range": Array [ + 323, + 324, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 90, + "line": 4, + }, + "start": Object { + "column": 89, + "line": 4, + }, + }, + "range": Array [ + 334, + 335, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 92, + "line": 4, + }, + "start": Object { + "column": 91, + "line": 4, + }, + }, + "range": Array [ + 336, + 337, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 93, + "line": 4, + }, + "start": Object { + "column": 92, + "line": 4, + }, + }, + "range": Array [ + 337, + 338, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/type-reference-comments.src 1`] = ` Object { "body": Array [ From 9f501a1dce558457ca40b6e9f6a851709b296ed3 Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 23 Jan 2019 00:49:23 +0100 Subject: [PATCH 33/88] feat(eslint-plugin): add option to no-object-literal-type-assertion rule (#87) --- .../rules/no-object-literal-type-assertion.md | 6 ++- .../rules/no-object-literal-type-assertion.js | 31 ++++++++++++++- .../rules/no-object-literal-type-assertion.js | 38 ++++++++++++++++++- 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md b/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md index fe25f8f64107..b81ae0d87b69 100644 --- a/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md @@ -20,9 +20,11 @@ const z = { ... } as unknown; ## Options -```json +```cjson { - "@typescript-eslint/no-object-literal-type-assertion": "error" + "@typescript-eslint/no-object-literal-type-assertion": ["error", { + allowAsParameter: false // Allow type assertion in call and new expression, default false + }] } ``` diff --git a/packages/eslint-plugin/lib/rules/no-object-literal-type-assertion.js b/packages/eslint-plugin/lib/rules/no-object-literal-type-assertion.js index f98a28a38f0c..11258a99315f 100644 --- a/packages/eslint-plugin/lib/rules/no-object-literal-type-assertion.js +++ b/packages/eslint-plugin/lib/rules/no-object-literal-type-assertion.js @@ -10,6 +10,12 @@ const util = require('../util'); // Rule Definition //------------------------------------------------------------------------------ +const defaultOptions = [ + { + allowAsParameter: false + } +]; + module.exports = { meta: { type: 'problem', @@ -25,9 +31,24 @@ module.exports = { unexpectedTypeAssertion: 'Type assertion on object literals is forbidden, use a type annotation instead.' }, - schema: [] + schema: [ + { + type: 'object', + additionalProperties: false, + properties: { + allowAsParameter: { + type: 'boolean' + } + } + } + ] }, create(context) { + const { allowAsParameter } = util.applyDefault( + defaultOptions, + context.options + )[0]; + //---------------------------------------------------------------------- // Public //---------------------------------------------------------------------- @@ -52,6 +73,14 @@ module.exports = { return { 'TSTypeAssertion, TSAsExpression'(node) { + if ( + allowAsParameter && + (node.parent.type === 'NewExpression' || + node.parent.type === 'CallExpression') + ) { + return; + } + if ( checkType(node.typeAnnotation) && node.expression.type === 'ObjectExpression' diff --git a/packages/eslint-plugin/tests/lib/rules/no-object-literal-type-assertion.js b/packages/eslint-plugin/tests/lib/rules/no-object-literal-type-assertion.js index 2a037390e0b5..aa19b09e8601 100644 --- a/packages/eslint-plugin/tests/lib/rules/no-object-literal-type-assertion.js +++ b/packages/eslint-plugin/tests/lib/rules/no-object-literal-type-assertion.js @@ -39,7 +39,23 @@ ruleTester.run('no-object-literal-type-assertion', rule, { `const foo = {};`, // Allow cast to 'unknown' `const foo = {} as unknown;`, - `const foo = {};` + `const foo = {};`, + { + code: `print({ bar: 5 } as Foo)`, + options: [ + { + allowAsParameter: true + } + ] + }, + { + code: `new print({ bar: 5 } as Foo)`, + options: [ + { + allowAsParameter: true + } + ] + } ], invalid: [ { @@ -71,6 +87,26 @@ ruleTester.run('no-object-literal-type-assertion', rule, { column: 11 } ] + }, + { + code: `print({ bar: 5 } as Foo)`, + errors: [ + { + messageId: 'unexpectedTypeAssertion', + line: 1, + column: 7 + } + ] + }, + { + code: `new print({ bar: 5 } as Foo)`, + errors: [ + { + messageId: 'unexpectedTypeAssertion', + line: 1, + column: 11 + } + ] } ] }); From da7e91e1b3e6f90d51bf3442e9c2771af1d61118 Mon Sep 17 00:00:00 2001 From: James Henry Date: Tue, 22 Jan 2019 19:01:11 -0500 Subject: [PATCH 34/88] chore: publish v1.1.0 --- CHANGELOG.md | 14 ++++++++++++++ lerna.json | 2 +- packages/eslint-plugin-tslint/CHANGELOG.md | 4 ++++ packages/eslint-plugin-tslint/package.json | 4 ++-- packages/eslint-plugin/CHANGELOG.md | 12 ++++++++++++ packages/eslint-plugin/package.json | 4 ++-- packages/parser/CHANGELOG.md | 7 +++++++ packages/parser/package.json | 6 +++--- packages/shared-fixtures/CHANGELOG.md | 11 +++++++++++ packages/shared-fixtures/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 7 +++++++ packages/typescript-estree/package.json | 4 ++-- 12 files changed, 66 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c87104215644..6fbb5db67f5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.0.0...v1.1.0) (2019-01-23) + +### Bug Fixes + +- **eslint-plugin:** don’t mark `declare class` as unused ([#110](https://github.com/typescript-eslint/typescript-eslint/issues/110)) ([5841cd2](https://github.com/typescript-eslint/typescript-eslint/commit/5841cd2)), closes [#106](https://github.com/typescript-eslint/typescript-eslint/issues/106) +- **eslint-plugin:** improve detection of used vars in heritage ([#102](https://github.com/typescript-eslint/typescript-eslint/issues/102)) ([193b434](https://github.com/typescript-eslint/typescript-eslint/commit/193b434)) +- **typescript-estree:** correct range of parameters with comments ([#128](https://github.com/typescript-eslint/typescript-eslint/issues/128)) ([91eedf2](https://github.com/typescript-eslint/typescript-eslint/commit/91eedf2)) +- **typescript-estree:** fix range of assignment in parameter ([#115](https://github.com/typescript-eslint/typescript-eslint/issues/115)) ([4e781f1](https://github.com/typescript-eslint/typescript-eslint/commit/4e781f1)) + +### Features + +- **eslint-plugin:** add new rule restrict-plus-operands ([#70](https://github.com/typescript-eslint/typescript-eslint/issues/70)) ([c541ede](https://github.com/typescript-eslint/typescript-eslint/commit/c541ede)) +- **eslint-plugin:** add option to no-object-literal-type-assertion rule ([#87](https://github.com/typescript-eslint/typescript-eslint/issues/87)) ([9f501a1](https://github.com/typescript-eslint/typescript-eslint/commit/9f501a1)) + # [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) ### Bug Fixes diff --git a/lerna.json b/lerna.json index c416cf72769b..844b711bb0fe 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.0", + "version": "1.1.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index a95c7b88cb36..6b4306f26855 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.0.0...v1.1.0) (2019-01-23) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + # [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 9c0668115ecc..fbe9ea5521e0 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "1.0.0", + "version": "1.1.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -33,6 +33,6 @@ "devDependencies": { "@types/eslint": "^4.16.3", "@types/lodash.memoize": "^4.1.4", - "@typescript-eslint/parser": "1.0.0" + "@typescript-eslint/parser": "1.1.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 188e6b07bec3..39a512dab49e 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.0.0...v1.1.0) (2019-01-23) + +### Bug Fixes + +- **eslint-plugin:** don’t mark `declare class` as unused ([#110](https://github.com/typescript-eslint/typescript-eslint/issues/110)) ([5841cd2](https://github.com/typescript-eslint/typescript-eslint/commit/5841cd2)), closes [#106](https://github.com/typescript-eslint/typescript-eslint/issues/106) +- **eslint-plugin:** improve detection of used vars in heritage ([#102](https://github.com/typescript-eslint/typescript-eslint/issues/102)) ([193b434](https://github.com/typescript-eslint/typescript-eslint/commit/193b434)) + +### Features + +- **eslint-plugin:** add new rule restrict-plus-operands ([#70](https://github.com/typescript-eslint/typescript-eslint/issues/70)) ([c541ede](https://github.com/typescript-eslint/typescript-eslint/commit/c541ede)) +- **eslint-plugin:** add option to no-object-literal-type-assertion rule ([#87](https://github.com/typescript-eslint/typescript-eslint/issues/87)) ([9f501a1](https://github.com/typescript-eslint/typescript-eslint/commit/9f501a1)) + # [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) ### Bug Fixes diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 34d125380e4c..7cd6f21b1ab3 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "1.0.0", + "version": "1.1.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -24,7 +24,7 @@ "recommended:update": "node tools/update-recommended.js" }, "dependencies": { - "@typescript-eslint/parser": "1.0.0", + "@typescript-eslint/parser": "1.1.0", "requireindex": "^1.2.0" }, "devDependencies": { diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index 1e519885b94a..3c8b8d4e4efc 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.0.0...v1.1.0) (2019-01-23) + +### Bug Fixes + +- **typescript-estree:** correct range of parameters with comments ([#128](https://github.com/typescript-eslint/typescript-eslint/issues/128)) ([91eedf2](https://github.com/typescript-eslint/typescript-eslint/commit/91eedf2)) +- **typescript-estree:** fix range of assignment in parameter ([#115](https://github.com/typescript-eslint/typescript-eslint/issues/115)) ([4e781f1](https://github.com/typescript-eslint/typescript-eslint/commit/4e781f1)) + # [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) ### Features diff --git a/packages/parser/package.json b/packages/parser/package.json index be34576e324c..23fe47afce3f 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "1.0.0", + "version": "1.1.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/parser.js", "files": [ @@ -36,7 +36,7 @@ "typescript": "*" }, "dependencies": { - "@typescript-eslint/typescript-estree": "1.0.0", + "@typescript-eslint/typescript-estree": "1.1.0", "eslint-scope": "^4.0.0", "eslint-visitor-keys": "^1.0.0" }, @@ -44,6 +44,6 @@ "@types/eslint": "^4.16.5", "@types/eslint-visitor-keys": "^1.0.0", "@types/estree": "^0.0.39", - "@typescript-eslint/shared-fixtures": "1.0.0" + "@typescript-eslint/shared-fixtures": "1.1.0" } } diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index 2b7402f262e4..3114aaabc99c 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.0.0...v1.1.0) (2019-01-23) + + +### Bug Fixes + +* **typescript-estree:** correct range of parameters with comments ([#128](https://github.com/typescript-eslint/typescript-eslint/issues/128)) ([91eedf2](https://github.com/typescript-eslint/typescript-eslint/commit/91eedf2)) + + + + + # [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index 4478df0606e9..2424070165f4 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "1.0.0", + "version": "1.1.0", "private": true } diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index 39323d365fd7..be11f821f745 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.0.0...v1.1.0) (2019-01-23) + +### Bug Fixes + +- **typescript-estree:** correct range of parameters with comments ([#128](https://github.com/typescript-eslint/typescript-eslint/issues/128)) ([91eedf2](https://github.com/typescript-eslint/typescript-eslint/commit/91eedf2)) +- **typescript-estree:** fix range of assignment in parameter ([#115](https://github.com/typescript-eslint/typescript-eslint/issues/115)) ([4e781f1](https://github.com/typescript-eslint/typescript-eslint/commit/4e781f1)) + # [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) ### Features diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 10d0639be1f4..a8490f513a68 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "1.0.0", + "version": "1.1.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/parser.js", "files": [ @@ -41,7 +41,7 @@ "typescript": "*" }, "devDependencies": { - "@typescript-eslint/shared-fixtures": "1.0.0", + "@typescript-eslint/shared-fixtures": "1.1.0", "typescript": "~3.2.1" } } From 7ed099706d1175bb92b9422a4c71f7e81420ddc2 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Wed, 23 Jan 2019 07:51:47 -0500 Subject: [PATCH 35/88] docs(eslint-plugin): update rule names in the roadmap (#108) --- packages/eslint-plugin/ROADMAP.md | 144 +++++++++++++++--------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/packages/eslint-plugin/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md index eb0cf5e33ec4..1fce16992a9c 100644 --- a/packages/eslint-plugin/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -10,30 +10,30 @@ ### TypeScript-specific -| TSLint rule | | ESLint rule | -| --------------------------------- | :-: | -------------------------------------------- | -| [`adjacent-overload-signatures`] | ✅ | [`typescript/adjacent-overload-signatures`] | -| [`ban-types`] | ✅ | [`typescript/ban-types`] | -| [`member-access`] | ✅ | [`typescript/explicit-member-accessibility`] | -| [`member-ordering`] | ✅ | [`typescript/member-ordering`] | -| [`no-any`] | ✅ | [`typescript/no-explicit-any`] | -| [`no-empty-interface`] | ✅ | [`typescript/no-empty-interface`] | -| [`no-import-side-effect`] | 🔌 | [`import/no-unassigned-import`] | -| [`no-inferrable-types`] | ✅ | [`typescript/no-inferrable-types`] | -| [`no-internal-module`] | ✅ | [`typescript/prefer-namespace-keyword`] | -| [`no-magic-numbers`] | 🌟 | [`no-magic-numbers`][no-magic-numbers] | -| [`no-namespace`] | ✅ | [`typescript/no-namespace`] | -| [`no-non-null-assertion`] | ✅ | [`typescript/no-non-null-assertion`] | -| [`no-parameter-reassignment`] | ✅ | [`no-param-reassign`][no-param-reassign] | -| [`no-reference`] | ✅ | [`typescript/no-triple-slash-reference`] | -| [`no-unnecessary-type-assertion`] | 🛑 | N/A | -| [`no-var-requires`] | ✅ | [`typescript/no-var-requires`] | -| [`only-arrow-functions`] | 🔌 | [`prefer-arrow/prefer-arrow-functions`] | -| [`prefer-for-of`] | 🛑 | N/A | -| [`promise-function-async`] | 🛑 | N/A ([relevant plugin][plugin:promise]) | -| [`typedef`] | 🛑 | N/A | -| [`typedef-whitespace`] | ✅ | [`typescript/type-annotation-spacing`] | -| [`unified-signatures`] | 🛑 | N/A | +| TSLint rule | | ESLint rule | +| --------------------------------- | :-: | ---------------------------------------------------- | +| [`adjacent-overload-signatures`] | ✅ | [`@typescript-eslint/adjacent-overload-signatures`] | +| [`ban-types`] | ✅ | [`@typescript-eslint/ban-types`] | +| [`member-access`] | ✅ | [`@typescript-eslint/explicit-member-accessibility`] | +| [`member-ordering`] | ✅ | [`@typescript-eslint/member-ordering`] | +| [`no-any`] | ✅ | [`@typescript-eslint/no-explicit-any`] | +| [`no-empty-interface`] | ✅ | [`@typescript-eslint/no-empty-interface`] | +| [`no-import-side-effect`] | 🔌 | [`import/no-unassigned-import`] | +| [`no-inferrable-types`] | ✅ | [`@typescript-eslint/no-inferrable-types`] | +| [`no-internal-module`] | ✅ | [`@typescript-eslint/prefer-namespace-keyword`] | +| [`no-magic-numbers`] | 🌟 | [`no-magic-numbers`][no-magic-numbers] | +| [`no-namespace`] | ✅ | [`@typescript-eslint/no-namespace`] | +| [`no-non-null-assertion`] | ✅ | [`@typescript-eslint/no-non-null-assertion`] | +| [`no-parameter-reassignment`] | ✅ | [`no-param-reassign`][no-param-reassign] | +| [`no-reference`] | ✅ | [`@typescript-eslint/no-triple-slash-reference`] | +| [`no-unnecessary-type-assertion`] | 🛑 | N/A | +| [`no-var-requires`] | ✅ | [`@typescript-eslint/no-var-requires`] | +| [`only-arrow-functions`] | 🔌 | [`prefer-arrow/prefer-arrow-functions`] | +| [`prefer-for-of`] | 🛑 | N/A | +| [`promise-function-async`] | 🛑 | N/A ([relevant plugin][plugin:promise]) | +| [`typedef`] | 🛑 | N/A | +| [`typedef-whitespace`] | ✅ | [`@typescript-eslint/type-annotation-spacing`] | +| [`unified-signatures`] | 🛑 | N/A | ### Functionality @@ -64,9 +64,9 @@ | [`no-inferred-empty-object-type`] | 🛑 | N/A | | [`no-invalid-template-strings`] | 🌟 | [`no-template-curly-in-string`][no-template-curly-in-string] | | [`no-invalid-this`] | 🌟 | [`no-invalid-this`][no-invalid-this] | -| [`no-misused-new`] | ✅ | [`typescript/no-misused-new`] | +| [`no-misused-new`] | ✅ | [`@typescript-eslint/no-misused-new`] | | [`no-null-keyword`] | 🔌 | [`no-null/no-null`] (doesn’t handle `null` type) | -| [`no-object-literal-type-assertion`] | ✅ | [`typescript/no-object-literal-type-assertion`] | +| [`no-object-literal-type-assertion`] | ✅ | [`@typescript-eslint/no-object-literal-type-assertion`] | | [`no-return-await`] | 🌟 | [`no-return-await`][no-return-await] | | [`no-shadowed-variable`] | 🌟 | [`no-shadow`][no-shadow] | | [`no-sparse-arrays`] | 🌟 | [`no-sparse-arrays`][no-sparse-arrays] | @@ -74,14 +74,14 @@ | [`no-string-throw`] | 🌟 | [`no-throw-literal`][no-throw-literal] | | [`no-submodule-imports`] | 🌓 | [`import/no-internal-modules`] (slightly different) | | [`no-switch-case-fall-through`] | 🌟 | [`no-fallthrough`][no-fallthrough] | -| [`no-this-assignment`] | ✅ | [`typescript/no-this-alias`] | +| [`no-this-assignment`] | ✅ | [`@typescript-eslint/no-this-alias`] | | [`no-unbound-method`] | 🛑 | N/A | -| [`no-unnecessary-class`] | ✅ | [`typescript/no-extraneous-class`] | +| [`no-unnecessary-class`] | ✅ | [`@typescript-eslint/no-extraneous-class`] | | [`no-unsafe-any`] | 🛑 | N/A | | [`no-unsafe-finally`] | 🌟 | [`no-unsafe-finally`][no-unsafe-finally] | | [`no-unused-expression`] | 🌟 | [`no-unused-expression`][no-unused-expressions] | | [`no-unused-variable`] | 🌓 | [`no-unused-vars`][no-unused-vars] [2] | -| [`no-use-before-declare`] | ✅ | [`typescript/no-use-before-define`] | +| [`no-use-before-declare`] | ✅ | [`@typescript-eslint/no-use-before-define`] | | [`no-var-keyword`] | 🌟 | [`no-var`][no-var] | | [`no-void-expression`] | 🌟 | [`no-void`][no-void] | | [`prefer-conditional-expression`] | 🛑 | N/A | @@ -97,7 +97,7 @@ | [`use-isnan`] | 🌟 | [`use-isnan`][use-isnan] | [1] The ESLint rule also supports silencing with an extra set of parens (`if ((foo = bar)) {}`) -[2] Missing private class member support. [`typescript/no-unused-vars`] adds support for some TS-specific features. +[2] Missing private class member support. [`@typescript-eslint/no-unused-vars`] adds support for some TS-specific features. ### Maintainability @@ -106,7 +106,7 @@ | [`cyclomatic-complexity`] | 🌟 | [`complexity`][complexity] | | [`deprecation`] | 🌓 | [`import/no-deprecated`] [1] | | [`eofline`] | 🌟 | [`eol-last`][eol-last] | -| [`indent`] | ✅ | [`typescript/indent`] or [Prettier] | +| [`indent`] | ✅ | [`@typescript-eslint/indent`] or [Prettier] | | [`linebreak-style`] | 🌟 | [`linebreak-style`][linebreak-style] or [Prettier] | | [`max-classes-per-file`] | 🌟 | [`max-classes-per-file`][max-classes-per-file] | | [`max-file-line-count`] | 🌟 | [`max-lines`][max-lines] | @@ -128,30 +128,30 @@ | TSLint rule | | ESLint rule | | ----------------------------------- | :-: | ----------------------------------------------------------------------------------- | | [`align`] | 🛑 | N/A | -| [`array-type`] | ✅ | [`typescript/array-type`] | +| [`array-type`] | ✅ | [`@typescript-eslint/array-type`] | | [`arrow-parens`] | 🌟 | [`arrow-parens`][arrow-parens] | | [`arrow-return-shorthand`] | 🌟 | [`arrow-body-style`][arrow-body-style] | | [`binary-expression-operand-order`] | 🌟 | [`yoda`][yoda] | | [`callable-types`] | 🛑 | N/A | -| [`class-name`] | ✅ | [`typescript/class-name-casing`] | +| [`class-name`] | ✅ | [`@typescript-eslint/class-name-casing`] | | [`comment-format`] | 🌟 | [`capitalized-comments`][capitalized-comments] & [`spaced-comment`][spaced-comment] | | [`completed-docs`] | 🔌 | [`eslint-plugin-jsdoc`][plugin:jsdoc] | | [`encoding`] | 🛑 | N/A | | [`file-header`] | 🔌 | [`eslint-plugin-header`][plugin:header] or [`-file-header`][plugin:file-header] | | [`file-name-casing`] | 🔌 | [`unicorn/filename-case`] | | [`import-spacing`] | 🔌 | Use [Prettier] | -| [`interface-name`] | ✅ | [`typescript/interface-name-prefix`] | -| [`interface-over-type-literal`] | ✅ | [`typescript/prefer-interface`] | +| [`interface-name`] | ✅ | [`@typescript-eslint/interface-name-prefix`] | +| [`interface-over-type-literal`] | ✅ | [`@typescript-eslint/prefer-interface`] | | [`jsdoc-format`] | 🌓 | [`valid-jsdoc`][valid-jsdoc] or [`eslint-plugin-jsdoc`][plugin:jsdoc] | | [`match-default-export-name`] | 🛑 | N/A | | [`newline-before-return`] | 🌟 | [`padding-line-between-statements`][padding-line-between-statements] [1] | | [`newline-per-chained-call`] | 🌟 | [`newline-per-chained-call`][newline-per-chained-call] | | [`new-parens`] | 🌟 | [`new-parens`][new-parens] | -| [`no-angle-bracket-type-assertion`] | ✅ | [`typescript/no-angle-bracket-type-assertion`] | +| [`no-angle-bracket-type-assertion`] | ✅ | [`@typescript-eslint/no-angle-bracket-type-assertion`] | | [`no-boolean-literal-compare`] | 🛑 | N/A | | [`no-consecutive-blank-lines`] | 🌟 | [`no-multiple-empty-lines`][no-multiple-empty-lines] | | [`no-irregular-whitespace`] | 🌟 | [`no-irregular-whitespace`][no-irregular-whitespace] with `skipStrings: false` | -| [`no-parameter-properties`] | ✅ | [`typescript/no-parameter-properties`] | +| [`no-parameter-properties`] | ✅ | [`@typescript-eslint/no-parameter-properties`] | | [`no-redundant-jsdoc`] | 🛑 | N/A ([open issue](https://github.com/gajus/eslint-plugin-jsdoc/issues/134)) | | [`no-reference-import`] | 🛑 | N/A | | [`no-trailing-whitespace`] | 🌟 | [`no-trailing-spaces`][no-trailing-spaces] | @@ -175,12 +175,12 @@ | [`space-before-function-paren`] | 🌟 | [`space-before-function-paren`][space-after-function-paren] | | [`space-within-parens`] | 🌟 | [`space-in-parens`][space-in-parens] | | [`switch-final-break`] | 🛑 | N/A | -| [`type-literal-delimiter`] | ✅ | [`typescript/member-delimiter-style`] | +| [`type-literal-delimiter`] | ✅ | [`@typescript-eslint/member-delimiter-style`] | | [`variable-name`] | 🌟 | [2] | | [`whitespace`] | 🔌 | Use [Prettier] | [1] Recommended config: `["error", { blankLine: "always", prev: "*", next: "return" }]` -[2] [`camelcase`][camelcase], [`no-underscore-dangle`][no-underscore-dangle], [`id-blacklist`][id-blacklist], and/or [`id-match`] +[2] [`camelcase`][camelcase], [`no-underscore-dangle`][no-underscore-dangle], [`id-blacklist`][id-blacklist], and/or [`id-match`][id-match] ## tslint-microsoft-contrib rules @@ -200,10 +200,10 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- ### TypeScript -| tslint-microsoft-contrib rule | | ESLint rule | -| ----------------------------- | :-: | -------------------------------------------------- | -| `prefer-array-literal` | 🌓 | [`typescript/no-array-constructor`] [1] | -| `prefer-type-cast` | 🛑 | N/A | +| tslint-microsoft-contrib rule | | ESLint rule | +| ----------------------------- | :-: | ---------------------------------------------------------- | +| `prefer-array-literal` | 🌓 | [`@typescript-eslint/no-array-constructor`] [1] | +| `prefer-type-cast` | 🛑 | N/A | [1] ESLint rule is slightly less strict, allowing `new Array()` and `Array(2)`. @@ -282,7 +282,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- | `no-exec-script` | 🌓 | Use [`no-restricted-syntax`][no-restricted-syntax] | | `no-jquery-raw-elements` | 🛑 | N/A | | `no-unsupported-browser-code` | 🔌 | [`eslint-plugin-compat`][plugin:compat] | -| `react-this-binding-issue` | 🛑 | | +| `react-this-binding-issue` | 🛑 | N/A | | `react-tsx-curly-spacing` | 🔌 | [`react/jsx-curly-spacing`] | | `react-unused-props-and-state` | 🌓 | [`react/no-unused-state`] | @@ -557,34 +557,34 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- -[`typescript/adjacent-overload-signatures`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/adjacent-overload-signatures.md -[`typescript/ban-types`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/ban-types.md -[`typescript/explicit-member-accessibility`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/explicit-member-accessibility.md -[`typescript/member-ordering`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/member-ordering.md -[`typescript/no-explicit-any`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-explicit-any.md -[`typescript/no-empty-interface`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-empty-interface.md -[`typescript/no-inferrable-types`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-inferrable-types.md -[`typescript/prefer-namespace-keyword`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/prefer-namespace-keyword.md -[`typescript/no-namespace`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-namespace.md -[`typescript/no-non-null-assertion`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-non-null-assertion.md -[`typescript/no-triple-slash-reference`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-triple-slash-reference.md -[`typescript/no-var-requires`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-var-requires.md -[`typescript/type-annotation-spacing`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/type-annotation-spacing.md -[`typescript/no-misused-new`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-misused-new.md -[`typescript/no-object-literal-type-assertion`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-object-literal-type-assertion.md -[`typescript/no-this-alias`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-this-alias.md -[`typescript/no-extraneous-class`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-extraneous-class.md -[`typescript/no-unused-vars`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-unused-vars.md -[`typescript/no-use-before-define`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-use-before-define.md -[`typescript/indent`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/indent.md -[`typescript/array-type`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/array-type.md -[`typescript/class-name-casing`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/class-name-casing.md -[`typescript/interface-name-prefix`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/interface-name-prefix.md -[`typescript/no-angle-bracket-type-assertion`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-angle-bracket-type-assertion.md -[`typescript/no-parameter-properties`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-parameter-properties.md -[`typescript/member-delimiter-style`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/member-delimiter-style.md -[`typescript/prefer-interface`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/prefer-interface.md -[`typescript/no-array-constructor`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-array-constructor.md +[`@typescript-eslint/adjacent-overload-signatures`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/adjacent-overload-signatures.md +[`@typescript-eslint/ban-types`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/ban-types.md +[`@typescript-eslint/explicit-member-accessibility`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/explicit-member-accessibility.md +[`@typescript-eslint/member-ordering`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/member-ordering.md +[`@typescript-eslint/no-explicit-any`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-explicit-any.md +[`@typescript-eslint/no-empty-interface`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-empty-interface.md +[`@typescript-eslint/no-inferrable-types`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-inferrable-types.md +[`@typescript-eslint/prefer-namespace-keyword`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/prefer-namespace-keyword.md +[`@typescript-eslint/no-namespace`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-namespace.md +[`@typescript-eslint/no-non-null-assertion`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-non-null-assertion.md +[`@typescript-eslint/no-triple-slash-reference`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-triple-slash-reference.md +[`@typescript-eslint/no-var-requires`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-var-requires.md +[`@typescript-eslint/type-annotation-spacing`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/type-annotation-spacing.md +[`@typescript-eslint/no-misused-new`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-misused-new.md +[`@typescript-eslint/no-object-literal-type-assertion`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-object-literal-type-assertion.md +[`@typescript-eslint/no-this-alias`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-this-alias.md +[`@typescript-eslint/no-extraneous-class`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-extraneous-class.md +[`@typescript-eslint/no-unused-vars`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-unused-vars.md +[`@typescript-eslint/no-use-before-define`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-use-before-define.md +[`@typescript-eslint/indent`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/indent.md +[`@typescript-eslint/array-type`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/array-type.md +[`@typescript-eslint/class-name-casing`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/class-name-casing.md +[`@typescript-eslint/interface-name-prefix`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/interface-name-prefix.md +[`@typescript-eslint/no-angle-bracket-type-assertion`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-angle-bracket-type-assertion.md +[`@typescript-eslint/no-parameter-properties`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-parameter-properties.md +[`@typescript-eslint/member-delimiter-style`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/member-delimiter-style.md +[`@typescript-eslint/prefer-interface`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/prefer-interface.md +[`@typescript-eslint/no-array-constructor`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-array-constructor.md From ba8ebb262e202103087b53c2ce3ca72c33743773 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Wed, 23 Jan 2019 05:04:10 -0800 Subject: [PATCH 36/88] chore: add vscode shared config files (#126) --- .gitignore | 1 - .vscode/extensions.json | 8 ++++++++ .vscode/launch.json | 21 +++++++++++++++++++++ .vscode/settings.json | 26 ++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 213ae9c36aa4..41847c7fd604 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,5 @@ typings/ .next .DS_Store -.vscode .idea dist diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000000..0a2e1c827047 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "esbenp.prettier-vscode", + "dbaeumer.vscode-eslint", + "editorconfig.editorconfig" + ], + "unwantedRecommendations": ["hookyqr.beautify", "dbaeumer.jshint"] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000000..18bf27ada556 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Jest Test Current eslint-plugin Rule", + "cwd": "${workspaceFolder}/packages/eslint-plugin/", + "program": "${workspaceFolder}/node_modules/jest/bin/jest.js", + "args": [ + "--colors", + "${workspaceFolder}/packages/eslint-plugin/tests/lib/rules/${fileBasename}" + ], + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000000..adcf2422e8f3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,26 @@ + +{ + // An array of language ids which should be validated by ESLint + "eslint.validate": [ + "javascript", + "javascriptreact", + { + "language": "typescript", + "autoFix": true + }, + { + "language": "typescriptreact", + "autoFix": true + } + ], + + // When enabled, will trim trailing whitespace when saving a file. + "files.trimTrailingWhitespace": true, + + // typescript auto-format settings + "typescript.tsdk": "node_modules/typescript/lib", + "javascript.preferences.importModuleSpecifier": "auto", + "typescript.preferences.importModuleSpecifier": "auto", + "javascript.preferences.quoteStyle": "single", + "typescript.preferences.quoteStyle": "single" +} From aa9d1e175c8dc6fc4b8c4db47648120478a71ba7 Mon Sep 17 00:00:00 2001 From: James Henry Date: Wed, 23 Jan 2019 08:54:50 -0500 Subject: [PATCH 37/88] fix(eslint-plugin): make parser services error clearer (#132) --- packages/eslint-plugin/README.md | 89 +++++++++++-------- packages/eslint-plugin/lib/util.js | 6 +- .../tests/lib/rules/restrict-plus-operands.js | 1 - packages/parser/README.md | 11 ++- 4 files changed, 68 insertions(+), 39 deletions(-) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 108dd0f994be..4f6f771d47c4 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -51,6 +51,23 @@ You can also enable all the recommended rules at once. Add `plugin:@typescript-e } ``` +If you want to use rules which require type information, you will need to specify a path to your tsconfig.json file in the "project" property of "parserOptions". + +```json +{ + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "./tsconfig.json" + }, + "plugins": ["@typescript-eslint"], + "rules": { + "@typescript-eslint/restrict-plus-operands": "error" + } +} +``` + +See [@typescript-eslint/parser's README.md](../parser/README.md) for more information on the available "parserOptions". + ## Supported Rules @@ -59,41 +76,41 @@ You can also enable all the recommended rules at once. Add `plugin:@typescript-e **Key**: :heavy_check_mark: = recommended, :wrench: = fixable -| Name | Description | :heavy_check_mark: | :wrench: | -| ---- | ----------- | ------------------ | -------- | -| [`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array` for arrays (`array-type` from TSLint) | :heavy_check_mark: | :wrench: | -| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Enforces that types will not to be used (`ban-types` from TSLint) | :heavy_check_mark: | :wrench: | -| [`@typescript-eslint/camelcase`](./docs/rules/camelcase.md) | Enforce camelCase naming convention | :heavy_check_mark: | | -| [`@typescript-eslint/class-name-casing`](./docs/rules/class-name-casing.md) | Require PascalCased class and interface names (`class-name` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | :heavy_check_mark: | | -| [`@typescript-eslint/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods (`member-access` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/generic-type-naming`](./docs/rules/generic-type-naming.md) | Enforces naming of generic type variables | | | -| [`@typescript-eslint/indent`](./docs/rules/indent.md) | Enforce consistent indentation (`indent` from TSLint) | :heavy_check_mark: | :wrench: | -| [`@typescript-eslint/interface-name-prefix`](./docs/rules/interface-name-prefix.md) | Require that interface names be prefixed with `I` (`interface-name` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | :heavy_check_mark: | :wrench: | -| [`@typescript-eslint/member-naming`](./docs/rules/member-naming.md) | Enforces naming conventions for class members by visibility. | | | -| [`@typescript-eslint/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order (`member-ordering` from TSLint) | | | -| [`@typescript-eslint/no-angle-bracket-type-assertion`](./docs/rules/no-angle-bracket-type-assertion.md) | Enforces the use of `as Type` assertions instead of `` assertions (`no-angle-bracket-type-assertion` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :heavy_check_mark: | :wrench: | -| [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type (`no-any` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) | | | -| [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (`no-inferrable-types` from TSLint) | :heavy_check_mark: | :wrench: | -| [`@typescript-eslint/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md) | Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/no-parameter-properties`](./docs/rules/no-parameter-properties.md) | Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | | -| [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// ` comments (`no-reference` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | | -| [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | | -| [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | | -| [`@typescript-eslint/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: | -| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: | -| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string. (`restrict-plus-operands` from TSLint) | | | -| [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: | +| Name | Description | :heavy_check_mark: | :wrench: | +| --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -------- | +| [`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array` for arrays (`array-type` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Enforces that types will not to be used (`ban-types` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/camelcase`](./docs/rules/camelcase.md) | Enforce camelCase naming convention | :heavy_check_mark: | | +| [`@typescript-eslint/class-name-casing`](./docs/rules/class-name-casing.md) | Require PascalCased class and interface names (`class-name` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | :heavy_check_mark: | | +| [`@typescript-eslint/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods (`member-access` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/generic-type-naming`](./docs/rules/generic-type-naming.md) | Enforces naming of generic type variables | | | +| [`@typescript-eslint/indent`](./docs/rules/indent.md) | Enforce consistent indentation (`indent` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/interface-name-prefix`](./docs/rules/interface-name-prefix.md) | Require that interface names be prefixed with `I` (`interface-name` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/member-naming`](./docs/rules/member-naming.md) | Enforces naming conventions for class members by visibility. | | | +| [`@typescript-eslint/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order (`member-ordering` from TSLint) | | | +| [`@typescript-eslint/no-angle-bracket-type-assertion`](./docs/rules/no-angle-bracket-type-assertion.md) | Enforces the use of `as Type` assertions instead of `` assertions (`no-angle-bracket-type-assertion` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type (`no-any` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) | | | +| [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (`no-inferrable-types` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md) | Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-parameter-properties`](./docs/rules/no-parameter-properties.md) | Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | | +| [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// ` comments (`no-reference` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | | +| [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | | +| [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string. (`restrict-plus-operands` from TSLint) | | | +| [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: | diff --git a/packages/eslint-plugin/lib/util.js b/packages/eslint-plugin/lib/util.js index 1df02bfb9e8e..e12e15f80413 100644 --- a/packages/eslint-plugin/lib/util.js +++ b/packages/eslint-plugin/lib/util.js @@ -117,8 +117,12 @@ exports.getParserServices = context => { !context.parserServices.program || !context.parserServices.esTreeNodeToTSNodeMap ) { + /** + * The user needs to have configured "project" in their parserOptions + * for @typescript-eslint/parser + */ throw new Error( - 'This rule requires you to use `@typescript-eslint/parser`.' + `You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.` ); } return context.parserServices; diff --git a/packages/eslint-plugin/tests/lib/rules/restrict-plus-operands.js b/packages/eslint-plugin/tests/lib/rules/restrict-plus-operands.js index a13b7cea3e47..d5a07e596982 100644 --- a/packages/eslint-plugin/tests/lib/rules/restrict-plus-operands.js +++ b/packages/eslint-plugin/tests/lib/rules/restrict-plus-operands.js @@ -22,7 +22,6 @@ const rootPath = path.join(process.cwd(), 'tests/fixtures/'); const ruleTester = new RuleTester({ parser: '@typescript-eslint/parser', parserOptions: { - generateServices: true, tsconfigRootDir: rootPath, project: './tsconfig.json' } diff --git a/packages/parser/README.md b/packages/parser/README.md index f348ae4617dc..d0a6879b4e57 100644 --- a/packages/parser/README.md +++ b/packages/parser/README.md @@ -48,6 +48,12 @@ The following additional configuration options are available by specifying them - **`useJSXTextNode`** - default `true`. Please set `false` if you use this parser on ESLint v4. If this is `false`, the parser creates the AST of JSX texts as the legacy style. +- **`project`** - default `undefined`. This option allows you to provide a path to your project's `tsconfig.json`. **This setting is required if you want to use rules which require type information**. You may want to use this setting in tandem with the `tsconfigRootDir` option below. + +- **`tsconfigRootDir`** - default `undefined`. This option allows you to provide the root directory for relative tsconfig paths specified in the `project` option above. + +- **`extraFileExtensions`** - default `undefined`. This option allows you to provide one or more additional file extensions which should be considered in the TypeScript Program compilation. E.g. a `.vue` file + ### .eslintrc.json ```json @@ -57,7 +63,10 @@ The following additional configuration options are available by specifying them "ecmaFeatures": { "jsx": true }, - "useJSXTextNode": true + "useJSXTextNode": true, + "project": "./tsconfig.json", + "tsconfigRootDir": "../../", + "extraFileExtensions": [".vue"] } } ``` From d8243b41893b0423bb0b29c99e076e1c4162a7a5 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 24 Jan 2019 14:03:11 +0100 Subject: [PATCH 38/88] fix(ts-estree): include modifiers in exported node range (#133) --- .../lib/__snapshots__/javascript.ts.snap | 1006 ++++++++++++++++- .../lib/__snapshots__/typescript.ts.snap | 28 +- .../export-async-named-function.src.js | 1 + .../javascript/modules/export-const.src.js | 1 + ...export-default-async-named-function.src.js | 1 + .../javascript/modules/export-let.src.js | 1 + packages/typescript-estree/src/node-utils.ts | 14 +- .../tests/ast-alignment/fixtures-to-test.ts | 9 +- .../lib/__snapshots__/javascript.ts.snap | 1002 +++++++++++++++- .../semantic-diagnostics-enabled.ts.snap | 8 + .../lib/__snapshots__/typescript.ts.snap | 28 +- 11 files changed, 2019 insertions(+), 80 deletions(-) create mode 100644 packages/shared-fixtures/fixtures/javascript/modules/export-async-named-function.src.js create mode 100644 packages/shared-fixtures/fixtures/javascript/modules/export-const.src.js create mode 100644 packages/shared-fixtures/fixtures/javascript/modules/export-default-async-named-function.src.js create mode 100644 packages/shared-fixtures/fixtures/javascript/modules/export-let.src.js diff --git a/packages/parser/tests/lib/__snapshots__/javascript.ts.snap b/packages/parser/tests/lib/__snapshots__/javascript.ts.snap index b31c5e710a2b..3dc1ea581abe 100644 --- a/packages/parser/tests/lib/__snapshots__/javascript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/javascript.ts.snap @@ -105637,15 +105637,677 @@ Object { } `; +exports[`javascript fixtures/modules/export-async-named-function.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "async": true, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 30, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 22, + 25, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 7, + 30, + ], + "type": "FunctionDeclaration", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 30, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 31, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 12, + ], + "type": "Identifier", + "value": "async", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 21, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 25, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 30, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/modules/export-const.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 13, + 16, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "raw": "2", + "type": "Literal", + "value": 2, + }, + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 20, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 21, + ], + "type": "VariableDeclaration", + }, + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 21, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 22, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 12, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 16, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Numeric", + "value": "2", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`javascript fixtures/modules/export-default-array.src 1`] = ` Object { "body": Array [ Object { "declaration": Object { - "elements": Array [], + "elements": Array [], + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 17, + ], + "type": "ArrayExpression", + }, + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "type": "ExportDefaultDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 14, + ], + "type": "Keyword", + "value": "default", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/modules/export-default-async-named-function.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "async": true, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, + }, + "range": Array [ + 36, + 38, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 30, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 30, + 33, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 17, + "column": 38, "line": 1, }, "start": Object { @@ -105653,15 +106315,16 @@ Object { "line": 1, }, }, + "params": Array [], "range": Array [ 15, - 17, + 38, ], - "type": "ArrayExpression", + "type": "FunctionDeclaration", }, "loc": Object { "end": Object { - "column": 18, + "column": 38, "line": 1, }, "start": Object { @@ -105671,7 +106334,7 @@ Object { }, "range": Array [ 0, - 18, + 38, ], "type": "ExportDefaultDeclaration", }, @@ -105689,7 +106352,7 @@ Object { }, "range": Array [ 0, - 19, + 39, ], "sourceType": "module", "tokens": Array [ @@ -105732,56 +106395,128 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 20, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 20, + ], + "type": "Identifier", + "value": "async", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 29, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 30, + "line": 1, + }, + }, + "range": Array [ + 30, + 33, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, "line": 1, }, "start": Object { - "column": 15, + "column": 34, "line": 1, }, }, "range": Array [ - 15, - 16, + 34, + 35, ], "type": "Punctuator", - "value": "[", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 37, "line": 1, }, "start": Object { - "column": 16, + "column": 36, "line": 1, }, }, "range": Array [ - 16, - 17, + 36, + 37, ], "type": "Punctuator", - "value": "]", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 18, + "column": 38, "line": 1, }, "start": Object { - "column": 17, + "column": 37, "line": 1, }, }, "range": Array [ - 17, - 18, + 37, + 38, ], "type": "Punctuator", - "value": ";", + "value": "}", }, ], "type": "Program", @@ -109520,6 +110255,233 @@ Object { } `; +exports[`javascript fixtures/modules/export-let.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 11, + 14, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "raw": "2", + "type": "Literal", + "value": 2, + }, + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 18, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 19, + ], + "type": "VariableDeclaration", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 20, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 10, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 14, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Numeric", + "value": "2", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`javascript fixtures/modules/export-named-as-default.src 1`] = ` Object { "body": Array [ diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index 39c74ab7586d..e2dfa3efa430 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -814,12 +814,12 @@ Object { "line": 3, }, "start": Object { - "column": 16, + "column": 7, "line": 1, }, }, "range": Array [ - 16, + 7, 68, ], "superClass": null, @@ -1262,12 +1262,12 @@ Object { "line": 3, }, "start": Object { - "column": 16, + "column": 7, "line": 1, }, }, "range": Array [ - 16, + 7, 86, ], "superClass": null, @@ -2567,12 +2567,12 @@ Object { "line": 3, }, "start": Object { - "column": 16, + "column": 7, "line": 1, }, }, "range": Array [ - 16, + 7, 78, ], "superClass": null, @@ -2955,12 +2955,12 @@ Object { "line": 2, }, "start": Object { - "column": 16, + "column": 7, "line": 1, }, }, "range": Array [ - 16, + 7, 31, ], "type": "TSInterfaceDeclaration", @@ -35463,7 +35463,7 @@ Object { "line": 4, }, "start": Object { - "column": 21, + "column": 7, "line": 1, }, }, @@ -35559,7 +35559,7 @@ Object { }, ], "range": Array [ - 21, + 7, 54, ], "type": "TSEnumDeclaration", @@ -35851,7 +35851,7 @@ Object { "line": 4, }, "start": Object { - "column": 15, + "column": 7, "line": 1, }, }, @@ -35947,7 +35947,7 @@ Object { }, ], "range": Array [ - 15, + 7, 48, ], "type": "TSEnumDeclaration", @@ -89438,7 +89438,7 @@ Object { "line": 1, }, "start": Object { - "column": 63, + "column": 7, "line": 1, }, }, @@ -89565,7 +89565,7 @@ Object { }, ], "range": Array [ - 63, + 7, 72, ], "type": "TSEnumDeclaration", diff --git a/packages/shared-fixtures/fixtures/javascript/modules/export-async-named-function.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-async-named-function.src.js new file mode 100644 index 000000000000..7c26b9ed6873 --- /dev/null +++ b/packages/shared-fixtures/fixtures/javascript/modules/export-async-named-function.src.js @@ -0,0 +1 @@ +export async function foo() {} diff --git a/packages/shared-fixtures/fixtures/javascript/modules/export-const.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-const.src.js new file mode 100644 index 000000000000..cc57a55e257d --- /dev/null +++ b/packages/shared-fixtures/fixtures/javascript/modules/export-const.src.js @@ -0,0 +1 @@ +export const foo = 2; diff --git a/packages/shared-fixtures/fixtures/javascript/modules/export-default-async-named-function.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-default-async-named-function.src.js new file mode 100644 index 000000000000..c40a5f27d267 --- /dev/null +++ b/packages/shared-fixtures/fixtures/javascript/modules/export-default-async-named-function.src.js @@ -0,0 +1 @@ +export default async function foo() {} diff --git a/packages/shared-fixtures/fixtures/javascript/modules/export-let.src.js b/packages/shared-fixtures/fixtures/javascript/modules/export-let.src.js new file mode 100644 index 000000000000..a3bcdb0d8122 --- /dev/null +++ b/packages/shared-fixtures/fixtures/javascript/modules/export-let.src.js @@ -0,0 +1 @@ +export let foo = 2; diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index 240c4d1c9f71..c844cf7ed20d 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -485,12 +485,14 @@ export function fixExports( ): ESTreeNode { // check for exports if (node.modifiers && node.modifiers[0].kind === SyntaxKind.ExportKeyword) { - const exportKeyword = node.modifiers[0], - nextModifier = node.modifiers[1], - lastModifier = node.modifiers[node.modifiers.length - 1], - declarationIsDefault = - nextModifier && nextModifier.kind === SyntaxKind.DefaultKeyword, - varToken = findNextToken(lastModifier, ast, ast); + const exportKeyword = node.modifiers[0]; + const nextModifier = node.modifiers[1]; + const declarationIsDefault = + nextModifier && nextModifier.kind === SyntaxKind.DefaultKeyword; + + const varToken = declarationIsDefault + ? findNextToken(nextModifier, ast, ast) + : findNextToken(exportKeyword, ast, ast); result.range[0] = varToken!.getStart(ast); result.loc = getLocFor(result.range[0], result.range[1], ast); 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 3b1a21e43d80..522cc53a3351 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -326,7 +326,6 @@ tester.addFixturePatternConfig('typescript/basics', { /** * there is difference in range between babel and ts-estree */ - 'export-declare-const-named-enum', 'interface-with-optional-properties', /** * Babel parses it as TSQualifiedName @@ -358,7 +357,13 @@ tester.addFixturePatternConfig('typescript/basics', { * Babel parses this incorrectly * https://github.com/babel/babel/issues/9324 */ - 'type-assertion-arrow-function' + 'type-assertion-arrow-function', + /** + * Babel does not include range of declare keyword into enum range + * https://github.com/babel/babel/issues/9399 + */ + 'export-declare-const-named-enum', + 'export-declare-named-enum' ], ignoreSourceType: [ /** diff --git a/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap index 8d02532b8d7f..5a57277c9353 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap @@ -105312,15 +105312,674 @@ Object { } `; +exports[`javascript fixtures/modules/export-async-named-function.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "async": true, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 30, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 22, + 25, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 7, + 30, + ], + "type": "FunctionDeclaration", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 30, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 31, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 12, + ], + "type": "Identifier", + "value": "async", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 21, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 25, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 30, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/modules/export-const.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 13, + 16, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "raw": "2", + "type": "Literal", + "value": 2, + }, + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 20, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 21, + ], + "type": "VariableDeclaration", + }, + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 21, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 22, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 12, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 16, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Numeric", + "value": "2", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`javascript fixtures/modules/export-default-array.src 1`] = ` Object { "body": Array [ Object { "declaration": Object { - "elements": Array [], + "elements": Array [], + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 17, + ], + "type": "ArrayExpression", + }, + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "type": "ExportDefaultDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 14, + ], + "type": "Keyword", + "value": "default", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/modules/export-default-async-named-function.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "async": true, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, + }, + "range": Array [ + 36, + 38, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 30, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 30, + 33, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 17, + "column": 38, "line": 1, }, "start": Object { @@ -105328,15 +105987,16 @@ Object { "line": 1, }, }, + "params": Array [], "range": Array [ 15, - 17, + 38, ], - "type": "ArrayExpression", + "type": "FunctionDeclaration", }, "loc": Object { "end": Object { - "column": 18, + "column": 38, "line": 1, }, "start": Object { @@ -105346,7 +106006,7 @@ Object { }, "range": Array [ 0, - 18, + 38, ], "type": "ExportDefaultDeclaration", }, @@ -105363,7 +106023,7 @@ Object { }, "range": Array [ 0, - 19, + 39, ], "sourceType": "module", "tokens": Array [ @@ -105406,56 +106066,128 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 20, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 20, + ], + "type": "Identifier", + "value": "async", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 29, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 30, + "line": 1, + }, + }, + "range": Array [ + 30, + 33, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, "line": 1, }, "start": Object { - "column": 15, + "column": 34, "line": 1, }, }, "range": Array [ - 15, - 16, + 34, + 35, ], "type": "Punctuator", - "value": "[", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 37, "line": 1, }, "start": Object { - "column": 16, + "column": 36, "line": 1, }, }, "range": Array [ - 16, - 17, + 36, + 37, ], "type": "Punctuator", - "value": "]", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 18, + "column": 38, "line": 1, }, "start": Object { - "column": 17, + "column": 37, "line": 1, }, }, "range": Array [ - 17, - 18, + 37, + 38, ], "type": "Punctuator", - "value": ";", + "value": "}", }, ], "type": "Program", @@ -109178,6 +109910,232 @@ Object { } `; +exports[`javascript fixtures/modules/export-let.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 11, + 14, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "raw": "2", + "type": "Literal", + "value": 2, + }, + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 18, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 19, + ], + "type": "VariableDeclaration", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 20, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 10, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 14, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Numeric", + "value": "2", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`javascript fixtures/modules/export-named-as-default.src 1`] = ` Object { "body": Array [ diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index 768b79a8fd31..e680cb92473c 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -790,8 +790,14 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/error-strict.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/export-async-named-function.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/export-const.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/export-default-array.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/export-default-async-named-function.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/export-default-class.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/export-default-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -824,6 +830,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/export-function.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/export-let.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/export-named-as-default.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/export-named-as-specifier.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index 90ebe3e137e0..b481510bdae7 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -812,12 +812,12 @@ Object { "line": 3, }, "start": Object { - "column": 16, + "column": 7, "line": 1, }, }, "range": Array [ - 16, + 7, 68, ], "superClass": null, @@ -1259,12 +1259,12 @@ Object { "line": 3, }, "start": Object { - "column": 16, + "column": 7, "line": 1, }, }, "range": Array [ - 16, + 7, 86, ], "superClass": null, @@ -2561,12 +2561,12 @@ Object { "line": 3, }, "start": Object { - "column": 16, + "column": 7, "line": 1, }, }, "range": Array [ - 16, + 7, 78, ], "superClass": null, @@ -2948,12 +2948,12 @@ Object { "line": 2, }, "start": Object { - "column": 16, + "column": 7, "line": 1, }, }, "range": Array [ - 16, + 7, 31, ], "type": "TSInterfaceDeclaration", @@ -35398,7 +35398,7 @@ Object { "line": 4, }, "start": Object { - "column": 21, + "column": 7, "line": 1, }, }, @@ -35494,7 +35494,7 @@ Object { }, ], "range": Array [ - 21, + 7, 54, ], "type": "TSEnumDeclaration", @@ -35785,7 +35785,7 @@ Object { "line": 4, }, "start": Object { - "column": 15, + "column": 7, "line": 1, }, }, @@ -35881,7 +35881,7 @@ Object { }, ], "range": Array [ - 15, + 7, 48, ], "type": "TSEnumDeclaration", @@ -88748,7 +88748,7 @@ Object { "line": 1, }, "start": Object { - "column": 63, + "column": 7, "line": 1, }, }, @@ -88875,7 +88875,7 @@ Object { }, ], "range": Array [ - 63, + 7, 72, ], "type": "TSEnumDeclaration", From 9068b6276064e6729e1635ab11f7d70a543afa68 Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 26 Jan 2019 00:56:41 +0100 Subject: [PATCH 39/88] fix(ts-estree): expand optional property to include question token (#138) --- .../tests/lib/__snapshots__/typescript.ts.snap | 12 ++++++------ packages/typescript-estree/src/convert.ts | 8 ++++++++ .../tests/ast-alignment/fixtures-to-test.ts | 4 ---- .../tests/lib/__snapshots__/typescript.ts.snap | 12 ++++++------ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index e2dfa3efa430..08e944aecc31 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -48454,7 +48454,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 14, "line": 12, }, "start": Object { @@ -48466,7 +48466,7 @@ Object { "optional": true, "range": Array [ 253, - 254, + 255, ], "type": "Identifier", }, @@ -48544,7 +48544,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 17, "line": 13, }, "start": Object { @@ -48556,7 +48556,7 @@ Object { "optional": true, "range": Array [ 281, - 282, + 283, ], "type": "Identifier", }, @@ -53553,7 +53553,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 31, + "column": 32, "line": 4, }, "start": Object { @@ -53565,7 +53565,7 @@ Object { "optional": true, "range": Array [ 73, - 76, + 77, ], "type": "Identifier", }, diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 64120d6a8d85..ff365b187c7e 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -1315,6 +1315,14 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { } if (node.questionToken) { + if (node.questionToken.end > parameter.range[1]) { + parameter.range[1] = node.questionToken.end; + parameter.loc = getLocFor( + parameter.range[0], + parameter.range[1], + ast + ); + } parameter.optional = true; } 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 522cc53a3351..b44faf0feb64 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -323,10 +323,6 @@ tester.addFixturePatternConfig('typescript/basics', { * TODO: Investigate in more depth, potentially split up different parts of the interface */ 'interface-with-all-property-types', // babel parse errors - /** - * there is difference in range between babel and ts-estree - */ - 'interface-with-optional-properties', /** * Babel parses it as TSQualifiedName * ts parses it as MemberExpression diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index b481510bdae7..c5085cf91009 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -48344,7 +48344,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 14, "line": 12, }, "start": Object { @@ -48356,7 +48356,7 @@ Object { "optional": true, "range": Array [ 253, - 254, + 255, ], "type": "Identifier", }, @@ -48434,7 +48434,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 17, "line": 13, }, "start": Object { @@ -48446,7 +48446,7 @@ Object { "optional": true, "range": Array [ 281, - 282, + 283, ], "type": "Identifier", }, @@ -53414,7 +53414,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 31, + "column": 32, "line": 4, }, "start": Object { @@ -53426,7 +53426,7 @@ Object { "optional": true, "range": Array [ 73, - 76, + 77, ], "type": "Identifier", }, From e442d280285e8acab253a5e80a7a6a6c5d1b4692 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 27 Jan 2019 18:00:24 +0100 Subject: [PATCH 40/88] test(ts-estree): add broken test cases (#140) --- .../lib/__snapshots__/javascript.ts.snap | 1178 +++++++++++++++++ .../lib/__snapshots__/typescript.ts.snap | 392 ++++++ .../function/function-with-return.js | 3 + .../function/return-multiline-sequence.src.js | 7 + .../function/return-sequence.src.js | 3 + ...ow-function-with-optional-parameter.src.ts | 1 + .../tests/ast-alignment/fixtures-to-test.ts | 27 +- .../lib/__snapshots__/javascript.ts.snap | 1176 ++++++++++++++++ .../semantic-diagnostics-enabled.ts.snap | 6 + .../lib/__snapshots__/typescript.ts.snap | 391 ++++++ 10 files changed, 3175 insertions(+), 9 deletions(-) create mode 100644 packages/shared-fixtures/fixtures/javascript/function/function-with-return.js create mode 100644 packages/shared-fixtures/fixtures/javascript/function/return-multiline-sequence.src.js create mode 100644 packages/shared-fixtures/fixtures/javascript/function/return-sequence.src.js create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/arrow-function-with-optional-parameter.src.ts diff --git a/packages/parser/tests/lib/__snapshots__/javascript.ts.snap b/packages/parser/tests/lib/__snapshots__/javascript.ts.snap index 3dc1ea581abe..6a51ccfcd4de 100644 --- a/packages/parser/tests/lib/__snapshots__/javascript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/javascript.ts.snap @@ -99362,6 +99362,1184 @@ Object { } `; +exports[`javascript fixtures/function/return-multiline-sequence.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "argument": Object { + "expressions": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "name": "x", + "range": Array [ + 40, + 41, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "name": "y", + "range": Array [ + 47, + 48, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 5, + }, + "start": Object { + "column": 4, + "line": 5, + }, + }, + "name": "z", + "range": Array [ + 54, + 55, + ], + "type": "Identifier", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 5, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 40, + 55, + ], + "type": "SequenceExpression", + }, + "loc": Object { + "end": Object { + "column": 4, + "line": 6, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 27, + 60, + ], + "type": "ReturnStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 7, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 62, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 7, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "name": "y", + "range": Array [ + 17, + 18, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "name": "z", + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + }, + ], + "range": Array [ + 0, + 62, + ], + "type": "FunctionDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 8, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 63, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Identifier", + "value": "y", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + "value": "z", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 27, + 33, + ], + "type": "Keyword", + "value": "return", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 40, + 41, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 3, + }, + "start": Object { + "column": 5, + "line": 3, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Identifier", + "value": "y", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 4, + }, + "start": Object { + "column": 5, + "line": 4, + }, + }, + "range": Array [ + 48, + 49, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 5, + }, + "start": Object { + "column": 4, + "line": 5, + }, + }, + "range": Array [ + 54, + 55, + ], + "type": "Identifier", + "value": "z", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 6, + }, + "start": Object { + "column": 2, + "line": 6, + }, + }, + "range": Array [ + 58, + 59, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 6, + }, + "start": Object { + "column": 3, + "line": 6, + }, + }, + "range": Array [ + 59, + 60, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 7, + }, + "start": Object { + "column": 0, + "line": 7, + }, + }, + "range": Array [ + 61, + 62, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/function/return-sequence.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "argument": Object { + "expressions": Array [ + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "name": "x", + "range": Array [ + 35, + 36, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "name": "y", + "range": Array [ + 38, + 39, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": "z", + "range": Array [ + 41, + 42, + ], + "type": "Identifier", + }, + ], + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 35, + 42, + ], + "type": "SequenceExpression", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 27, + 44, + ], + "type": "ReturnStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 46, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "name": "y", + "range": Array [ + 17, + 18, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "name": "z", + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + }, + ], + "range": Array [ + 0, + 46, + ], + "type": "FunctionDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 47, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Identifier", + "value": "y", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + "value": "z", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 27, + 33, + ], + "type": "Keyword", + "value": "return", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Identifier", + "value": "y", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Identifier", + "value": "z", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 42, + 43, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 45, + 46, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + exports[`javascript fixtures/generators/anonymous-generator.src 1`] = ` Object { "body": Array [ diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index 08e944aecc31..f540948a5558 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -3114,6 +3114,398 @@ Object { } `; +exports[`typescript fixtures/basics/arrow-function-with-optional-parameter.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "arguments": Array [], + "callee": Object { + "async": false, + "body": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "k", + "range": Array [ + 9, + 10, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "operator": "+", + "range": Array [ + 9, + 14, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "type": "BinaryExpression", + }, + "expression": true, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 2, + "line": 1, + }, + }, + "name": "k", + "optional": true, + "range": Array [ + 2, + 4, + ], + "type": "Identifier", + }, + ], + "range": Array [ + 1, + 14, + ], + "type": "ArrowFunctionExpression", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 17, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "type": "ExpressionStatement", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 1, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 2, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 2, + "line": 1, + }, + }, + "range": Array [ + 2, + 3, + ], + "type": "Identifier", + "value": "k", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "range": Array [ + 3, + 4, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 8, + ], + "type": "Punctuator", + "value": "=>", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Identifier", + "value": "k", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "+", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/arrow-function-with-type-parameters.src 1`] = ` Object { "body": Array [ diff --git a/packages/shared-fixtures/fixtures/javascript/function/function-with-return.js b/packages/shared-fixtures/fixtures/javascript/function/function-with-return.js new file mode 100644 index 000000000000..c98a373f0c38 --- /dev/null +++ b/packages/shared-fixtures/fixtures/javascript/function/function-with-return.js @@ -0,0 +1,3 @@ +function foo () { + return 1; +} diff --git a/packages/shared-fixtures/fixtures/javascript/function/return-multiline-sequence.src.js b/packages/shared-fixtures/fixtures/javascript/function/return-multiline-sequence.src.js new file mode 100644 index 000000000000..be3070488139 --- /dev/null +++ b/packages/shared-fixtures/fixtures/javascript/function/return-multiline-sequence.src.js @@ -0,0 +1,7 @@ +function foo (x, y, z) { + return ( + x, + y, + z + ); +} diff --git a/packages/shared-fixtures/fixtures/javascript/function/return-sequence.src.js b/packages/shared-fixtures/fixtures/javascript/function/return-sequence.src.js new file mode 100644 index 000000000000..3ffe77903028 --- /dev/null +++ b/packages/shared-fixtures/fixtures/javascript/function/return-sequence.src.js @@ -0,0 +1,3 @@ +function foo (x, y, z) { + return (x, y, z); +} diff --git a/packages/shared-fixtures/fixtures/typescript/basics/arrow-function-with-optional-parameter.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/arrow-function-with-optional-parameter.src.ts new file mode 100644 index 000000000000..0289f3828aa8 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/arrow-function-with-optional-parameter.src.ts @@ -0,0 +1 @@ +((k?) => k + 1)(); 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 b44faf0feb64..e92f68f968f4 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -167,6 +167,15 @@ tester.addFixturePatternConfig('javascript/arrowFunctions', { 'error-strict-dup-params' // babel parse errors ] }); +tester.addFixturePatternConfig('javascript/function', { + ignore: [ + /** + * Babel has invalid end range of multiline SequenceExpression + * TODO: report it to babel + */ + 'return-multiline-sequence' + ] +}); tester.addFixturePatternConfig('javascript/bigIntLiterals'); tester.addFixturePatternConfig('javascript/binaryLiterals'); @@ -355,11 +364,16 @@ tester.addFixturePatternConfig('typescript/basics', { */ 'type-assertion-arrow-function', /** - * Babel does not include range of declare keyword into enum range - * https://github.com/babel/babel/issues/9399 + * PR for range of declare keyword has been merged into Babel: https://github.com/babel/babel/pull/9406 + * TODO: remove me in next babel > 7.3.1 */ 'export-declare-const-named-enum', - 'export-declare-named-enum' + 'export-declare-named-enum', + /** + * Babel does not include optional keyword into range parameter in arrow function + * TODO: report it to babel + */ + 'arrow-function-with-optional-parameter' ], ignoreSourceType: [ /** @@ -418,13 +432,8 @@ tester.addFixturePatternConfig('typescript/declare', { tester.addFixturePatternConfig('typescript/namespaces-and-modules', { fileType: 'ts', - ignore: [ - /** - * Minor AST difference - */ - 'nested-internal-module' - ], ignoreSourceType: [ + 'nested-internal-module', 'module-with-default-exports', 'ambient-module-declaration-with-import', 'declare-namespace-with-exported-function' diff --git a/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap index 5a57277c9353..85045786c853 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap @@ -99058,6 +99058,1182 @@ Object { } `; +exports[`javascript fixtures/function/return-multiline-sequence.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "argument": Object { + "expressions": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "name": "x", + "range": Array [ + 40, + 41, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "name": "y", + "range": Array [ + 47, + 48, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 5, + }, + "start": Object { + "column": 4, + "line": 5, + }, + }, + "name": "z", + "range": Array [ + 54, + 55, + ], + "type": "Identifier", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 5, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 40, + 55, + ], + "type": "SequenceExpression", + }, + "loc": Object { + "end": Object { + "column": 4, + "line": 6, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 27, + 60, + ], + "type": "ReturnStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 7, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 62, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 7, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "name": "y", + "range": Array [ + 17, + 18, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "name": "z", + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + }, + ], + "range": Array [ + 0, + 62, + ], + "type": "FunctionDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 8, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 63, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Identifier", + "value": "y", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + "value": "z", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 27, + 33, + ], + "type": "Keyword", + "value": "return", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 40, + 41, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 3, + }, + "start": Object { + "column": 5, + "line": 3, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Identifier", + "value": "y", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 4, + }, + "start": Object { + "column": 5, + "line": 4, + }, + }, + "range": Array [ + 48, + 49, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 5, + }, + "start": Object { + "column": 4, + "line": 5, + }, + }, + "range": Array [ + 54, + 55, + ], + "type": "Identifier", + "value": "z", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 6, + }, + "start": Object { + "column": 2, + "line": 6, + }, + }, + "range": Array [ + 58, + 59, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 6, + }, + "start": Object { + "column": 3, + "line": 6, + }, + }, + "range": Array [ + 59, + 60, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 7, + }, + "start": Object { + "column": 0, + "line": 7, + }, + }, + "range": Array [ + 61, + 62, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/function/return-sequence.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "argument": Object { + "expressions": Array [ + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "name": "x", + "range": Array [ + 35, + 36, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "name": "y", + "range": Array [ + 38, + 39, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": "z", + "range": Array [ + 41, + 42, + ], + "type": "Identifier", + }, + ], + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 35, + 42, + ], + "type": "SequenceExpression", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 27, + 44, + ], + "type": "ReturnStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 46, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "name": "y", + "range": Array [ + 17, + 18, + ], + "type": "Identifier", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "name": "z", + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + }, + ], + "range": Array [ + 0, + 46, + ], + "type": "FunctionDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 47, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Identifier", + "value": "y", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + "value": "z", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 27, + 33, + ], + "type": "Keyword", + "value": "return", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Identifier", + "value": "y", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Identifier", + "value": "z", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 42, + 43, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 45, + 46, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + exports[`javascript fixtures/generators/anonymous-generator.src 1`] = ` Object { "body": Array [ diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index e680cb92473c..1db62d5b9140 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -739,6 +739,10 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/forOf/invalid-for-of-with-let-and-no-braces.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/function/return-multiline-sequence.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/function/return-sequence.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/generators/anonymous-generator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/generators/async-generator-function.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -1887,6 +1891,8 @@ Object { } `; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/arrow-function-with-optional-parameter.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/arrow-function-with-type-parameters.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/async-function-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index c5085cf91009..b807e63a8220 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -3106,6 +3106,397 @@ Object { } `; +exports[`typescript fixtures/basics/arrow-function-with-optional-parameter.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "arguments": Array [], + "callee": Object { + "async": false, + "body": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "k", + "range": Array [ + 9, + 10, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "operator": "+", + "range": Array [ + 9, + 14, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "type": "BinaryExpression", + }, + "expression": true, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 2, + "line": 1, + }, + }, + "name": "k", + "optional": true, + "range": Array [ + 2, + 4, + ], + "type": "Identifier", + }, + ], + "range": Array [ + 1, + 14, + ], + "type": "ArrowFunctionExpression", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 17, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 1, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 2, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 2, + "line": 1, + }, + }, + "range": Array [ + 2, + 3, + ], + "type": "Identifier", + "value": "k", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "range": Array [ + 3, + 4, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 8, + ], + "type": "Punctuator", + "value": "=>", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Identifier", + "value": "k", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "+", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/arrow-function-with-type-parameters.src 1`] = ` Object { "body": Array [ From 5e1600308d7121fd986181cc8db589c9573d0d31 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 27 Jan 2019 18:06:26 +0100 Subject: [PATCH 41/88] fix(parser): add visiting of type parameters in JSXOpeningElement (#150) --- .../tests/lib/rules/no-unused-vars.js | 15 +- packages/parser/src/analyze-scope.ts | 9 + packages/parser/src/visitor-keys.ts | 7 + .../fixtures/scope-analysis/import-keyword.ts | 1 + .../scope-analysis/typed-jsx-element.tsx | 1 + .../lib/__snapshots__/scope-analysis.ts.snap | 312 ++++++++++++++++++ packages/parser/tests/lib/scope-analysis.ts | 8 +- packages/parser/tests/lib/visitor-keys.ts | 28 ++ packages/typescript-estree/package.json | 1 + 9 files changed, 379 insertions(+), 3 deletions(-) create mode 100644 packages/parser/tests/fixtures/scope-analysis/import-keyword.ts create mode 100644 packages/parser/tests/fixtures/scope-analysis/typed-jsx-element.tsx create mode 100644 packages/parser/tests/lib/visitor-keys.ts diff --git a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js index 726f755c3956..2fe854b2c442 100644 --- a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js @@ -557,7 +557,20 @@ export interface Bar extends foo.i18n {} import foo from 'foo'; import bar from 'foo'; export interface Bar extends foo.i18n {} - ` + `, + // https://github.com/typescript-eslint/typescript-eslint/issues/141 + { + filename: 'test.tsx', + code: ` +import { TypeA } from './interface'; +export const a = />; + `, + parserOptions: { + ecmaFeatures: { + jsx: true + } + } + } ], invalid: [ diff --git a/packages/parser/src/analyze-scope.ts b/packages/parser/src/analyze-scope.ts index dc17e977683b..eb9f3c92c752 100644 --- a/packages/parser/src/analyze-scope.ts +++ b/packages/parser/src/analyze-scope.ts @@ -235,6 +235,15 @@ class Referencer extends OriginalReferencer { } } + /** + * Override. + */ + JSXOpeningElement(node: any) { + this.visit(node.name); + this.visitTypeParameters(node); + this.visit(node.attributes); + } + /** * Override. * Don't create the reference object in the type mode. diff --git a/packages/parser/src/visitor-keys.ts b/packages/parser/src/visitor-keys.ts index d1dd5e616aeb..d3938529e820 100644 --- a/packages/parser/src/visitor-keys.ts +++ b/packages/parser/src/visitor-keys.ts @@ -1,6 +1,8 @@ import eslintVisitorKeys from 'eslint-visitor-keys'; export const visitorKeys = eslintVisitorKeys.unionWith({ + // Additional estree nodes. + Import: [], // Additional Properties. ArrayPattern: ['elements', 'typeAnnotation'], ArrowFunctionExpression: ['typeParameters', 'params', 'returnType', 'body'], @@ -30,6 +32,11 @@ export const visitorKeys = eslintVisitorKeys.unionWith({ RestElement: ['argument', 'typeAnnotation'], NewExpression: ['callee', 'typeParameters', 'arguments'], CallExpression: ['callee', 'typeParameters', 'arguments'], + // JSX + JSXOpeningElement: ['name', 'typeParameters', 'attributes'], + JSXClosingFragment: [], + JSXOpeningFragment: [], + JSXSpreadChild: ['expression'], // Additional Nodes. BigIntLiteral: [], diff --git a/packages/parser/tests/fixtures/scope-analysis/import-keyword.ts b/packages/parser/tests/fixtures/scope-analysis/import-keyword.ts new file mode 100644 index 000000000000..3beea868f04b --- /dev/null +++ b/packages/parser/tests/fixtures/scope-analysis/import-keyword.ts @@ -0,0 +1 @@ +import('test'); diff --git a/packages/parser/tests/fixtures/scope-analysis/typed-jsx-element.tsx b/packages/parser/tests/fixtures/scope-analysis/typed-jsx-element.tsx new file mode 100644 index 000000000000..29158b30c8dc --- /dev/null +++ b/packages/parser/tests/fixtures/scope-analysis/typed-jsx-element.tsx @@ -0,0 +1 @@ +const a = />; diff --git a/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap b/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap index 0644b066632e..8fd73916d216 100644 --- a/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap @@ -5225,6 +5225,56 @@ Object { } `; +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/import-keyword.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 16, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 16, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 1, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], +} +`; + exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/interface-type.ts 1`] = ` Object { "$id": 1, @@ -6822,6 +6872,137 @@ Object { } `; +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/typed-jsx-element.tsx 1`] = ` +Object { + "$id": 3, + "block": Object { + "range": Array [ + 0, + 39, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 39, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 1, + "from": Object { + "$ref": 2, + }, + "identifier": Object { + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": Object { + "range": Array [ + 10, + 37, + ], + "type": "JSXElement", + }, + }, + ], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 3, + }, + "variableMap": Object { + "a": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 6, + 37, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 38, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + ], + "name": "a", + "references": Array [ + Object { + "$ref": 1, + }, + ], + "scope": Object { + "$ref": 2, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 3, + }, + "variables": Array [], +} +`; + exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/typeof.ts 1`] = ` Object { "$id": 4, @@ -15395,6 +15576,31 @@ Object { } `; +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/import-keyword.ts 1`] = ` +Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 16, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], +} +`; + exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/interface-type.ts 1`] = ` Object { "$id": 0, @@ -16775,6 +16981,112 @@ Object { } `; +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/typed-jsx-element.tsx 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 39, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [ + Object { + "$id": 1, + "from": Object { + "$ref": 2, + }, + "identifier": Object { + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": Object { + "range": Array [ + 10, + 37, + ], + "type": "JSXElement", + }, + }, + ], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "a": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 6, + 37, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 38, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + ], + "name": "a", + "references": Array [ + Object { + "$ref": 1, + }, + ], + "scope": Object { + "$ref": 2, + }, + }, + ], +} +`; + exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/typeof.ts 1`] = ` Object { "$id": 3, diff --git a/packages/parser/tests/lib/scope-analysis.ts b/packages/parser/tests/lib/scope-analysis.ts index 8eec626225f1..b8eafccc63e9 100644 --- a/packages/parser/tests/lib/scope-analysis.ts +++ b/packages/parser/tests/lib/scope-analysis.ts @@ -159,7 +159,9 @@ describe('TypeScript scope analysis', () => { range: true, tokens: true, sourceType: 'module', - ecmaFeatures: {} + ecmaFeatures: { + jsx: path.extname(filePath) === '.tsx' + } }); const { globalScope } = scopeManager; @@ -191,7 +193,9 @@ describe('TypeScript scope analysis', () => { range: true, tokens: true, sourceType: 'script', - ecmaFeatures: {} + ecmaFeatures: { + jsx: path.extname(filePath) === '.tsx' + } }); const { globalScope } = scopeManager; diff --git a/packages/parser/tests/lib/visitor-keys.ts b/packages/parser/tests/lib/visitor-keys.ts new file mode 100644 index 000000000000..00fcde2a005e --- /dev/null +++ b/packages/parser/tests/lib/visitor-keys.ts @@ -0,0 +1,28 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/typescript-estree'; +import { visitorKeys } from '../../src/visitor-keys'; + +//------------------------------------------------------------------------------ +// Setup +//------------------------------------------------------------------------------ + +const astTypes = Object.keys(AST_NODE_TYPES); +astTypes.push('TSEmptyBodyFunctionExpression'); // node created by parser.ts + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +describe('visitor-keys', () => { + for (const type of astTypes) { + it(`type ${type} should be present in visitor-keys`, () => { + expect(visitorKeys).toHaveProperty(type); + }); + } + + it('check if there is no deprecated TS nodes', () => { + const TSTypes = Object.keys(visitorKeys).filter(type => + type.startsWith('TS') + ); + expect(astTypes).toEqual(expect.arrayContaining(TSTypes)); + }); +}); diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index a8490f513a68..3d112005adce 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -3,6 +3,7 @@ "version": "1.1.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/parser.js", + "types": "dist/parser.d.ts", "files": [ "dist", "README.md", From bdf880bc2c7817852e542fb926a7fa6510c2db69 Mon Sep 17 00:00:00 2001 From: Adam Fields Date: Sun, 27 Jan 2019 12:12:45 -0500 Subject: [PATCH 42/88] chore: update peer dependencies and node engines (#151) --- packages/eslint-plugin-tslint/package.json | 3 ++- packages/eslint-plugin/package.json | 4 ++-- packages/parser/package.json | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index fbe9ea5521e0..d8aeedf6ef0e 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -11,7 +11,7 @@ "tslint" ], "engines": { - "node": ">=6" + "node": "^6.14.0 || ^8.10.0 || >=9.10.0" }, "repository": "typescript-eslint/typescript-eslint", "bugs": { @@ -28,6 +28,7 @@ "lodash.memoize": "^4.1.2" }, "peerDependencies": { + "eslint": "^5.0.0", "tslint": "^5.0.0" }, "devDependencies": { diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 7cd6f21b1ab3..7d414aa3576d 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -9,7 +9,7 @@ "typescript" ], "engines": { - "node": ">=6" + "node": "^6.14.0 || ^8.10.0 || >=9.10.0" }, "repository": "typescript-eslint/typescript-eslint", "bugs": { @@ -32,7 +32,7 @@ "eslint-docs": "^0.2.6" }, "peerDependencies": { - "eslint": ">=4.13.1 < 6", + "eslint": "^5.0.0", "typescript": "~3.2.1" } } diff --git a/packages/parser/package.json b/packages/parser/package.json index 23fe47afce3f..2ba2e642ebd9 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -9,7 +9,7 @@ "LICENSE" ], "engines": { - "node": ">=6.14.0" + "node": "^6.14.0 || ^8.10.0 || >=9.10.0" }, "repository": "typescript-eslint/typescript-eslint", "bugs": { @@ -32,7 +32,7 @@ "test": "jest --coverage" }, "peerDependencies": { - "eslint": ">=4.19.1", + "eslint": "^5.0.0", "typescript": "*" }, "dependencies": { From 4954ed2c476bf9654ffe020b587fd6691a985d01 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 27 Jan 2019 18:18:11 +0100 Subject: [PATCH 43/88] refactor(ts-estree): simplify methods location calculation (#152) --- packages/typescript-estree/src/convert.ts | 66 ++++++-------------- packages/typescript-estree/src/node-utils.ts | 56 +++++++---------- 2 files changed, 39 insertions(+), 83 deletions(-) diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index ff365b187c7e..bc9e209f23ed 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -23,10 +23,10 @@ import { isComma, getBinaryExpressionType, isOptional, - findFirstMatchingToken, unescapeStringLiteralText, getDeclarationKind, - getLastModifier + getLastModifier, + getLineAndCharacterFor } from './node-utils'; import { AST_NODE_TYPES } from './ast-node-types'; import { ESTreeNode } from './temp-types-based-on-js-source'; @@ -858,38 +858,19 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.MethodDeclaration: { - const openingParen = findFirstMatchingToken( - node.name, - ast, - (token: any) => { - if (!token || !token.kind) { - return false; - } - return getTextForTokenKind(token.kind) === '('; - }, - ast - ); - - const methodLoc = ast.getLineAndCharacterOfPosition( - (openingParen as any).getStart(ast) - ), - nodeIsMethod = node.kind === SyntaxKind.MethodDeclaration, - method: ESTreeNode = { - type: AST_NODE_TYPES.FunctionExpression, - id: null, - generator: !!node.asteriskToken, - expression: false, // ESTreeNode as ESTreeNode here - async: hasModifier(SyntaxKind.AsyncKeyword, node), - body: convertChild(node.body), - range: [node.parameters.pos - 1, result.range[1]], - loc: { - start: { - line: methodLoc.line + 1, - column: methodLoc.character - }, - end: result.loc.end - } - } as any; + const method: ESTreeNode = { + type: AST_NODE_TYPES.FunctionExpression, + id: null, + generator: !!node.asteriskToken, + expression: false, // ESTreeNode as ESTreeNode here + async: hasModifier(SyntaxKind.AsyncKeyword, node), + body: convertChild(node.body), + range: [node.parameters.pos - 1, result.range[1]], + loc: { + start: getLineAndCharacterFor(node.parameters.pos - 1, ast), + end: result.loc.end + } + } as any; if (node.type) { (method as any).returnType = convertTypeAnnotation(node.type); @@ -903,7 +884,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { key: convertChild(node.name), value: method, computed: isComputedProperty(node.name), - method: nodeIsMethod, + method: node.kind === SyntaxKind.MethodDeclaration, shorthand: false, kind: 'init' }); @@ -992,10 +973,6 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { constructorToken.end ]; - const constructorLoc = ast.getLineAndCharacterOfPosition( - node.parameters.pos - 1 - ); - const constructor: ESTreeNode = { type: AST_NODE_TYPES.FunctionExpression, id: null, @@ -1006,10 +983,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { body: convertChild(node.body), range: [node.parameters.pos - 1, result.range[1]], loc: { - start: { - line: constructorLoc.line + 1, - column: constructorLoc.character - }, + start: getLineAndCharacterFor(node.parameters.pos - 1, ast), end: result.loc.end } } as any; @@ -1906,16 +1880,12 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { break; case SyntaxKind.JsxExpression: { - const eloc = ast.getLineAndCharacterOfPosition(result.range[0] + 1); const expression = node.expression ? convertChild(node.expression) : { type: AST_NODE_TYPES.JSXEmptyExpression, loc: { - start: { - line: eloc.line + 1, - column: eloc.character - }, + start: getLineAndCharacterFor(result.range[0] + 1, ast), end: { line: result.loc.end.line, column: result.loc.end.column - 1 diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index c844cf7ed20d..d79353f755e6 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -9,7 +9,8 @@ import unescape from 'lodash.unescape'; import { ESTreeNodeLoc, ESTreeNode, - ESTreeToken + ESTreeToken, + LineAndColumnData } from './temp-types-based-on-js-source'; import { AST_NODE_TYPES } from './ast-node-types'; @@ -219,6 +220,23 @@ export function getBinaryExpressionType( return AST_NODE_TYPES.BinaryExpression; } +/** + * Returns line and column data for the given positions, + * @param pos position to check + * @param ast the AST object + * @returns line and column + */ +export function getLineAndCharacterFor( + pos: number, + ast: ts.SourceFile +): LineAndColumnData { + const loc = ast.getLineAndCharacterOfPosition(pos); + return { + line: loc.line + 1, + column: loc.character + }; +} + /** * Returns line and column data for the given start and end positions, * for the given AST @@ -232,18 +250,9 @@ export function getLocFor( end: number, ast: ts.SourceFile ): ESTreeNodeLoc { - const startLoc = ast.getLineAndCharacterOfPosition(start), - endLoc = ast.getLineAndCharacterOfPosition(end); - return { - start: { - line: startLoc.line + 1, - column: startLoc.character - }, - end: { - line: endLoc.line + 1, - column: endLoc.character - } + start: getLineAndCharacterFor(start, ast), + end: getLineAndCharacterFor(end, ast) }; } @@ -389,29 +398,6 @@ export function findNextToken( } } -/** - * Find the first matching token based on the given predicate function. - * @param {ts.Node} previousToken The previous ts.Token - * @param {ts.Node} parent The parent ts.Node - * @param {Function} predicate The predicate function to apply to each checked token - * @param {ts.SourceFile} ast The TS AST - * @returns {ts.Node|undefined} a matching ts.Token - */ -export function findFirstMatchingToken( - previousToken: ts.Node | undefined, - parent: ts.Node, - predicate: (node: ts.Node) => boolean, - ast: ts.SourceFile -): ts.Node | undefined { - while (previousToken) { - if (predicate(previousToken)) { - return previousToken; - } - previousToken = findNextToken(previousToken, parent, ast); - } - return undefined; -} - /** * Find the first matching ancestor based on the given predicate function. * @param {ts.Node} node The current ts.Node From e291ec30240b109c19111d1eedb81440f3fa2670 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 27 Jan 2019 18:25:35 +0100 Subject: [PATCH 44/88] refactor(ts-estree): remove dead legacy code (#153) --- packages/typescript-estree/src/convert.ts | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index bc9e209f23ed..9a7adebc8e2e 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -796,21 +796,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { } case SyntaxKind.ComputedPropertyName: - if (parent!.kind === SyntaxKind.ObjectLiteralExpression) { - // TODO: ComputedPropertyName has no name field - Object.assign(result, { - type: AST_NODE_TYPES.Property, - key: convertChild((node as any).name), - value: convertChild((node as any).name), - computed: false, - method: false, - shorthand: true, - kind: 'init' - }); - } else { - return convertChild(node.expression); - } - break; + return convertChild(node.expression); case SyntaxKind.PropertyDeclaration: { const isAbstract = hasModifier(SyntaxKind.AbstractKeyword, node); From 5017c115f232b42285c61ae53dcf531d66a9c4b5 Mon Sep 17 00:00:00 2001 From: ikeryo1182 Date: Tue, 29 Jan 2019 07:42:39 +0700 Subject: [PATCH 45/88] chore: upgrade husky and lint-staged (#144) --- .huskyrc | 8 +++ .lintstagedrc | 6 ++ package.json | 14 +--- yarn.lock | 196 ++++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 183 insertions(+), 41 deletions(-) create mode 100644 .huskyrc create mode 100644 .lintstagedrc diff --git a/.huskyrc b/.huskyrc new file mode 100644 index 000000000000..a3f3f7002ed4 --- /dev/null +++ b/.huskyrc @@ -0,0 +1,8 @@ +{ + "hooks": { + "pre-commit": [ + "yarn test && lint-staged" + ], + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" + } +} diff --git a/.lintstagedrc b/.lintstagedrc new file mode 100644 index 000000000000..889b734ac28f --- /dev/null +++ b/.lintstagedrc @@ -0,0 +1,6 @@ +{ + "*.{ts,js,json,md}": [ + "prettier --write", + "git add" + ] +} diff --git a/package.json b/package.json index c7a27e9a643d..18059f7381ed 100644 --- a/package.json +++ b/package.json @@ -21,22 +21,14 @@ "test": "lerna run test --parallel", "build": "lerna run build", "clean": "lerna clean && lerna run clean", - "precommit": "yarn test && lint-staged", "lint": "eslint . --ext .js,.ts", "lint-fix": "eslint . --ext .js,.ts --fix", "cz": "git-cz", - "commitmsg": "commitlint -E GIT_PARAMS", "check-format": "prettier --list-different \"./**/*.{ts,js,json,md}\"", "format": "prettier --write \"./**/*.{ts,js,json,md}\"", "integration-tests": "docker-compose -f tests/integration/docker-compose.yml up", "kill-integration-test-containers": "docker-compose -f tests/integration/docker-compose.yml down -v --rmi local" }, - "lint-staged": { - "*.{ts,js,json,md}": [ - "prettier --write", - "git add" - ] - }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" @@ -65,13 +57,13 @@ "@types/semver": "^5.5.0", "cz-conventional-changelog": "2.1.0", "eslint": "^5.12.1", - "eslint-plugin-jest": "^22.1.3", "eslint-plugin-eslint-plugin": "^2.0.1", + "eslint-plugin-jest": "^22.1.3", "glob": "7.1.2", - "husky": "0.14.3", + "husky": "^1.3.1", "jest": "23.6.0", "lerna": "^3.10.5", - "lint-staged": "7.3.0", + "lint-staged": "8.1.0", "lodash.isplainobject": "4.0.6", "prettier": "^1.14.3", "rimraf": "^2.6.3", diff --git a/yarn.lock b/yarn.lock index e2d917cdc557..b6a6d614dfc0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -163,6 +163,20 @@ babel-runtime "6.26.0" execa "0.9.0" +"@iamstarkov/listr-update-renderer@0.4.1": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@iamstarkov/listr-update-renderer/-/listr-update-renderer-0.4.1.tgz#d7c48092a2dcf90fd672b6c8b458649cb350c77e" + integrity sha512-IJyxQWsYDEkf8C8QthBn5N8tIUR9V9je6j3sMIpAkonaadjbvxmRC6RAhpa3RKxndhNnU2M6iNbtJwd7usQYIA== + dependencies: + chalk "^1.1.3" + cli-truncate "^0.2.1" + elegant-spinner "^1.0.1" + figures "^1.7.0" + indent-string "^3.0.0" + log-symbols "^1.0.2" + log-update "^2.3.0" + strip-ansi "^3.0.1" + "@lerna/add@3.10.5": version "3.10.5" resolved "https://registry.yarnpkg.com/@lerna/add/-/add-3.10.5.tgz#10dcd1069eee18a84432f826a38d6791af8a2fef" @@ -1618,6 +1632,11 @@ ci-info@^1.5.0: resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.6.0.tgz#2ca20dbb9ceb32d4524a683303313f0304b1e497" integrity sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A== +ci-info@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" + integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== + circular-json@^0.3.1: version "0.3.3" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" @@ -1919,6 +1938,15 @@ core-util-is@1.0.2, core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= +cosmiconfig@5.0.6: + version "5.0.6" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.0.6.tgz#dca6cf680a0bd03589aff684700858c81abeeb39" + integrity sha512-6DWfizHriCrFWURP1/qyhsiFvYdlJzbCzmtFWh744+KyWsJo5+kPzUZZaMRSSItoYc0pxFX7gEO7ZC1/gN/7AQ== + dependencies: + is-directory "^0.3.1" + js-yaml "^3.9.0" + parse-json "^4.0.0" + cosmiconfig@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-4.0.0.tgz#760391549580bbd2df1e562bc177b13c290972dc" @@ -1929,7 +1957,7 @@ cosmiconfig@^4.0.0: parse-json "^4.0.0" require-from-string "^2.0.1" -cosmiconfig@^5.0.2: +cosmiconfig@^5.0.2, cosmiconfig@^5.0.7: version "5.0.7" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.0.7.tgz#39826b292ee0d78eda137dfa3173bd1c21a43b04" integrity sha512-PcLqxTKiDmNT6pSpy4N6KtuPwb53W+2tzNvwOZw0WH9N6O0vLIBq0x8aj8Oj75ere4YcGi48bDFCL+3fRJdlNA== @@ -2136,6 +2164,18 @@ define-property@^2.0.2: is-descriptor "^1.0.2" isobject "^3.0.1" +del@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/del/-/del-3.0.0.tgz#53ecf699ffcbcb39637691ab13baf160819766e5" + integrity sha1-U+z2mf/LyzljdpGrE7rxYIGXZuU= + dependencies: + globby "^6.1.0" + is-path-cwd "^1.0.0" + is-path-in-cwd "^1.0.0" + p-map "^1.1.1" + pify "^3.0.0" + rimraf "^2.2.8" + delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" @@ -2304,7 +2344,7 @@ es6-promisify@^5.0.0: dependencies: es6-promise "^4.0.3" -escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: +escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.4, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= @@ -2497,7 +2537,7 @@ exec-sh@^0.2.0: dependencies: merge "^1.2.0" -execa@0.9.0, execa@^0.9.0: +execa@0.9.0: version "0.9.0" resolved "https://registry.yarnpkg.com/execa/-/execa-0.9.0.tgz#adb7ce62cf985071f60580deb4a88b9e34712d01" integrity sha512-BbUMBiX4hqiHZUA5+JujIjNb6TyAlp2D5KLheMjMluwOuzcnylDL4AxZYLLn1n2AGB49eSWwyKvvEQoRpnAtmA== @@ -2895,6 +2935,15 @@ functional-red-black-tree@^1.0.1: resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= +g-status@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/g-status/-/g-status-2.0.2.tgz#270fd32119e8fc9496f066fe5fe88e0a6bc78b97" + integrity sha512-kQoE9qH+T1AHKgSSD0Hkv98bobE90ILQcXAF4wvGgsr7uFqNvwmh8j+Lq3l0RVt3E3HjSbv2B9biEGcEtpHLCA== + dependencies: + arrify "^1.0.1" + matcher "^1.0.0" + simple-git "^1.85.0" + gauge@~2.7.3: version "2.7.4" resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" @@ -2964,6 +3013,11 @@ get-stdin@^4.0.1: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4= +get-stdin@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" + integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== + get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -3102,6 +3156,17 @@ globals@^9.18.0: resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ== +globby@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" + integrity sha1-9abXDoOV4hyFj7BInWTfAkJNUGw= + dependencies: + array-union "^1.0.1" + glob "^7.0.3" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + globby@^8.0.1: version "8.0.2" resolved "https://registry.yarnpkg.com/globby/-/globby-8.0.2.tgz#5697619ccd95c5275dbb2d6faa42087c1a941d8d" @@ -3271,14 +3336,21 @@ humanize-ms@^1.2.1: dependencies: ms "^2.0.0" -husky@0.14.3: - version "0.14.3" - resolved "https://registry.yarnpkg.com/husky/-/husky-0.14.3.tgz#c69ed74e2d2779769a17ba8399b54ce0b63c12c3" - integrity sha512-e21wivqHpstpoiWA/Yi8eFti8E+sQDSS53cpJsPptPs295QTOQR0ZwnHo2TXy1XOpZFD9rPOd3NpmqTK6uMLJA== +husky@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/husky/-/husky-1.3.1.tgz#26823e399300388ca2afff11cfa8a86b0033fae0" + integrity sha512-86U6sVVVf4b5NYSZ0yvv88dRgBSSXXmHaiq5pP4KDj5JVzdwKgBjEtUPOm8hcoytezFwbU+7gotXNhpHdystlg== dependencies: - is-ci "^1.0.10" - normalize-path "^1.0.0" - strip-indent "^2.0.0" + cosmiconfig "^5.0.7" + execa "^1.0.0" + find-up "^3.0.0" + get-stdin "^6.0.0" + is-ci "^2.0.0" + pkg-dir "^3.0.0" + please-upgrade-node "^3.1.1" + read-pkg "^4.0.1" + run-node "^1.0.0" + slash "^2.0.0" iconv-lite@0.4.24, iconv-lite@^0.4.24, iconv-lite@^0.4.4, iconv-lite@~0.4.13: version "0.4.24" @@ -3471,6 +3543,13 @@ is-ci@^1.0.10: dependencies: ci-info "^1.5.0" +is-ci@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" + integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w== + dependencies: + ci-info "^2.0.0" + is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" @@ -3623,6 +3702,25 @@ is-observable@^1.1.0: dependencies: symbol-observable "^1.1.0" +is-path-cwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" + integrity sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0= + +is-path-in-cwd@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz#5ac48b345ef675339bd6c7a48a912110b241cf52" + integrity sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ== + dependencies: + is-path-inside "^1.0.0" + +is-path-inside@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" + integrity sha1-jvW33lBDej/cprToZe96pVy0gDY= + dependencies: + path-is-inside "^1.0.1" + is-plain-obj@^1.0.0, is-plain-obj@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" @@ -4417,22 +4515,25 @@ libnpmteam@^1.0.1: get-stream "^4.0.0" npm-registry-fetch "^3.8.0" -lint-staged@7.3.0: - version "7.3.0" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-7.3.0.tgz#90ff33e5ca61ed3dbac35b6f6502dbefdc0db58d" - integrity sha512-AXk40M9DAiPi7f4tdJggwuKIViUplYtVj1os1MVEteW7qOkU50EOehayCfO9TsoGK24o/EsWb41yrEgfJDDjCw== +lint-staged@8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-8.1.0.tgz#dbc3ae2565366d8f20efb9f9799d076da64863f2" + integrity sha512-yfSkyJy7EuVsaoxtUSEhrD81spdJOe/gMTGea3XaV7HyoRhTb9Gdlp6/JppRZERvKSEYXP9bjcmq6CA5oL2lYQ== dependencies: + "@iamstarkov/listr-update-renderer" "0.4.1" chalk "^2.3.1" commander "^2.14.1" - cosmiconfig "^5.0.2" + cosmiconfig "5.0.6" debug "^3.1.0" dedent "^0.7.0" - execa "^0.9.0" + del "^3.0.0" + execa "^1.0.0" find-parent-dir "^0.3.0" + g-status "^2.0.2" is-glob "^4.0.0" is-windows "^1.0.2" jest-validate "^23.5.0" - listr "^0.14.1" + listr "^0.14.2" lodash "^4.17.5" log-symbols "^2.2.0" micromatch "^3.1.8" @@ -4441,7 +4542,7 @@ lint-staged@7.3.0: path-is-inside "^1.0.2" pify "^3.0.0" please-upgrade-node "^3.0.2" - staged-git-files "1.1.1" + staged-git-files "1.1.2" string-argv "^0.0.2" stringify-object "^3.2.2" @@ -4474,7 +4575,7 @@ listr-verbose-renderer@^0.5.0: date-fns "^1.27.2" figures "^2.0.0" -listr@^0.14.1: +listr@^0.14.2: version "0.14.3" resolved "https://registry.yarnpkg.com/listr/-/listr-0.14.3.tgz#2fea909604e434be464c50bddba0d496928fa586" integrity sha512-RmAl7su35BFd/xoMamRjpIE4j3v+L28o8CT5YhAXQJm1fD+1l9ngXY8JAQRJ+tFK2i5njvi0iRUKV09vPwA0iA== @@ -4712,6 +4813,13 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" +matcher@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/matcher/-/matcher-1.1.1.tgz#51d8301e138f840982b338b116bb0c09af62c1c2" + integrity sha512-+BmqxWIubKTRKNWx/ahnCkk3mG8m7OturVlqq6HiojGJTd5hVYbgZm6WzcYPCoB+KBT4Vd6R7WSRG2OADNaCjg== + dependencies: + escape-string-regexp "^1.0.4" + math-random@^1.0.1: version "1.0.4" resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.4.tgz#5dd6943c938548267016d4e34f057583080c514c" @@ -5107,11 +5215,6 @@ normalize-package-data@^2.0.0, normalize-package-data@^2.3.0, normalize-package- semver "2 || 3 || 4 || 5" validate-npm-package-license "^3.0.1" -normalize-path@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-1.0.0.tgz#32d0e472f91ff345701c15a8311018d3b0a90379" - integrity sha1-MtDkcvkf80VwHBWoMRAY07CpA3k= - normalize-path@^2.0.1, normalize-path@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" @@ -5633,7 +5736,14 @@ pkg-dir@^2.0.0: dependencies: find-up "^2.1.0" -please-upgrade-node@^3.0.2: +pkg-dir@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-3.0.0.tgz#2749020f239ed990881b1f71210d51eb6523bea3" + integrity sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw== + dependencies: + find-up "^3.0.0" + +please-upgrade-node@^3.0.2, please-upgrade-node@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.1.1.tgz#ed320051dfcc5024fae696712c8288993595e8ac" integrity sha512-KY1uHnQ2NlQHqIJQpnh/i54rKkuxCEBx+voJIS/Mvb+L2iYd2NMotwduhKTMjfC1uKoX3VXOxLjIYG66dfJTVQ== @@ -5884,6 +5994,15 @@ read-pkg@^3.0.0: normalize-package-data "^2.3.2" path-type "^3.0.0" +read-pkg@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-4.0.1.tgz#963625378f3e1c4d48c85872b5a6ec7d5d093237" + integrity sha1-ljYlN48+HE1IyFhytabsfV0JMjc= + dependencies: + normalize-package-data "^2.3.2" + parse-json "^4.0.0" + pify "^3.0.0" + read@1, read@~1.0.1: version "1.0.7" resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4" @@ -6128,7 +6247,7 @@ right-pad@^1.0.1: resolved "https://registry.yarnpkg.com/right-pad/-/right-pad-1.0.1.tgz#8ca08c2cbb5b55e74dafa96bf7fd1a27d568c8d0" integrity sha1-jKCMLLtbVedNr6lr9/0aJ9VoyNA= -rimraf@2, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3, rimraf@~2.6.2: +rimraf@2, rimraf@^2.2.8, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3, rimraf@~2.6.2: version "2.6.3" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== @@ -6147,6 +6266,11 @@ run-async@^2.2.0: dependencies: is-promise "^2.1.0" +run-node@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/run-node/-/run-node-1.0.0.tgz#46b50b946a2aa2d4947ae1d886e9856fd9cabe5e" + integrity sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A== + run-queue@^1.0.0, run-queue@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/run-queue/-/run-queue-1.0.3.tgz#e848396f057d223f24386924618e25694161ec47" @@ -6266,6 +6390,13 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= +simple-git@^1.85.0: + version "1.107.0" + resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-1.107.0.tgz#12cffaf261c14d6f450f7fdb86c21ccee968b383" + integrity sha512-t4OK1JRlp4ayKRfcW6owrWcRVLyHRUlhGd0uN6ZZTqfDq8a5XpcUdOKiGRNobHEuMtNqzp0vcJNvhYWwh5PsQA== + dependencies: + debug "^4.0.1" + sisteransi@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-0.1.1.tgz#5431447d5f7d1675aac667ccd0b865a4994cb3ce" @@ -6276,6 +6407,11 @@ slash@^1.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" integrity sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU= +slash@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44" + integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A== + slice-ansi@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" @@ -6473,10 +6609,10 @@ stack-utils@^1.0.1: resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.2.tgz#33eba3897788558bebfc2db059dc158ec36cebb8" integrity sha512-MTX+MeG5U994cazkjd/9KNAapsHnibjMLnfXodlkXw76JEea0UiNzrqidzo1emMwk7w5Qhc9jd4Bn9TBb1MFwA== -staged-git-files@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/staged-git-files/-/staged-git-files-1.1.1.tgz#37c2218ef0d6d26178b1310719309a16a59f8f7b" - integrity sha512-H89UNKr1rQJvI1c/PIR3kiAMBV23yvR7LItZiV74HWZwzt7f3YHuujJ9nJZlt58WlFox7XQsOahexwk7nTe69A== +staged-git-files@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/staged-git-files/-/staged-git-files-1.1.2.tgz#4326d33886dc9ecfa29a6193bf511ba90a46454b" + integrity sha512-0Eyrk6uXW6tg9PYkhi/V/J4zHp33aNyi2hOCmhFLqLTIhbgqWn5jlSzI+IU0VqrZq6+DbHcabQl/WP6P3BG0QA== static-extend@^0.1.1: version "0.1.2" From aacf5b05c7f0d802bbc28222d7c95141fa0ff86c Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 28 Jan 2019 21:25:44 -0500 Subject: [PATCH 46/88] perf(ts-estree): don't create Program in parse() (#148) --- packages/typescript-estree/src/parser.ts | 347 ++++++++++-------- .../tests/lib/__snapshots__/parse.ts.snap | 82 ++++- packages/typescript-estree/tests/lib/parse.ts | 7 +- .../tests/lib/semanticInfo.ts | 18 + .../tests/lib/warn-on-unsupported-ts.ts | 22 ++ 5 files changed, 324 insertions(+), 152 deletions(-) create mode 100644 packages/typescript-estree/tests/lib/warn-on-unsupported-ts.ts diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index ff2784aa9963..225899a106f9 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -36,7 +36,10 @@ let extra: Extra; let warnedAboutTSVersion = false; /** - * Compute the filename based on the parser options + * Compute the filename based on the parser options. + * + * Even if jsx option is set in typescript compiler, filename still has to + * contain .tsx file extension. * * @param options Parser options */ @@ -106,8 +109,6 @@ function getASTAndDefaultProject(code: string, options: ParserOptions) { * @returns {{ast: ts.SourceFile, program: ts.Program}} Returns a new source file and program corresponding to the linted code */ function createNewProgram(code: string) { - // Even if jsx option is set in typescript compiler, filename still has to - // contain .tsx file extension const FILENAME = getFileName(extra); const compilerHost = { @@ -178,6 +179,98 @@ function getProgramAndAST( ); } +function applyParserOptionsToExtra(options: ParserOptions): void { + /** + * Track range information in the AST + */ + extra.range = typeof options.range === 'boolean' && options.range; + extra.loc = typeof options.loc === 'boolean' && options.loc; + /** + * Track tokens in the AST + */ + if (typeof options.tokens === 'boolean' && options.tokens) { + extra.tokens = []; + } + /** + * Track comments in the AST + */ + if (typeof options.comment === 'boolean' && options.comment) { + extra.comment = true; + extra.comments = []; + } + /** + * Enable JSX - note the applicable file extension is still required + */ + if (typeof options.jsx === 'boolean' && options.jsx) { + extra.jsx = true; + } + /** + * The JSX AST changed the node type for string literals + * inside a JSX Element from `Literal` to `JSXText`. + * + * When value is `true`, these nodes will be parsed as type `JSXText`. + * When value is `false`, these nodes will be parsed as type `Literal`. + */ + if (typeof options.useJSXTextNode === 'boolean' && options.useJSXTextNode) { + extra.useJSXTextNode = true; + } + /** + * Allow the user to cause the parser to error if it encounters an unknown AST Node Type + * (used in testing) + */ + if ( + typeof options.errorOnUnknownASTType === 'boolean' && + options.errorOnUnknownASTType + ) { + extra.errorOnUnknownASTType = true; + } + /** + * Allow the user to override the function used for logging + */ + if (typeof options.loggerFn === 'function') { + extra.log = options.loggerFn; + } else if (options.loggerFn === false) { + extra.log = Function.prototype; + } + + if (typeof options.project === 'string') { + extra.projects = [options.project]; + } else if ( + Array.isArray(options.project) && + options.project.every(projectPath => typeof projectPath === 'string') + ) { + extra.projects = options.project; + } + + if (typeof options.tsconfigRootDir === 'string') { + extra.tsconfigRootDir = options.tsconfigRootDir; + } + + if ( + Array.isArray(options.extraFileExtensions) && + options.extraFileExtensions.every(ext => typeof ext === 'string') + ) { + extra.extraFileExtensions = options.extraFileExtensions; + } +} + +function warnAboutTSVersion(): void { + if (!isRunningSupportedTypeScriptVersion && !warnedAboutTSVersion) { + const border = '============='; + const versionWarning = [ + border, + 'WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-estree.', + 'You may find that it works just fine, or you may not.', + `SUPPORTED TYPESCRIPT VERSIONS: ${SUPPORTED_TYPESCRIPT_VERSIONS}`, + `YOUR TYPESCRIPT VERSION: ${ACTIVE_TYPESCRIPT_VERSION}`, + 'Please only submit bug reports when using the officially supported version.', + border + ]; + extra.log(versionWarning.join('\n\n')); + warnedAboutTSVersion = true; + } +} + //------------------------------------------------------------------------------ // Parser //------------------------------------------------------------------------------ @@ -187,143 +280,118 @@ type AST = Program & (T['tokens'] extends true ? { tokens: ESTreeToken[] } : {}) & (T['comment'] extends true ? { comments: ESTreeComment[] } : {}); -/** - * Parses the given source code to produce a valid AST - * @param {string} code TypeScript code - * @param {boolean} shouldGenerateServices Flag determining whether to generate ast maps and program or not - * @param {ParserOptions} options configuration object for the parser - * @returns {Object} the AST - */ -function generateAST( +interface ParseAndGenerateServicesResult { + ast: AST; + services: { + program: ts.Program | undefined; + esTreeNodeToTSNodeMap: WeakMap | undefined; + tsNodeToESTreeNodeMap: WeakMap | undefined; + }; +} + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +export const version: string = packageJSON.version; + +export function parse( code: string, - options: T = {} as T, - shouldGenerateServices = false -): { - estree: AST; - program: typeof shouldGenerateServices extends true - ? ts.Program - : (ts.Program | undefined); - astMaps: typeof shouldGenerateServices extends true - ? { - esTreeNodeToTSNodeMap: WeakMap; - tsNodeToESTreeNodeMap: WeakMap; - } - : { - esTreeNodeToTSNodeMap?: WeakMap; - tsNodeToESTreeNodeMap?: WeakMap; - }; -} { + options?: T +): AST { + /** + * Reset the parse configuration + */ + resetExtra(); + /** + * Ensure users do not attempt to use parse() when they need parseAndGenerateServices() + */ + if (options && options.errorOnTypeScriptSyntacticAndSemanticIssues) { + throw new Error( + `"errorOnTypeScriptSyntacticAndSemanticIssues" is only supported for parseAndGenerateServices()` + ); + } + /** + * Ensure the source code is a string, and store a reference to it + */ if (typeof code !== 'string' && !((code as any) instanceof String)) { code = String(code); } + extra.code = code; + /** + * Apply the given parser options + */ + if (typeof options !== 'undefined') { + applyParserOptionsToExtra(options); + } + /** + * Warn if the user is using an unsupported version of TypeScript + */ + warnAboutTSVersion(); + /** + * Create a ts.SourceFile directly, no ts.Program is needed for a simple + * parse + */ + const ast = ts.createSourceFile( + getFileName(extra), + code, + ts.ScriptTarget.Latest, + /* setParentNodes */ true + ); + /** + * Convert the TypeScript AST to an ESTree-compatible one + */ + const { estree } = convert(ast, extra, false); + return estree; +} +export function parseAndGenerateServices< + T extends ParserOptions = ParserOptions +>(code: string, options: T): ParseAndGenerateServicesResult { + /** + * Reset the parse configuration + */ resetExtra(); - + /** + * Ensure the source code is a string, and store a reference to it + */ + if (typeof code !== 'string' && !((code as any) instanceof String)) { + code = String(code); + } + extra.code = code; + /** + * Apply the given parser options + */ if (typeof options !== 'undefined') { - extra.range = typeof options.range === 'boolean' && options.range; - extra.loc = typeof options.loc === 'boolean' && options.loc; - - if (typeof options.tokens === 'boolean' && options.tokens) { - extra.tokens = []; - } - - if (typeof options.comment === 'boolean' && options.comment) { - extra.comment = true; - extra.comments = []; - } - - if (typeof options.jsx === 'boolean' && options.jsx) { - extra.jsx = true; - } - - /** - * Allow the user to cause the parser to error if it encounters an unknown AST Node Type - * (used in testing). - */ - if ( - typeof options.errorOnUnknownASTType === 'boolean' && - options.errorOnUnknownASTType - ) { - extra.errorOnUnknownASTType = true; - } - - /** - * Retrieve semantic and syntactic diagnostics from the underlying TypeScript Program - * and turn them into parse errors - */ + applyParserOptionsToExtra(options); if ( - shouldGenerateServices && typeof options.errorOnTypeScriptSyntacticAndSemanticIssues === 'boolean' && options.errorOnTypeScriptSyntacticAndSemanticIssues ) { extra.errorOnTypeScriptSyntacticAndSemanticIssues = true; } - - if (typeof options.useJSXTextNode === 'boolean' && options.useJSXTextNode) { - extra.useJSXTextNode = true; - } - - /** - * Allow the user to override the function used for logging - */ - if (typeof options.loggerFn === 'function') { - extra.log = options.loggerFn; - } else if (options.loggerFn === false) { - extra.log = Function.prototype; - } - - if (typeof options.project === 'string') { - extra.projects = [options.project]; - } else if ( - Array.isArray(options.project) && - options.project.every(projectPath => typeof projectPath === 'string') - ) { - extra.projects = options.project; - } - - if (typeof options.tsconfigRootDir === 'string') { - extra.tsconfigRootDir = options.tsconfigRootDir; - } - - if ( - Array.isArray(options.extraFileExtensions) && - options.extraFileExtensions.every(ext => typeof ext === 'string') - ) { - extra.extraFileExtensions = options.extraFileExtensions; - } } - - if (!isRunningSupportedTypeScriptVersion && !warnedAboutTSVersion) { - const border = '============='; - const versionWarning = [ - border, - 'WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-estree.', - 'You may find that it works just fine, or you may not.', - `SUPPORTED TYPESCRIPT VERSIONS: ${SUPPORTED_TYPESCRIPT_VERSIONS}`, - `YOUR TYPESCRIPT VERSION: ${ACTIVE_TYPESCRIPT_VERSION}`, - 'Please only submit bug reports when using the officially supported version.', - border - ]; - extra.log(versionWarning.join('\n\n')); - warnedAboutTSVersion = true; - } - + /** + * Warn if the user is using an unsupported version of TypeScript + */ + warnAboutTSVersion(); + /** + * Generate a full ts.Program in order to be able to provide parser + * services, such as type-checking + */ const shouldProvideParserServices = - shouldGenerateServices && extra.projects && extra.projects.length > 0; + extra.projects && extra.projects.length > 0; const { ast, program } = getProgramAndAST( code, options, shouldProvideParserServices ); - - extra.code = code; - /** - * Convert the AST + * Convert the TypeScript AST to an ESTree-compatible one, and optionally preserve + * mappings between converted and original AST nodes */ const { estree, astMaps } = convert(ast, extra, shouldProvideParserServices); - /** * Even if TypeScript parsed the source code ok, and we had no problems converting the AST, * there may be other syntactic or semantic issues in the code that we can optionally report on. @@ -334,42 +402,21 @@ function generateAST( throw convertError(error); } } - - return { - estree, - program: shouldProvideParserServices ? program : undefined, - astMaps: shouldProvideParserServices - ? astMaps! - : { esTreeNodeToTSNodeMap: undefined, tsNodeToESTreeNodeMap: undefined } - }; -} - -//------------------------------------------------------------------------------ -// Public -//------------------------------------------------------------------------------ - -export const version: string = packageJSON.version; - -export function parse( - code: string, - options?: T -) { - if (options && options.errorOnTypeScriptSyntacticAndSemanticIssues) { - throw new Error( - `"errorOnTypeScriptSyntacticAndSemanticIssues" is only supported for parseAndGenerateServices()` - ); - } - return generateAST(code, options).estree; -} - -export function parseAndGenerateServices(code: string, options: ParserOptions) { - const result = generateAST(code, options, /*shouldGenerateServices*/ true); + /** + * Return the converted AST and additional parser services + */ return { - ast: result.estree, + ast: estree, services: { - program: result.program, - esTreeNodeToTSNodeMap: result.astMaps.esTreeNodeToTSNodeMap, - tsNodeToESTreeNodeMap: result.astMaps.tsNodeToESTreeNodeMap + program: shouldProvideParserServices ? program : undefined, + esTreeNodeToTSNodeMap: + shouldProvideParserServices && astMaps + ? astMaps.esTreeNodeToTSNodeMap + : undefined, + tsNodeToESTreeNodeMap: + shouldProvideParserServices && astMaps + ? astMaps.tsNodeToESTreeNodeMap + : undefined } }; } diff --git a/packages/typescript-estree/tests/lib/__snapshots__/parse.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/parse.ts.snap index 4509f7441037..38e378d9f7e0 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/parse.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/parse.ts.snap @@ -189,7 +189,87 @@ Object { } `; -exports[`parse() non string code should correctly convert code to string 1`] = ` +exports[`parse() non string code should correctly convert code to a string for parse() 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "raw": "12345", + "type": "Literal", + "value": 12345, + }, + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "ExpressionStatement", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Numeric", + "value": "12345", + }, + ], + "type": "Program", +} +`; + +exports[`parse() non string code should correctly convert code to a string for parseAndGenerateServices() 1`] = ` Object { "body": Array [ Object { diff --git a/packages/typescript-estree/tests/lib/parse.ts b/packages/typescript-estree/tests/lib/parse.ts index 74f02d03792c..fc7e8af99a10 100644 --- a/packages/typescript-estree/tests/lib/parse.ts +++ b/packages/typescript-estree/tests/lib/parse.ts @@ -57,9 +57,14 @@ describe('parse()', () => { }; it( - 'should correctly convert code to string', + 'should correctly convert code to a string for parse()', createSnapshotTestBlock(code, config) ); + + it( + 'should correctly convert code to a string for parseAndGenerateServices()', + createSnapshotTestBlock(code, config, true) + ); }); describe('loggerFn should be propagated to ast-converter', () => { diff --git a/packages/typescript-estree/tests/lib/semanticInfo.ts b/packages/typescript-estree/tests/lib/semanticInfo.ts index eb5af8677e97..e45cae843ed5 100644 --- a/packages/typescript-estree/tests/lib/semanticInfo.ts +++ b/packages/typescript-estree/tests/lib/semanticInfo.ts @@ -17,6 +17,7 @@ import { formatSnapshotName, parseCodeAndGenerateServices } from '../../tools/test-utils'; +import { parseAndGenerateServices } from '../../src/parser'; //------------------------------------------------------------------------------ // Setup @@ -59,6 +60,23 @@ describe('semanticInfo', () => { ); }); + it(`should handle "project": "./tsconfig.json" and "project": ["./tsconfig.json"] the same`, () => { + const filename = testFiles[0]; + const code = readFileSync(filename, 'utf8'); + const options = createOptions(filename); + const optionsProjectString = { + ...options, + project: './tsconfig.json' + }; + const optionsProjectArray = { + ...options, + project: ['./tsconfig.json'] + }; + expect(parseAndGenerateServices(code, optionsProjectString)).toEqual( + parseAndGenerateServices(code, optionsProjectArray) + ); + }); + // case-specific tests it('isolated-file tests', () => { const fileName = resolve(FIXTURES_DIR, 'isolated-file.src.ts'); diff --git a/packages/typescript-estree/tests/lib/warn-on-unsupported-ts.ts b/packages/typescript-estree/tests/lib/warn-on-unsupported-ts.ts new file mode 100644 index 000000000000..d984007bf757 --- /dev/null +++ b/packages/typescript-estree/tests/lib/warn-on-unsupported-ts.ts @@ -0,0 +1,22 @@ +import semver from 'semver'; +import * as parser from '../../src/parser'; + +jest.mock('semver'); + +describe('Warn on unsupported TypeScript version', () => { + afterEach(() => { + jest.resetModules(); + jest.resetAllMocks(); + }); + + it('should warn the user if they are using an unsupported TypeScript version', () => { + (semver.satisfies as jest.Mock).mockReturnValue(false); + console.log = jest.fn(); + parser.parse(''); + expect(console.log).toHaveBeenCalledWith( + expect.stringContaining( + 'WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-estree' + ) + ); + }); +}); From 5b0b3d9edbcb3ab588a34c431037d9deece30824 Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 28 Jan 2019 21:35:58 -0500 Subject: [PATCH 47/88] chore: publish v1.1.1 --- CHANGELOG.md | 12 ++++++++++++ lerna.json | 2 +- packages/eslint-plugin-tslint/CHANGELOG.md | 4 ++++ packages/eslint-plugin-tslint/package.json | 4 ++-- packages/eslint-plugin/CHANGELOG.md | 7 +++++++ packages/eslint-plugin/package.json | 4 ++-- packages/parser/CHANGELOG.md | 8 ++++++++ packages/parser/package.json | 6 +++--- packages/shared-fixtures/CHANGELOG.md | 8 ++++++++ packages/shared-fixtures/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 11 +++++++++++ packages/typescript-estree/package.json | 4 ++-- 12 files changed, 61 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fbb5db67f5c..ccbbce028b9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.0...v1.1.1) (2019-01-29) + +### Bug Fixes + +- **eslint-plugin:** make parser services error clearer ([#132](https://github.com/typescript-eslint/typescript-eslint/issues/132)) ([aa9d1e1](https://github.com/typescript-eslint/typescript-eslint/commit/aa9d1e1)) +- **parser:** add visiting of type parameters in JSXOpeningElement ([#150](https://github.com/typescript-eslint/typescript-eslint/issues/150)) ([5e16003](https://github.com/typescript-eslint/typescript-eslint/commit/5e16003)) +- **ts-estree:** expand optional property to include question token ([#138](https://github.com/typescript-eslint/typescript-eslint/issues/138)) ([9068b62](https://github.com/typescript-eslint/typescript-eslint/commit/9068b62)) + +### Performance Improvements + +- **ts-estree:** don't create Program in parse() ([#148](https://github.com/typescript-eslint/typescript-eslint/issues/148)) ([aacf5b0](https://github.com/typescript-eslint/typescript-eslint/commit/aacf5b0)) + # [1.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.0.0...v1.1.0) (2019-01-23) ### Bug Fixes diff --git a/lerna.json b/lerna.json index 844b711bb0fe..06bbd031b2c8 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.1.0", + "version": "1.1.1", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index 6b4306f26855..46f2c1960d94 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.0...v1.1.1) (2019-01-29) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + # [1.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.0.0...v1.1.0) (2019-01-23) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index d8aeedf6ef0e..b54084d620e4 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "1.1.0", + "version": "1.1.1", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -34,6 +34,6 @@ "devDependencies": { "@types/eslint": "^4.16.3", "@types/lodash.memoize": "^4.1.4", - "@typescript-eslint/parser": "1.1.0" + "@typescript-eslint/parser": "1.1.1" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 39a512dab49e..992ae046dde3 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.0...v1.1.1) (2019-01-29) + +### Bug Fixes + +- **eslint-plugin:** make parser services error clearer ([#132](https://github.com/typescript-eslint/typescript-eslint/issues/132)) ([aa9d1e1](https://github.com/typescript-eslint/typescript-eslint/commit/aa9d1e1)) +- **parser:** add visiting of type parameters in JSXOpeningElement ([#150](https://github.com/typescript-eslint/typescript-eslint/issues/150)) ([5e16003](https://github.com/typescript-eslint/typescript-eslint/commit/5e16003)) + # [1.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.0.0...v1.1.0) (2019-01-23) ### Bug Fixes diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 7d414aa3576d..5e824cfd98c3 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "1.1.0", + "version": "1.1.1", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -24,7 +24,7 @@ "recommended:update": "node tools/update-recommended.js" }, "dependencies": { - "@typescript-eslint/parser": "1.1.0", + "@typescript-eslint/parser": "1.1.1", "requireindex": "^1.2.0" }, "devDependencies": { diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index 3c8b8d4e4efc..f2047e5c6d25 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.0...v1.1.1) (2019-01-29) + +### Bug Fixes + +- **eslint-plugin:** make parser services error clearer ([#132](https://github.com/typescript-eslint/typescript-eslint/issues/132)) ([aa9d1e1](https://github.com/typescript-eslint/typescript-eslint/commit/aa9d1e1)) +- **parser:** add visiting of type parameters in JSXOpeningElement ([#150](https://github.com/typescript-eslint/typescript-eslint/issues/150)) ([5e16003](https://github.com/typescript-eslint/typescript-eslint/commit/5e16003)) +- **ts-estree:** expand optional property to include question token ([#138](https://github.com/typescript-eslint/typescript-eslint/issues/138)) ([9068b62](https://github.com/typescript-eslint/typescript-eslint/commit/9068b62)) + # [1.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.0.0...v1.1.0) (2019-01-23) ### Bug Fixes diff --git a/packages/parser/package.json b/packages/parser/package.json index 2ba2e642ebd9..6cf42f6ce6db 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "1.1.0", + "version": "1.1.1", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/parser.js", "files": [ @@ -36,7 +36,7 @@ "typescript": "*" }, "dependencies": { - "@typescript-eslint/typescript-estree": "1.1.0", + "@typescript-eslint/typescript-estree": "1.1.1", "eslint-scope": "^4.0.0", "eslint-visitor-keys": "^1.0.0" }, @@ -44,6 +44,6 @@ "@types/eslint": "^4.16.5", "@types/eslint-visitor-keys": "^1.0.0", "@types/estree": "^0.0.39", - "@typescript-eslint/shared-fixtures": "1.1.0" + "@typescript-eslint/shared-fixtures": "1.1.1" } } diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index 3114aaabc99c..2c81f52bfe1e 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.0...v1.1.1) (2019-01-29) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + + + + + # [1.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.0.0...v1.1.0) (2019-01-23) diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index 2424070165f4..e5b8b9613aad 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "1.1.0", + "version": "1.1.1", "private": true } diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index be11f821f745..2fcfd25aae42 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.0...v1.1.1) (2019-01-29) + +### Bug Fixes + +- **parser:** add visiting of type parameters in JSXOpeningElement ([#150](https://github.com/typescript-eslint/typescript-eslint/issues/150)) ([5e16003](https://github.com/typescript-eslint/typescript-eslint/commit/5e16003)) +- **ts-estree:** expand optional property to include question token ([#138](https://github.com/typescript-eslint/typescript-eslint/issues/138)) ([9068b62](https://github.com/typescript-eslint/typescript-eslint/commit/9068b62)) + +### Performance Improvements + +- **ts-estree:** don't create Program in parse() ([#148](https://github.com/typescript-eslint/typescript-eslint/issues/148)) ([aacf5b0](https://github.com/typescript-eslint/typescript-eslint/commit/aacf5b0)) + # [1.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.0.0...v1.1.0) (2019-01-23) ### Bug Fixes diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 3d112005adce..2be4fceecffc 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "1.1.0", + "version": "1.1.1", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/parser.js", "types": "dist/parser.d.ts", @@ -42,7 +42,7 @@ "typescript": "*" }, "devDependencies": { - "@typescript-eslint/shared-fixtures": "1.1.0", + "@typescript-eslint/shared-fixtures": "1.1.1", "typescript": "~3.2.1" } } From 38abc282ec03b907ae0eac9fae962cf262c9f885 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Tue, 29 Jan 2019 12:58:21 -0800 Subject: [PATCH 48/88] feat(eslint-plugin): add no-unnecessary-type-assertion rule (#157) Adding equivalent of TSLint's `no-unnecessary-type-assertion`. --- packages/eslint-plugin/README.md | 1 + packages/eslint-plugin/ROADMAP.md | 8 +- .../rules/no-unnecessary-type-assertion.md | 57 ++++++ .../rules/no-unnecessary-type-assertion.js | 179 ++++++++++++++++++ .../rules/no-unnecessary-type-assertion.js | 122 ++++++++++++ 5 files changed, 363 insertions(+), 4 deletions(-) create mode 100644 packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md create mode 100644 packages/eslint-plugin/lib/rules/no-unnecessary-type-assertion.js create mode 100644 packages/eslint-plugin/tests/lib/rules/no-unnecessary-type-assertion.js diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 4f6f771d47c4..09b00a8e69a6 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -105,6 +105,7 @@ See [@typescript-eslint/parser's README.md](../parser/README.md) for more inform | [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | | | [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// ` comments (`no-reference` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | | +| [`typescript/no-unnecessary-type-assertion`](./docs/rules/no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression (`no-unnecessary-type-assertion` from TSLint) | | :wrench: | | [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | | | [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | | diff --git a/packages/eslint-plugin/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md index 1fce16992a9c..378a3140ffb8 100644 --- a/packages/eslint-plugin/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -1,10 +1,10 @@ -# Roadmap +# Roadmap -✅ (27) = done +✅ (28) = done 🌟 (79) = in ESLint core 🔌 (33) = in another plugin 🌓 (16) = implementations differ or ESLint version is missing functionality -🛑 (71) = unimplemented +🛑 (70) = unimplemented ## TSLint rules @@ -26,7 +26,7 @@ | [`no-non-null-assertion`] | ✅ | [`@typescript-eslint/no-non-null-assertion`] | | [`no-parameter-reassignment`] | ✅ | [`no-param-reassign`][no-param-reassign] | | [`no-reference`] | ✅ | [`@typescript-eslint/no-triple-slash-reference`] | -| [`no-unnecessary-type-assertion`] | 🛑 | N/A | +| [`no-unnecessary-type-assertion`] | ✅ | [`@typescript-eslint/no-unnecessary-type-assertion`] | | [`no-var-requires`] | ✅ | [`@typescript-eslint/no-var-requires`] | | [`only-arrow-functions`] | 🔌 | [`prefer-arrow/prefer-arrow-functions`] | | [`prefer-for-of`] | 🛑 | N/A | diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md b/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md new file mode 100644 index 000000000000..c41d0f2a4300 --- /dev/null +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md @@ -0,0 +1,57 @@ +# Warns if a type assertion does not change the type of an expression (no-unnecessary-type-assertion) + +This rule prohibits using a type assertion that does not change the type of an expression. + +## Rule Details + +This rule aims to prevent unnecessary type assertions. + +Examples of **incorrect** code for this rule: + +```ts +const foo = 3; +const bar = foo!; +``` + +```ts +const foo = <3>3; +``` + +```ts +type Foo = 3; +const foo = 3; +``` + +```ts +type Foo = 3; +const foo = 3 as Foo; +``` + +Examples of **correct** code for this rule: + +```ts +const foo = 3; +``` + +```ts +const foo = 3 as number; +``` + +### Options + +This rule optionally takes an object with a single property `typesToIgnore`, which can be set to a list of type names to ignore. + +For example, with `@typescript-eslint/no-unnecessary-type-assertion: ["error", { typesToIgnore: ['Foo'] }]`, the following is **correct** code": + +```ts +type Foo = 3; +const foo: Foo = 3; +``` + +## When Not To Use It + +If you don't care about having no-op type assertions in your code, then you can turn off this rule. + +## Related to + +- TSLint: ['no-unnecessary-type-assertion`](https://palantir.github.io/tslint/rules/no-unnecessary-type-assertion/) diff --git a/packages/eslint-plugin/lib/rules/no-unnecessary-type-assertion.js b/packages/eslint-plugin/lib/rules/no-unnecessary-type-assertion.js new file mode 100644 index 000000000000..ed1747c0d95e --- /dev/null +++ b/packages/eslint-plugin/lib/rules/no-unnecessary-type-assertion.js @@ -0,0 +1,179 @@ +/** + * @fileoverview Rule to warn if a type assertion does not change the type of an expression + * @author Benjamin Lichtman + */ + +'use strict'; +const tsutils = require('tsutils'); +const ts = require('typescript'); +const util = require('../util'); + +/** @typedef {import("estree").Node} Node */ +/** @typedef {import("eslint").Rule.RuleContext} Context */ + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +/** + * Sometimes tuple types don't have ObjectFlags.Tuple set, like when they're being matched against an inferred type. + * So, in addition, check if there are integer properties 0..n and no other numeric keys + * @param {ts.ObjectType} type type + * @returns {boolean} true if type could be a tuple type + */ +function couldBeTupleType(type) { + const properties = type.getProperties(); + + if (properties.length === 0) { + return false; + } + let i = 0; + + for (; i < properties.length; ++i) { + const name = properties[i].name; + + if (String(i) !== name) { + if (i === 0) { + // if there are no integer properties, this is not a tuple + return false; + } + break; + } + } + for (; i < properties.length; ++i) { + if (String(+properties[i].name) === properties[i].name) { + return false; // if there are any other numeric properties, this is not a tuple + } + } + return true; +} + +/** + * + * @param {Node} node node being linted + * @param {Context} context linting context + * @param {ts.TypeChecker} checker TypeScript typechecker + * @returns {void} + */ +function checkNonNullAssertion(node, context, checker) { + /** + * Corresponding TSNode is guaranteed to be in map + * @type {ts.NonNullExpression} + */ + const originalNode = context.parserServices.esTreeNodeToTSNodeMap.get(node); + const type = checker.getTypeAtLocation(originalNode.expression); + + if (type === checker.getNonNullableType(type)) { + context.report({ + node, + messageId: 'unnecessaryAssertion', + fix(fixer) { + return fixer.removeRange([ + originalNode.expression.end, + originalNode.end + ]); + } + }); + } +} + +/** + * @param {Node} node node being linted + * @param {Context} context linting context + * @param {ts.TypeChecker} checker TypeScript typechecker + * @returns {void} + */ +function verifyCast(node, context, checker) { + /** + * * Corresponding TSNode is guaranteed to be in map + * @type {ts.AssertionExpression} + */ + const originalNode = context.parserServices.esTreeNodeToTSNodeMap.get(node); + const options = context.options[0]; + + if ( + options && + options.typesToIgnore && + options.typesToIgnore.indexOf(originalNode.type.getText()) !== -1 + ) { + return; + } + const castType = checker.getTypeAtLocation(originalNode); + + if ( + tsutils.isTypeFlagSet(castType, ts.TypeFlags.Literal) || + (tsutils.isObjectType(castType) && + (tsutils.isObjectFlagSet(castType, ts.ObjectFlags.Tuple) || + couldBeTupleType(castType))) + ) { + // It's not always safe to remove a cast to a literal type or tuple + // type, as those types are sometimes widened without the cast. + return; + } + + const uncastType = checker.getTypeAtLocation(originalNode.expression); + + if (uncastType === castType) { + context.report({ + node, + messageId: 'unnecessaryAssertion', + fix(fixer) { + return originalNode.kind === ts.SyntaxKind.TypeAssertionExpression + ? fixer.removeRange([ + originalNode.getStart(), + originalNode.expression.getStart() + ]) + : fixer.removeRange([originalNode.expression.end, originalNode.end]); + } + }); + } +} + +/** @type {import("eslint").Rule.RuleModule} */ +module.exports = { + meta: { + docs: { + description: + 'Warns if a type assertion does not change the type of an expression', + category: 'TypeScript-specific', + recommended: false, + extraDescription: [util.tslintRule('no-unnecessary-type-assertion')], + url: util.metaDocsUrl('no-unnecessary-type-assertion') + }, + fixable: 'code', + messages: { + unnecessaryAssertion: + 'This assertion is unnecessary since it does not change the type of the expression.' + }, + schema: [ + { + type: 'object', + properties: { + typesToIgnore: { + type: 'array', + items: { + type: 'string' + } + } + } + } + ], + type: 'suggestion' + }, + + create(context) { + const checker = util.getParserServices(context).program.getTypeChecker(); + + return { + TSNonNullExpression(node) { + checkNonNullAssertion(node, context, checker); + }, + TSTypeAssertion(node) { + verifyCast(node, context, checker); + }, + TSAsExpression(node) { + verifyCast(node, context, checker); + } + }; + } +}; diff --git a/packages/eslint-plugin/tests/lib/rules/no-unnecessary-type-assertion.js b/packages/eslint-plugin/tests/lib/rules/no-unnecessary-type-assertion.js new file mode 100644 index 000000000000..633f1a334330 --- /dev/null +++ b/packages/eslint-plugin/tests/lib/rules/no-unnecessary-type-assertion.js @@ -0,0 +1,122 @@ +/** + * @fileoverview Warns if a type assertion does not change the type of an expression. + * @author Benjamin Lichtman + */ +'use strict'; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const rule = require('../../../lib/rules/no-unnecessary-type-assertion'), + RuleTester = require('eslint').RuleTester, + path = require('path'); + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +const rootDir = path.join(process.cwd(), 'tests/fixtures'); +const parserOptions = { + ecmaVersion: 2015, + tsconfigRootDir: rootDir, + project: './tsconfig.json' +}; +const ruleTester = new RuleTester({ + parserOptions, + parser: '@typescript-eslint/parser' +}); + +ruleTester.run('no-unnecessary-type-assertion', rule, { + valid: [ + 'const foo = 3 as number;', + 'const foo = 3;', + 'const foo = <3>3;', + 'const foo = 3 as 3;', + ` +type Tuple = [3, "hi", "bye"]; +const foo = ([3, "hi", "bye"]) as Tuple;`, + ` +type PossibleTuple = {}; +const foo = ({}) as PossibleTuple;`, + ` +type PossibleTuple = { hello: "hello" }; +const foo = ({ hello: "hello" }) as PossibleTuple;`, + ` +type PossibleTuple = { 0: "hello", 5: "hello" }; +const foo = ({ 0: "hello", 5: "hello" }) as PossibleTuple;`, + { + code: ` +type Foo = number; +const foo = (3 + 5) as Foo;`, + options: [{ typesToIgnore: ['Foo'] }] + }, + { + code: ` +type Foo = number; +const foo = (3 + 5);`, + options: [{ typesToIgnore: ['Foo'] }] + } + ], + + invalid: [ + { + code: ` +const foo = 3; +const bar = foo!;`, + errors: [ + { + messageId: 'unnecessaryAssertion', + line: 3, + column: 13 + } + ] + }, + { + code: ` +const foo = (3 + 5) as number;`, + errors: [ + { + messageId: 'unnecessaryAssertion', + line: 2, + column: 13 + } + ] + }, + { + code: ` +const foo = (3 + 5);`, + errors: [ + { + messageId: 'unnecessaryAssertion', + line: 2, + column: 13 + } + ] + }, + { + code: ` +type Foo = number; +const foo = (3 + 5) as Foo;`, + errors: [ + { + messageId: 'unnecessaryAssertion', + line: 3, + column: 13 + } + ] + }, + { + code: ` +type Foo = number; +const foo = (3 + 5);`, + errors: [ + { + messageId: 'unnecessaryAssertion', + line: 3, + column: 13 + } + ] + } + ] +}); From 6147de1bb20e269b1e0a650c8be5376d0f51752e Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 29 Jan 2019 22:10:01 +0100 Subject: [PATCH 49/88] fix(parser): fix regression with no-unused-vars for jsx attributes (#161) --- .../tests/lib/rules/no-unused-vars.js | 16 +- packages/parser/src/analyze-scope.ts | 2 +- .../scope-analysis/jsx-attributes.tsx | 8 + .../lib/__snapshots__/scope-analysis.ts.snap | 459 ++++++++++++++++++ 4 files changed, 483 insertions(+), 2 deletions(-) create mode 100644 packages/parser/tests/fixtures/scope-analysis/jsx-attributes.tsx diff --git a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js index 2fe854b2c442..6aef8a1e50ad 100644 --- a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js @@ -558,8 +558,8 @@ import foo from 'foo'; import bar from 'foo'; export interface Bar extends foo.i18n {} `, - // https://github.com/typescript-eslint/typescript-eslint/issues/141 { + // https://github.com/typescript-eslint/typescript-eslint/issues/141 filename: 'test.tsx', code: ` import { TypeA } from './interface'; @@ -570,6 +570,20 @@ export const a = />; jsx: true } } + }, + { + // https://github.com/typescript-eslint/typescript-eslint/issues/160 + filename: 'test.tsx', + code: ` +const text = 'text'; +export function Foo() { + return ( +

+ +
+ ); +} + ` } ], diff --git a/packages/parser/src/analyze-scope.ts b/packages/parser/src/analyze-scope.ts index eb9f3c92c752..2e8ae2e0a3cd 100644 --- a/packages/parser/src/analyze-scope.ts +++ b/packages/parser/src/analyze-scope.ts @@ -241,7 +241,7 @@ class Referencer extends OriginalReferencer { JSXOpeningElement(node: any) { this.visit(node.name); this.visitTypeParameters(node); - this.visit(node.attributes); + node.attributes.forEach(this.visit, this); } /** diff --git a/packages/parser/tests/fixtures/scope-analysis/jsx-attributes.tsx b/packages/parser/tests/fixtures/scope-analysis/jsx-attributes.tsx new file mode 100644 index 000000000000..04bb4b42ac80 --- /dev/null +++ b/packages/parser/tests/fixtures/scope-analysis/jsx-attributes.tsx @@ -0,0 +1,8 @@ +const text = 'text'; +export function Foo() { + return ( +
+ +
+ ); +} diff --git a/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap b/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap index 8fd73916d216..39fedcb8277b 100644 --- a/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap @@ -5325,6 +5325,248 @@ Object { } `; +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/jsx-attributes.tsx 1`] = ` +Object { + "$id": 7, + "block": Object { + "range": Array [ + 0, + 143, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 6, + "block": Object { + "range": Array [ + 0, + 143, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 5, + "block": Object { + "range": Array [ + 28, + 142, + ], + "type": "FunctionDeclaration", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 4, + "from": Object { + "$ref": 5, + }, + "identifier": Object { + "name": "text", + "range": Array [ + 116, + 120, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 4, + }, + ], + "type": "function", + "upperScope": Object { + "$ref": 6, + }, + "variableMap": Object { + "arguments": Object { + "$ref": 3, + }, + }, + "variableScope": Object { + "$ref": 5, + }, + "variables": Array [ + Object { + "$id": 3, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 2, + "from": Object { + "$ref": 6, + }, + "identifier": Object { + "name": "text", + "range": Array [ + 6, + 10, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": Object { + "range": Array [ + 13, + 19, + ], + "type": "Literal", + }, + }, + ], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 7, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 1, + }, + "text": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 6, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "text", + "range": Array [ + 6, + 10, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 6, + 19, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 20, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "text", + "range": Array [ + 6, + 10, + ], + "type": "Identifier", + }, + ], + "name": "text", + "references": Array [ + Object { + "$ref": 2, + }, + Object { + "$ref": 4, + }, + ], + "scope": Object { + "$ref": 6, + }, + }, + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 37, + 40, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 28, + 142, + ], + "type": "FunctionDeclaration", + }, + "parent": null, + "type": "FunctionName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 37, + 40, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 6, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 7, + }, + "variables": Array [], +} +`; + exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/method-overload.ts 1`] = ` Object { "$id": 11, @@ -15626,6 +15868,223 @@ Object { } `; +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/jsx-attributes.tsx 1`] = ` +Object { + "$id": 6, + "block": Object { + "range": Array [ + 0, + 143, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 5, + "block": Object { + "range": Array [ + 28, + 142, + ], + "type": "FunctionDeclaration", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [ + Object { + "$id": 4, + "from": Object { + "$ref": 5, + }, + "identifier": Object { + "name": "text", + "range": Array [ + 116, + 120, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 4, + }, + ], + "type": "function", + "upperScope": Object { + "$ref": 6, + }, + "variableMap": Object { + "arguments": Object { + "$ref": 3, + }, + }, + "variableScope": Object { + "$ref": 5, + }, + "variables": Array [ + Object { + "$id": 3, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [ + Object { + "$id": 2, + "from": Object { + "$ref": 6, + }, + "identifier": Object { + "name": "text", + "range": Array [ + 6, + 10, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": Object { + "range": Array [ + 13, + 19, + ], + "type": "Literal", + }, + }, + ], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "Foo": Object { + "$ref": 1, + }, + "text": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 6, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "text", + "range": Array [ + 6, + 10, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 6, + 19, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 20, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "text", + "range": Array [ + 6, + 10, + ], + "type": "Identifier", + }, + ], + "name": "text", + "references": Array [ + Object { + "$ref": 2, + }, + Object { + "$ref": 4, + }, + ], + "scope": Object { + "$ref": 6, + }, + }, + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 37, + 40, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 28, + 142, + ], + "type": "FunctionDeclaration", + }, + "parent": null, + "type": "FunctionName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 37, + 40, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 6, + }, + }, + ], +} +`; + exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/method-overload.ts 1`] = ` Object { "$id": 10, From f8f9b90d6941cf6138a08275e0ba10d8a86f82aa Mon Sep 17 00:00:00 2001 From: Veniamin Krol <153412+vkrol@users.noreply.github.com> Date: Wed, 30 Jan 2019 15:07:11 +0200 Subject: [PATCH 50/88] docs(eslint-plugin): no-unnecessary-type-assertion rule name in README.md (#163) --- packages/eslint-plugin/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 09b00a8e69a6..6766e831a3f4 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -105,7 +105,7 @@ See [@typescript-eslint/parser's README.md](../parser/README.md) for more inform | [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | | | [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// ` comments (`no-reference` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | | -| [`typescript/no-unnecessary-type-assertion`](./docs/rules/no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression (`no-unnecessary-type-assertion` from TSLint) | | :wrench: | +| [`@typescript-eslint/no-unnecessary-type-assertion`](./docs/rules/no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression (`no-unnecessary-type-assertion` from TSLint) | | :wrench: | | [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | | | [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | | From c779ad489b9176033a9fe7ceb722ff9847d51d35 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Wed, 30 Jan 2019 08:25:11 -0500 Subject: [PATCH 51/88] docs(eslint-plugin): add docs on using Prettier with the plugin (#104) --- packages/eslint-plugin/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 6766e831a3f4..f0c11446353e 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -68,6 +68,22 @@ If you want to use rules which require type information, you will need to specif See [@typescript-eslint/parser's README.md](../parser/README.md) for more information on the available "parserOptions". +## Usage with Prettier + +Install [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier) to disable our code formatting related rules: + +```json +{ + "extends": [ + "plugin:@typescript-eslint/recommended", + "prettier", + "prettier/@typescript-eslint" + ] +} +``` + +**Note: Make sure you have `eslint-config-prettier@4.0.0` or newer.** + ## Supported Rules From 417c7fb1c7c66108822b41152fb0c019152acabd Mon Sep 17 00:00:00 2001 From: James Henry Date: Wed, 30 Jan 2019 08:39:11 -0500 Subject: [PATCH 52/88] docs(readme): add notes about package versions (#164) --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index de2fdd5da6ae..75e75658d069 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,20 @@ This repo contains several packages which allow ESLint users to lint their TypeS - [`@typescript-eslint/eslint-plugin-tslint`](./packages/eslint-plugin-tslint) - An ESLint-specific plugin which runs an instance of TSLint within your ESLint setup to allow for users to more easily migrate from TSLint to ESLint. +## Package Versions + +All of the packages are published with the same version number to make it easier to coordinate both releases and installations. + +Additionally, we also publish a canary release on every successful merge to master, so you never need to wait for a new stable version to make use of any updates. + +The `latest` (stable) version is: + +NPM Version + +The `canary` (latest master) version is: + +NPM Version + ## Supported TypeScript Version We will always endeavor to support the latest stable version of TypeScript. From f0dddbc19cbbbba409d48c111d19e24f00db5073 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Wed, 30 Jan 2019 11:34:13 -0800 Subject: [PATCH 53/88] chore(eslint-plugin): add tsutils as dependency (#165) Managed to forget to add `tsutils` as a true dependency to `eslint-plugin` in #157. --- packages/eslint-plugin/package.json | 3 ++- yarn.lock | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 5e824cfd98c3..350da0cb2aff 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -25,7 +25,8 @@ }, "dependencies": { "@typescript-eslint/parser": "1.1.1", - "requireindex": "^1.2.0" + "requireindex": "^1.2.0", + "tsutils": "^3.7.0" }, "devDependencies": { "eslint": "^5.9.0", diff --git a/yarn.lock b/yarn.lock index b6a6d614dfc0..6980f52cafb8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7025,6 +7025,13 @@ tsutils@^2.27.2: dependencies: tslib "^1.8.1" +tsutils@^3.7.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.7.0.tgz#f97bdd2f109070bd1865467183e015b25734b477" + integrity sha512-n+e+3q7Jx2kfZw7tjfI9axEIWBY0sFMOlC+1K70X0SeXpO/UYSB+PN+E9tIJNqViB7oiXQdqD7dNchnvoneZew== + dependencies: + tslib "^1.8.1" + tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" From 1f868cec3d6279beb24094f77c8e72626ce6fb9f Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 31 Jan 2019 22:58:38 +0100 Subject: [PATCH 54/88] fix(eslint-plugin): use bracket for infer type in array-type rule (#173) --- .../eslint-plugin/lib/rules/array-type.js | 1 + .../tests/lib/rules/array-type.js | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/packages/eslint-plugin/lib/rules/array-type.js b/packages/eslint-plugin/lib/rules/array-type.js index 9d30f23cfb4f..ba7d83a5a7f5 100644 --- a/packages/eslint-plugin/lib/rules/array-type.js +++ b/packages/eslint-plugin/lib/rules/array-type.js @@ -67,6 +67,7 @@ function typeNeedsParentheses(node) { case 'TSFunctionType': case 'TSIntersectionType': case 'TSTypeOperator': + case 'TSInferType': return true; default: return false; diff --git a/packages/eslint-plugin/tests/lib/rules/array-type.js b/packages/eslint-plugin/tests/lib/rules/array-type.js index e39796f90c0d..39716675cf1c 100644 --- a/packages/eslint-plugin/tests/lib/rules/array-type.js +++ b/packages/eslint-plugin/tests/lib/rules/array-type.js @@ -138,6 +138,11 @@ ruleTester.run('array-type', rule, { }`, options: ['array'] }, + { + // https://github.com/typescript-eslint/typescript-eslint/issues/172 + code: 'type Unwrap = T extends (infer E)[] ? E : T', + options: ['array'] + }, { code: `let z: Array = [3, "4"];`, options: ['generic'] @@ -173,6 +178,11 @@ ruleTester.run('array-type', rule, { { code: `type fooIntersection = Array;`, options: ['generic'] + }, + { + // https://github.com/typescript-eslint/typescript-eslint/issues/172 + code: 'type Unwrap = T extends Array ? E : T', + options: ['generic'] } ], invalid: [ @@ -774,6 +784,34 @@ let yyyy: Arr>>> = [[[["2"]]]];`, column: 19 } ] + }, + { + // https://github.com/typescript-eslint/typescript-eslint/issues/172 + code: 'type Unwrap = T extends Array ? E : T', + output: 'type Unwrap = T extends (infer E)[] ? E : T', + options: ['array'], + errors: [ + { + messageId: 'errorStringArray', + data: { type: 'T' }, + line: 1, + column: 28 + } + ] + }, + { + // https://github.com/typescript-eslint/typescript-eslint/issues/172 + code: 'type Unwrap = T extends (infer E)[] ? E : T', + output: 'type Unwrap = T extends Array ? E : T', + options: ['generic'], + errors: [ + { + messageId: 'errorStringGeneric', + data: { type: 'T' }, + line: 1, + column: 28 + } + ] } ] }); From b1dbb648e529d43bfcc2b6581348420af5eb8736 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 31 Jan 2019 23:23:57 +0100 Subject: [PATCH 55/88] fix(eslint-plugin): fix no-extraneous-class for class without name (#174) --- .../eslint-plugin/lib/rules/no-extraneous-class.js | 12 +++++++++--- .../tests/lib/rules/no-extraneous-class.js | 10 ++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/eslint-plugin/lib/rules/no-extraneous-class.js b/packages/eslint-plugin/lib/rules/no-extraneous-class.js index e2eb3f0216dc..0690fc3963de 100644 --- a/packages/eslint-plugin/lib/rules/no-extraneous-class.js +++ b/packages/eslint-plugin/lib/rules/no-extraneous-class.js @@ -68,7 +68,10 @@ module.exports = { if (node.body.length === 0) { if (allowEmpty) return; - context.report({ node: id, messageId: 'empty' }); + context.report({ + node: id || node.parent, + messageId: 'empty' + }); return; } @@ -97,14 +100,17 @@ module.exports = { if (onlyConstructor) { if (!allowConstructorOnly) { context.report({ - node: id, + node: id || node.parent, messageId: 'onlyConstructor' }); } return; } if (onlyStatic && !allowStaticOnly) { - context.report({ node: id, messageId: 'onlyStatic' }); + context.report({ + node: id || node.parent, + messageId: 'onlyStatic' + }); } } }; diff --git a/packages/eslint-plugin/tests/lib/rules/no-extraneous-class.js b/packages/eslint-plugin/tests/lib/rules/no-extraneous-class.js index 4243677a8679..713e5224ccb1 100644 --- a/packages/eslint-plugin/tests/lib/rules/no-extraneous-class.js +++ b/packages/eslint-plugin/tests/lib/rules/no-extraneous-class.js @@ -70,7 +70,9 @@ export class Bar { } `.trim(), options: [{ allowStaticOnly: true }] - } + }, + // https://github.com/typescript-eslint/typescript-eslint/issues/170 + 'export default class { hello() { return "I am foo!"; } }' ], invalid: [ @@ -117,9 +119,13 @@ export class AClass { } } } - `.trim(), errors: [onlyStatic, empty] + }, + { + // https://github.com/typescript-eslint/typescript-eslint/issues/170 + code: 'export default class { static hello() {} }', + errors: [{ messageId: 'onlyStatic', type: 'ClassDeclaration' }] } ] }); From 1ecc2f2fd8dd9feb578f63c53b3916210dd96797 Mon Sep 17 00:00:00 2001 From: Armano Date: Fri, 1 Feb 2019 02:06:02 +0100 Subject: [PATCH 56/88] test(eslint-plugin): add test case for eslint arrow-parens (#176) --- .../tests/lib/eslint-rules/arrow-parens.js | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 packages/eslint-plugin/tests/lib/eslint-rules/arrow-parens.js diff --git a/packages/eslint-plugin/tests/lib/eslint-rules/arrow-parens.js b/packages/eslint-plugin/tests/lib/eslint-rules/arrow-parens.js new file mode 100644 index 000000000000..e8a77ca2013d --- /dev/null +++ b/packages/eslint-plugin/tests/lib/eslint-rules/arrow-parens.js @@ -0,0 +1,44 @@ +'use strict'; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const rule = require('eslint/lib/rules/arrow-parens'), + RuleTester = require('eslint').RuleTester; + +const ruleTester = new RuleTester({ + parser: '@typescript-eslint/parser' +}); + +ruleTester.run('arrow-parens', rule, { + valid: [ + // https://github.com/typescript-eslint/typescript-eslint/issues/14 + 'const foo = (t) => {};', + 'const foo = (t) => {};', + 'const foo = (t: T) => {};', + 'const foo = ((t: T) => {});', + 'const foo = function (t: T) {};', + { + code: 'const foo = t => {};', + options: ['as-needed'] + }, + { + code: 'const foo = (t) => {};', + options: ['as-needed'] + }, + { + code: 'const foo = (t: T) => {};', + options: ['as-needed'] + }, + { + code: 'const foo = (t: T) => {};', + options: ['as-needed'] + }, + { + code: 'const foo = (t: T) => ({});', + options: ['as-needed', { requireForBlockBody: true }] + } + ], + invalid: [] +}); From 00d020d991f5bc10dd49d9704449660af50cb61d Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Fri, 1 Feb 2019 21:33:53 +0900 Subject: [PATCH 57/88] fix(eslint-plugin): fix wrong URL (#180) --- packages/eslint-plugin/lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/lib/util.js b/packages/eslint-plugin/lib/util.js index e12e15f80413..dac41fe21bb7 100644 --- a/packages/eslint-plugin/lib/util.js +++ b/packages/eslint-plugin/lib/util.js @@ -5,7 +5,7 @@ const version = require('../package.json').version; exports.tslintRule = name => `\`${name}\` from TSLint`; exports.metaDocsUrl = name => - `https://github.com/typescript-eslint/typescript-eslint/blob/${version}/packages/eslint-plugin/docs/rules/${name}.md`; + `https://github.com/typescript-eslint/typescript-eslint/blob/v${version}/packages/eslint-plugin/docs/rules/${name}.md`; /** * Check if the context file name is *.ts or *.tsx From 3fb57a5676cdbe41f75e4dc42472986cb8881993 Mon Sep 17 00:00:00 2001 From: Armano Date: Fri, 1 Feb 2019 13:39:31 +0100 Subject: [PATCH 58/88] feat(eslint-plugin): add eslint rule no-useless-constructor (#167) --- packages/eslint-plugin/README.md | 3 +- .../docs/rules/no-useless-constructor.md | 78 ++++++++++++++ .../lib/rules/no-useless-constructor.js | 80 ++++++++++++++ .../tests/lib/rules/no-useless-constructor.js | 100 ++++++++++++++++++ 4 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 packages/eslint-plugin/docs/rules/no-useless-constructor.md create mode 100644 packages/eslint-plugin/lib/rules/no-useless-constructor.js create mode 100644 packages/eslint-plugin/tests/lib/rules/no-useless-constructor.js diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index f0c11446353e..1ec6df216048 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -121,9 +121,10 @@ Install [`eslint-config-prettier`](https://github.com/prettier/eslint-config-pre | [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | | | [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// ` comments (`no-reference` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | | -| [`@typescript-eslint/no-unnecessary-type-assertion`](./docs/rules/no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression (`no-unnecessary-type-assertion` from TSLint) | | :wrench: | +| [`@typescript-eslint/no-unnecessary-type-assertion`](./docs/rules/no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression (`no-unnecessary-type-assertion` from TSLint) | | :wrench: | | [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | | +| [`@typescript-eslint/no-useless-constructor`](./docs/rules/no-useless-constructor.md) | Disallow unnecessary constructors | | | | [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: | | [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: | diff --git a/packages/eslint-plugin/docs/rules/no-useless-constructor.md b/packages/eslint-plugin/docs/rules/no-useless-constructor.md new file mode 100644 index 000000000000..0e136d122ac1 --- /dev/null +++ b/packages/eslint-plugin/docs/rules/no-useless-constructor.md @@ -0,0 +1,78 @@ +# Disallow unnecessary constructors (no-useless-constructor) + +ES2015 provides a default class constructor if one is not specified. As such, it is unnecessary to provide an empty constructor or one that simply delegates into its parent class, as in the following examples: + +```js +class A { + constructor() {} +} + +class A extends B { + constructor(value) { + super(value); + } +} +``` + +## Rule Details + +This rule flags class constructors that can be safely removed without changing how the class works. + +## Examples + +Examples of **incorrect** code for this rule: + +```js +/*eslint no-useless-constructor: "error"*/ + +class A { + constructor() {} +} + +class A extends B { + constructor(...args) { + super(...args); + } +} +``` + +Examples of **correct** code for this rule: + +```js +/*eslint no-useless-constructor: "error"*/ + +class A {} + +class A { + constructor() { + doSomething(); + } +} + +class A extends B { + constructor() { + super('foo'); + } +} + +class A extends B { + constructor() { + super(); + doSomething(); + } +} + +class A extends B { + constructor(protected name: string) {} +} + +class A extends B { + protected constructor() {} +} +``` + +## When Not To Use It + +If you don't want to be notified about unnecessary constructors, you can safely disable this rule. + +Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/no-useless-constructor.md) diff --git a/packages/eslint-plugin/lib/rules/no-useless-constructor.js b/packages/eslint-plugin/lib/rules/no-useless-constructor.js new file mode 100644 index 000000000000..c30cdcf872bf --- /dev/null +++ b/packages/eslint-plugin/lib/rules/no-useless-constructor.js @@ -0,0 +1,80 @@ +/** + * @fileoverview Disallow unnecessary constructors + * @author Armano + */ +'use strict'; + +const baseRule = require('eslint/lib/rules/no-useless-constructor'); +const util = require('../util'); + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +/** + * Check if method with accessibility is not useless + * @param {MethodDefinition} node + * @returns {boolean} + */ +function checkAccessibility(node) { + switch (node.accessibility) { + case 'protected': + case 'private': + return false; + case 'public': + if ( + node.parent.type === 'ClassBody' && + node.parent.parent && + node.parent.parent.superClass + ) { + return false; + } + break; + } + return true; +} + +/** + * Check if method is not unless due to typescript parameter properties + * @param {MethodDefinition} node + * @returns {boolean} + */ +function checkParams(node) { + return ( + !node.value.params || + !node.value.params.some(param => param.type === 'TSParameterProperty') + ); +} + +module.exports = Object.assign({}, baseRule, { + meta: { + type: 'problem', + docs: { + description: 'Disallow unnecessary constructors', + category: 'ECMAScript 6', + url: util.metaDocsUrl('no-useless-constructor') + }, + schema: baseRule.meta.schema, + messages: baseRule.meta.messages + }, + + create(context) { + const rules = baseRule.create(context); + + //---------------------------------------------------------------------- + // Public + //---------------------------------------------------------------------- + return { + MethodDefinition(node) { + if ( + node.value && + node.value.type === 'FunctionExpression' && + checkAccessibility(node) && + checkParams(node) + ) { + rules.MethodDefinition(node); + } + } + }; + } +}); diff --git a/packages/eslint-plugin/tests/lib/rules/no-useless-constructor.js b/packages/eslint-plugin/tests/lib/rules/no-useless-constructor.js new file mode 100644 index 000000000000..c73c5034f121 --- /dev/null +++ b/packages/eslint-plugin/tests/lib/rules/no-useless-constructor.js @@ -0,0 +1,100 @@ +'use strict'; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const rule = require('../../../lib/rules/no-useless-constructor'), + RuleTester = require('eslint').RuleTester; + +const ruleTester = new RuleTester({ + parserOptions: { + ecmaVersion: 6, + sourceType: 'module' + }, + parser: '@typescript-eslint/parser' +}); + +const error = { message: 'Useless constructor.', type: 'MethodDefinition' }; + +ruleTester.run('no-useless-constructor', rule, { + valid: [ + 'class A { }', + 'class A { constructor(){ doSomething(); } }', + 'class A extends B { constructor(){} }', + "class A extends B { constructor(){ super('foo'); } }", + 'class A extends B { constructor(foo, bar){ super(foo, bar, 1); } }', + 'class A extends B { constructor(){ super(); doSomething(); } }', + 'class A extends B { constructor(...args){ super(...args); doSomething(); } }', + 'class A { dummyMethod(){ doSomething(); } }', + 'class A extends B.C { constructor() { super(foo); } }', + 'class A extends B.C { constructor([a, b, c]) { super(...arguments); } }', + 'class A extends B.C { constructor(a = f()) { super(...arguments); } }', + 'class A extends B { constructor(a, b, c) { super(a, b); } }', + 'class A extends B { constructor(foo, bar){ super(foo); } }', + 'class A extends B { constructor(test) { super(); } }', + 'class A extends B { constructor() { foo; } }', + 'class A extends B { constructor(foo, bar) { super(bar); } }', + // https://github.com/typescript-eslint/typescript-eslint/issues/15 + 'declare class A { constructor(); }', + 'class A { constructor(); }', + 'abstract class A { constructor(); }', + 'abstract class A { abstract constructor(); }', + // https://github.com/typescript-eslint/typescript-eslint/issues/48 + 'class A { constructor(private name: string) {} }', + 'class A { constructor(public name: string) {} }', + 'class A { constructor(protected name: string) {} }', + // https://github.com/typescript-eslint/typescript-eslint/pull/167#discussion_r252638401 + 'class A { private constructor() {} }', + 'class A { protected constructor() {} }', + 'class A extends B { public constructor() {} }', + 'class A extends B { protected constructor(foo, bar) { super(bar); } }', + 'class A extends B { private constructor(foo, bar) { super(bar); } }', + 'class A extends B { public constructor(foo){ super(foo); } }', + 'class A extends B { public constructor(foo){} }' + ], + invalid: [ + { + code: 'class A { constructor(){} }', + errors: [error] + }, + { + code: "class A { 'constructor'(){} }", + errors: [error] + }, + { + code: 'class A extends B { constructor() { super(); } }', + errors: [error] + }, + { + code: 'class A extends B { constructor(foo){ super(foo); } }', + errors: [error] + }, + { + code: 'class A extends B { constructor(foo, bar){ super(foo, bar); } }', + errors: [error] + }, + { + code: 'class A extends B { constructor(...args){ super(...args); } }', + errors: [error] + }, + { + code: 'class A extends B.C { constructor() { super(...arguments); } }', + errors: [error] + }, + { + code: + 'class A extends B { constructor(a, b, ...c) { super(...arguments); } }', + errors: [error] + }, + { + code: + 'class A extends B { constructor(a, b, ...c) { super(a, b, ...c); } }', + errors: [error] + }, + { + code: 'class A { public constructor() {} }', + errors: [error] + } + ] +}); From 76600a53e0695b3d1051cb6e6a2b8802631438c2 Mon Sep 17 00:00:00 2001 From: James Henry Date: Fri, 1 Feb 2019 07:44:18 -0500 Subject: [PATCH 59/88] chore: publish v1.2.0 --- CHANGELOG.md | 14 ++++++++++++++ lerna.json | 2 +- packages/eslint-plugin-tslint/CHANGELOG.md | 4 ++++ packages/eslint-plugin-tslint/package.json | 4 ++-- packages/eslint-plugin/CHANGELOG.md | 14 ++++++++++++++ packages/eslint-plugin/package.json | 4 ++-- packages/parser/CHANGELOG.md | 6 ++++++ packages/parser/package.json | 6 +++--- packages/shared-fixtures/CHANGELOG.md | 8 ++++++++ packages/shared-fixtures/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 4 ++++ packages/typescript-estree/package.json | 4 ++-- 12 files changed, 61 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccbbce028b9f..fbde088c3966 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01) + +### Bug Fixes + +- **eslint-plugin:** fix no-extraneous-class for class without name ([#174](https://github.com/typescript-eslint/typescript-eslint/issues/174)) ([b1dbb64](https://github.com/typescript-eslint/typescript-eslint/commit/b1dbb64)) +- **eslint-plugin:** fix wrong URL ([#180](https://github.com/typescript-eslint/typescript-eslint/issues/180)) ([00d020d](https://github.com/typescript-eslint/typescript-eslint/commit/00d020d)) +- **eslint-plugin:** use bracket for infer type in array-type rule ([#173](https://github.com/typescript-eslint/typescript-eslint/issues/173)) ([1f868ce](https://github.com/typescript-eslint/typescript-eslint/commit/1f868ce)) +- **parser:** fix regression with no-unused-vars for jsx attributes ([#161](https://github.com/typescript-eslint/typescript-eslint/issues/161)) ([6147de1](https://github.com/typescript-eslint/typescript-eslint/commit/6147de1)) + +### Features + +- **eslint-plugin:** add eslint rule no-useless-constructor ([#167](https://github.com/typescript-eslint/typescript-eslint/issues/167)) ([3fb57a5](https://github.com/typescript-eslint/typescript-eslint/commit/3fb57a5)) +- **eslint-plugin:** add no-unnecessary-type-assertion rule ([#157](https://github.com/typescript-eslint/typescript-eslint/issues/157)) ([38abc28](https://github.com/typescript-eslint/typescript-eslint/commit/38abc28)) + ## [1.1.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.0...v1.1.1) (2019-01-29) ### Bug Fixes diff --git a/lerna.json b/lerna.json index 06bbd031b2c8..77a95bb3fb2c 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.1.1", + "version": "1.2.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index 46f2c1960d94..ca4b53781cd3 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + ## [1.1.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.0...v1.1.1) (2019-01-29) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index b54084d620e4..59b66dd7b153 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "1.1.1", + "version": "1.2.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -34,6 +34,6 @@ "devDependencies": { "@types/eslint": "^4.16.3", "@types/lodash.memoize": "^4.1.4", - "@typescript-eslint/parser": "1.1.1" + "@typescript-eslint/parser": "1.2.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 992ae046dde3..6f10e09e6f08 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01) + +### Bug Fixes + +- **eslint-plugin:** fix no-extraneous-class for class without name ([#174](https://github.com/typescript-eslint/typescript-eslint/issues/174)) ([b1dbb64](https://github.com/typescript-eslint/typescript-eslint/commit/b1dbb64)) +- **eslint-plugin:** fix wrong URL ([#180](https://github.com/typescript-eslint/typescript-eslint/issues/180)) ([00d020d](https://github.com/typescript-eslint/typescript-eslint/commit/00d020d)) +- **eslint-plugin:** use bracket for infer type in array-type rule ([#173](https://github.com/typescript-eslint/typescript-eslint/issues/173)) ([1f868ce](https://github.com/typescript-eslint/typescript-eslint/commit/1f868ce)) +- **parser:** fix regression with no-unused-vars for jsx attributes ([#161](https://github.com/typescript-eslint/typescript-eslint/issues/161)) ([6147de1](https://github.com/typescript-eslint/typescript-eslint/commit/6147de1)) + +### Features + +- **eslint-plugin:** add eslint rule no-useless-constructor ([#167](https://github.com/typescript-eslint/typescript-eslint/issues/167)) ([3fb57a5](https://github.com/typescript-eslint/typescript-eslint/commit/3fb57a5)) +- **eslint-plugin:** add no-unnecessary-type-assertion rule ([#157](https://github.com/typescript-eslint/typescript-eslint/issues/157)) ([38abc28](https://github.com/typescript-eslint/typescript-eslint/commit/38abc28)) + ## [1.1.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.0...v1.1.1) (2019-01-29) ### Bug Fixes diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 350da0cb2aff..b0bf9f288e0e 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "1.1.1", + "version": "1.2.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -24,7 +24,7 @@ "recommended:update": "node tools/update-recommended.js" }, "dependencies": { - "@typescript-eslint/parser": "1.1.1", + "@typescript-eslint/parser": "1.2.0", "requireindex": "^1.2.0", "tsutils": "^3.7.0" }, diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index f2047e5c6d25..5e618787d914 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01) + +### Bug Fixes + +- **parser:** fix regression with no-unused-vars for jsx attributes ([#161](https://github.com/typescript-eslint/typescript-eslint/issues/161)) ([6147de1](https://github.com/typescript-eslint/typescript-eslint/commit/6147de1)) + ## [1.1.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.0...v1.1.1) (2019-01-29) ### Bug Fixes diff --git a/packages/parser/package.json b/packages/parser/package.json index 6cf42f6ce6db..26de602491a7 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "1.1.1", + "version": "1.2.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/parser.js", "files": [ @@ -36,7 +36,7 @@ "typescript": "*" }, "dependencies": { - "@typescript-eslint/typescript-estree": "1.1.1", + "@typescript-eslint/typescript-estree": "1.2.0", "eslint-scope": "^4.0.0", "eslint-visitor-keys": "^1.0.0" }, @@ -44,6 +44,6 @@ "@types/eslint": "^4.16.5", "@types/eslint-visitor-keys": "^1.0.0", "@types/estree": "^0.0.39", - "@typescript-eslint/shared-fixtures": "1.1.1" + "@typescript-eslint/shared-fixtures": "1.2.0" } } diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index 2c81f52bfe1e..6ac765de90a1 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + + + + + ## [1.1.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.0...v1.1.1) (2019-01-29) **Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index e5b8b9613aad..99e0091de873 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "1.1.1", + "version": "1.2.0", "private": true } diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index 2fcfd25aae42..a1fc5f4167ef 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01) + +**Note:** Version bump only for package @typescript-eslint/typescript-estree + ## [1.1.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.0...v1.1.1) (2019-01-29) ### Bug Fixes diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 2be4fceecffc..5c7f52edf274 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "1.1.1", + "version": "1.2.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/parser.js", "types": "dist/parser.d.ts", @@ -42,7 +42,7 @@ "typescript": "*" }, "devDependencies": { - "@typescript-eslint/shared-fixtures": "1.1.1", + "@typescript-eslint/shared-fixtures": "1.2.0", "typescript": "~3.2.1" } } From 3efb265ea85406f8700cca1c40a87f5c30b1452b Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 2 Feb 2019 15:35:59 +0100 Subject: [PATCH 60/88] test(ts-estree): add regression test for decorators on variables (#186) --- .../lib/__snapshots__/typescript.ts.snap | 244 ++++++++++++++++++ .../decorator-on-variable.src.ts | 2 + .../semantic-diagnostics-enabled.ts.snap | 9 + .../lib/__snapshots__/typescript.ts.snap | 243 +++++++++++++++++ 4 files changed, 498 insertions(+) create mode 100644 packages/shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-variable.src.ts diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index f540948a5558..f57d7523a358 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -89541,6 +89541,250 @@ Object { } `; +exports[`typescript fixtures/errorRecovery/decorator-on-variable.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "name": "a", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 18, + 19, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 14, + 19, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "type": "VariableDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 20, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 1, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 5, + ], + "type": "Identifier", + "value": "deco", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 8, + 13, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Numeric", + "value": "1", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/errorRecovery/empty-type-arguments.src 1`] = ` Object { "body": Array [ diff --git a/packages/shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-variable.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-variable.src.ts new file mode 100644 index 000000000000..700dea545cce --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-variable.src.ts @@ -0,0 +1,2 @@ +@deco() +const a = 1 diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index 1db62d5b9140..a0cc4cb96444 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -2299,6 +2299,15 @@ Object { } `; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/decorator-on-variable.src 1`] = ` +Object { + "column": 0, + "index": 0, + "lineNumber": 1, + "message": "Decorators are not valid here.", +} +`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/enum-with-keywords.src 1`] = ` diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index b807e63a8220..0c1e0c5afe60 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -88851,6 +88851,249 @@ Object { } `; +exports[`typescript fixtures/errorRecovery/decorator-on-variable.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "name": "a", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 18, + 19, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 14, + 19, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 20, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 1, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 5, + ], + "type": "Identifier", + "value": "deco", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 8, + 13, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Numeric", + "value": "1", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/errorRecovery/empty-type-arguments.src 1`] = ` Object { "body": Array [ From 3b0fed6674e84523ef84005229e9e271a65d6e23 Mon Sep 17 00:00:00 2001 From: Kanitkorn Sujautra Date: Sun, 3 Feb 2019 21:57:23 +0900 Subject: [PATCH 61/88] docs(eslint-plugin): fix rule URLs still point to the old repository (#189) * docs(eslint-plugin): update rule url to the new repo Fix https://github.com/typescript-eslint/typescript-eslint/issues/188 * docs(eslint-plugin): add a link for no-unnecessary-type-assertion rule --- packages/eslint-plugin/ROADMAP.md | 57 ++++++++++++++++--------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/packages/eslint-plugin/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md index 378a3140ffb8..48e0696eea9c 100644 --- a/packages/eslint-plugin/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -557,34 +557,35 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- -[`@typescript-eslint/adjacent-overload-signatures`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/adjacent-overload-signatures.md -[`@typescript-eslint/ban-types`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/ban-types.md -[`@typescript-eslint/explicit-member-accessibility`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/explicit-member-accessibility.md -[`@typescript-eslint/member-ordering`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/member-ordering.md -[`@typescript-eslint/no-explicit-any`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-explicit-any.md -[`@typescript-eslint/no-empty-interface`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-empty-interface.md -[`@typescript-eslint/no-inferrable-types`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-inferrable-types.md -[`@typescript-eslint/prefer-namespace-keyword`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/prefer-namespace-keyword.md -[`@typescript-eslint/no-namespace`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-namespace.md -[`@typescript-eslint/no-non-null-assertion`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-non-null-assertion.md -[`@typescript-eslint/no-triple-slash-reference`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-triple-slash-reference.md -[`@typescript-eslint/no-var-requires`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-var-requires.md -[`@typescript-eslint/type-annotation-spacing`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/type-annotation-spacing.md -[`@typescript-eslint/no-misused-new`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-misused-new.md -[`@typescript-eslint/no-object-literal-type-assertion`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-object-literal-type-assertion.md -[`@typescript-eslint/no-this-alias`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-this-alias.md -[`@typescript-eslint/no-extraneous-class`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-extraneous-class.md -[`@typescript-eslint/no-unused-vars`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-unused-vars.md -[`@typescript-eslint/no-use-before-define`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-use-before-define.md -[`@typescript-eslint/indent`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/indent.md -[`@typescript-eslint/array-type`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/array-type.md -[`@typescript-eslint/class-name-casing`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/class-name-casing.md -[`@typescript-eslint/interface-name-prefix`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/interface-name-prefix.md -[`@typescript-eslint/no-angle-bracket-type-assertion`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-angle-bracket-type-assertion.md -[`@typescript-eslint/no-parameter-properties`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-parameter-properties.md -[`@typescript-eslint/member-delimiter-style`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/member-delimiter-style.md -[`@typescript-eslint/prefer-interface`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/prefer-interface.md -[`@typescript-eslint/no-array-constructor`]: https://github.com/bradzacher/@typescript-eslint/eslint-plugin/blob/master/docs/rules/no-array-constructor.md +[`@typescript-eslint/adjacent-overload-signatures`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md +[`@typescript-eslint/ban-types`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md +[`@typescript-eslint/explicit-member-accessibility`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md +[`@typescript-eslint/member-ordering`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-ordering.md +[`@typescript-eslint/no-explicit-any`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-explicit-any.md +[`@typescript-eslint/no-empty-interface`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-interface.md +[`@typescript-eslint/no-inferrable-types`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-inferrable-types.md +[`@typescript-eslint/prefer-namespace-keyword`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md +[`@typescript-eslint/no-namespace`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-namespace.md +[`@typescript-eslint/no-non-null-assertion`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-non-null-assertion.md +[`@typescript-eslint/no-triple-slash-reference`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-triple-slash-reference.md +[`@typescript-eslint/no-unnecessary-type-assertion`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md +[`@typescript-eslint/no-var-requires`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-var-requires.md +[`@typescript-eslint/type-annotation-spacing`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/type-annotation-spacing.md +[`@typescript-eslint/no-misused-new`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-misused-new.md +[`@typescript-eslint/no-object-literal-type-assertion`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md +[`@typescript-eslint/no-this-alias`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-this-alias.md +[`@typescript-eslint/no-extraneous-class`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extraneous-class.md +[`@typescript-eslint/no-unused-vars`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md +[`@typescript-eslint/no-use-before-define`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md +[`@typescript-eslint/indent`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/indent.md +[`@typescript-eslint/array-type`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md +[`@typescript-eslint/class-name-casing`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/class-name-casing.md +[`@typescript-eslint/interface-name-prefix`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/interface-name-prefix.md +[`@typescript-eslint/no-angle-bracket-type-assertion`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-angle-bracket-type-assertion.md +[`@typescript-eslint/no-parameter-properties`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-parameter-properties.md +[`@typescript-eslint/member-delimiter-style`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md +[`@typescript-eslint/prefer-interface`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-interface.md +[`@typescript-eslint/no-array-constructor`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-array-constructor.md From f03ed0765fd93539a5aef71ddd66fde8d92f1ce3 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 3 Feb 2019 17:09:48 +0100 Subject: [PATCH 62/88] docs(eslint-plugin): replace whitespaces with
tag (#198) --- packages/eslint-plugin/ROADMAP.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/eslint-plugin/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md index 48e0696eea9c..f26d0e80175c 100644 --- a/packages/eslint-plugin/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -1,9 +1,9 @@ # Roadmap -✅ (28) = done -🌟 (79) = in ESLint core -🔌 (33) = in another plugin -🌓 (16) = implementations differ or ESLint version is missing functionality +✅ (28) = done
+🌟 (79) = in ESLint core
+🔌 (33) = in another plugin
+🌓 (16) = implementations differ or ESLint version is missing functionality
🛑 (70) = unimplemented ## TSLint rules @@ -96,7 +96,7 @@ | [`use-default-type-parameter`] | 🛑 | N/A | | [`use-isnan`] | 🌟 | [`use-isnan`][use-isnan] | -[1] The ESLint rule also supports silencing with an extra set of parens (`if ((foo = bar)) {}`) +[1] The ESLint rule also supports silencing with an extra set of parens (`if ((foo = bar)) {}`)
[2] Missing private class member support. [`@typescript-eslint/no-unused-vars`] adds support for some TS-specific features. ### Maintainability @@ -120,7 +120,7 @@ | [`prefer-readonly`] | 🛑 | N/A | | [`trailing-comma`] | 🌓 | [`comma-dangle`][comma-dangle] or [Prettier] | -[1] Only warns when importing deprecated symbols +[1] Only warns when importing deprecated symbols
[2] Missing support for blank-line-delimited sections ### Style @@ -179,7 +179,7 @@ | [`variable-name`] | 🌟 | [2] | | [`whitespace`] | 🔌 | Use [Prettier] | -[1] Recommended config: `["error", { blankLine: "always", prev: "*", next: "return" }]` +[1] Recommended config: `["error", { blankLine: "always", prev: "*", next: "return" }]`
[2] [`camelcase`][camelcase], [`no-underscore-dangle`][no-underscore-dangle], [`id-blacklist`][id-blacklist], and/or [`id-match`][id-match] ## tslint-microsoft-contrib rules @@ -245,10 +245,10 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- | `use-named-parameter` | 🛑 | N/A | | `use-simple-attributes` | 🛑 | N/A | -[1] Enforces blank lines both at the beginning and end of a block -[2] Recommended config: `["error", "ForInStatement"]` -[3] Recommended config: `["error", "declaration", { "allowArrowFunctions": true }]` -[4] Recommended config: `["error", { "terms": ["BUG", "HACK", "FIXME", "LATER", "LATER2", "TODO"], "location": "anywhere" }]` +[1] Enforces blank lines both at the beginning and end of a block
+[2] Recommended config: `["error", "ForInStatement"]`
+[3] Recommended config: `["error", "declaration", { "allowArrowFunctions": true }]`
+[4] Recommended config: `["error", { "terms": ["BUG", "HACK", "FIXME", "LATER", "LATER2", "TODO"], "location": "anywhere" }]`
[5] Does not check class fields. [insecure-random]: https://github.com/desktop/desktop/blob/master/eslint-rules/insecure-random.js @@ -310,7 +310,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- | `react-a11y-titles` | 🛑 | N/A | | `react-anchor-blank-noopener` | 🛑 | N/A | -[1] TSLint rule is more strict +[1] TSLint rule is more strict
[2] ESLint rule only reports for click handlers [prettier]: https://prettier.io From f35c20b100dfa516d695000f6cdc38b6fd5248a2 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 3 Feb 2019 11:10:41 -0500 Subject: [PATCH 63/88] chore: removed unnecessary path prefix from .vscode/launch.json (#196) --- .vscode/launch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 18bf27ada556..4ac7bc13cdd0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,7 +12,7 @@ "program": "${workspaceFolder}/node_modules/jest/bin/jest.js", "args": [ "--colors", - "${workspaceFolder}/packages/eslint-plugin/tests/lib/rules/${fileBasename}" + "tests/lib/rules/${fileBasename}" ], "console": "integratedTerminal", "internalConsoleOptions": "neverOpen" From f856e76629e4f737a727c53cfd58f7561e490579 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 3 Feb 2019 19:23:40 +0100 Subject: [PATCH 64/88] test(*): update eslint-plugin-jest and enable recommended rules (#190) --- .eslintrc.json | 15 +++++++++++---- package.json | 2 +- packages/parser/tests/lib/parser.ts | 2 +- packages/typescript-estree/tests/lib/parse.ts | 6 +++--- .../typescript-estree/tests/lib/semanticInfo.ts | 4 ++-- .../tests/lib/warn-on-unsupported-ts.ts | 2 +- yarn.lock | 8 ++++---- 7 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index f44790c843c8..40a5182652ad 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -29,10 +29,10 @@ "overrides": [ { "files": [ - "packages/eslint-plugin-tslint/**/*.ts", - "packages/eslint-plugin/**/*.js", - "packages/parser/**/*.ts", - "packages/typescript-estree/**/*.ts" + "packages/eslint-plugin-tslint/tests/**/*.ts", + "packages/eslint-plugin/tests/**/*.js", + "packages/parser/tests/**/*.ts", + "packages/typescript-estree/tests/**/*.ts" ], "env": { "jest/globals": true @@ -40,8 +40,15 @@ "rules": { "jest/no-disabled-tests": "warn", "jest/no-focused-tests": "error", + "jest/no-alias-methods": "error", "jest/no-identical-title": "error", + "jest/no-jasmine-globals": "error", + "jest/no-jest-import": "error", + "jest/no-test-prefixes": "error", + "jest/no-test-callback": "error", + "jest/no-test-return-statement": "error", "jest/prefer-to-have-length": "warn", + "jest/prefer-spy-on": "error", "jest/valid-expect": "error" } }, diff --git a/package.json b/package.json index 18059f7381ed..a95c4a1a5710 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "cz-conventional-changelog": "2.1.0", "eslint": "^5.12.1", "eslint-plugin-eslint-plugin": "^2.0.1", - "eslint-plugin-jest": "^22.1.3", + "eslint-plugin-jest": "^22.2.2", "glob": "7.1.2", "husky": "^1.3.1", "jest": "23.6.0", diff --git a/packages/parser/tests/lib/parser.ts b/packages/parser/tests/lib/parser.ts index bfc23bac5abb..332be8b6e43c 100644 --- a/packages/parser/tests/lib/parser.ts +++ b/packages/parser/tests/lib/parser.ts @@ -24,7 +24,7 @@ describe('parser', () => { sourceType: 'script', useJSXTextNode: true }); - expect(spyScope).toHaveBeenCalledWith(jasmine.any(Object), { + expect(spyScope).toHaveBeenCalledWith(expect.any(Object), { ecmaFeatures: {}, sourceType: 'script' }); diff --git a/packages/typescript-estree/tests/lib/parse.ts b/packages/typescript-estree/tests/lib/parse.ts index fc7e8af99a10..6bed7ce8bcef 100644 --- a/packages/typescript-estree/tests/lib/parse.ts +++ b/packages/typescript-estree/tests/lib/parse.ts @@ -82,7 +82,7 @@ describe('parse()', () => { }); expect(spy).toHaveBeenCalledWith( - jasmine.any(Object), + expect.any(Object), { code: 'let foo = bar;', comment: true, @@ -96,8 +96,8 @@ describe('parse()', () => { projects: [], range: true, strict: false, - tokens: jasmine.any(Array), - tsconfigRootDir: jasmine.any(String), + tokens: expect.any(Array), + tsconfigRootDir: expect.any(String), useJSXTextNode: false }, false diff --git a/packages/typescript-estree/tests/lib/semanticInfo.ts b/packages/typescript-estree/tests/lib/semanticInfo.ts index e45cae843ed5..f5612f191cc5 100644 --- a/packages/typescript-estree/tests/lib/semanticInfo.ts +++ b/packages/typescript-estree/tests/lib/semanticInfo.ts @@ -179,7 +179,7 @@ describe('semanticInfo', () => { badConfig.project = './tsconfigs.json'; expect(() => parseCodeAndGenerateServices(readFileSync(fileName, 'utf8'), badConfig) - ).toThrowError(/File .+tsconfigs\.json' not found/); + ).toThrow(/File .+tsconfigs\.json' not found/); }); it('fail to read project file', () => { @@ -188,7 +188,7 @@ describe('semanticInfo', () => { badConfig.project = '.'; expect(() => parseCodeAndGenerateServices(readFileSync(fileName, 'utf8'), badConfig) - ).toThrowError(/File .+semanticInfo' not found/); + ).toThrow(/File .+semanticInfo' not found/); }); it('malformed project file', () => { diff --git a/packages/typescript-estree/tests/lib/warn-on-unsupported-ts.ts b/packages/typescript-estree/tests/lib/warn-on-unsupported-ts.ts index d984007bf757..565b997c35fc 100644 --- a/packages/typescript-estree/tests/lib/warn-on-unsupported-ts.ts +++ b/packages/typescript-estree/tests/lib/warn-on-unsupported-ts.ts @@ -11,7 +11,7 @@ describe('Warn on unsupported TypeScript version', () => { it('should warn the user if they are using an unsupported TypeScript version', () => { (semver.satisfies as jest.Mock).mockReturnValue(false); - console.log = jest.fn(); + jest.spyOn(console, 'log').mockImplementation(); parser.parse(''); expect(console.log).toHaveBeenCalledWith( expect.stringContaining( diff --git a/yarn.lock b/yarn.lock index 6980f52cafb8..1969160e6c41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2378,10 +2378,10 @@ eslint-plugin-eslint-plugin@^2.0.1: resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-plugin/-/eslint-plugin-eslint-plugin-2.0.1.tgz#d275434969dbde3da1d4cb7a121dc8d88457c786" integrity sha512-kJ5TZsRJH/xYstG07v3YeOy/W5SDAEzV+bvvoL0aiG1HtqDmg4mJvNPnn/JngANMmsx8oXlJrIcBTCpJzm+9kg== -eslint-plugin-jest@^22.1.3: - version "22.1.3" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.1.3.tgz#4444108dfcddc5d2117ed6dc551f529d7e73a99e" - integrity sha512-JTZTI6WQoNruAugNyCO8fXfTONVcDd5i6dMRFA5g3rUFn1UDDLILY1bTL6alvNXbW2U7Sc2OSpi8m08pInnq0A== +eslint-plugin-jest@^22.2.2: + version "22.2.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.2.2.tgz#2a80d70a20c27dfb1503a6f32cdcb647fe5476df" + integrity sha512-hnWgh9o39VJfz6lJEyQJdTW7dN2yynlGkmPOlU/oMHh+d7WVMsJP1GeDTB520VCDljEdKExCwD5IBpQIUl4mJg== eslint-scope@^4.0.0: version "4.0.0" From a36e727277d9815cfdd6f0b67e0981d84035698f Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 3 Feb 2019 19:40:26 +0100 Subject: [PATCH 65/88] test(ts-estree): add test for parsing nested jsx tag names (#191) --- .../tests/lib/__snapshots__/jsx.ts.snap | 1716 +++++++++++++++++ .../tag-names-with-multi-dots-multi.src.js | 3 + .../tests/ast-alignment/fixtures-to-test.ts | 7 +- .../tests/lib/__snapshots__/jsx.ts.snap | 1715 ++++++++++++++++ .../semantic-diagnostics-enabled.ts.snap | 9 + 5 files changed, 3449 insertions(+), 1 deletion(-) create mode 100644 packages/shared-fixtures/fixtures/jsx/tag-names-with-multi-dots-multi.src.js diff --git a/packages/parser/tests/lib/__snapshots__/jsx.ts.snap b/packages/parser/tests/lib/__snapshots__/jsx.ts.snap index 8a6365ac56b6..02d917e3fb56 100644 --- a/packages/parser/tests/lib/__snapshots__/jsx.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/jsx.ts.snap @@ -9463,6 +9463,1722 @@ Object { } `; +exports[`JSX useJSXTextNode: false fixtures/tag-names-with-multi-dots-multi.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "children": Array [ + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 16, + ], + "raw": " + ", + "type": "Literal", + "value": " + ", + }, + Object { + "children": Array [], + "closingElement": Object { + "loc": Object { + "end": Object { + "column": 57, + "line": 2, + }, + "start": Object { + "column": 29, + "line": 2, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 49, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "range": Array [ + 45, + 49, + ], + "type": "ThisExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "name": "const", + "range": Array [ + 50, + 55, + ], + "type": "Identifier", + }, + "range": Array [ + 45, + 55, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 49, + "line": 2, + }, + "start": Object { + "column": 42, + "line": 2, + }, + }, + "name": "declare", + "range": Array [ + 56, + 63, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 45, + 63, + ], + "type": "JSXMemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 2, + }, + "start": Object { + "column": 50, + "line": 2, + }, + }, + "name": "static", + "range": Array [ + 64, + 70, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 45, + 70, + ], + "type": "JSXMemberExpression", + }, + "range": Array [ + 43, + 71, + ], + "type": "JSXClosingElement", + }, + "loc": Object { + "end": Object { + "column": 57, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "openingElement": Object { + "attributes": Array [], + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 2, + }, + "start": Object { + "column": 3, + "line": 2, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 3, + "line": 2, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 3, + "line": 2, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 3, + "line": 2, + }, + }, + "range": Array [ + 17, + 21, + ], + "type": "ThisExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "name": "const", + "range": Array [ + 22, + 27, + ], + "type": "Identifier", + }, + "range": Array [ + 17, + 27, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "name": "declare", + "range": Array [ + 28, + 35, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 17, + 35, + ], + "type": "JSXMemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 2, + }, + "start": Object { + "column": 22, + "line": 2, + }, + }, + "name": "static", + "range": Array [ + 36, + 42, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 17, + 42, + ], + "type": "JSXMemberExpression", + }, + "range": Array [ + 16, + 43, + ], + "selfClosing": false, + "type": "JSXOpeningElement", + }, + "range": Array [ + 16, + 71, + ], + "type": "JSXElement", + }, + Object { + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 57, + "line": 2, + }, + }, + "range": Array [ + 71, + 72, + ], + "raw": " +", + "type": "Literal", + "value": " +", + }, + ], + "closingElement": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "name": "a", + "range": Array [ + 74, + 75, + ], + "type": "Identifier", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "name": "b", + "range": Array [ + 76, + 77, + ], + "type": "Identifier", + }, + "range": Array [ + 74, + 77, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "name": "c", + "range": Array [ + 78, + 79, + ], + "type": "Identifier", + }, + "range": Array [ + 74, + 79, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "name": "d", + "range": Array [ + 80, + 81, + ], + "type": "Identifier", + }, + "range": Array [ + 74, + 81, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "name": "e", + "range": Array [ + 82, + 83, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 74, + 83, + ], + "type": "JSXMemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 12, + "line": 3, + }, + }, + "name": "f", + "range": Array [ + 84, + 85, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 74, + 85, + ], + "type": "JSXMemberExpression", + }, + "range": Array [ + 72, + 86, + ], + "type": "JSXClosingElement", + }, + "loc": Object { + "end": Object { + "column": 14, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "openingElement": Object { + "attributes": Array [], + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 1, + 2, + ], + "type": "Identifier", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "name": "b", + "range": Array [ + 3, + 4, + ], + "type": "Identifier", + }, + "range": Array [ + 1, + 4, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "c", + "range": Array [ + 5, + 6, + ], + "type": "Identifier", + }, + "range": Array [ + 1, + 6, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "name": "d", + "range": Array [ + 7, + 8, + ], + "type": "Identifier", + }, + "range": Array [ + 1, + 8, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "e", + "range": Array [ + 9, + 10, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 1, + 10, + ], + "type": "JSXMemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "name": "f", + "range": Array [ + 11, + 12, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 1, + 12, + ], + "type": "JSXMemberExpression", + }, + "range": Array [ + 0, + 13, + ], + "selfClosing": false, + "type": "JSXOpeningElement", + }, + "range": Array [ + 0, + 86, + ], + "type": "JSXElement", + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 87, + ], + "type": "ExpressionStatement", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 88, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 1, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 2, + ], + "type": "JSXIdentifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 2, + "line": 1, + }, + }, + "range": Array [ + 2, + 3, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "range": Array [ + 3, + 4, + ], + "type": "JSXIdentifier", + "value": "b", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "JSXIdentifier", + "value": "c", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "JSXIdentifier", + "value": "d", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "JSXIdentifier", + "value": "e", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "JSXIdentifier", + "value": "f", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 16, + ], + "type": "JSXText", + "value": " + ", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 3, + "line": 2, + }, + }, + "range": Array [ + 17, + 21, + ], + "type": "Keyword", + "value": "this", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 22, + 27, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 28, + 35, + ], + "type": "Keyword", + "value": "declare", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 21, + "line": 2, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 2, + }, + "start": Object { + "column": 22, + "line": 2, + }, + }, + "range": Array [ + 36, + 42, + ], + "type": "Keyword", + "value": "static", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 42, + 43, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 2, + }, + "start": Object { + "column": 29, + "line": 2, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "Punctuator", + "value": "/", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "range": Array [ + 45, + 49, + ], + "type": "Keyword", + "value": "this", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 2, + }, + "start": Object { + "column": 35, + "line": 2, + }, + }, + "range": Array [ + 49, + 50, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 50, + 55, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 2, + }, + "start": Object { + "column": 41, + "line": 2, + }, + }, + "range": Array [ + 55, + 56, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 49, + "line": 2, + }, + "start": Object { + "column": 42, + "line": 2, + }, + }, + "range": Array [ + 56, + 63, + ], + "type": "Keyword", + "value": "declare", + }, + Object { + "loc": Object { + "end": Object { + "column": 50, + "line": 2, + }, + "start": Object { + "column": 49, + "line": 2, + }, + }, + "range": Array [ + 63, + 64, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 2, + }, + "start": Object { + "column": 50, + "line": 2, + }, + }, + "range": Array [ + 64, + 70, + ], + "type": "Keyword", + "value": "static", + }, + Object { + "loc": Object { + "end": Object { + "column": 57, + "line": 2, + }, + "start": Object { + "column": 56, + "line": 2, + }, + }, + "range": Array [ + 70, + 71, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 57, + "line": 2, + }, + }, + "range": Array [ + 71, + 72, + ], + "type": "JSXText", + "value": " +", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 72, + 73, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 3, + }, + "start": Object { + "column": 1, + "line": 3, + }, + }, + "range": Array [ + 73, + 74, + ], + "type": "Punctuator", + "value": "/", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 74, + 75, + ], + "type": "JSXIdentifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 3, + }, + "start": Object { + "column": 3, + "line": 3, + }, + }, + "range": Array [ + 75, + 76, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 76, + 77, + ], + "type": "JSXIdentifier", + "value": "b", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 3, + }, + "start": Object { + "column": 5, + "line": 3, + }, + }, + "range": Array [ + 77, + 78, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 78, + 79, + ], + "type": "JSXIdentifier", + "value": "c", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 3, + }, + "start": Object { + "column": 7, + "line": 3, + }, + }, + "range": Array [ + 79, + 80, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 80, + 81, + ], + "type": "JSXIdentifier", + "value": "d", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 3, + }, + "start": Object { + "column": 9, + "line": 3, + }, + }, + "range": Array [ + 81, + 82, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 82, + 83, + ], + "type": "JSXIdentifier", + "value": "e", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "range": Array [ + 83, + 84, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 12, + "line": 3, + }, + }, + "range": Array [ + 84, + 85, + ], + "type": "JSXIdentifier", + "value": "f", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 3, + }, + "start": Object { + "column": 13, + "line": 3, + }, + }, + "range": Array [ + 85, + 86, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 3, + }, + "start": Object { + "column": 14, + "line": 3, + }, + }, + "range": Array [ + 86, + 87, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`JSX useJSXTextNode: false fixtures/test-content.src 1`] = ` Object { "body": Array [ diff --git a/packages/shared-fixtures/fixtures/jsx/tag-names-with-multi-dots-multi.src.js b/packages/shared-fixtures/fixtures/jsx/tag-names-with-multi-dots-multi.src.js new file mode 100644 index 000000000000..1599e0620cd9 --- /dev/null +++ b/packages/shared-fixtures/fixtures/jsx/tag-names-with-multi-dots-multi.src.js @@ -0,0 +1,3 @@ + + +; 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 e92f68f968f4..ede45e93fcda 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -284,7 +284,12 @@ tester.addFixturePatternConfig('javascript/unicodeCodePointEscapes'); /* ================================================== */ tester.addFixturePatternConfig('jsx', { - ignore: jsxFilesWithKnownIssues + ignore: jsxFilesWithKnownIssues.concat([ + /** + * ts-estree: nested jsx tag names are not correctly converted + */ + 'tag-names-with-multi-dots-multi' + ]) }); tester.addFixturePatternConfig('jsx-useJSXTextNode'); diff --git a/packages/typescript-estree/tests/lib/__snapshots__/jsx.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/jsx.ts.snap index 1da61ddcac7e..cb1f698c267c 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/jsx.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/jsx.ts.snap @@ -9423,6 +9423,1721 @@ Object { } `; +exports[`JSX useJSXTextNode: false fixtures/tag-names-with-multi-dots-multi.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "children": Array [ + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 16, + ], + "raw": " + ", + "type": "Literal", + "value": " + ", + }, + Object { + "children": Array [], + "closingElement": Object { + "loc": Object { + "end": Object { + "column": 57, + "line": 2, + }, + "start": Object { + "column": 29, + "line": 2, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 49, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "range": Array [ + 45, + 49, + ], + "type": "ThisExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "name": "const", + "range": Array [ + 50, + 55, + ], + "type": "Identifier", + }, + "range": Array [ + 45, + 55, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 49, + "line": 2, + }, + "start": Object { + "column": 42, + "line": 2, + }, + }, + "name": "declare", + "range": Array [ + 56, + 63, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 45, + 63, + ], + "type": "JSXMemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 2, + }, + "start": Object { + "column": 50, + "line": 2, + }, + }, + "name": "static", + "range": Array [ + 64, + 70, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 45, + 70, + ], + "type": "JSXMemberExpression", + }, + "range": Array [ + 43, + 71, + ], + "type": "JSXClosingElement", + }, + "loc": Object { + "end": Object { + "column": 57, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "openingElement": Object { + "attributes": Array [], + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 2, + }, + "start": Object { + "column": 3, + "line": 2, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 3, + "line": 2, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 3, + "line": 2, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 3, + "line": 2, + }, + }, + "range": Array [ + 17, + 21, + ], + "type": "ThisExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "name": "const", + "range": Array [ + 22, + 27, + ], + "type": "Identifier", + }, + "range": Array [ + 17, + 27, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "name": "declare", + "range": Array [ + 28, + 35, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 17, + 35, + ], + "type": "JSXMemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 2, + }, + "start": Object { + "column": 22, + "line": 2, + }, + }, + "name": "static", + "range": Array [ + 36, + 42, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 17, + 42, + ], + "type": "JSXMemberExpression", + }, + "range": Array [ + 16, + 43, + ], + "selfClosing": false, + "type": "JSXOpeningElement", + }, + "range": Array [ + 16, + 71, + ], + "type": "JSXElement", + }, + Object { + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 57, + "line": 2, + }, + }, + "range": Array [ + 71, + 72, + ], + "raw": " +", + "type": "Literal", + "value": " +", + }, + ], + "closingElement": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "name": "a", + "range": Array [ + 74, + 75, + ], + "type": "Identifier", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "name": "b", + "range": Array [ + 76, + 77, + ], + "type": "Identifier", + }, + "range": Array [ + 74, + 77, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "name": "c", + "range": Array [ + 78, + 79, + ], + "type": "Identifier", + }, + "range": Array [ + 74, + 79, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "name": "d", + "range": Array [ + 80, + 81, + ], + "type": "Identifier", + }, + "range": Array [ + 74, + 81, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "name": "e", + "range": Array [ + 82, + 83, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 74, + 83, + ], + "type": "JSXMemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 12, + "line": 3, + }, + }, + "name": "f", + "range": Array [ + 84, + 85, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 74, + 85, + ], + "type": "JSXMemberExpression", + }, + "range": Array [ + 72, + 86, + ], + "type": "JSXClosingElement", + }, + "loc": Object { + "end": Object { + "column": 14, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "openingElement": Object { + "attributes": Array [], + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "object": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 1, + 2, + ], + "type": "Identifier", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "name": "b", + "range": Array [ + 3, + 4, + ], + "type": "Identifier", + }, + "range": Array [ + 1, + 4, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "c", + "range": Array [ + 5, + 6, + ], + "type": "Identifier", + }, + "range": Array [ + 1, + 6, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "name": "d", + "range": Array [ + 7, + 8, + ], + "type": "Identifier", + }, + "range": Array [ + 1, + 8, + ], + "type": "MemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "e", + "range": Array [ + 9, + 10, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 1, + 10, + ], + "type": "JSXMemberExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "name": "f", + "range": Array [ + 11, + 12, + ], + "type": "JSXIdentifier", + }, + "range": Array [ + 1, + 12, + ], + "type": "JSXMemberExpression", + }, + "range": Array [ + 0, + 13, + ], + "selfClosing": false, + "type": "JSXOpeningElement", + }, + "range": Array [ + 0, + 86, + ], + "type": "JSXElement", + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 87, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 88, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 1, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 2, + ], + "type": "JSXIdentifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 2, + "line": 1, + }, + }, + "range": Array [ + 2, + 3, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "range": Array [ + 3, + 4, + ], + "type": "JSXIdentifier", + "value": "b", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "JSXIdentifier", + "value": "c", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "JSXIdentifier", + "value": "d", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "JSXIdentifier", + "value": "e", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "JSXIdentifier", + "value": "f", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 16, + ], + "type": "JSXText", + "value": " + ", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 3, + "line": 2, + }, + }, + "range": Array [ + 17, + 21, + ], + "type": "Keyword", + "value": "this", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 22, + 27, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 28, + 35, + ], + "type": "Keyword", + "value": "declare", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 21, + "line": 2, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 2, + }, + "start": Object { + "column": 22, + "line": 2, + }, + }, + "range": Array [ + 36, + 42, + ], + "type": "Keyword", + "value": "static", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 42, + 43, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 2, + }, + "start": Object { + "column": 29, + "line": 2, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "Punctuator", + "value": "/", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "range": Array [ + 45, + 49, + ], + "type": "Keyword", + "value": "this", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 2, + }, + "start": Object { + "column": 35, + "line": 2, + }, + }, + "range": Array [ + 49, + 50, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 50, + 55, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 2, + }, + "start": Object { + "column": 41, + "line": 2, + }, + }, + "range": Array [ + 55, + 56, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 49, + "line": 2, + }, + "start": Object { + "column": 42, + "line": 2, + }, + }, + "range": Array [ + 56, + 63, + ], + "type": "Keyword", + "value": "declare", + }, + Object { + "loc": Object { + "end": Object { + "column": 50, + "line": 2, + }, + "start": Object { + "column": 49, + "line": 2, + }, + }, + "range": Array [ + 63, + 64, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 2, + }, + "start": Object { + "column": 50, + "line": 2, + }, + }, + "range": Array [ + 64, + 70, + ], + "type": "Keyword", + "value": "static", + }, + Object { + "loc": Object { + "end": Object { + "column": 57, + "line": 2, + }, + "start": Object { + "column": 56, + "line": 2, + }, + }, + "range": Array [ + 70, + 71, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 57, + "line": 2, + }, + }, + "range": Array [ + 71, + 72, + ], + "type": "JSXText", + "value": " +", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 72, + 73, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 3, + }, + "start": Object { + "column": 1, + "line": 3, + }, + }, + "range": Array [ + 73, + 74, + ], + "type": "Punctuator", + "value": "/", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 74, + 75, + ], + "type": "JSXIdentifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 3, + }, + "start": Object { + "column": 3, + "line": 3, + }, + }, + "range": Array [ + 75, + 76, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 76, + 77, + ], + "type": "JSXIdentifier", + "value": "b", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 3, + }, + "start": Object { + "column": 5, + "line": 3, + }, + }, + "range": Array [ + 77, + 78, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 78, + 79, + ], + "type": "JSXIdentifier", + "value": "c", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 3, + }, + "start": Object { + "column": 7, + "line": 3, + }, + }, + "range": Array [ + 79, + 80, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 80, + 81, + ], + "type": "JSXIdentifier", + "value": "d", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 3, + }, + "start": Object { + "column": 9, + "line": 3, + }, + }, + "range": Array [ + 81, + 82, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 82, + 83, + ], + "type": "JSXIdentifier", + "value": "e", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "range": Array [ + 83, + 84, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 12, + "line": 3, + }, + }, + "range": Array [ + 84, + 85, + ], + "type": "JSXIdentifier", + "value": "f", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 3, + }, + "start": Object { + "column": 13, + "line": 3, + }, + }, + "range": Array [ + 85, + 86, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 3, + }, + "start": Object { + "column": 14, + "line": 3, + }, + }, + "range": Array [ + 86, + 87, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`JSX useJSXTextNode: false fixtures/test-content.src 1`] = ` Object { "body": Array [ diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index a0cc4cb96444..842757edb3df 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -1798,6 +1798,15 @@ Object { } `; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/tag-names-with-multi-dots-multi.src 1`] = ` +Object { + "column": 7, + "index": 21, + "lineNumber": 2, + "message": "'>' expected.", +} +`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/test-content.src 1`] = ` Object { "column": 5, From bf13399ce05275a21d95bfea327eb9b0356c8e2c Mon Sep 17 00:00:00 2001 From: Kanitkorn Sujautra Date: Mon, 4 Feb 2019 04:15:23 +0900 Subject: [PATCH 66/88] docs(eslint-plugin): add missing rule and remove duplicate rule (#200) * add missing restrict-plus-operands * remove duplicate rule function-name --- packages/eslint-plugin/ROADMAP.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-plugin/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md index f26d0e80175c..bd0480101cf1 100644 --- a/packages/eslint-plugin/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -1,10 +1,10 @@ # Roadmap -✅ (28) = done
+✅ (29) = done
🌟 (79) = in ESLint core
🔌 (33) = in another plugin
🌓 (16) = implementations differ or ESLint version is missing functionality
-🛑 (70) = unimplemented +🛑 (68) = unimplemented ## TSLint rules @@ -87,7 +87,7 @@ | [`prefer-conditional-expression`] | 🛑 | N/A | | [`prefer-object-spread`] | 🌟 | [`prefer-object-spread`][prefer-object-spread] | | [`radix`] | 🌟 | [`radix`][radix] | -| [`restrict-plus-operands`] | 🛑 | N/A | +| [`restrict-plus-operands`] | ✅ | [`@typescript-eslint/restrict-plus-operands`] | | [`strict-boolean-expressions`] | 🛑 | N/A | | [`strict-type-predicates`] | 🛑 | N/A | | [`switch-default`] | 🌟 | [`default-case`][default-case] | @@ -214,7 +214,6 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- | `export-name` | 🛑 | N/A ([relevant plugin][plugin:import]) | | `function-name` | 🛑 | N/A | | `import-name` | 🛑 | N/A ([relevant plugin][plugin:import]) | -| `function-name` | 🛑 | N/A | | `informative-docs` | 🛑 | N/A | | `insecure-random` | 🔌 | [custom implementation][insecure-random] | | `max-func-body-length` | 🌟 | [`max-statements`][max-statements] | @@ -577,6 +576,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- [`@typescript-eslint/no-extraneous-class`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extraneous-class.md [`@typescript-eslint/no-unused-vars`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md [`@typescript-eslint/no-use-before-define`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md +[`@typescript-eslint/restrict-plus-operands`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/restrict-plus-operands.md [`@typescript-eslint/indent`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/indent.md [`@typescript-eslint/array-type`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md [`@typescript-eslint/class-name-casing`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/class-name-casing.md From 773723b4e38e7b33f43fff0c9e4a109742ebb332 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 3 Feb 2019 21:32:51 +0100 Subject: [PATCH 67/88] refactor(ts-estree): add types to converter (#156) --- .../typescript-estree/src/ast-converter.ts | 27 +- .../typescript-estree/src/convert-comments.ts | 55 +- packages/typescript-estree/src/convert.ts | 3903 ++++++++--------- .../src/estree/experimental.ts | 30 - .../src/estree/extensions.ts | 63 - packages/typescript-estree/src/estree/spec.ts | 985 ----- packages/typescript-estree/src/node-utils.ts | 228 +- .../typescript-estree/src/parser-options.ts | 35 + packages/typescript-estree/src/parser.ts | 44 +- .../src/temp-types-based-on-js-source.ts | 106 - .../typescript-estree/src/tsconfig-parser.ts | 25 +- packages/typescript-estree/src/typedefs.ts | 1409 ++++++ .../typescript-estree/tests/lib/comments.ts | 2 +- .../typescript-estree/tests/lib/javascript.ts | 2 +- packages/typescript-estree/tests/lib/jsx.ts | 2 +- packages/typescript-estree/tests/lib/parse.ts | 2 +- .../tests/lib/semanticInfo.ts | 2 +- packages/typescript-estree/tests/lib/tsx.ts | 2 +- .../typescript-estree/tests/lib/typescript.ts | 2 +- .../typescript-estree/tools/test-utils.ts | 2 +- 20 files changed, 3568 insertions(+), 3358 deletions(-) delete mode 100644 packages/typescript-estree/src/estree/experimental.ts delete mode 100644 packages/typescript-estree/src/estree/extensions.ts delete mode 100644 packages/typescript-estree/src/estree/spec.ts create mode 100644 packages/typescript-estree/src/parser-options.ts delete mode 100644 packages/typescript-estree/src/temp-types-based-on-js-source.ts create mode 100644 packages/typescript-estree/src/typedefs.ts diff --git a/packages/typescript-estree/src/ast-converter.ts b/packages/typescript-estree/src/ast-converter.ts index 13d2212c5c4f..131539a981b8 100644 --- a/packages/typescript-estree/src/ast-converter.ts +++ b/packages/typescript-estree/src/ast-converter.ts @@ -5,11 +5,11 @@ * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ -import convert, { getASTMaps, resetASTMaps, convertError } from './convert'; +import { convertError, Converter } from './convert'; import { convertComments } from './convert-comments'; import { convertTokens } from './node-utils'; import ts from 'typescript'; -import { Extra } from './temp-types-based-on-js-source'; +import { Extra } from './parser-options'; export default function astConverter( ast: ts.SourceFile, @@ -27,17 +27,14 @@ export default function astConverter( /** * Recursively convert the TypeScript AST into an ESTree-compatible AST */ - const estree: any = convert({ - node: ast, - parent: null, - ast, - additionalOptions: { - errorOnUnknownASTType: extra.errorOnUnknownASTType || false, - useJSXTextNode: extra.useJSXTextNode || false, - shouldProvideParserServices - } + const instance = new Converter(ast, { + errorOnUnknownASTType: extra.errorOnUnknownASTType || false, + useJSXTextNode: extra.useJSXTextNode || false, + shouldProvideParserServices }); + const estree = instance.convertProgram(); + /** * Optionally convert and include all tokens in the AST */ @@ -52,11 +49,9 @@ export default function astConverter( estree.comments = convertComments(ast, extra.code); } - let astMaps = undefined; - if (shouldProvideParserServices) { - astMaps = getASTMaps(); - resetASTMaps(); - } + const astMaps = shouldProvideParserServices + ? instance.getASTMaps() + : undefined; return { estree, astMaps }; } diff --git a/packages/typescript-estree/src/convert-comments.ts b/packages/typescript-estree/src/convert-comments.ts index ac7f8504d8aa..59a2326122c8 100644 --- a/packages/typescript-estree/src/convert-comments.ts +++ b/packages/typescript-estree/src/convert-comments.ts @@ -7,31 +7,28 @@ import ts from 'typescript'; import { getLocFor, getNodeContainer } from './node-utils'; -import { - ESTreeComment, - LineAndColumnData -} from './temp-types-based-on-js-source'; +import * as es from './typedefs'; /** * Converts a TypeScript comment to an Esprima comment. - * @param {boolean} block True if it's a block comment, false if not. - * @param {string} text The text of the comment. - * @param {number} start The index at which the comment starts. - * @param {number} end The index at which the comment ends. - * @param {LineAndColumnData} startLoc The location at which the comment starts. - * @param {LineAndColumnData} endLoc The location at which the comment ends. - * @returns {Object} The comment object. - * @private + * @param block True if it's a block comment, false if not. + * @param text The text of the comment. + * @param start The index at which the comment starts. + * @param end The index at which the comment ends. + * @param startLoc The location at which the comment starts. + * @param endLoc The location at which the comment ends. + * @returns The comment object. + * @internal */ function convertTypeScriptCommentToEsprimaComment( block: boolean, text: string, start: number, end: number, - startLoc: LineAndColumnData, - endLoc: LineAndColumnData -): ESTreeComment { - const comment: ESTreeComment = { + startLoc: es.LineAndColumnData, + endLoc: es.LineAndColumnData +): es.Comment { + const comment: es.OptionalRangeAndLoc = { type: block ? 'Block' : 'Line', value: text }; @@ -47,22 +44,22 @@ function convertTypeScriptCommentToEsprimaComment( }; } - return comment; + return comment as es.Comment; } /** * Convert comment from TypeScript Triva Scanner. - * @param {ts.Scanner} triviaScanner TS Scanner - * @param {ts.SourceFile} ast the AST object - * @param {string} code TypeScript code - * @returns {ESTreeComment} the converted ESTreeComment + * @param triviaScanner TS Scanner + * @param ast the AST object + * @param code TypeScript code + * @returns the converted Comment * @private */ function getCommentFromTriviaScanner( triviaScanner: ts.Scanner, ast: ts.SourceFile, code: string -): ESTreeComment { +): es.Comment { const kind = triviaScanner.getToken(); const isBlock = kind === ts.SyntaxKind.MultiLineCommentTrivia; const range = { @@ -77,7 +74,7 @@ function getCommentFromTriviaScanner( : comment.replace(/^\/\//, ''); const loc = getLocFor(range.pos, range.end, ast); - const esprimaComment = convertTypeScriptCommentToEsprimaComment( + return convertTypeScriptCommentToEsprimaComment( isBlock, text, range.pos, @@ -85,22 +82,20 @@ function getCommentFromTriviaScanner( loc.start, loc.end ); - - return esprimaComment; } /** * Convert all comments for the given AST. - * @param {ts.SourceFile} ast the AST object - * @param {string} code the TypeScript code - * @returns {ESTreeComment[]} the converted ESTreeComment + * @param ast the AST object + * @param code the TypeScript code + * @returns the converted ESTreeComment * @private */ export function convertComments( ast: ts.SourceFile, code: string -): ESTreeComment[] { - const comments: ESTreeComment[] = []; +): es.Comment[] { + const comments: es.Comment[] = []; /** * Create a TypeScript Scanner, with skipTrivia set to false so that diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 9a7adebc8e2e..8e2d6a876a15 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -6,65 +6,44 @@ * MIT License */ import ts from 'typescript'; +import * as es from './typedefs'; import { canContainDirective, + convertToken, createError, - getLoc, - getLocFor, findNextToken, - convertToken, - hasModifier, fixExports, - getTSNodeAccessibility, + getBinaryExpressionType, + getDeclarationKind, + getLastModifier, + getLineAndCharacterFor, + getLocFor, + getRange, getTextForTokenKind, - isJSXToken, + getTSNodeAccessibility, + hasModifier, + isComma, isComputedProperty, isESTreeClassMember, - isComma, - getBinaryExpressionType, + isJSXToken, isOptional, - unescapeStringLiteralText, - getDeclarationKind, - getLastModifier, - getLineAndCharacterFor + unescapeStringLiteralText } from './node-utils'; import { AST_NODE_TYPES } from './ast-node-types'; -import { ESTreeNode } from './temp-types-based-on-js-source'; import { TSNode } from './ts-nodes'; const SyntaxKind = ts.SyntaxKind; -let esTreeNodeToTSNodeMap = new WeakMap(); -let tsNodeToESTreeNodeMap = new WeakMap(); - -export function resetASTMaps() { - esTreeNodeToTSNodeMap = new WeakMap(); - tsNodeToESTreeNodeMap = new WeakMap(); -} - -export function getASTMaps() { - return { esTreeNodeToTSNodeMap, tsNodeToESTreeNodeMap }; -} - -interface ConvertAdditionalOptions { +interface ConverterOptions { errorOnUnknownASTType: boolean; useJSXTextNode: boolean; shouldProvideParserServices: boolean; } -interface ConvertConfig { - node: ts.Node; - parent?: ts.Node | null; - inTypeMode?: boolean; - allowPattern?: boolean; - ast: ts.SourceFile; - additionalOptions: ConvertAdditionalOptions; -} - /** * Extends and formats a given error object - * @param {Object} error the error object - * @returns {Object} converted error object + * @param error the error object + * @returns converted error object */ export function convertError(error: any) { return createError( @@ -74,121 +53,171 @@ export function convertError(error: any) { ); } -/** - * Converts a TypeScript node into an ESTree node - * @param {Object} config configuration options for the conversion - * @param {TSNode} config.node the ts.Node - * @param {ts.Node} config.parent the parent ts.Node - * @param {ts.SourceFile} config.ast the full TypeScript AST - * @param {Object} config.additionalOptions additional options for the conversion - * @returns {ESTreeNode|null} the converted ESTreeNode - */ -export default function convert(config: ConvertConfig): ESTreeNode | null { - const node: TSNode = config.node as TSNode; - const parent = config.parent; - const ast = config.ast; - const additionalOptions = config.additionalOptions || {}; +export class Converter { + private readonly ast: ts.SourceFile; + private options: ConverterOptions; + private esTreeNodeToTSNodeMap = new WeakMap(); + private tsNodeToESTreeNodeMap = new WeakMap(); + + private allowPattern: boolean = false; + private inTypeMode: boolean = false; /** - * Exit early for null and undefined + * Converts a TypeScript node into an ESTree node + * @param ast the full TypeScript AST + * @param options additional options for the conversion + * @returns the converted ESTreeNode */ - if (!node) { - return null; + constructor(ast: ts.SourceFile, options: ConverterOptions) { + this.ast = ast; + this.options = options; + } + + getASTMaps() { + return { + esTreeNodeToTSNodeMap: this.esTreeNodeToTSNodeMap, + tsNodeToESTreeNodeMap: this.tsNodeToESTreeNodeMap + }; + } + + convertProgram(): es.Program { + return this.converter(this.ast) as es.Program; } /** - * Create a new ESTree node + * Converts a TypeScript node into an ESTree node. + * @param node the child ts.Node + * @param parent parentNode + * @param inTypeMode flag to determine if we are in typeMode + * @param allowPattern flag to determine if patterns are allowed + * @returns the converted ESTree node */ - let result: ESTreeNode = { - type: '' as AST_NODE_TYPES, - range: [node.getStart(ast), node.end], - loc: getLoc(node, ast) - }; - - function converter( - child?: ts.Node, + private converter( + node?: ts.Node, + parent?: ts.Node, inTypeMode?: boolean, allowPattern?: boolean - ): ESTreeNode | null { - if (!child) { + ): any { + /** + * Exit early for null and undefined + */ + if (!node) { return null; } - return convert({ - node: child, - parent: node, - inTypeMode, - allowPattern, - ast, - additionalOptions - }); + + const typeMode = this.inTypeMode; + const pattern = this.allowPattern; + if (inTypeMode !== undefined) { + this.inTypeMode = inTypeMode; + } + if (allowPattern !== undefined) { + this.allowPattern = allowPattern; + } + + let result: es.BaseNode | null = this.convertNode( + node as TSNode, + parent || node.parent + ); + + if (result && this.options.shouldProvideParserServices) { + this.tsNodeToESTreeNodeMap.set(node, result); + this.esTreeNodeToTSNodeMap.set(result, node); + } + + this.inTypeMode = typeMode; + this.allowPattern = pattern; + return result; } /** * Converts a TypeScript node into an ESTree node. - * @param {ts.Node} child the child ts.Node - * @returns {ESTreeNode|null} the converted ESTree node + * @param child the child ts.Node + * @param parent parentNode + * @returns the converted ESTree node */ - function convertPattern(child?: ts.Node): ESTreeNode | null { - return converter(child, config.inTypeMode, true); + private convertPattern(child?: ts.Node, parent?: ts.Node): any | null { + return this.converter(child, parent, this.inTypeMode, true); } /** * Converts a TypeScript node into an ESTree node. - * @param {ts.Node} child the child ts.Node - * @returns {ESTreeNode|null} the converted ESTree node + * @param child the child ts.Node + * @param parent parentNode + * @returns the converted ESTree node */ - function convertChild(child?: ts.Node): ESTreeNode | null { - return converter(child, config.inTypeMode, false); + private convertChild(child?: ts.Node, parent?: ts.Node): any | null { + return this.converter(child, parent, this.inTypeMode, false); } /** * Converts a TypeScript node into an ESTree node. - * @param {ts.Node} child the child ts.Node - * @returns {ESTreeNode|null} the converted ESTree node + * @param child the child ts.Node + * @param parent parentNode + * @returns the converted ESTree node */ - function convertChildType(child?: ts.Node): ESTreeNode | null { - return converter(child, true, false); + private convertType(child?: ts.Node, parent?: ts.Node): any | null { + return this.converter(child, parent, true, false); + } + + private createNode( + node: ts.Node, + data: es.OptionalRangeAndLoc + ): T { + const result = data; + if (!result.range) { + result.range = getRange(node, this.ast); + } + if (!result.loc) { + result.loc = getLocFor(result.range[0], result.range[1], this.ast); + } + + return result as T; } /** * Converts a child into a type annotation. This creates an intermediary * TypeAnnotation node to match what Flow does. - * @param {ts.TypeNode} child The TypeScript AST node to convert. - * @returns {ESTreeNode} The type annotation node. + * @param child The TypeScript AST node to convert. + * @param parent parentNode + * @returns The type annotation node. */ - function convertTypeAnnotation(child: ts.TypeNode): ESTreeNode { - const annotation = convertChildType(child); + private convertTypeAnnotation( + child: ts.TypeNode, + parent: ts.Node + ): es.TSTypeAnnotation { // in FunctionType and ConstructorType typeAnnotation has 2 characters `=>` and in other places is just colon const offset = - node.kind === SyntaxKind.FunctionType || - node.kind === SyntaxKind.ConstructorType + parent.kind === SyntaxKind.FunctionType || + parent.kind === SyntaxKind.ConstructorType ? 2 : 1; const annotationStartCol = child.getFullStart() - offset; - const loc = getLocFor(annotationStartCol, child.end, ast); + const loc = getLocFor(annotationStartCol, child.end, this.ast); return { type: AST_NODE_TYPES.TSTypeAnnotation, loc, range: [annotationStartCol, child.end], - typeAnnotation: annotation + typeAnnotation: this.convertType(child) }; } /** * Coverts body Nodes and add directive field to StringLiterals - * @param {ts.NodeArray} nodes of ts.Node - * @returns {ESTreeNode[]} Array of body statements + * @param nodes of ts.Node + * @param parent parentNode + * @returns Array of body statements */ - function convertBodyExpressions( - nodes: ts.NodeArray - ): ESTreeNode[] { - let allowDirectives = canContainDirective(node); + private convertBodyExpressions( + nodes: ts.NodeArray, + parent: ts.Node + ): any[] { + let allowDirectives = canContainDirective(parent); return ( nodes .map(statement => { - const child = convertChild(statement); + const child = this.convertChild(statement); if (allowDirectives) { if ( child && @@ -196,14 +225,14 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { ts.isExpressionStatement(statement) && ts.isStringLiteral(statement.expression) ) { - const raw = child.expression.raw!; + const raw = child.expression.raw; child.directive = raw.slice(1, -1); - return child!; // child can be null but it's filtered below + return child; // child can be null but it's filtered below } else { allowDirectives = false; } } - return child!; // child can be null but it's filtered below + return child; // child can be null but it's filtered below }) // filter out unknown nodes for now .filter(statement => statement) @@ -212,58 +241,60 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { /** * Converts a ts.Node's typeArguments to TSTypeParameterInstantiation node - * @param {ts.NodeArray} typeArguments ts.Node typeArguments - * @returns {ESTreeNode} TypeParameterInstantiation node + * @param typeArguments ts.Node typeArguments + * @returns TypeParameterInstantiation node */ - function convertTypeArgumentsToTypeParameters( - typeArguments: ts.NodeArray - ): ESTreeNode { - const greaterThanToken = findNextToken(typeArguments, ast, ast)!; + private convertTypeArgumentsToTypeParameters( + typeArguments: ts.NodeArray + ): es.TSTypeParameterInstantiation { + const greaterThanToken = findNextToken(typeArguments, this.ast, this.ast)!; return { type: AST_NODE_TYPES.TSTypeParameterInstantiation, range: [typeArguments.pos - 1, greaterThanToken.end], - loc: getLocFor(typeArguments.pos - 1, greaterThanToken.end, ast), - params: typeArguments.map(typeArgument => convertChildType(typeArgument)) + loc: getLocFor(typeArguments.pos - 1, greaterThanToken.end, this.ast), + params: typeArguments.map(typeArgument => this.convertType(typeArgument)) }; } /** * Converts a ts.Node's typeParameters to TSTypeParameterDeclaration node - * @param {ts.NodeArray} typeParameters ts.Node typeParameters - * @returns {ESTreeNode} TypeParameterDeclaration node + * @param typeParameters ts.Node typeParameters + * @returns TypeParameterDeclaration node */ - function convertTSTypeParametersToTypeParametersDeclaration( - typeParameters: ts.NodeArray - ): ESTreeNode { - const greaterThanToken = findNextToken(typeParameters, ast, ast)!; + private convertTSTypeParametersToTypeParametersDeclaration( + typeParameters: ts.NodeArray + ): es.TSTypeParameterDeclaration { + const greaterThanToken = findNextToken(typeParameters, this.ast, this.ast)!; return { type: AST_NODE_TYPES.TSTypeParameterDeclaration, range: [typeParameters.pos - 1, greaterThanToken.end], - loc: getLocFor(typeParameters.pos - 1, greaterThanToken.end, ast), + loc: getLocFor(typeParameters.pos - 1, greaterThanToken.end, this.ast), params: typeParameters.map(typeParameter => - convertChildType(typeParameter) + this.convertType(typeParameter) ) }; } /** * Converts an array of ts.Node parameters into an array of ESTreeNode params - * @param {ts.Node[]} parameters An array of ts.Node params to be converted - * @returns {ESTreeNode[]} an array of converted ESTreeNode params + * @param parameters An array of ts.Node params to be converted + * @returns an array of converted ESTreeNode params */ - function convertParameters(parameters: ts.NodeArray): ESTreeNode[] { + private convertParameters( + parameters: ts.NodeArray + ): (es.TSParameterProperty | es.RestElement | es.AssignmentPattern)[] { if (!parameters || !parameters.length) { return []; } return parameters.map(param => { - const convertedParam = convertChild(param)!; + const convertedParam = this.convertChild(param); if (!param.decorators || !param.decorators.length) { return convertedParam; } return Object.assign(convertedParam, { - decorators: param.decorators.map(convertChild) + decorators: param.decorators.map(el => this.convertChild(el)) }); }); } @@ -272,21 +303,20 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { * For nodes that are copied directly from the TypeScript AST into * ESTree mostly as-is. The only difference is the addition of a type * property instead of a kind property. Recursively copies all children. - * @returns {void} */ - function deeplyCopy(): void { + private deeplyCopy(node: ts.Node): any { const customType = `TS${SyntaxKind[node.kind]}` as AST_NODE_TYPES; /** * If the "errorOnUnknownASTType" option is set to true, throw an error, * otherwise fallback to just including the unknown type as-is. */ - if ( - additionalOptions.errorOnUnknownASTType && - !AST_NODE_TYPES[customType] - ) { + if (this.options.errorOnUnknownASTType && !AST_NODE_TYPES[customType]) { throw new Error(`Unknown AST_NODE_TYPE: "${customType}"`); } - result.type = customType; + const result = this.createNode(node, { + type: customType + }); + Object.keys(node) .filter( key => @@ -297,83 +327,105 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { .forEach(key => { if (key === 'type') { result.typeAnnotation = (node as any).type - ? convertTypeAnnotation((node as any).type) + ? this.convertTypeAnnotation((node as any).type, node) : null; } else if (key === 'typeArguments') { result.typeParameters = (node as any).typeArguments - ? convertTypeArgumentsToTypeParameters((node as any).typeArguments) + ? this.convertTypeArgumentsToTypeParameters( + (node as any).typeArguments + ) : null; } else if (key === 'typeParameters') { result.typeParameters = (node as any).typeParameters - ? convertTSTypeParametersToTypeParametersDeclaration( + ? this.convertTSTypeParametersToTypeParametersDeclaration( (node as any).typeParameters ) : null; } else if (key === 'decorators') { if (node.decorators && node.decorators.length) { - result.decorators = node.decorators.map(convertChild); + result.decorators = node.decorators.map((el: any) => + this.convertChild(el) + ); } } else { if (Array.isArray((node as any)[key])) { - (result as any)[key] = (node as any)[key].map(convertChild); + result[key] = (node as any)[key].map((el: any) => + this.convertChild(el) + ); } else if ( (node as any)[key] && typeof (node as any)[key] === 'object' && (node as any)[key].kind ) { // need to check node[key].kind to ensure we don't try to convert a symbol - (result as any)[key] = convertChild((node as any)[key]); + result[key] = this.convertChild((node as any)[key]); } else { - (result as any)[key] = (node as any)[key]; + result[key] = (node as any)[key]; } } }); + return result; } /** * Converts a TypeScript JSX node.tagName into an ESTree node.name - * @param {ts.JsxTagNameExpression} tagName the tagName object from a JSX ts.Node - * @returns {Object} the converted ESTree name object + * @param tagName the tagName object from a JSX ts.Node + * @param parent + * @returns the converted ESTree name object */ - function convertTypeScriptJSXTagNameToESTreeName( - tagName: ts.JsxTagNameExpression - ): ESTreeNode { - const tagNameToken = convertToken(tagName, ast); - - if (tagNameToken.type === AST_NODE_TYPES.JSXMemberExpression) { + private convertTypeScriptJSXTagNameToESTreeName( + tagName: ts.JsxTagNameExpression, + parent: ts.Node + ): es.JSXMemberExpression | es.JSXIdentifier { + // TODO: remove convertToken call + const tagNameToken = convertToken(tagName, this.ast); + + if (tagName.kind === SyntaxKind.PropertyAccessExpression) { const isNestedMemberExpression = - (node as any).tagName.expression.kind === - SyntaxKind.PropertyAccessExpression; + tagName.expression.kind === SyntaxKind.PropertyAccessExpression; // Convert TSNode left and right objects into ESTreeNode object // and property objects - tagNameToken.object = convertChild((node as any).tagName.expression); - tagNameToken.property = convertChild((node as any).tagName.name); + const object = this.convertChild(tagName.expression, parent); + const property = this.convertChild(tagName.name, parent); // Assign the appropriate types - tagNameToken.object.type = isNestedMemberExpression + object.type = isNestedMemberExpression ? AST_NODE_TYPES.JSXMemberExpression : AST_NODE_TYPES.JSXIdentifier; - tagNameToken.property.type = AST_NODE_TYPES.JSXIdentifier; + property.type = AST_NODE_TYPES.JSXIdentifier; if ((tagName as any).expression.kind === SyntaxKind.ThisKeyword) { - tagNameToken.object.name = 'this'; + object.name = 'this'; } + + return this.createNode(tagName, { + type: AST_NODE_TYPES.JSXMemberExpression, + range: tagNameToken.range, + loc: tagNameToken.loc, + object: object, + property: property + }); } else { - tagNameToken.type = AST_NODE_TYPES.JSXIdentifier; - tagNameToken.name = tagNameToken.value; + return this.createNode(tagName, { + type: AST_NODE_TYPES.JSXIdentifier, + range: tagNameToken.range, + loc: tagNameToken.loc, + name: tagNameToken.value + }); } - - delete tagNameToken.value; - - return tagNameToken; } /** * Applies the given TS modifiers to the given result object. - * @param {ts.ModifiersArray} modifiers original ts.Nodes from the node.modifiers array - * @returns {void} (the current result object will be mutated) + * @param result + * @param modifiers original ts.Nodes from the node.modifiers array + * @returns the current result object will be mutated + * @deprecated This method adds not standardized `modifiers` property in nodes */ - function applyModifiersToResult(modifiers?: ts.ModifiersArray): void { + private applyModifiersToResult( + result: es.TSEnumDeclaration | es.TSModuleDeclaration, + modifiers?: ts.ModifiersArray + ): void { if (!modifiers || !modifiers.length) { return; } @@ -396,7 +448,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { handledModifierIndices[i] = true; break; case SyntaxKind.ConstKeyword: - result.const = true; + (result as any).const = true; handledModifierIndices[i] = true; break; case SyntaxKind.DeclareKeyword: @@ -417,2091 +469,2022 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { if (!remainingModifiers || !remainingModifiers.length) { return; } - result.modifiers = remainingModifiers.map(convertChild); + result.modifiers = remainingModifiers.map(el => this.convertChild(el)); } /** * Uses the current TSNode's end location for its `type` to adjust the location data of the given * ESTreeNode, which should be the parent of the final typeAnnotation node - * @param {ESTreeNode} typeAnnotationParent The node that will have its location data mutated - * @returns {void} + * @param typeAnnotationParent The node that will have its location data mutated + * @param node */ - function fixTypeAnnotationParentLocation( - typeAnnotationParent: ESTreeNode + private fixTypeAnnotationParentLocation( + typeAnnotationParent: es.BaseNode, + node: ts.TypeNode ): void { - typeAnnotationParent.range[1] = (node as any).type.getEnd(); - typeAnnotationParent.loc = getLocFor( - typeAnnotationParent.range[0], + typeAnnotationParent.range[1] = node.getEnd(); + typeAnnotationParent.loc.end = getLineAndCharacterFor( typeAnnotationParent.range[1], - ast + this.ast ); } /** + * Converts a TypeScript node into an ESTree node. * The core of the conversion logic: * Identify and convert each relevant TypeScript SyntaxKind + * @param node the child ts.Node + * @param parent parentNode + * @returns the converted ESTree node */ - switch (node.kind) { - case SyntaxKind.SourceFile: - Object.assign(result, { - type: AST_NODE_TYPES.Program, - body: convertBodyExpressions(node.statements), - // externalModuleIndicator is internal field in TSC - sourceType: (node as any).externalModuleIndicator ? 'module' : 'script' - }); + private convertNode(node: TSNode, parent: ts.Node): es.Node | null { + switch (node.kind) { + case SyntaxKind.SourceFile: { + return this.createNode(node, { + type: AST_NODE_TYPES.Program, + body: this.convertBodyExpressions(node.statements, node), + // externalModuleIndicator is internal field in TSC + sourceType: (node as any).externalModuleIndicator + ? 'module' + : 'script', + range: [node.getStart(this.ast), node.endOfFileToken.end] + }); + } - result.range[1] = node.endOfFileToken.end; - result.loc = getLocFor(node.getStart(ast), result.range[1], ast); - break; + case SyntaxKind.Block: { + return this.createNode(node, { + type: AST_NODE_TYPES.BlockStatement, + body: this.convertBodyExpressions(node.statements, node) + }); + } - case SyntaxKind.Block: - Object.assign(result, { - type: AST_NODE_TYPES.BlockStatement, - body: convertBodyExpressions(node.statements) - }); - break; + case SyntaxKind.Identifier: { + return this.createNode(node, { + type: AST_NODE_TYPES.Identifier, + name: node.text + }); + } - case SyntaxKind.Identifier: - Object.assign(result, { - type: AST_NODE_TYPES.Identifier, - name: node.text - }); - break; + case SyntaxKind.WithStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.WithStatement, + object: this.convertChild(node.expression), + body: this.convertChild(node.statement) + }); - case SyntaxKind.WithStatement: - Object.assign(result, { - type: AST_NODE_TYPES.WithStatement, - object: convertChild(node.expression), - body: convertChild(node.statement) - }); - break; + // Control Flow - // Control Flow + case SyntaxKind.ReturnStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.ReturnStatement, + argument: this.convertChild(node.expression) + }); - case SyntaxKind.ReturnStatement: - Object.assign(result, { - type: AST_NODE_TYPES.ReturnStatement, - argument: convertChild(node.expression) - }); - break; + case SyntaxKind.LabeledStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.LabeledStatement, + label: this.convertChild(node.label), + body: this.convertChild(node.statement) + }); - case SyntaxKind.LabeledStatement: - Object.assign(result, { - type: AST_NODE_TYPES.LabeledStatement, - label: convertChild(node.label), - body: convertChild(node.statement) - }); - break; + case SyntaxKind.ContinueStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.ContinueStatement, + label: this.convertChild(node.label) + }); - case SyntaxKind.BreakStatement: - case SyntaxKind.ContinueStatement: - Object.assign(result, { - type: SyntaxKind[node.kind], - label: convertChild(node.label) - }); - break; + case SyntaxKind.BreakStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.BreakStatement, + label: this.convertChild(node.label) + }); - // Choice + // Choice - case SyntaxKind.IfStatement: - Object.assign(result, { - type: AST_NODE_TYPES.IfStatement, - test: convertChild(node.expression), - consequent: convertChild(node.thenStatement), - alternate: convertChild(node.elseStatement) - }); - break; + case SyntaxKind.IfStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.IfStatement, + test: this.convertChild(node.expression), + consequent: this.convertChild(node.thenStatement), + alternate: this.convertChild(node.elseStatement) + }); - case SyntaxKind.SwitchStatement: - Object.assign(result, { - type: AST_NODE_TYPES.SwitchStatement, - discriminant: convertChild(node.expression), - cases: node.caseBlock.clauses.map(convertChild) - }); - break; - - case SyntaxKind.CaseClause: - case SyntaxKind.DefaultClause: - Object.assign(result, { - type: AST_NODE_TYPES.SwitchCase, - // expression is present in case only - test: - node.kind === SyntaxKind.CaseClause - ? convertChild(node.expression) - : null, - consequent: node.statements.map(convertChild) - }); - break; + case SyntaxKind.SwitchStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.SwitchStatement, + discriminant: this.convertChild(node.expression), + cases: node.caseBlock.clauses.map(el => this.convertChild(el)) + }); - // Exceptions + case SyntaxKind.CaseClause: + case SyntaxKind.DefaultClause: + return this.createNode(node, { + type: AST_NODE_TYPES.SwitchCase, + // expression is present in case only + test: + node.kind === SyntaxKind.CaseClause + ? this.convertChild(node.expression) + : null, + consequent: node.statements.map(el => this.convertChild(el)) + }); - case SyntaxKind.ThrowStatement: - Object.assign(result, { - type: AST_NODE_TYPES.ThrowStatement, - argument: convertChild(node.expression) - }); - break; - - case SyntaxKind.TryStatement: - Object.assign(result, { - type: AST_NODE_TYPES.TryStatement, - block: convert({ - node: node.tryBlock, - parent: null, - ast, - additionalOptions - }), - handler: convertChild(node.catchClause), - finalizer: convertChild(node.finallyBlock) - }); - break; - - case SyntaxKind.CatchClause: - Object.assign(result, { - type: AST_NODE_TYPES.CatchClause, - param: node.variableDeclaration - ? convertChild(node.variableDeclaration.name) - : null, - body: convertChild(node.block) - }); - break; + // Exceptions - // Loops + case SyntaxKind.ThrowStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.ThrowStatement, + argument: this.convertChild(node.expression) + }); - case SyntaxKind.WhileStatement: - Object.assign(result, { - type: AST_NODE_TYPES.WhileStatement, - test: convertChild(node.expression), - body: convertChild(node.statement) - }); - break; + case SyntaxKind.TryStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.TryStatement, + block: this.convertChild(node.tryBlock), + handler: this.convertChild(node.catchClause), + finalizer: this.convertChild(node.finallyBlock) + }); - /** - * Unlike other parsers, TypeScript calls a "DoWhileStatement" - * a "DoStatement" - */ - case SyntaxKind.DoStatement: - Object.assign(result, { - type: AST_NODE_TYPES.DoWhileStatement, - test: convertChild(node.expression), - body: convertChild(node.statement) - }); - break; - - case SyntaxKind.ForStatement: - Object.assign(result, { - type: AST_NODE_TYPES.ForStatement, - init: convertChild(node.initializer), - test: convertChild(node.condition), - update: convertChild(node.incrementor), - body: convertChild(node.statement) - }); - break; - - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: { - Object.assign(result, { - type: SyntaxKind[node.kind], - left: convertPattern(node.initializer), - right: convertChild(node.expression), - body: convertChild(node.statement) - }); + case SyntaxKind.CatchClause: + return this.createNode(node, { + type: AST_NODE_TYPES.CatchClause, + param: node.variableDeclaration + ? this.convertChild(node.variableDeclaration.name) + : null, + body: this.convertChild(node.block) + }); - // await is only available in for of statement - if (node.kind === SyntaxKind.ForOfStatement) { - (result as any).await = Boolean( - node.awaitModifier && - node.awaitModifier.kind === SyntaxKind.AwaitKeyword - ); - } - break; - } + // Loops - // Declarations + case SyntaxKind.WhileStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.WhileStatement, + test: this.convertChild(node.expression), + body: this.convertChild(node.statement) + }); - case SyntaxKind.FunctionDeclaration: { - const isDeclare = hasModifier(SyntaxKind.DeclareKeyword, node); - let functionDeclarationType = AST_NODE_TYPES.FunctionDeclaration; - if (isDeclare || !node.body) { - functionDeclarationType = AST_NODE_TYPES.TSDeclareFunction; - } + /** + * Unlike other parsers, TypeScript calls a "DoWhileStatement" + * a "DoStatement" + */ + case SyntaxKind.DoStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.DoWhileStatement, + test: this.convertChild(node.expression), + body: this.convertChild(node.statement) + }); - Object.assign(result, { - type: functionDeclarationType, - id: convertChild(node.name), - generator: !!node.asteriskToken, - expression: false, - async: hasModifier(SyntaxKind.AsyncKeyword, node), - params: convertParameters(node.parameters), - body: convertChild(node.body) || undefined - }); + case SyntaxKind.ForStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.ForStatement, + init: this.convertChild(node.initializer), + test: this.convertChild(node.condition), + update: this.convertChild(node.incrementor), + body: this.convertChild(node.statement) + }); - // Process returnType - if (node.type) { - result.returnType = convertTypeAnnotation(node.type); - } + case SyntaxKind.ForInStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.ForInStatement, + left: this.convertPattern(node.initializer), + right: this.convertChild(node.expression), + body: this.convertChild(node.statement) + }); - if (isDeclare) { - result.declare = true; - } + case SyntaxKind.ForOfStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.ForOfStatement, + left: this.convertPattern(node.initializer), + right: this.convertChild(node.expression), + body: this.convertChild(node.statement), + await: Boolean( + node.awaitModifier && + node.awaitModifier.kind === SyntaxKind.AwaitKeyword + ) + }); - // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { - result.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); - } + // Declarations + + case SyntaxKind.FunctionDeclaration: { + const isDeclare = hasModifier(SyntaxKind.DeclareKeyword, node); + + const result = this.createNode< + es.TSDeclareFunction | es.FunctionDeclaration + >(node, { + type: + isDeclare || !node.body + ? AST_NODE_TYPES.TSDeclareFunction + : AST_NODE_TYPES.FunctionDeclaration, + id: this.convertChild(node.name), + generator: !!node.asteriskToken, + expression: false, + async: hasModifier(SyntaxKind.AsyncKeyword, node), + params: this.convertParameters(node.parameters), + body: this.convertChild(node.body) || undefined + }); - // check for exports - result = fixExports(node, result, ast); + // Process returnType + if (node.type) { + result.returnType = this.convertTypeAnnotation(node.type, node); + } - break; - } + if (isDeclare) { + result.declare = true; + } - case SyntaxKind.VariableDeclaration: { - Object.assign(result, { - type: AST_NODE_TYPES.VariableDeclarator, - id: convertPattern(node.name), - init: convertChild(node.initializer) - }); + // Process typeParameters + if (node.typeParameters && node.typeParameters.length) { + result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters + ); + } - if (node.exclamationToken) { - (result as any).definite = true; + // check for exports + return fixExports(node, result, this.ast); } - if (node.type) { - result.id!.typeAnnotation = convertTypeAnnotation(node.type); - fixTypeAnnotationParentLocation(result.id!); - } - break; - } + case SyntaxKind.VariableDeclaration: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.VariableDeclarator, + id: this.convertPattern(node.name), + init: this.convertChild(node.initializer) + }); - case SyntaxKind.VariableStatement: - Object.assign(result, { - type: AST_NODE_TYPES.VariableDeclaration, - declarations: node.declarationList.declarations.map(convertChild), - kind: getDeclarationKind(node.declarationList) - }); + if (node.exclamationToken) { + result.definite = true; + } - if (hasModifier(SyntaxKind.DeclareKeyword, node)) { - result.declare = true; + if (node.type) { + result.id.typeAnnotation = this.convertTypeAnnotation( + node.type, + node + ); + this.fixTypeAnnotationParentLocation(result.id, node.type); + } + return result; } - // check for exports - result = fixExports(node, result, ast); - break; - - // mostly for for-of, for-in - case SyntaxKind.VariableDeclarationList: - Object.assign(result, { - type: AST_NODE_TYPES.VariableDeclaration, - declarations: node.declarations.map(convertChild), - kind: getDeclarationKind(node) - }); - break; - - // Expressions - - case SyntaxKind.ExpressionStatement: - Object.assign(result, { - type: AST_NODE_TYPES.ExpressionStatement, - expression: convertChild(node.expression) - }); - break; + case SyntaxKind.VariableStatement: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.VariableDeclaration, + declarations: node.declarationList.declarations.map(el => + this.convertChild(el) + ), + kind: getDeclarationKind(node.declarationList) + }); - case SyntaxKind.ThisKeyword: - Object.assign(result, { - type: AST_NODE_TYPES.ThisExpression - }); - break; + if (hasModifier(SyntaxKind.DeclareKeyword, node)) { + result.declare = true; + } - case SyntaxKind.ArrayLiteralExpression: { - // TypeScript uses ArrayLiteralExpression in destructuring assignment, too - if (config.allowPattern) { - Object.assign(result, { - type: AST_NODE_TYPES.ArrayPattern, - elements: node.elements.map(convertPattern) - }); - } else { - Object.assign(result, { - type: AST_NODE_TYPES.ArrayExpression, - elements: node.elements.map(convertChild) - }); + // check for exports + return fixExports(node, result, this.ast); } - break; - } - case SyntaxKind.ObjectLiteralExpression: { - // TypeScript uses ObjectLiteralExpression in destructuring assignment, too - if (config.allowPattern) { - Object.assign(result, { - type: AST_NODE_TYPES.ObjectPattern, - properties: node.properties.map(convertPattern) - }); - } else { - Object.assign(result, { - type: AST_NODE_TYPES.ObjectExpression, - properties: node.properties.map(convertChild) + // mostly for for-of, for-in + case SyntaxKind.VariableDeclarationList: + return this.createNode(node, { + type: AST_NODE_TYPES.VariableDeclaration, + declarations: node.declarations.map(el => this.convertChild(el)), + kind: getDeclarationKind(node) }); - } - break; - } - case SyntaxKind.PropertyAssignment: - Object.assign(result, { - type: AST_NODE_TYPES.Property, - key: convertChild(node.name), - value: converter( - node.initializer, - config.inTypeMode, - config.allowPattern - ), - computed: isComputedProperty(node.name), - method: false, - shorthand: false, - kind: 'init' - }); - break; + // Expressions - case SyntaxKind.ShorthandPropertyAssignment: { - if (node.objectAssignmentInitializer) { - Object.assign(result, { - type: AST_NODE_TYPES.Property, - key: convertChild(node.name), - value: { - type: AST_NODE_TYPES.AssignmentPattern, - left: convertPattern(node.name), - right: convertChild(node.objectAssignmentInitializer), - loc: result.loc, - range: result.range - }, - computed: false, - method: false, - shorthand: true, - kind: 'init' + case SyntaxKind.ExpressionStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.ExpressionStatement, + expression: this.convertChild(node.expression) }); - } else { - // TODO: this node has no initializer field - Object.assign(result, { - type: AST_NODE_TYPES.Property, - key: convertChild(node.name), - value: convertChild((node as any).initializer || node.name), - computed: false, - method: false, - shorthand: true, - kind: 'init' - }); - } - break; - } - - case SyntaxKind.ComputedPropertyName: - return convertChild(node.expression); - - case SyntaxKind.PropertyDeclaration: { - const isAbstract = hasModifier(SyntaxKind.AbstractKeyword, node); - Object.assign(result, { - type: isAbstract - ? AST_NODE_TYPES.TSAbstractClassProperty - : AST_NODE_TYPES.ClassProperty, - key: convertChild(node.name), - value: convertChild(node.initializer), - computed: isComputedProperty(node.name), - static: hasModifier(SyntaxKind.StaticKeyword, node), - readonly: hasModifier(SyntaxKind.ReadonlyKeyword, node) || undefined - }); - - if (node.type) { - result.typeAnnotation = convertTypeAnnotation(node.type); - } - - if (node.decorators) { - result.decorators = node.decorators.map(convertChild); - } - - const accessibility = getTSNodeAccessibility(node); - if (accessibility) { - result.accessibility = accessibility; - } - - if (node.name.kind === SyntaxKind.Identifier && node.questionToken) { - result.optional = true; - } - if (node.exclamationToken) { - (result as any).definite = true; - } + case SyntaxKind.ThisKeyword: + return this.createNode(node, { + type: AST_NODE_TYPES.ThisExpression + }); - if ( - (result as any).key.type === AST_NODE_TYPES.Literal && - node.questionToken - ) { - result.optional = true; + case SyntaxKind.ArrayLiteralExpression: { + // TypeScript uses ArrayLiteralExpression in destructuring assignment, too + if (this.allowPattern) { + return this.createNode(node, { + type: AST_NODE_TYPES.ArrayPattern, + elements: node.elements.map(el => this.convertPattern(el)) + }); + } else { + return this.createNode(node, { + type: AST_NODE_TYPES.ArrayExpression, + elements: node.elements.map(el => this.convertChild(el)) + }); + } } - break; - } - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.MethodDeclaration: { - const method: ESTreeNode = { - type: AST_NODE_TYPES.FunctionExpression, - id: null, - generator: !!node.asteriskToken, - expression: false, // ESTreeNode as ESTreeNode here - async: hasModifier(SyntaxKind.AsyncKeyword, node), - body: convertChild(node.body), - range: [node.parameters.pos - 1, result.range[1]], - loc: { - start: getLineAndCharacterFor(node.parameters.pos - 1, ast), - end: result.loc.end + case SyntaxKind.ObjectLiteralExpression: { + // TypeScript uses ObjectLiteralExpression in destructuring assignment, too + if (this.allowPattern) { + return this.createNode(node, { + type: AST_NODE_TYPES.ObjectPattern, + properties: node.properties.map(el => this.convertPattern(el)) + }); + } else { + return this.createNode(node, { + type: AST_NODE_TYPES.ObjectExpression, + properties: node.properties.map(el => this.convertChild(el)) + }); } - } as any; - - if (node.type) { - (method as any).returnType = convertTypeAnnotation(node.type); } - if (parent!.kind === SyntaxKind.ObjectLiteralExpression) { - (method as any).params = node.parameters.map(convertChild); - - Object.assign(result, { + case SyntaxKind.PropertyAssignment: + return this.createNode(node, { type: AST_NODE_TYPES.Property, - key: convertChild(node.name), - value: method, + key: this.convertChild(node.name), + value: this.converter( + node.initializer, + node, + this.inTypeMode, + this.allowPattern + ), computed: isComputedProperty(node.name), - method: node.kind === SyntaxKind.MethodDeclaration, + method: false, shorthand: false, kind: 'init' }); - } else { - // class - /** - * Unlike in object literal methods, class method params can have decorators - */ - (method as any).params = convertParameters(node.parameters); + case SyntaxKind.ShorthandPropertyAssignment: { + if (node.objectAssignmentInitializer) { + return this.createNode(node, { + type: AST_NODE_TYPES.Property, + key: this.convertChild(node.name), + value: this.createNode(node, { + type: AST_NODE_TYPES.AssignmentPattern, + left: this.convertPattern(node.name), + right: this.convertChild(node.objectAssignmentInitializer) + }), + computed: false, + method: false, + shorthand: true, + kind: 'init' + }); + } else { + return this.createNode(node, { + type: AST_NODE_TYPES.Property, + key: this.convertChild(node.name), + value: this.convertChild(node.name), + computed: false, + method: false, + shorthand: true, + kind: 'init' + }); + } + } - /** - * TypeScript class methods can be defined as "abstract" - */ - const methodDefinitionType = hasModifier( - SyntaxKind.AbstractKeyword, - node - ) - ? AST_NODE_TYPES.TSAbstractMethodDefinition - : AST_NODE_TYPES.MethodDefinition; - - Object.assign(result, { - type: methodDefinitionType, - key: convertChild(node.name), - value: method, + case SyntaxKind.ComputedPropertyName: + return this.convertChild(node.expression); + + case SyntaxKind.PropertyDeclaration: { + const isAbstract = hasModifier(SyntaxKind.AbstractKeyword, node); + const result = this.createNode< + es.TSAbstractClassProperty | es.ClassProperty + >(node, { + type: isAbstract + ? AST_NODE_TYPES.TSAbstractClassProperty + : AST_NODE_TYPES.ClassProperty, + key: this.convertChild(node.name), + value: this.convertChild(node.initializer), computed: isComputedProperty(node.name), static: hasModifier(SyntaxKind.StaticKeyword, node), - kind: 'method' + readonly: hasModifier(SyntaxKind.ReadonlyKeyword, node) || undefined }); + if (node.type) { + result.typeAnnotation = this.convertTypeAnnotation(node.type, node); + } + if (node.decorators) { - result.decorators = node.decorators.map(convertChild); + result.decorators = node.decorators.map(el => this.convertChild(el)); } const accessibility = getTSNodeAccessibility(node); if (accessibility) { result.accessibility = accessibility; } - } - - if ( - (result as any).key.type === AST_NODE_TYPES.Identifier && - node.questionToken - ) { - (result as any).key.optional = true; - } - if (node.kind === SyntaxKind.GetAccessor) { - (result as any).kind = 'get'; - } else if (node.kind === SyntaxKind.SetAccessor) { - (result as any).kind = 'set'; - } else if ( - !(result as any).static && - node.name.kind === SyntaxKind.StringLiteral && - node.name.text === 'constructor' && - result.type !== AST_NODE_TYPES.Property - ) { - (result as any).kind = 'constructor'; - } + if (node.name.kind === SyntaxKind.Identifier && node.questionToken) { + result.optional = true; + } - // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { - if (result.type !== AST_NODE_TYPES.Property) { - method.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); - } else { - result.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); + if (node.exclamationToken) { + result.definite = true; } - } - break; - } + if (result.key.type === AST_NODE_TYPES.Literal && node.questionToken) { + result.optional = true; + } + return result; + } + + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.MethodDeclaration: { + const method = this.createNode(node, { + type: AST_NODE_TYPES.FunctionExpression, + id: null, + generator: !!node.asteriskToken, + expression: false, // ESTreeNode as ESTreeNode here + async: hasModifier(SyntaxKind.AsyncKeyword, node), + body: this.convertChild(node.body), + range: [node.parameters.pos - 1, node.end], + params: [] + }); - // TypeScript uses this even for static methods named "constructor" - case SyntaxKind.Constructor: { - const lastModifier = getLastModifier(node); - const constructorToken = - (lastModifier && findNextToken(lastModifier, node, ast)) || - node.getFirstToken()!; - - const constructorTokenRange = [ - constructorToken.getStart(ast), - constructorToken.end - ]; - - const constructor: ESTreeNode = { - type: AST_NODE_TYPES.FunctionExpression, - id: null, - params: convertParameters(node.parameters), - generator: false, - expression: false, // is not present in ESTreeNode - async: false, - body: convertChild(node.body), - range: [node.parameters.pos - 1, result.range[1]], - loc: { - start: getLineAndCharacterFor(node.parameters.pos - 1, ast), - end: result.loc.end - } - } as any; - - // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { - constructor.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); - } + if (node.type) { + method.returnType = this.convertTypeAnnotation(node.type, node); + } - // Process returnType - if (node.type) { - constructor.returnType = convertTypeAnnotation(node.type); - } + let result: + | es.Property + | es.TSAbstractMethodDefinition + | es.MethodDefinition; - const constructorKey = { - type: AST_NODE_TYPES.Identifier, - name: 'constructor', - range: constructorTokenRange, - loc: getLocFor(constructorTokenRange[0], constructorTokenRange[1], ast) - }; + if (parent.kind === SyntaxKind.ObjectLiteralExpression) { + method.params = node.parameters.map(el => this.convertChild(el)); - const isStatic = hasModifier(SyntaxKind.StaticKeyword, node); + result = this.createNode(node, { + type: AST_NODE_TYPES.Property, + key: this.convertChild(node.name), + value: method, + computed: isComputedProperty(node.name), + method: node.kind === SyntaxKind.MethodDeclaration, + shorthand: false, + kind: 'init' + }); + } else { + // class + + /** + * Unlike in object literal methods, class method params can have decorators + */ + method.params = this.convertParameters(node.parameters); + + /** + * TypeScript class methods can be defined as "abstract" + */ + const methodDefinitionType = hasModifier( + SyntaxKind.AbstractKeyword, + node + ) + ? AST_NODE_TYPES.TSAbstractMethodDefinition + : AST_NODE_TYPES.MethodDefinition; + + result = this.createNode< + es.TSAbstractMethodDefinition | es.MethodDefinition + >(node, { + type: methodDefinitionType, + key: this.convertChild(node.name), + value: method, + computed: isComputedProperty(node.name), + static: hasModifier(SyntaxKind.StaticKeyword, node), + kind: 'method' + }); - Object.assign(result, { - type: hasModifier(SyntaxKind.AbstractKeyword, node) - ? AST_NODE_TYPES.TSAbstractMethodDefinition - : AST_NODE_TYPES.MethodDefinition, - key: constructorKey, - value: constructor, - computed: false, - static: isStatic, - kind: isStatic ? 'method' : 'constructor' - }); + if (node.decorators) { + result.decorators = node.decorators.map(el => + this.convertChild(el) + ); + } - const accessibility = getTSNodeAccessibility(node); - if (accessibility) { - result.accessibility = accessibility; - } + const accessibility = getTSNodeAccessibility(node); + if (accessibility) { + result.accessibility = accessibility; + } + } - break; - } + if ( + result.key.type === AST_NODE_TYPES.Identifier && + node.questionToken + ) { + result.key.optional = true; + } - case SyntaxKind.FunctionExpression: - Object.assign(result, { - type: AST_NODE_TYPES.FunctionExpression, - id: convertChild(node.name), - generator: !!node.asteriskToken, - params: convertParameters(node.parameters), - body: convertChild(node.body), - async: hasModifier(SyntaxKind.AsyncKeyword, node), - expression: false - }); + if (node.kind === SyntaxKind.GetAccessor) { + result.kind = 'get'; + } else if (node.kind === SyntaxKind.SetAccessor) { + result.kind = 'set'; + } else if ( + !(result as es.MethodDefinition).static && + node.name.kind === SyntaxKind.StringLiteral && + node.name.text === 'constructor' && + result.type !== AST_NODE_TYPES.Property + ) { + result.kind = 'constructor'; + } - // Process returnType - if (node.type) { - result.returnType = convertTypeAnnotation(node.type); - } + // Process typeParameters + if (node.typeParameters && node.typeParameters.length) { + if (result.type !== AST_NODE_TYPES.Property) { + method.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters + ); + } else { + result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters + ); + } + } + return result; + } + + // TypeScript uses this even for static methods named "constructor" + case SyntaxKind.Constructor: { + const lastModifier = getLastModifier(node); + const constructorToken = + (lastModifier && findNextToken(lastModifier, node, this.ast)) || + node.getFirstToken()!; + + const constructor = this.createNode(node, { + type: AST_NODE_TYPES.FunctionExpression, + id: null, + params: this.convertParameters(node.parameters), + generator: false, + expression: false, // is not present in ESTreeNode + async: false, + body: this.convertChild(node.body), + range: [node.parameters.pos - 1, node.end] + }); - // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { - result.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); - } - break; + // Process typeParameters + if (node.typeParameters && node.typeParameters.length) { + constructor.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters + ); + } - case SyntaxKind.SuperKeyword: - Object.assign(result, { - type: AST_NODE_TYPES.Super - }); - break; + // Process returnType + if (node.type) { + constructor.returnType = this.convertTypeAnnotation(node.type, node); + } - case SyntaxKind.ArrayBindingPattern: - Object.assign(result, { - type: AST_NODE_TYPES.ArrayPattern, - elements: node.elements.map(convertPattern) - }); - break; + const constructorKey = this.createNode(node, { + type: AST_NODE_TYPES.Identifier, + name: 'constructor', + range: [constructorToken.getStart(this.ast), constructorToken.end] + }); - // occurs with missing array elements like [,] - case SyntaxKind.OmittedExpression: - return null; + const isStatic = hasModifier(SyntaxKind.StaticKeyword, node); + const result = this.createNode< + es.TSAbstractMethodDefinition | es.MethodDefinition + >(node, { + type: hasModifier(SyntaxKind.AbstractKeyword, node) + ? AST_NODE_TYPES.TSAbstractMethodDefinition + : AST_NODE_TYPES.MethodDefinition, + key: constructorKey, + value: constructor, + computed: false, + static: isStatic, + kind: isStatic ? 'method' : 'constructor' + }); - case SyntaxKind.ObjectBindingPattern: - Object.assign(result, { - type: AST_NODE_TYPES.ObjectPattern, - properties: node.elements.map(convertPattern) - }); - break; + const accessibility = getTSNodeAccessibility(node); + if (accessibility) { + result.accessibility = accessibility; + } + + return result; + } - case SyntaxKind.BindingElement: - if (parent!.kind === SyntaxKind.ArrayBindingPattern) { - const arrayItem = convert({ - node: node.name, - parent, - ast, - additionalOptions + case SyntaxKind.FunctionExpression: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.FunctionExpression, + id: this.convertChild(node.name), + generator: !!node.asteriskToken, + params: this.convertParameters(node.parameters), + body: this.convertChild(node.body), + async: hasModifier(SyntaxKind.AsyncKeyword, node), + expression: false }); - if (node.initializer) { - Object.assign(result, { - type: AST_NODE_TYPES.AssignmentPattern, - left: arrayItem, - right: convertChild(node.initializer) - }); - } else if (node.dotDotDotToken) { - Object.assign(result, { - type: AST_NODE_TYPES.RestElement, - argument: arrayItem - }); - } else { - return arrayItem; + // Process returnType + if (node.type) { + result.returnType = this.convertTypeAnnotation(node.type, node); } - } else if (parent!.kind === SyntaxKind.ObjectBindingPattern) { - if (node.dotDotDotToken) { - Object.assign(result, { - type: AST_NODE_TYPES.RestElement, - argument: convertChild(node.propertyName || node.name) - }); - } else { - Object.assign(result, { - type: AST_NODE_TYPES.Property, - key: convertChild(node.propertyName || node.name), - value: convertChild(node.name), - computed: Boolean( - node.propertyName && - node.propertyName.kind === SyntaxKind.ComputedPropertyName - ), - method: false, - shorthand: !node.propertyName, - kind: 'init' - }); + + // Process typeParameters + if (node.typeParameters && node.typeParameters.length) { + result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters + ); } + return result; + } - if (node.initializer) { - (result as any).value = { - type: AST_NODE_TYPES.AssignmentPattern, - left: convertChild(node.name), - right: convertChild(node.initializer), - range: [node.name.getStart(ast), node.initializer.end], - loc: getLocFor(node.name.getStart(ast), node.initializer.end, ast) - }; - } - } - break; - - case SyntaxKind.ArrowFunction: - Object.assign(result, { - type: AST_NODE_TYPES.ArrowFunctionExpression, - generator: false, - id: null, - params: convertParameters(node.parameters), - body: convertChild(node.body), - async: hasModifier(SyntaxKind.AsyncKeyword, node), - expression: node.body.kind !== SyntaxKind.Block - }); + case SyntaxKind.SuperKeyword: + return this.createNode(node, { + type: AST_NODE_TYPES.Super + }); - // Process returnType - if (node.type) { - result.returnType = convertTypeAnnotation(node.type); - } + case SyntaxKind.ArrayBindingPattern: + return this.createNode(node, { + type: AST_NODE_TYPES.ArrayPattern, + elements: node.elements.map(el => this.convertPattern(el)) + }); - // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { - result.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); - } - break; + // occurs with missing array elements like [,] + case SyntaxKind.OmittedExpression: + return null; - case SyntaxKind.YieldExpression: - Object.assign(result, { - type: AST_NODE_TYPES.YieldExpression, - delegate: !!node.asteriskToken, - argument: convertChild(node.expression) - }); - break; + case SyntaxKind.ObjectBindingPattern: + return this.createNode(node, { + type: AST_NODE_TYPES.ObjectPattern, + properties: node.elements.map(el => this.convertPattern(el)) + }); - case SyntaxKind.AwaitExpression: - Object.assign(result, { - type: AST_NODE_TYPES.AwaitExpression, - argument: convertChild(node.expression) - }); - break; - - // Template Literals - - case SyntaxKind.NoSubstitutionTemplateLiteral: - Object.assign(result, { - type: AST_NODE_TYPES.TemplateLiteral, - quasis: [ - { - type: AST_NODE_TYPES.TemplateElement, - value: { - raw: ast.text.slice(node.getStart(ast) + 1, node.end - 1), - cooked: node.text - }, - tail: true, - range: result.range, - loc: result.loc + case SyntaxKind.BindingElement: { + if (parent.kind === SyntaxKind.ArrayBindingPattern) { + const arrayItem = this.convertChild(node.name, parent); + + if (node.initializer) { + return this.createNode(node, { + type: AST_NODE_TYPES.AssignmentPattern, + left: arrayItem, + right: this.convertChild(node.initializer) + }); + } else if (node.dotDotDotToken) { + return this.createNode(node, { + type: AST_NODE_TYPES.RestElement, + argument: arrayItem + }); + } else { + return arrayItem; + } + } else if (parent.kind === SyntaxKind.ObjectBindingPattern) { + let result: es.RestElement | es.Property; + if (node.dotDotDotToken) { + result = this.createNode(node, { + type: AST_NODE_TYPES.RestElement, + argument: this.convertChild(node.propertyName || node.name) + }); + } else { + result = this.createNode(node, { + type: AST_NODE_TYPES.Property, + key: this.convertChild(node.propertyName || node.name), + value: this.convertChild(node.name), + computed: Boolean( + node.propertyName && + node.propertyName.kind === SyntaxKind.ComputedPropertyName + ), + method: false, + shorthand: !node.propertyName, + kind: 'init' + }); } - ], - expressions: [] - }); - break; - case SyntaxKind.TemplateExpression: - Object.assign(result, { - type: AST_NODE_TYPES.TemplateLiteral, - quasis: [convertChild(node.head)], - expressions: [] - }); + if (node.initializer) { + result.value = this.createNode(node, { + type: AST_NODE_TYPES.AssignmentPattern, + left: this.convertChild(node.name), + right: this.convertChild(node.initializer), + range: [node.name.getStart(this.ast), node.initializer.end] + }); + } + return result; + } + return null; + } + + case SyntaxKind.ArrowFunction: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.ArrowFunctionExpression, + generator: false, + id: null, + params: this.convertParameters(node.parameters), + body: this.convertChild(node.body), + async: hasModifier(SyntaxKind.AsyncKeyword, node), + expression: node.body.kind !== SyntaxKind.Block + }); - node.templateSpans.forEach(templateSpan => { - (result as any).expressions.push(convertChild(templateSpan.expression)); - (result as any).quasis.push(convertChild(templateSpan.literal)); - }); - break; - - case SyntaxKind.TaggedTemplateExpression: - Object.assign(result, { - type: AST_NODE_TYPES.TaggedTemplateExpression, - typeParameters: node.typeArguments - ? convertTypeArgumentsToTypeParameters(node.typeArguments) - : undefined, - tag: convertChild(node.tag), - quasi: convertChild(node.template) - }); - break; - - case SyntaxKind.TemplateHead: - case SyntaxKind.TemplateMiddle: - case SyntaxKind.TemplateTail: { - const tail = node.kind === SyntaxKind.TemplateTail; - Object.assign(result, { - type: AST_NODE_TYPES.TemplateElement, - value: { - raw: ast.text.slice( - node.getStart(ast) + 1, - node.end - (tail ? 1 : 2) - ), - cooked: node.text - }, - tail - }); - break; - } + // Process returnType + if (node.type) { + result.returnType = this.convertTypeAnnotation(node.type, node); + } - // Patterns + // Process typeParameters + if (node.typeParameters && node.typeParameters.length) { + result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters + ); + } + return result; + } - case SyntaxKind.SpreadAssignment: - case SyntaxKind.SpreadElement: { - if (config.allowPattern) { - Object.assign(result, { - type: AST_NODE_TYPES.RestElement, - argument: convertPattern(node.expression) - }); - } else { - Object.assign(result, { - type: AST_NODE_TYPES.SpreadElement, - argument: convertChild(node.expression) + case SyntaxKind.YieldExpression: + return this.createNode(node, { + type: AST_NODE_TYPES.YieldExpression, + delegate: !!node.asteriskToken, + argument: this.convertChild(node.expression) }); - } - break; - } - case SyntaxKind.Parameter: { - let parameter: ESTreeNode; + case SyntaxKind.AwaitExpression: + return this.createNode(node, { + type: AST_NODE_TYPES.AwaitExpression, + argument: this.convertChild(node.expression) + }); - if (node.dotDotDotToken) { - Object.assign(result, { - type: AST_NODE_TYPES.RestElement, - argument: convertChild(node.name) + // Template Literals + + case SyntaxKind.NoSubstitutionTemplateLiteral: + return this.createNode(node, { + type: AST_NODE_TYPES.TemplateLiteral, + quasis: [ + this.createNode(node, { + type: AST_NODE_TYPES.TemplateElement, + value: { + raw: this.ast.text.slice( + node.getStart(this.ast) + 1, + node.end - 1 + ), + cooked: node.text + }, + tail: true + }) + ], + expressions: [] }); - parameter = result; - } else if (node.initializer) { - parameter = convertChild(node.name)!; - Object.assign(result, { - type: AST_NODE_TYPES.AssignmentPattern, - left: parameter, - right: convertChild(node.initializer) + + case SyntaxKind.TemplateExpression: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.TemplateLiteral, + quasis: [this.convertChild(node.head)], + expressions: [] }); - if (node.modifiers) { - // AssignmentPattern should not contain modifiers in range - result.range[0] = parameter.range[0]; - result.loc = getLocFor(result.range[0], result.range[1], ast); - } - } else { - parameter = result = convert({ - node: node.name, - parent, - ast, - additionalOptions - })!; - } - - if (node.type) { - parameter.typeAnnotation = convertTypeAnnotation(node.type); - fixTypeAnnotationParentLocation(parameter); - } - - if (node.questionToken) { - if (node.questionToken.end > parameter.range[1]) { - parameter.range[1] = node.questionToken.end; - parameter.loc = getLocFor( - parameter.range[0], - parameter.range[1], - ast - ); - } - parameter.optional = true; + node.templateSpans.forEach(templateSpan => { + result.expressions.push(this.convertChild(templateSpan.expression)); + result.quasis.push(this.convertChild(templateSpan.literal)); + }); + return result; } - if (node.modifiers) { - return { - type: AST_NODE_TYPES.TSParameterProperty, - range: [node.getStart(ast), node.end], - loc: getLoc(node, ast), - accessibility: getTSNodeAccessibility(node) || undefined, - readonly: hasModifier(SyntaxKind.ReadonlyKeyword, node) || undefined, - static: hasModifier(SyntaxKind.StaticKeyword, node) || undefined, - export: hasModifier(SyntaxKind.ExportKeyword, node) || undefined, - parameter: result - }; + case SyntaxKind.TaggedTemplateExpression: + return this.createNode(node, { + type: AST_NODE_TYPES.TaggedTemplateExpression, + typeParameters: node.typeArguments + ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) + : undefined, + tag: this.convertChild(node.tag), + quasi: this.convertChild(node.template) + }); + + case SyntaxKind.TemplateHead: + case SyntaxKind.TemplateMiddle: + case SyntaxKind.TemplateTail: { + const tail = node.kind === SyntaxKind.TemplateTail; + return this.createNode(node, { + type: AST_NODE_TYPES.TemplateElement, + value: { + raw: this.ast.text.slice( + node.getStart(this.ast) + 1, + node.end - (tail ? 1 : 2) + ), + cooked: node.text + }, + tail + }); } - break; - } + // Patterns - // Classes + case SyntaxKind.SpreadAssignment: + case SyntaxKind.SpreadElement: { + if (this.allowPattern) { + return this.createNode(node, { + type: AST_NODE_TYPES.RestElement, + argument: this.convertPattern(node.expression) + }); + } else { + return this.createNode(node, { + type: AST_NODE_TYPES.SpreadElement, + argument: this.convertChild(node.expression) + }); + } + } - case SyntaxKind.ClassDeclaration: - case SyntaxKind.ClassExpression: { - const heritageClauses = node.heritageClauses || []; - let classNodeType = SyntaxKind[node.kind]; + case SyntaxKind.Parameter: { + let parameter: any; + let result: es.RestElement | es.AssignmentPattern; - if (node.typeParameters && node.typeParameters.length) { - result.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); - } + if (node.dotDotDotToken) { + parameter = result = this.createNode(node, { + type: AST_NODE_TYPES.RestElement, + argument: this.convertChild(node.name) + }); + } else if (node.initializer) { + parameter = this.convertChild(node.name); + result = this.createNode(node, { + type: AST_NODE_TYPES.AssignmentPattern, + left: parameter, + right: this.convertChild(node.initializer) + }); - const superClass = heritageClauses.find( - clause => clause.token === SyntaxKind.ExtendsKeyword - ); + if (node.modifiers) { + // AssignmentPattern should not contain modifiers in range + result.range[0] = parameter.range[0]; + result.loc = getLocFor(result.range[0], result.range[1], this.ast); + } + } else { + parameter = result = this.convertChild(node.name, parent); + } - if (superClass) { - if (superClass.types.length > 1) { - throw createError( - ast, - superClass.types[1].pos, - 'Classes can only extend a single class.' + if (node.type) { + parameter.typeAnnotation = this.convertTypeAnnotation( + node.type, + node ); + this.fixTypeAnnotationParentLocation(parameter, node.type); } - if (superClass.types[0] && superClass.types[0].typeArguments) { - (result as any).superTypeParameters = convertTypeArgumentsToTypeParameters( - superClass.types[0].typeArguments - ); + if (node.questionToken) { + if (node.questionToken.end > parameter.range[1]) { + parameter.range[1] = node.questionToken.end; + parameter.loc.end = getLineAndCharacterFor( + parameter.range[1], + this.ast + ); + } + parameter.optional = true; + } + + if (node.modifiers) { + return this.createNode(node, { + type: AST_NODE_TYPES.TSParameterProperty, + accessibility: getTSNodeAccessibility(node) || undefined, + readonly: + hasModifier(SyntaxKind.ReadonlyKeyword, node) || undefined, + static: hasModifier(SyntaxKind.StaticKeyword, node) || undefined, + export: hasModifier(SyntaxKind.ExportKeyword, node) || undefined, + parameter: result + }); } + return result; } - const implementsClause = heritageClauses.find( - clause => clause.token === SyntaxKind.ImplementsKeyword - ); + // Classes - const classBodyRange = [node.members.pos - 1, node.end]; + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: { + const heritageClauses = node.heritageClauses || []; + let classNodeType = + node.kind === SyntaxKind.ClassDeclaration + ? AST_NODE_TYPES.ClassDeclaration + : AST_NODE_TYPES.ClassExpression; - Object.assign(result, { - type: classNodeType, - id: convertChild(node.name), - body: { - type: AST_NODE_TYPES.ClassBody, - body: [], - range: classBodyRange, - loc: getLocFor(classBodyRange[0], classBodyRange[1], ast) - }, - superClass: - superClass && superClass.types[0] - ? convertChild(superClass.types[0].expression) - : null - }); + const superClass = heritageClauses.find( + clause => clause.token === SyntaxKind.ExtendsKeyword + ); - if (implementsClause) { - result.implements = implementsClause.types.map(convertChild); - } + const implementsClause = heritageClauses.find( + clause => clause.token === SyntaxKind.ImplementsKeyword + ); - /** - * TypeScript class declarations can be defined as "abstract" - */ - if (hasModifier(SyntaxKind.AbstractKeyword, node)) { - result.abstract = true; - } + const result = this.createNode< + es.ClassDeclaration | es.ClassExpression + >(node, { + type: classNodeType, + id: this.convertChild(node.name), + body: this.createNode(node, { + type: AST_NODE_TYPES.ClassBody, + body: [], + range: [node.members.pos - 1, node.end] + }), + superClass: + superClass && superClass.types[0] + ? this.convertChild(superClass.types[0].expression) + : null + }); - if (hasModifier(SyntaxKind.DeclareKeyword, node)) { - result.declare = true; - } + if (superClass) { + if (superClass.types.length > 1) { + throw createError( + this.ast, + superClass.types[1].pos, + 'Classes can only extend a single class.' + ); + } - if (node.decorators) { - result.decorators = node.decorators.map(convertChild); - } + if (superClass.types[0] && superClass.types[0].typeArguments) { + result.superTypeParameters = this.convertTypeArgumentsToTypeParameters( + superClass.types[0].typeArguments + ); + } + } - const filteredMembers = node.members.filter(isESTreeClassMember); + if (node.typeParameters && node.typeParameters.length) { + result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters + ); + } - if (filteredMembers.length) { - result.body.body = filteredMembers.map(convertChild); - } + if (implementsClause) { + result.implements = implementsClause.types.map(el => + this.convertChild(el) + ); + } - // check for exports - result = fixExports(node, result, ast); + /** + * TypeScript class declarations can be defined as "abstract" + */ + if (hasModifier(SyntaxKind.AbstractKeyword, node)) { + result.abstract = true; + } - break; - } + if (hasModifier(SyntaxKind.DeclareKeyword, node)) { + result.declare = true; + } - // Modules - case SyntaxKind.ModuleBlock: - Object.assign(result, { - type: AST_NODE_TYPES.TSModuleBlock, - body: convertBodyExpressions(node.statements) - }); - break; + if (node.decorators) { + result.decorators = node.decorators.map(el => this.convertChild(el)); + } - case SyntaxKind.ImportDeclaration: - Object.assign(result, { - type: AST_NODE_TYPES.ImportDeclaration, - source: convertChild(node.moduleSpecifier), - specifiers: [] - }); + const filteredMembers = node.members.filter(isESTreeClassMember); - if (node.importClause) { - if (node.importClause.name) { - result.specifiers!.push(convertChild(node.importClause)); - } - - if (node.importClause.namedBindings) { - switch (node.importClause.namedBindings.kind) { - case SyntaxKind.NamespaceImport: - result.specifiers!.push( - convertChild(node.importClause.namedBindings) - ); - break; - case SyntaxKind.NamedImports: - result.specifiers = result.specifiers!.concat( - node.importClause.namedBindings.elements.map(convertChild) - ); - break; - } + if (filteredMembers.length) { + result.body.body = filteredMembers.map(el => this.convertChild(el)); } + + // check for exports + return fixExports(node, result, this.ast); } - break; - case SyntaxKind.NamespaceImport: - Object.assign(result, { - type: AST_NODE_TYPES.ImportNamespaceSpecifier, - local: convertChild(node.name) - }); - break; + // Modules + case SyntaxKind.ModuleBlock: + return this.createNode(node, { + type: AST_NODE_TYPES.TSModuleBlock, + body: this.convertBodyExpressions(node.statements, node) + }); - case SyntaxKind.ImportSpecifier: - Object.assign(result, { - type: AST_NODE_TYPES.ImportSpecifier, - local: convertChild(node.name), - imported: convertChild(node.propertyName || node.name) - }); - break; + case SyntaxKind.ImportDeclaration: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.ImportDeclaration, + source: this.convertChild(node.moduleSpecifier), + specifiers: [] + }); - case SyntaxKind.ImportClause: - Object.assign(result, { - type: AST_NODE_TYPES.ImportDefaultSpecifier, - local: convertChild(node.name) - }); + if (node.importClause) { + if (node.importClause.name) { + result.specifiers.push(this.convertChild(node.importClause)); + } - // have to adjust location information due to tree differences - result.range[1] = node.name!.end; - result.loc = getLocFor(result.range[0], result.range[1], ast); - break; + if (node.importClause.namedBindings) { + switch (node.importClause.namedBindings.kind) { + case SyntaxKind.NamespaceImport: + result.specifiers.push( + this.convertChild(node.importClause.namedBindings) + ); + break; + case SyntaxKind.NamedImports: + result.specifiers = result.specifiers.concat( + node.importClause.namedBindings.elements.map(el => + this.convertChild(el) + ) + ); + break; + } + } + } + return result; + } - case SyntaxKind.ExportDeclaration: - if (node.exportClause) { - Object.assign(result, { - type: AST_NODE_TYPES.ExportNamedDeclaration, - source: convertChild(node.moduleSpecifier), - specifiers: node.exportClause.elements.map(convertChild), - declaration: null - }); - } else { - Object.assign(result, { - type: AST_NODE_TYPES.ExportAllDeclaration, - source: convertChild(node.moduleSpecifier) + case SyntaxKind.NamespaceImport: + return this.createNode(node, { + type: AST_NODE_TYPES.ImportNamespaceSpecifier, + local: this.convertChild(node.name) }); - } - break; - case SyntaxKind.ExportSpecifier: - Object.assign(result, { - type: AST_NODE_TYPES.ExportSpecifier, - local: convertChild(node.propertyName || node.name), - exported: convertChild(node.name) - }); - break; + case SyntaxKind.ImportSpecifier: + return this.createNode(node, { + type: AST_NODE_TYPES.ImportSpecifier, + local: this.convertChild(node.name), + imported: this.convertChild(node.propertyName || node.name) + }); - case SyntaxKind.ExportAssignment: - if (node.isExportEquals) { - Object.assign(result, { - type: AST_NODE_TYPES.TSExportAssignment, - expression: convertChild(node.expression) + case SyntaxKind.ImportClause: + return this.createNode(node, { + type: AST_NODE_TYPES.ImportDefaultSpecifier, + local: this.convertChild(node.name), + range: [node.getStart(this.ast), node.name!.end] }); - } else { - Object.assign(result, { - type: AST_NODE_TYPES.ExportDefaultDeclaration, - declaration: convertChild(node.expression) + + case SyntaxKind.ExportDeclaration: + if (node.exportClause) { + return this.createNode(node, { + type: AST_NODE_TYPES.ExportNamedDeclaration, + source: this.convertChild(node.moduleSpecifier), + specifiers: node.exportClause.elements.map(el => + this.convertChild(el) + ), + declaration: null + }); + } else { + return this.createNode(node, { + type: AST_NODE_TYPES.ExportAllDeclaration, + source: this.convertChild(node.moduleSpecifier) + }); + } + + case SyntaxKind.ExportSpecifier: + return this.createNode(node, { + type: AST_NODE_TYPES.ExportSpecifier, + local: this.convertChild(node.propertyName || node.name), + exported: this.convertChild(node.name) }); - } - break; - // Unary Operations + case SyntaxKind.ExportAssignment: + if (node.isExportEquals) { + return this.createNode(node, { + type: AST_NODE_TYPES.TSExportAssignment, + expression: this.convertChild(node.expression) + }); + } else { + return this.createNode(node, { + type: AST_NODE_TYPES.ExportDefaultDeclaration, + declaration: this.convertChild(node.expression) + }); + } + + // Unary Operations - case SyntaxKind.PrefixUnaryExpression: - case SyntaxKind.PostfixUnaryExpression: { - const operator = getTextForTokenKind(node.operator) || ''; - Object.assign(result, { + case SyntaxKind.PrefixUnaryExpression: + case SyntaxKind.PostfixUnaryExpression: { + const operator = (getTextForTokenKind(node.operator) || '') as any; /** * ESTree uses UpdateExpression for ++/-- */ - type: /^(?:\+\+|--)$/.test(operator) - ? AST_NODE_TYPES.UpdateExpression - : AST_NODE_TYPES.UnaryExpression, - operator, - prefix: node.kind === SyntaxKind.PrefixUnaryExpression, - argument: convertChild(node.operand) - }); - break; - } + if (/^(?:\+\+|--)$/.test(operator)) { + return this.createNode(node, { + type: AST_NODE_TYPES.UpdateExpression, + operator, + prefix: node.kind === SyntaxKind.PrefixUnaryExpression, + argument: this.convertChild(node.operand) + }); + } else { + return this.createNode(node, { + type: AST_NODE_TYPES.UnaryExpression, + operator, + prefix: node.kind === SyntaxKind.PrefixUnaryExpression, + argument: this.convertChild(node.operand) + }); + } + } - case SyntaxKind.DeleteExpression: - Object.assign(result, { - type: AST_NODE_TYPES.UnaryExpression, - operator: 'delete', - prefix: true, - argument: convertChild(node.expression) - }); - break; - - case SyntaxKind.VoidExpression: - Object.assign(result, { - type: AST_NODE_TYPES.UnaryExpression, - operator: 'void', - prefix: true, - argument: convertChild(node.expression) - }); - break; - - case SyntaxKind.TypeOfExpression: - Object.assign(result, { - type: AST_NODE_TYPES.UnaryExpression, - operator: 'typeof', - prefix: true, - argument: convertChild(node.expression) - }); - break; + case SyntaxKind.DeleteExpression: + return this.createNode(node, { + type: AST_NODE_TYPES.UnaryExpression, + operator: 'delete', + prefix: true, + argument: this.convertChild(node.expression) + }); - case SyntaxKind.TypeOperator: - Object.assign(result, { - type: AST_NODE_TYPES.TSTypeOperator, - operator: getTextForTokenKind(node.operator), - typeAnnotation: convertChild(node.type) - }); - break; + case SyntaxKind.VoidExpression: + return this.createNode(node, { + type: AST_NODE_TYPES.UnaryExpression, + operator: 'void', + prefix: true, + argument: this.convertChild(node.expression) + }); - // Binary Operations + case SyntaxKind.TypeOfExpression: + return this.createNode(node, { + type: AST_NODE_TYPES.UnaryExpression, + operator: 'typeof', + prefix: true, + argument: this.convertChild(node.expression) + }); - case SyntaxKind.BinaryExpression: - // TypeScript uses BinaryExpression for sequences as well - if (isComma(node.operatorToken)) { - Object.assign(result, { - type: AST_NODE_TYPES.SequenceExpression, - expressions: [] + case SyntaxKind.TypeOperator: + return this.createNode(node, { + type: AST_NODE_TYPES.TSTypeOperator, + operator: getTextForTokenKind(node.operator) as any, + typeAnnotation: this.convertChild(node.type) }); - const left = convertChild(node.left)!, - right = convertChild(node.right)!; + // Binary Operations - if (left.type === AST_NODE_TYPES.SequenceExpression) { - (result as any).expressions = (result as any).expressions.concat( - (left as any).expressions - ); - } else { - (result as any).expressions.push(left); - } + case SyntaxKind.BinaryExpression: { + // TypeScript uses BinaryExpression for sequences as well + if (isComma(node.operatorToken)) { + const result = this.createNode(node, { + type: AST_NODE_TYPES.SequenceExpression, + expressions: [] + }); - if (right.type === AST_NODE_TYPES.SequenceExpression) { - (result as any).expressions = (result as any).expressions.concat( - (right as any).expressions - ); + const left = this.convertChild(node.left), + right = this.convertChild(node.right); + + if (left.type === AST_NODE_TYPES.SequenceExpression) { + result.expressions = result.expressions.concat(left.expressions); + } else { + result.expressions.push(left); + } + + if (right.type === AST_NODE_TYPES.SequenceExpression) { + result.expressions = result.expressions.concat(right.expressions); + } else { + result.expressions.push(right); + } + return result; } else { - (result as any).expressions.push(right); - } - } else { - const type = getBinaryExpressionType(node.operatorToken); - Object.assign(result, { - type, - operator: getTextForTokenKind(node.operatorToken.kind), - left: converter( - node.left, - config.inTypeMode, + const type = getBinaryExpressionType(node.operatorToken); + if ( + this.allowPattern && type === AST_NODE_TYPES.AssignmentExpression - ), - right: convertChild(node.right) - }); - - // if the binary expression is in a destructured array, switch it - if (result.type === AST_NODE_TYPES.AssignmentExpression) { - if (config.allowPattern) { - delete (result as any).operator; - result.type = AST_NODE_TYPES.AssignmentPattern; + ) { + return this.createNode(node, { + type: AST_NODE_TYPES.AssignmentPattern, + left: this.convertPattern(node.left, node), + right: this.convertChild(node.right) + }); } + return this.createNode< + es.AssignmentExpression | es.LogicalExpression | es.BinaryExpression + >(node, { + type: type, + operator: getTextForTokenKind(node.operatorToken.kind)!, + left: this.converter( + node.left, + node, + this.inTypeMode, + type === AST_NODE_TYPES.AssignmentExpression + ), + right: this.convertChild(node.right) + }); } } - break; - case SyntaxKind.PropertyAccessExpression: - if (isJSXToken(parent!)) { - const jsxMemberExpression = { - type: AST_NODE_TYPES.MemberExpression, - object: convertChild(node.expression), - property: convertChild(node.name) - }; - const isNestedMemberExpression = - node.expression.kind === SyntaxKind.PropertyAccessExpression; - if (node.expression.kind === SyntaxKind.ThisKeyword) { - (jsxMemberExpression as any).object.name = 'this'; - } - - (jsxMemberExpression as any).object.type = isNestedMemberExpression - ? AST_NODE_TYPES.MemberExpression - : AST_NODE_TYPES.JSXIdentifier; - (jsxMemberExpression as any).property.type = - AST_NODE_TYPES.JSXIdentifier; - Object.assign(result, jsxMemberExpression); - } else { - Object.assign(result, { + case SyntaxKind.PropertyAccessExpression: + if (isJSXToken(parent)) { + const jsxMemberExpression = this.createNode( + node, + { + type: AST_NODE_TYPES.MemberExpression, + object: this.convertChild(node.expression), + property: this.convertChild(node.name) + } + ); + // TODO: refactor this + const isNestedMemberExpression = + node.expression.kind === SyntaxKind.PropertyAccessExpression; + if (node.expression.kind === SyntaxKind.ThisKeyword) { + (jsxMemberExpression.object as any).name = 'this'; + } + + (jsxMemberExpression.object as any).type = isNestedMemberExpression + ? AST_NODE_TYPES.MemberExpression + : AST_NODE_TYPES.JSXIdentifier; + (jsxMemberExpression as any).property.type = + AST_NODE_TYPES.JSXIdentifier; + return jsxMemberExpression; + } else { + return this.createNode(node, { + type: AST_NODE_TYPES.MemberExpression, + object: this.convertChild(node.expression), + property: this.convertChild(node.name), + computed: false + }); + } + + case SyntaxKind.ElementAccessExpression: + return this.createNode(node, { type: AST_NODE_TYPES.MemberExpression, - object: convertChild(node.expression), - property: convertChild(node.name), - computed: false + object: this.convertChild(node.expression), + property: this.convertChild(node.argumentExpression), + computed: true }); - } - break; - case SyntaxKind.ElementAccessExpression: - Object.assign(result, { - type: AST_NODE_TYPES.MemberExpression, - object: convertChild(node.expression), - property: convertChild(node.argumentExpression), - computed: true - }); - break; - - case SyntaxKind.ConditionalExpression: - Object.assign(result, { - type: AST_NODE_TYPES.ConditionalExpression, - test: convertChild(node.condition), - consequent: convertChild(node.whenTrue), - alternate: convertChild(node.whenFalse) - }); - break; + case SyntaxKind.ConditionalExpression: + return this.createNode(node, { + type: AST_NODE_TYPES.ConditionalExpression, + test: this.convertChild(node.condition), + consequent: this.convertChild(node.whenTrue), + alternate: this.convertChild(node.whenFalse) + }); - case SyntaxKind.CallExpression: - Object.assign(result, { - type: AST_NODE_TYPES.CallExpression, - callee: convertChild(node.expression), - arguments: node.arguments.map(convertChild) - }); - if (node.typeArguments && node.typeArguments.length) { - result.typeParameters = convertTypeArgumentsToTypeParameters( - node.typeArguments - ); + case SyntaxKind.CallExpression: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.CallExpression, + callee: this.convertChild(node.expression), + arguments: node.arguments.map(el => this.convertChild(el)) + }); + if (node.typeArguments && node.typeArguments.length) { + result.typeParameters = this.convertTypeArgumentsToTypeParameters( + node.typeArguments + ); + } + return result; } - break; - case SyntaxKind.NewExpression: - Object.assign(result, { - type: AST_NODE_TYPES.NewExpression, - callee: convertChild(node.expression), - arguments: node.arguments ? node.arguments.map(convertChild) : [] - }); - if (node.typeArguments && node.typeArguments.length) { - result.typeParameters = convertTypeArgumentsToTypeParameters( - node.typeArguments - ); + case SyntaxKind.NewExpression: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.NewExpression, + callee: this.convertChild(node.expression), + arguments: node.arguments + ? node.arguments.map(el => this.convertChild(el)) + : [] + }); + if (node.typeArguments && node.typeArguments.length) { + result.typeParameters = this.convertTypeArgumentsToTypeParameters( + node.typeArguments + ); + } + return result; } - break; - - case SyntaxKind.MetaProperty: { - const newToken = convertToken(node.getFirstToken()!, ast); - Object.assign(result, { - type: AST_NODE_TYPES.MetaProperty, - meta: { - type: AST_NODE_TYPES.Identifier, - range: newToken.range, - loc: newToken.loc, - name: getTextForTokenKind(node.keywordToken) - }, - property: convertChild(node.name) - }); - break; - } - - case SyntaxKind.Decorator: { - Object.assign(result, { - type: AST_NODE_TYPES.Decorator, - expression: convertChild(node.expression) - }); - break; - } - // Literals + case SyntaxKind.MetaProperty: { + return this.createNode(node, { + type: AST_NODE_TYPES.MetaProperty, + meta: this.createNode(node.getFirstToken()!, { + type: AST_NODE_TYPES.Identifier, + name: getTextForTokenKind(node.keywordToken)! + }), + property: this.convertChild(node.name) + }); + } - case SyntaxKind.StringLiteral: - Object.assign(result, { - type: AST_NODE_TYPES.Literal, - raw: ast.text.slice(result.range[0], result.range[1]) - }); - if ((parent as any).name && (parent as any).name === node) { - (result as any).value = node.text; - } else { - (result as any).value = unescapeStringLiteralText(node.text); - } - break; - - case SyntaxKind.NumericLiteral: { - Object.assign(result, { - type: AST_NODE_TYPES.Literal, - value: Number(node.text), - raw: node.getText() - }); - break; - } + case SyntaxKind.Decorator: { + return this.createNode(node, { + type: AST_NODE_TYPES.Decorator, + expression: this.convertChild(node.expression) + }); + } - case SyntaxKind.BigIntLiteral: { - const raw = ast.text.slice(result.range[0], result.range[1]); - const value = raw.slice(0, -1); // remove suffix `n` - Object.assign(result, { - type: AST_NODE_TYPES.BigIntLiteral, - raw, - value - }); - break; - } + // Literals - case SyntaxKind.RegularExpressionLiteral: { - const pattern = node.text.slice(1, node.text.lastIndexOf('/')); - const flags = node.text.slice(node.text.lastIndexOf('/') + 1); + case SyntaxKind.StringLiteral: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.Literal, + raw: '', + value: '' + }); + result.raw = this.ast.text.slice(result.range[0], result.range[1]); + if ((parent as any).name && (parent as any).name === node) { + result.value = node.text; + } else { + result.value = unescapeStringLiteralText(node.text); + } + return result; + } - let regex = null; - try { - regex = new RegExp(pattern, flags); - } catch (exception) { - regex = null; + case SyntaxKind.NumericLiteral: { + return this.createNode(node, { + type: AST_NODE_TYPES.Literal, + value: Number(node.text), + raw: node.getText() + }); } - Object.assign(result, { - type: AST_NODE_TYPES.Literal, - value: regex, - raw: node.text, - regex: { - pattern, - flags - } - }); - break; - } + case SyntaxKind.BigIntLiteral: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.BigIntLiteral, + raw: '', + value: '' + }); + result.raw = this.ast.text.slice(result.range[0], result.range[1]); + result.value = result.raw.slice(0, -1); // remove suffix `n` + return result; + } - case SyntaxKind.TrueKeyword: - Object.assign(result, { - type: AST_NODE_TYPES.Literal, - value: true, - raw: 'true' - }); - break; + case SyntaxKind.RegularExpressionLiteral: { + const pattern = node.text.slice(1, node.text.lastIndexOf('/')); + const flags = node.text.slice(node.text.lastIndexOf('/') + 1); - case SyntaxKind.FalseKeyword: - Object.assign(result, { - type: AST_NODE_TYPES.Literal, - value: false, - raw: 'false' - }); - break; + let regex = null; + try { + regex = new RegExp(pattern, flags); + } catch (exception) { + regex = null; + } - case SyntaxKind.NullKeyword: { - if (config.inTypeMode) { - Object.assign(result, { - type: AST_NODE_TYPES.TSNullKeyword - }); - } else { - Object.assign(result, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, - value: null, - raw: 'null' + value: regex, + raw: node.text, + regex: { + pattern, + flags + } }); } - break; - } - case SyntaxKind.ImportKeyword: - Object.assign(result, { - type: AST_NODE_TYPES.Import - }); - break; + case SyntaxKind.TrueKeyword: + return this.createNode(node, { + type: AST_NODE_TYPES.Literal, + value: true, + raw: 'true' + }); - case SyntaxKind.EmptyStatement: - case SyntaxKind.DebuggerStatement: - Object.assign(result, { - type: SyntaxKind[node.kind] - }); - break; + case SyntaxKind.FalseKeyword: + return this.createNode(node, { + type: AST_NODE_TYPES.Literal, + value: false, + raw: 'false' + }); - // JSX + case SyntaxKind.NullKeyword: { + if (this.inTypeMode) { + return this.createNode(node, { + type: AST_NODE_TYPES.TSNullKeyword + }); + } else { + return this.createNode(node, { + type: AST_NODE_TYPES.Literal, + value: null, + raw: 'null' + }); + } + } - case SyntaxKind.JsxElement: - Object.assign(result, { - type: AST_NODE_TYPES.JSXElement, - openingElement: convertChild(node.openingElement), - closingElement: convertChild(node.closingElement), - children: node.children.map(convertChild) - }); + case SyntaxKind.ImportKeyword: + return this.createNode(node, { + type: AST_NODE_TYPES.Import + }); - break; + case SyntaxKind.EmptyStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.EmptyStatement + }); - case SyntaxKind.JsxFragment: - Object.assign(result, { - type: AST_NODE_TYPES.JSXFragment, - openingFragment: convertChild(node.openingFragment), - closingFragment: convertChild(node.closingFragment), - children: node.children.map(convertChild) - }); - break; + case SyntaxKind.DebuggerStatement: + return this.createNode(node, { + type: AST_NODE_TYPES.DebuggerStatement + }); - case SyntaxKind.JsxSelfClosingElement: { - Object.assign(result, { - type: AST_NODE_TYPES.JSXElement, - /** - * Convert SyntaxKind.JsxSelfClosingElement to SyntaxKind.JsxOpeningElement, - * TypeScript does not seem to have the idea of openingElement when tag is self-closing - */ - openingElement: { + // JSX + + case SyntaxKind.JsxElement: + return this.createNode(node, { + type: AST_NODE_TYPES.JSXElement, + openingElement: this.convertChild(node.openingElement), + closingElement: this.convertChild(node.closingElement), + children: node.children.map(el => this.convertChild(el)) + }); + + case SyntaxKind.JsxFragment: + return this.createNode(node, { + type: AST_NODE_TYPES.JSXFragment, + openingFragment: this.convertChild(node.openingFragment), + closingFragment: this.convertChild(node.closingFragment), + children: node.children.map(el => this.convertChild(el)) + }); + + case SyntaxKind.JsxSelfClosingElement: { + return this.createNode(node, { + type: AST_NODE_TYPES.JSXElement, + /** + * Convert SyntaxKind.JsxSelfClosingElement to SyntaxKind.JsxOpeningElement, + * TypeScript does not seem to have the idea of openingElement when tag is self-closing + */ + openingElement: this.createNode(node, { + type: AST_NODE_TYPES.JSXOpeningElement, + typeParameters: node.typeArguments + ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) + : undefined, + selfClosing: true, + name: this.convertTypeScriptJSXTagNameToESTreeName( + node.tagName, + node + ), + attributes: node.attributes.properties.map(el => + this.convertChild(el) + ), + range: getRange(node, this.ast) + }), + closingElement: null, + children: [] + }); + } + + case SyntaxKind.JsxOpeningElement: + return this.createNode(node, { type: AST_NODE_TYPES.JSXOpeningElement, typeParameters: node.typeArguments - ? convertTypeArgumentsToTypeParameters(node.typeArguments) + ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) : undefined, - selfClosing: true, - name: convertTypeScriptJSXTagNameToESTreeName(node.tagName), - attributes: node.attributes.properties.map(convertChild), - range: result.range, - loc: result.loc - }, - closingElement: null, - children: [] - }); - break; - } - - case SyntaxKind.JsxOpeningElement: - Object.assign(result, { - type: AST_NODE_TYPES.JSXOpeningElement, - typeParameters: node.typeArguments - ? convertTypeArgumentsToTypeParameters(node.typeArguments) - : undefined, - selfClosing: false, - name: convertTypeScriptJSXTagNameToESTreeName(node.tagName), - attributes: node.attributes.properties.map(convertChild) - }); - break; + selfClosing: false, + name: this.convertTypeScriptJSXTagNameToESTreeName( + node.tagName, + node + ), + attributes: node.attributes.properties.map(el => + this.convertChild(el) + ) + }); - case SyntaxKind.JsxClosingElement: - Object.assign(result, { - type: AST_NODE_TYPES.JSXClosingElement, - name: convertTypeScriptJSXTagNameToESTreeName(node.tagName) - }); - break; + case SyntaxKind.JsxClosingElement: + return this.createNode(node, { + type: AST_NODE_TYPES.JSXClosingElement, + name: this.convertTypeScriptJSXTagNameToESTreeName(node.tagName, node) + }); - case SyntaxKind.JsxOpeningFragment: - Object.assign(result, { - type: AST_NODE_TYPES.JSXOpeningFragment - }); - break; - case SyntaxKind.JsxClosingFragment: - Object.assign(result, { - type: AST_NODE_TYPES.JSXClosingFragment - }); - break; - - case SyntaxKind.JsxExpression: { - const expression = node.expression - ? convertChild(node.expression) - : { - type: AST_NODE_TYPES.JSXEmptyExpression, - loc: { - start: getLineAndCharacterFor(result.range[0] + 1, ast), - end: { - line: result.loc.end.line, - column: result.loc.end.column - 1 - } - }, - range: [result.range[0] + 1, result.range[1] - 1] - }; - - Object.assign(result, { - type: node.dotDotDotToken - ? AST_NODE_TYPES.JSXSpreadChild - : AST_NODE_TYPES.JSXExpressionContainer, - expression - }); + case SyntaxKind.JsxOpeningFragment: + return this.createNode(node, { + type: AST_NODE_TYPES.JSXOpeningFragment + }); - break; - } + case SyntaxKind.JsxClosingFragment: + return this.createNode(node, { + type: AST_NODE_TYPES.JSXClosingFragment + }); - case SyntaxKind.JsxAttribute: { - const attributeName = convertToken(node.name, ast); - attributeName.type = AST_NODE_TYPES.JSXIdentifier; - attributeName.name = attributeName.value; - delete attributeName.value; + case SyntaxKind.JsxExpression: { + const expression = node.expression + ? this.convertChild(node.expression) + : this.createNode(node, { + type: AST_NODE_TYPES.JSXEmptyExpression, + range: [node.getStart(this.ast) + 1, node.getEnd() - 1] + }); - Object.assign(result, { - type: AST_NODE_TYPES.JSXAttribute, - name: attributeName, - value: convertChild(node.initializer) - }); + if (node.dotDotDotToken) { + return this.createNode(node, { + type: AST_NODE_TYPES.JSXSpreadChild, + expression + }); + } else { + return this.createNode(node, { + type: AST_NODE_TYPES.JSXExpressionContainer, + expression + }); + } + } - break; - } + case SyntaxKind.JsxAttribute: { + const attributeName = this.convertChild(node.name); + attributeName.type = AST_NODE_TYPES.JSXIdentifier; - /** - * The JSX AST changed the node type for string literals - * inside a JSX Element from `Literal` to `JSXText`. We - * provide a flag to support both types until `Literal` - * node type is deprecated in ESLint v5. - */ - case SyntaxKind.JsxText: { - const start = node.getFullStart(); - const end = node.getEnd(); - - const type = additionalOptions.useJSXTextNode - ? AST_NODE_TYPES.JSXText - : AST_NODE_TYPES.Literal; - - Object.assign(result, { - type, - value: ast.text.slice(start, end), - raw: ast.text.slice(start, end) - }); + return this.createNode(node, { + type: AST_NODE_TYPES.JSXAttribute, + name: attributeName, + value: this.convertChild(node.initializer) + }); + } - result.loc = getLocFor(start, end, ast); - result.range = [start, end]; + /** + * The JSX AST changed the node type for string literals + * inside a JSX Element from `Literal` to `JSXText`. We + * provide a flag to support both types until `Literal` + * node type is deprecated in ESLint v5. + */ + case SyntaxKind.JsxText: { + const start = node.getFullStart(); + const end = node.getEnd(); + + if (this.options.useJSXTextNode) { + return this.createNode(node, { + type: AST_NODE_TYPES.JSXText, + value: this.ast.text.slice(start, end), + raw: this.ast.text.slice(start, end), + range: [start, end] + }); + } else { + return this.createNode(node, { + type: AST_NODE_TYPES.Literal, + value: this.ast.text.slice(start, end), + raw: this.ast.text.slice(start, end), + range: [start, end] + }); + } + } - break; - } + case SyntaxKind.JsxSpreadAttribute: + return this.createNode(node, { + type: AST_NODE_TYPES.JSXSpreadAttribute, + argument: this.convertChild(node.expression) + }); - case SyntaxKind.JsxSpreadAttribute: - Object.assign(result, { - type: AST_NODE_TYPES.JSXSpreadAttribute, - argument: convertChild(node.expression) - }); - break; + case SyntaxKind.QualifiedName: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSQualifiedName, + left: this.convertChild(node.left), + right: this.convertChild(node.right) + }); + } - case SyntaxKind.QualifiedName: { - Object.assign(result, { - type: AST_NODE_TYPES.TSQualifiedName, - left: convertChild(node.left), - right: convertChild(node.right) - }); - break; - } + // TypeScript specific - // TypeScript specific + case SyntaxKind.TypeReference: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSTypeReference, + typeName: this.convertType(node.typeName), + typeParameters: node.typeArguments + ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) + : undefined + }); + } - case SyntaxKind.TypeReference: { - Object.assign(result, { - type: AST_NODE_TYPES.TSTypeReference, - typeName: convertChildType(node.typeName), - typeParameters: node.typeArguments - ? convertTypeArgumentsToTypeParameters(node.typeArguments) - : undefined - }); - break; - } + case SyntaxKind.TypeParameter: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSTypeParameter, + name: this.convertType(node.name), + constraint: node.constraint + ? this.convertType(node.constraint) + : undefined, + default: node.default ? this.convertType(node.default) : undefined + }); + } - case SyntaxKind.TypeParameter: { - Object.assign(result, { - type: AST_NODE_TYPES.TSTypeParameter, - name: convertChildType(node.name), - constraint: node.constraint - ? convertChildType(node.constraint) - : undefined, - default: node.default ? convertChildType(node.default) : undefined - }); - break; - } + case SyntaxKind.ThisType: + case SyntaxKind.AnyKeyword: + case SyntaxKind.BigIntKeyword: + case SyntaxKind.BooleanKeyword: + case SyntaxKind.NeverKeyword: + case SyntaxKind.NumberKeyword: + case SyntaxKind.ObjectKeyword: + case SyntaxKind.StringKeyword: + case SyntaxKind.SymbolKeyword: + case SyntaxKind.UnknownKeyword: + case SyntaxKind.VoidKeyword: + case SyntaxKind.UndefinedKeyword: { + return this.createNode(node, { + type: AST_NODE_TYPES[`TS${SyntaxKind[node.kind]}` as AST_NODE_TYPES] + }); + } - case SyntaxKind.ThisType: - case SyntaxKind.AnyKeyword: - case SyntaxKind.BigIntKeyword: - case SyntaxKind.BooleanKeyword: - case SyntaxKind.NeverKeyword: - case SyntaxKind.NumberKeyword: - case SyntaxKind.ObjectKeyword: - case SyntaxKind.StringKeyword: - case SyntaxKind.SymbolKeyword: - case SyntaxKind.UnknownKeyword: - case SyntaxKind.VoidKeyword: - case SyntaxKind.UndefinedKeyword: { - Object.assign(result, { - type: AST_NODE_TYPES[`TS${SyntaxKind[node.kind]}` as AST_NODE_TYPES] - }); - break; - } + case SyntaxKind.NonNullExpression: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSNonNullExpression, + expression: this.convertChild(node.expression) + }); + } - case SyntaxKind.NonNullExpression: { - Object.assign(result, { - type: AST_NODE_TYPES.TSNonNullExpression, - expression: convertChild(node.expression) - }); - break; - } + case SyntaxKind.TypeLiteral: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSTypeLiteral, + members: node.members.map(el => this.convertChild(el)) + }); + } - case SyntaxKind.TypeLiteral: { - Object.assign(result, { - type: AST_NODE_TYPES.TSTypeLiteral, - members: node.members.map(convertChild) - }); - break; - } + case SyntaxKind.ArrayType: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSArrayType, + elementType: this.convertType(node.elementType) + }); + } - case SyntaxKind.ArrayType: { - Object.assign(result, { - type: AST_NODE_TYPES.TSArrayType, - elementType: convertChildType(node.elementType) - }); - break; - } + case SyntaxKind.IndexedAccessType: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSIndexedAccessType, + objectType: this.convertType(node.objectType), + indexType: this.convertType(node.indexType) + }); + } - case SyntaxKind.IndexedAccessType: { - Object.assign(result, { - type: AST_NODE_TYPES.TSIndexedAccessType, - objectType: convertChildType(node.objectType), - indexType: convertChildType(node.indexType) - }); - break; - } + case SyntaxKind.ConditionalType: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSConditionalType, + checkType: this.convertType(node.checkType), + extendsType: this.convertType(node.extendsType), + trueType: this.convertType(node.trueType), + falseType: this.convertType(node.falseType) + }); + } - case SyntaxKind.ConditionalType: { - Object.assign(result, { - type: AST_NODE_TYPES.TSConditionalType, - checkType: convertChildType(node.checkType), - extendsType: convertChildType(node.extendsType), - trueType: convertChildType(node.trueType), - falseType: convertChildType(node.falseType) - }); - break; - } + case SyntaxKind.TypeQuery: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSTypeQuery, + exprName: this.convertType(node.exprName) + }); + } - case SyntaxKind.TypeQuery: { - Object.assign(result, { - type: AST_NODE_TYPES.TSTypeQuery, - exprName: convertChildType(node.exprName) - }); - break; - } + case SyntaxKind.MappedType: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.TSMappedType, + typeParameter: this.convertType(node.typeParameter) + }); - case SyntaxKind.MappedType: { - Object.assign(result, { - type: AST_NODE_TYPES.TSMappedType, - typeParameter: convertChildType(node.typeParameter) - }); + if (node.readonlyToken) { + if (node.readonlyToken.kind === SyntaxKind.ReadonlyKeyword) { + result.readonly = true; + } else { + result.readonly = getTextForTokenKind(node.readonlyToken.kind) as + | '+' + | '-'; + } + } - if (node.readonlyToken) { - if (node.readonlyToken.kind === SyntaxKind.ReadonlyKeyword) { - result.readonly = true; - } else { - result.readonly = getTextForTokenKind(node.readonlyToken.kind); + if (node.questionToken) { + if (node.questionToken.kind === SyntaxKind.QuestionToken) { + result.optional = true; + } else { + result.optional = getTextForTokenKind(node.questionToken.kind) as + | '+' + | '-'; + } } - } - if (node.questionToken) { - if (node.questionToken.kind === SyntaxKind.QuestionToken) { - result.optional = true; - } else { - result.optional = getTextForTokenKind(node.questionToken.kind); + if (node.type) { + result.typeAnnotation = this.convertType(node.type); } + return result; } - if (node.type) { - result.typeAnnotation = convertChildType(node.type); - } - break; - } + case SyntaxKind.ParenthesizedExpression: + return this.convertChild(node.expression, parent); - case SyntaxKind.ParenthesizedExpression: - return convert({ - node: node.expression, - parent, - ast, - additionalOptions - }); + case SyntaxKind.TypeAliasDeclaration: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.TSTypeAliasDeclaration, + id: this.convertChild(node.name), + typeAnnotation: this.convertType(node.type) + }); - case SyntaxKind.TypeAliasDeclaration: { - Object.assign(result, { - type: AST_NODE_TYPES.TSTypeAliasDeclaration, - id: convertChild(node.name), - typeAnnotation: convertChildType(node.type) - }); + if (hasModifier(SyntaxKind.DeclareKeyword, node)) { + result.declare = true; + } - if (hasModifier(SyntaxKind.DeclareKeyword, node)) { - result.declare = true; - } + // Process typeParameters + if (node.typeParameters && node.typeParameters.length) { + result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters + ); + } - // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { - result.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); + // check for exports + return fixExports(node, result, this.ast); } - // check for exports - result = fixExports(node, result, ast); - break; - } + case SyntaxKind.MethodSignature: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.TSMethodSignature, + computed: isComputedProperty(node.name), + key: this.convertChild(node.name), + params: this.convertParameters(node.parameters) + }); - case SyntaxKind.MethodSignature: { - Object.assign(result, { - type: AST_NODE_TYPES.TSMethodSignature, - computed: isComputedProperty(node.name), - key: convertChild(node.name), - params: convertParameters(node.parameters) - }); + if (isOptional(node)) { + result.optional = true; + } - if (isOptional(node)) { - result.optional = true; - } + if (node.type) { + result.returnType = this.convertTypeAnnotation(node.type, node); + } - if (node.type) { - result.returnType = convertTypeAnnotation(node.type); - } + if (hasModifier(SyntaxKind.ReadonlyKeyword, node)) { + result.readonly = true; + } - if (hasModifier(SyntaxKind.ReadonlyKeyword, node)) { - result.readonly = true; - } + if (node.typeParameters) { + result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters + ); + } - if (node.typeParameters) { - result.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); - } + const accessibility = getTSNodeAccessibility(node); + if (accessibility) { + result.accessibility = accessibility; + } - const accessibility = getTSNodeAccessibility(node); - if (accessibility) { - result.accessibility = accessibility; - } + if (hasModifier(SyntaxKind.ExportKeyword, node)) { + result.export = true; + } - if (hasModifier(SyntaxKind.ExportKeyword, node)) { - result.export = true; + if (hasModifier(SyntaxKind.StaticKeyword, node)) { + result.static = true; + } + return result; } - if (hasModifier(SyntaxKind.StaticKeyword, node)) { - result.static = true; - } - break; - } + case SyntaxKind.PropertySignature: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.TSPropertySignature, + optional: isOptional(node) || undefined, + computed: isComputedProperty(node.name), + key: this.convertChild(node.name), + typeAnnotation: node.type + ? this.convertTypeAnnotation(node.type, node) + : undefined, + initializer: this.convertChild(node.initializer) || undefined, + readonly: hasModifier(SyntaxKind.ReadonlyKeyword, node) || undefined, + static: hasModifier(SyntaxKind.StaticKeyword, node) || undefined, + export: hasModifier(SyntaxKind.ExportKeyword, node) || undefined + }); - case SyntaxKind.PropertySignature: { - Object.assign(result, { - type: AST_NODE_TYPES.TSPropertySignature, - optional: isOptional(node) || undefined, - computed: isComputedProperty(node.name), - key: convertChild(node.name), - typeAnnotation: node.type - ? convertTypeAnnotation(node.type) - : undefined, - initializer: convertChild(node.initializer) || undefined, - readonly: hasModifier(SyntaxKind.ReadonlyKeyword, node) || undefined, - static: hasModifier(SyntaxKind.StaticKeyword, node) || undefined, - export: hasModifier(SyntaxKind.ExportKeyword, node) || undefined - }); + const accessibility = getTSNodeAccessibility(node); + if (accessibility) { + result.accessibility = accessibility; + } - const accessibility = getTSNodeAccessibility(node); - if (accessibility) { - result.accessibility = accessibility; + return result; } - break; - } + case SyntaxKind.IndexSignature: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.TSIndexSignature, + parameters: node.parameters.map(el => this.convertChild(el)) + }); - case SyntaxKind.IndexSignature: { - Object.assign(result, { - type: AST_NODE_TYPES.TSIndexSignature, - parameters: node.parameters.map(convertChild) - }); + if (node.type) { + result.typeAnnotation = this.convertTypeAnnotation(node.type, node); + } - if (node.type) { - result.typeAnnotation = convertTypeAnnotation(node.type); - } + if (hasModifier(SyntaxKind.ReadonlyKeyword, node)) { + result.readonly = true; + } - if (hasModifier(SyntaxKind.ReadonlyKeyword, node)) { - result.readonly = true; - } + const accessibility = getTSNodeAccessibility(node); + if (accessibility) { + result.accessibility = accessibility; + } - const accessibility = getTSNodeAccessibility(node); - if (accessibility) { - result.accessibility = accessibility; - } + if (hasModifier(SyntaxKind.ExportKeyword, node)) { + result.export = true; + } - if (hasModifier(SyntaxKind.ExportKeyword, node)) { - result.export = true; - } + if (hasModifier(SyntaxKind.StaticKeyword, node)) { + result.static = true; + } + return result; + } + case SyntaxKind.ConstructorType: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructSignature: + case SyntaxKind.CallSignature: { + let type: AST_NODE_TYPES; + switch (node.kind) { + case SyntaxKind.ConstructSignature: + type = AST_NODE_TYPES.TSConstructSignatureDeclaration; + break; + case SyntaxKind.CallSignature: + type = AST_NODE_TYPES.TSCallSignatureDeclaration; + break; + case SyntaxKind.FunctionType: + type = AST_NODE_TYPES.TSFunctionType; + break; + case SyntaxKind.ConstructorType: + default: + type = AST_NODE_TYPES.TSConstructorType; + break; + } + const result = this.createNode< + | es.TSConstructSignatureDeclaration + | es.TSCallSignatureDeclaration + | es.TSFunctionType + | es.TSConstructorType + >(node, { + type: type, + params: this.convertParameters(node.parameters) + }); - if (hasModifier(SyntaxKind.StaticKeyword, node)) { - result.static = true; - } - break; - } - case SyntaxKind.ConstructorType: - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructSignature: - case SyntaxKind.CallSignature: { - let type: AST_NODE_TYPES; - switch (node.kind) { - case SyntaxKind.ConstructSignature: - type = AST_NODE_TYPES.TSConstructSignatureDeclaration; - break; - case SyntaxKind.CallSignature: - type = AST_NODE_TYPES.TSCallSignatureDeclaration; - break; - case SyntaxKind.FunctionType: - type = AST_NODE_TYPES.TSFunctionType; - break; - case SyntaxKind.ConstructorType: - default: - type = AST_NODE_TYPES.TSConstructorType; - break; - } - Object.assign(result, { - type: type, - params: convertParameters(node.parameters) - }); + if (node.type) { + result.returnType = this.convertTypeAnnotation(node.type, node); + } - if (node.type) { - result.returnType = convertTypeAnnotation(node.type); - } + if (node.typeParameters) { + result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters + ); + } - if (node.typeParameters) { - result.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); + return result; } - break; - } + case SyntaxKind.ExpressionWithTypeArguments: { + const result = this.createNode< + es.TSInterfaceHeritage | es.TSClassImplements + >(node, { + type: + parent && parent.kind === SyntaxKind.InterfaceDeclaration + ? AST_NODE_TYPES.TSInterfaceHeritage + : AST_NODE_TYPES.TSClassImplements, + expression: this.convertChild(node.expression) + }); - case SyntaxKind.ExpressionWithTypeArguments: { - Object.assign(result, { - type: - parent && parent.kind === SyntaxKind.InterfaceDeclaration - ? AST_NODE_TYPES.TSInterfaceHeritage - : AST_NODE_TYPES.TSClassImplements, - expression: convertChild(node.expression) - }); + if (node.typeArguments && node.typeArguments.length) { + result.typeParameters = this.convertTypeArgumentsToTypeParameters( + node.typeArguments + ); + } + return result; + } + + case SyntaxKind.InterfaceDeclaration: { + const interfaceHeritageClauses = node.heritageClauses || []; + const result = this.createNode(node, { + type: AST_NODE_TYPES.TSInterfaceDeclaration, + body: this.createNode(node, { + type: AST_NODE_TYPES.TSInterfaceBody, + body: node.members.map(member => this.convertChild(member)), + range: [node.members.pos - 1, node.end] + }), + id: this.convertChild(node.name) + }); - if (node.typeArguments && node.typeArguments.length) { - result.typeParameters = convertTypeArgumentsToTypeParameters( - node.typeArguments - ); - } - break; - } + if (node.typeParameters && node.typeParameters.length) { + result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters + ); + } - case SyntaxKind.InterfaceDeclaration: { - const interfaceHeritageClauses = node.heritageClauses || []; + if (interfaceHeritageClauses.length > 0) { + const interfaceExtends = []; + const interfaceImplements = []; - if (node.typeParameters && node.typeParameters.length) { - result.typeParameters = convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); - } + for (const heritageClause of interfaceHeritageClauses) { + if (heritageClause.token === SyntaxKind.ExtendsKeyword) { + for (const n of heritageClause.types) { + interfaceExtends.push(this.convertChild(n, node)); + } + } else if (heritageClause.token === SyntaxKind.ImplementsKeyword) { + for (const n of heritageClause.types) { + interfaceImplements.push(this.convertChild(n, node)); + } + } + } - const interfaceBodyRange = [node.members.pos - 1, node.end]; + if (interfaceExtends.length) { + result.extends = interfaceExtends; + } - Object.assign(result, { - type: AST_NODE_TYPES.TSInterfaceDeclaration, - body: { - type: AST_NODE_TYPES.TSInterfaceBody, - body: node.members.map(member => convertChild(member)), - range: interfaceBodyRange, - loc: getLocFor(interfaceBodyRange[0], interfaceBodyRange[1], ast) - }, - id: convertChild(node.name) - }); + if (interfaceImplements.length) { + result.implements = interfaceImplements; + } + } + + /** + * Semantically, decorators are not allowed on interface declarations, + * but the TypeScript compiler will parse them and produce a valid AST, + * so we handle them here too. + */ + if (node.decorators) { + result.decorators = node.decorators.map(el => this.convertChild(el)); + } + if (hasModifier(SyntaxKind.AbstractKeyword, node)) { + result.abstract = true; + } + if (hasModifier(SyntaxKind.DeclareKeyword, node)) { + result.declare = true; + } + // check for exports + return fixExports(node, result, this.ast); + } - if (interfaceHeritageClauses.length > 0) { - const interfaceExtends = []; - const interfaceImplements = []; + case SyntaxKind.FirstTypeNode: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.TSTypePredicate, + parameterName: this.convertChild(node.parameterName), + typeAnnotation: this.convertTypeAnnotation(node.type, node) + }); + /** + * Specific fix for type-guard location data + */ + result.typeAnnotation.loc = result.typeAnnotation.typeAnnotation.loc; + result.typeAnnotation.range = + result.typeAnnotation.typeAnnotation.range; + return result; + } + + case SyntaxKind.ImportType: + return this.createNode(node, { + type: AST_NODE_TYPES.TSImportType, + isTypeOf: !!node.isTypeOf, + parameter: this.convertChild(node.argument), + qualifier: this.convertChild(node.qualifier), + typeParameters: node.typeArguments + ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) + : null + }); - for (const heritageClause of interfaceHeritageClauses) { - if (heritageClause.token === SyntaxKind.ExtendsKeyword) { - for (const n of heritageClause.types) { - interfaceExtends.push(convertChild(n)); - } - } else if (heritageClause.token === SyntaxKind.ImplementsKeyword) { - for (const n of heritageClause.types) { - interfaceImplements.push(convertChild(n)); - } - } + case SyntaxKind.EnumDeclaration: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.TSEnumDeclaration, + id: this.convertChild(node.name), + members: node.members.map(el => this.convertChild(el)) + }); + // apply modifiers first... + this.applyModifiersToResult(result, node.modifiers); + /** + * Semantically, decorators are not allowed on enum declarations, + * but the TypeScript compiler will parse them and produce a valid AST, + * so we handle them here too. + */ + if (node.decorators) { + result.decorators = node.decorators.map(el => this.convertChild(el)); } + // ...then check for exports + return fixExports(node, result, this.ast); + } - if (interfaceExtends.length) { - result.extends = interfaceExtends; + case SyntaxKind.EnumMember: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.TSEnumMember, + id: this.convertChild(node.name) + }); + if (node.initializer) { + result.initializer = this.convertChild(node.initializer); } + return result; + } - if (interfaceImplements.length) { - result.implements = interfaceImplements; + case SyntaxKind.ModuleDeclaration: { + const result = this.createNode(node, { + type: AST_NODE_TYPES.TSModuleDeclaration, + id: this.convertChild(node.name) + }); + if (node.body) { + result.body = this.convertChild(node.body); } + // apply modifiers first... + this.applyModifiersToResult(result, node.modifiers); + if (node.flags & ts.NodeFlags.GlobalAugmentation) { + result.global = true; + } + // ...then check for exports + return fixExports(node, result, this.ast); } - /** - * Semantically, decorators are not allowed on interface declarations, - * but the TypeScript compiler will parse them and produce a valid AST, - * so we handle them here too. - */ - if (node.decorators) { - result.decorators = node.decorators.map(convertChild); + // TypeScript specific types + case SyntaxKind.OptionalType: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSOptionalType, + typeAnnotation: this.convertType(node.type) + }); } - if (hasModifier(SyntaxKind.AbstractKeyword, node)) { - result.abstract = true; + case SyntaxKind.ParenthesizedType: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSParenthesizedType, + typeAnnotation: this.convertType(node.type) + }); } - if (hasModifier(SyntaxKind.DeclareKeyword, node)) { - result.declare = true; + case SyntaxKind.TupleType: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSTupleType, + elementTypes: node.elementTypes.map(el => this.convertType(el)) + }); } - // check for exports - result = fixExports(node, result, ast); - - break; - } - - case SyntaxKind.FirstTypeNode: - Object.assign(result, { - type: AST_NODE_TYPES.TSTypePredicate, - parameterName: convertChild(node.parameterName), - typeAnnotation: convertTypeAnnotation(node.type) - }); - /** - * Specific fix for type-guard location data - */ - result.typeAnnotation!.loc = result.typeAnnotation!.typeAnnotation!.loc; - result.typeAnnotation!.range = result.typeAnnotation!.typeAnnotation!.range; - break; - - case SyntaxKind.ImportType: - Object.assign(result, { - type: AST_NODE_TYPES.TSImportType, - isTypeOf: !!node.isTypeOf, - parameter: convertChild(node.argument), - qualifier: convertChild(node.qualifier), - typeParameters: node.typeArguments - ? convertTypeArgumentsToTypeParameters(node.typeArguments) - : null - }); - break; - - case SyntaxKind.EnumDeclaration: { - Object.assign(result, { - type: AST_NODE_TYPES.TSEnumDeclaration, - id: convertChild(node.name), - members: node.members.map(convertChild) - }); - // apply modifiers first... - applyModifiersToResult(node.modifiers); - // ...then check for exports - result = fixExports(node, result, ast); - /** - * Semantically, decorators are not allowed on enum declarations, - * but the TypeScript compiler will parse them and produce a valid AST, - * so we handle them here too. - */ - if (node.decorators) { - result.decorators = node.decorators.map(convertChild); + case SyntaxKind.UnionType: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSUnionType, + types: node.types.map(el => this.convertType(el)) + }); } - break; - } - - case SyntaxKind.EnumMember: { - Object.assign(result, { - type: AST_NODE_TYPES.TSEnumMember, - id: convertChild(node.name) - }); - if (node.initializer) { - (result as any).initializer = convertChild(node.initializer); + case SyntaxKind.IntersectionType: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSIntersectionType, + types: node.types.map(el => this.convertType(el)) + }); } - break; - } - - case SyntaxKind.AbstractKeyword: { - Object.assign(result, { - type: AST_NODE_TYPES.TSAbstractKeyword - }); - break; - } - - case SyntaxKind.ModuleDeclaration: { - Object.assign(result, { - type: AST_NODE_TYPES.TSModuleDeclaration, - id: convertChild(node.name) - }); - if (node.body) { - result.body = convertChild(node.body); + case SyntaxKind.RestType: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSRestType, + typeAnnotation: this.convertType(node.type) + }); } - // apply modifiers first... - applyModifiersToResult(node.modifiers); - if (node.flags & ts.NodeFlags.GlobalAugmentation) { - result.global = true; + case SyntaxKind.AsExpression: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSAsExpression, + expression: this.convertChild(node.expression), + typeAnnotation: this.convertType(node.type) + }); } - // ...then check for exports - result = fixExports(node, result, ast); - break; - } - - // TypeScript specific types - case SyntaxKind.OptionalType: { - Object.assign(result, { - type: AST_NODE_TYPES.TSOptionalType, - typeAnnotation: convertChildType(node.type) - }); - break; - } - case SyntaxKind.ParenthesizedType: { - Object.assign(result, { - type: AST_NODE_TYPES.TSParenthesizedType, - typeAnnotation: convertChildType(node.type) - }); - break; - } - case SyntaxKind.TupleType: { - Object.assign(result, { - type: AST_NODE_TYPES.TSTupleType, - elementTypes: node.elementTypes.map(convertChildType) - }); - break; - } - case SyntaxKind.UnionType: { - Object.assign(result, { - type: AST_NODE_TYPES.TSUnionType, - types: node.types.map(convertChildType) - }); - break; - } - case SyntaxKind.IntersectionType: { - Object.assign(result, { - type: AST_NODE_TYPES.TSIntersectionType, - types: node.types.map(convertChildType) - }); - break; - } - case SyntaxKind.RestType: { - Object.assign(result, { - type: AST_NODE_TYPES.TSRestType, - typeAnnotation: convertChildType(node.type) - }); - break; - } - case SyntaxKind.AsExpression: { - Object.assign(result, { - type: AST_NODE_TYPES.TSAsExpression, - expression: convertChild(node.expression), - typeAnnotation: convertChildType(node.type) - }); - break; - } - case SyntaxKind.InferType: { - Object.assign(result, { - type: AST_NODE_TYPES.TSInferType, - typeParameter: convertChildType(node.typeParameter) - }); - break; - } - case SyntaxKind.LiteralType: { - Object.assign(result, { - type: AST_NODE_TYPES.TSLiteralType, - literal: convertChildType(node.literal) - }); - break; - } - case SyntaxKind.TypeAssertionExpression: { - Object.assign(result, { - type: AST_NODE_TYPES.TSTypeAssertion, - typeAnnotation: convertChildType(node.type), - expression: convertChild(node.expression) - }); - break; - } - case SyntaxKind.ImportEqualsDeclaration: { - Object.assign(result, { - type: AST_NODE_TYPES.TSImportEqualsDeclaration, - id: convertChild(node.name), - moduleReference: convertChild(node.moduleReference), - isExport: hasModifier(SyntaxKind.ExportKeyword, node) - }); - break; - } - case SyntaxKind.ExternalModuleReference: { - Object.assign(result, { - type: AST_NODE_TYPES.TSExternalModuleReference, - expression: convertChild(node.expression) - }); - break; - } - case SyntaxKind.NamespaceExportDeclaration: { - Object.assign(result, { - type: AST_NODE_TYPES.TSNamespaceExportDeclaration, - id: convertChild(node.name) - }); - break; + case SyntaxKind.InferType: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSInferType, + typeParameter: this.convertType(node.typeParameter) + }); + } + case SyntaxKind.LiteralType: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSLiteralType, + literal: this.convertType(node.literal) + }); + } + case SyntaxKind.TypeAssertionExpression: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSTypeAssertion, + typeAnnotation: this.convertType(node.type), + expression: this.convertChild(node.expression) + }); + } + case SyntaxKind.ImportEqualsDeclaration: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSImportEqualsDeclaration, + id: this.convertChild(node.name), + moduleReference: this.convertChild(node.moduleReference), + isExport: hasModifier(SyntaxKind.ExportKeyword, node) + }); + } + case SyntaxKind.ExternalModuleReference: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSExternalModuleReference, + expression: this.convertChild(node.expression) + }); + } + case SyntaxKind.NamespaceExportDeclaration: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSNamespaceExportDeclaration, + id: this.convertChild(node.name) + }); + } + case SyntaxKind.AbstractKeyword: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSAbstractKeyword + }); + } + default: + return this.deeplyCopy(node); } - - default: - deeplyCopy(); } - - if (additionalOptions.shouldProvideParserServices) { - tsNodeToESTreeNodeMap.set(node, result); - esTreeNodeToTSNodeMap.set(result, node); - } - - return result; } diff --git a/packages/typescript-estree/src/estree/experimental.ts b/packages/typescript-estree/src/estree/experimental.ts deleted file mode 100644 index 103d9ffd53a5..000000000000 --- a/packages/typescript-estree/src/estree/experimental.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Node, Expression, MethodDefinition, Property, Class } from './spec'; - -/** - * Decorator - */ -export interface Decorator extends Node { - type: 'Decorator'; - expression: Expression; -} - -/** - * MethodDefinition - */ -export interface ExtendedMethodDefinition extends MethodDefinition { - decorators: Decorator[]; -} - -/** - * Property - */ -export interface ExtendedProperty extends Property { - decorators: Decorator[]; -} - -/** - * Class - */ -export interface ExtendedClass extends Class { - decorators: Decorator[]; -} diff --git a/packages/typescript-estree/src/estree/extensions.ts b/packages/typescript-estree/src/estree/extensions.ts deleted file mode 100644 index 5e036917a3b3..000000000000 --- a/packages/typescript-estree/src/estree/extensions.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Based on https://github.com/estree/estree/blob/master/extensions/type-annotations.md - */ - -import { - Identifier, - Function, - ObjectPattern, - ArrayPattern, - RestElement -} from './spec'; - -/** - * Type Annotations - */ - -/** - * Any type annotation. - */ -export interface TypeAnnotation extends Node {} - -/** - * Identifier - * - * The `typeAnnotation` property is used only in the case of variable declarations with type annotations or function arguments with type annotations. - */ -export interface ExtendedIdentifier extends Identifier { - typeAnnotation: TypeAnnotation | null; -} - -/** - * Functions - * - * The `returnType` property is used to specify the type annotation for the return value of the function. - */ -export interface ExtendedFunction extends Function { - returnType: TypeAnnotation | null; -} - -/** - * Patterns - */ - -/** - * ObjectPattern - */ -export interface ExtendedObjectPattern extends ObjectPattern { - typeAnnotation: TypeAnnotation | null; -} - -/** - * ArrayPattern - */ -export interface ExtendedArrayPattern extends ArrayPattern { - typeAnnotation: TypeAnnotation | null; -} - -/** - * RestElement - */ -export interface ExtendedRestElement extends RestElement { - typeAnnotation: TypeAnnotation | null; -} diff --git a/packages/typescript-estree/src/estree/spec.ts b/packages/typescript-estree/src/estree/spec.ts deleted file mode 100644 index 1d2a0a765ee6..000000000000 --- a/packages/typescript-estree/src/estree/spec.ts +++ /dev/null @@ -1,985 +0,0 @@ -/** - * This document specifies the core ESTree AST node types based on: - * - ES5: https://github.com/estree/estree/blob/master/es5.md - * - ES2015: https://github.com/estree/estree/blob/master/es2015.md - * - ES2016: https://github.com/estree/estree/blob/master/es2016.md - * - ES2017: https://github.com/estree/estree/blob/master/es2017.md - * - ES2018: https://github.com/estree/estree/blob/master/es2018.md - */ - -/** - * Node objects - * - * ESTree AST nodes are represented as `Node` objects, which may have any prototype inheritance but which implement the following interface: - */ - -export interface Node { - type: string; - loc: SourceLocation | null; -} - -/** - * The `type` field is a string representing the AST variant type. Each subtype of `Node` is documented below with the specific string of its `type` field. You can use this field to determine which interface a node implements. - * - * The `loc` field represents the source location information of the node. If the node contains no information about the source location, the field is `null`; otherwise it is an object consisting of a start position (the position of the first character of the parsed source region) and an end position (the position of the first character after the parsed source region): - */ -export interface SourceLocation { - source: string | null; - start: Position; - end: Position; -} - -/** - * Each `Position` object consists of a `line` number (1-indexed) and a `column` number (0-indexed): - */ -export interface Position { - line: number; // >= 1 - column: number; // >= 0 -} - -/** - * Identifier - * - * An identifier. Note that an identifier may be an expression or a destructuring pattern. - */ -export interface Identifier extends Expression, Pattern { - type: 'Identifier'; - name: string; -} - -/** - * Literal - * - * A literal token. Note that a literal can be an expression. - */ -export interface Literal extends Expression { - type: 'Literal'; - value: string | boolean | null | number | RegExp; -} - -/** - * RegExpLiteral - * - * The `regex` property allows regexes to be represented in environments that don’t - * support certain flags such as `y` or `u`. In environments that don't support - * these flags `value` will be `null` as the regex can't be represented natively. - */ -export interface RegExpLiteral extends Literal { - regex: { - pattern: string; - flags: string; - }; -} - -/** - * Programs - * - * A complete program source tree. - * - * ES2015+ Parsers must specify sourceType as "module" if the source has been parsed as an ES6 module. Otherwise, sourceType must be "script". - */ -export interface Program extends Node { - type: 'Program'; - body: Array; - sourceType: 'script' | 'module'; -} - -/** - * Functions - * - * A function declaration or expression. - */ -export interface Function extends Node { - id: Identifier | null; - params: Pattern[]; - body: FunctionBody; - generator: boolean; - async: boolean; -} - -/** - * Statements - * - * Any statement. - */ -export interface Statement extends Node {} - -/** - * ExpressionStatement - * - * An expression statement, i.e., a statement consisting of a single expression. - */ -export interface ExpressionStatement extends Statement { - type: 'ExpressionStatement'; - expression: Expression; -} - -/** - * Directive - * - * A directive from the directive prologue of a script or function. - * The `directive` property is the raw string source of the directive without quotes. - */ -export interface Directive extends Node { - type: 'ExpressionStatement'; - expression: Literal; - directive: string; -} - -/** - * BlockStatement - * - * A block statement, i.e., a sequence of statements surrounded by braces. - */ -export interface BlockStatement extends Statement { - type: 'BlockStatement'; - body: Statement[]; -} - -/** - * FunctionBody - * - * The body of a function, which is a block statement that may begin with directives. - */ -export interface FunctionBody extends BlockStatement { - body: Array; -} - -/** - * EmptyStatement - * - * An empty statement, i.e., a solitary semicolon. - */ -export interface EmptyStatement extends Statement { - type: 'EmptyStatement'; -} - -/** - * DebuggerStatement - * - * A `debugger` statement. - */ -export interface DebuggerStatement extends Statement { - type: 'DebuggerStatement'; -} - -/** - * WithStatement - * - * A `with` statement. - */ -export interface WithStatement extends Statement { - type: 'WithStatement'; - object: Expression; - body: Statement; -} - -/** - * Control flow - */ - -/** - * ReturnStatement - * - * A `return` statement. - */ -export interface ReturnStatement extends Statement { - type: 'ReturnStatement'; - argument: Expression | null; -} - -/** - * LabeledStatement - * - * A labeled statement, i.e., a statement prefixed by a `break`/`continue` label. - */ -export interface LabeledStatement extends Statement { - type: 'LabeledStatement'; - label: Identifier; - body: Statement; -} - -/** - * BreakStatement - * - * A `break` statement. - */ -export interface BreakStatement extends Statement { - type: 'BreakStatement'; - label: Identifier | null; -} - -/** - * ContinueStatement - * - * A `continue` statement. - */ -export interface ContinueStatement extends Statement { - type: 'ContinueStatement'; - label: Identifier | null; -} - -/** - * Choice - */ - -/** - * IfStatement - * - * An `if` statement. - */ -export interface IfStatement extends Statement { - type: 'IfStatement'; - test: Expression; - consequent: Statement; - alternate: Statement | null; -} - -/** - * SwitchStatement - * - * A `switch` statement. - */ -export interface SwitchStatement extends Statement { - type: 'SwitchStatement'; - discriminant: Expression; - cases: SwitchCase[]; -} - -/** - * SwitchCase - * - * A `case` (if `test` is an `Expression`) or `default` (if `test === null`) clause in the body of a `switch` statement. - */ -export interface SwitchCase extends Node { - type: 'SwitchCase'; - test: Expression | null; - consequent: Statement[]; -} - -/** - * Exceptions - */ - -/** - * ThrowStatement - * - * A `throw` statement. - */ -export interface ThrowStatement extends Statement { - type: 'ThrowStatement'; - argument: Expression; -} - -/** - * TryStatement - * - * A `try` statement. If `handler` is `null` then `finalizer` must be a `BlockStatement`. - */ -export interface TryStatement extends Statement { - type: 'TryStatement'; - block: BlockStatement; - handler: CatchClause | null; - finalizer: BlockStatement | null; -} - -/** - * CatchClause - * - * A `catch` clause following a `try` block. - * - * The param is null if the catch binding is omitted. E.g., try { foo() } catch { bar() } - */ -export interface CatchClause extends Node { - type: 'CatchClause'; - param: Pattern | null; - body: BlockStatement; -} - -/** - * Loops - */ - -/** - * WhileStatement - * - * A `while` statement. - */ -export interface WhileStatement extends Statement { - type: 'WhileStatement'; - test: Expression; - body: Statement; -} - -/** - * DoWhileStatement - * - * A `do`/`while` statement. - */ -export interface DoWhileStatement extends Statement { - type: 'DoWhileStatement'; - body: Statement; - test: Expression; -} - -/** - * ForStatement - * - * A `for` statement. - */ -export interface ForStatement extends Statement { - type: 'ForStatement'; - init: VariableDeclaration | Expression | null; - test: Expression | null; - update: Expression | null; - body: Statement; -} - -/** - * ForInStatement - * - * A `for`/`in` statement. - */ -export interface ForInStatement extends Statement { - type: 'ForInStatement'; - left: VariableDeclaration | Pattern; - right: Expression; - body: Statement; -} - -/** - * ForOfStatement - * - * A `for`/`of` statement and for-await-of statements, e.g., for await (const x of xs) { - */ -export interface ForOfStatement { - type: 'ForOfStatement'; - left: VariableDeclaration | Pattern; - right: Expression; - body: Statement; - await: boolean; -} - -/** - * Declarations - * - * Any declaration node. Note that declarations are considered statements; this is because declarations can appear in any statement context. - */ -export interface Declaration extends Statement {} - -/** - * FunctionDeclaration - * - * A function declaration. Note that unlike in the parent interface `Function`, the `id` cannot be `null`. - */ -export interface FunctionDeclaration extends Function, Declaration { - type: 'FunctionDeclaration'; - id: Identifier; -} - -/** - * VariableDeclaration - * - * A variable declaration. - */ -export interface VariableDeclaration extends Declaration { - type: 'VariableDeclaration'; - declarations: VariableDeclarator[]; - kind: 'var' | 'let' | 'const'; -} - -/** - * VariableDeclarator - * - * A variable declarator. - */ -export interface VariableDeclarator extends Node { - type: 'VariableDeclarator'; - id: Pattern; - init: Expression | null; -} - -/** - * Expressions - * - * Any expression node. Since the left-hand side of an assignment may be any expression in general, an expression can also be a pattern. - */ -export interface Expression extends Node {} - -/** - * Super - * - * A super pseudo-expression. - */ -export interface Super extends Node { - type: 'Super'; -} - -/** - * ThisExpression - * - * A `this` expression. - */ -export interface ThisExpression extends Expression { - type: 'ThisExpression'; -} - -/** - * SpreadElement - * - * Spread expression, e.g., [head, ...iter, tail], f(head, ...iter, ...tail). - */ -export interface SpreadElement extends Node { - type: 'SpreadElement'; - argument: Expression; -} - -/** - * ArrayExpression - * - * An array expression. - */ -export interface ArrayExpression extends Expression { - type: 'ArrayExpression'; - elements: Array; -} - -/** - * ObjectExpression - * - * An object expression. - * - * Spread properties, e.g., {a: 1, ...obj, b: 2}. - */ -export interface ObjectExpression extends Expression { - type: 'ObjectExpression'; - properties: Array; -} - -/** - * Property - * - * A literal property in an object expression can have either a string or number as its `value`. Ordinary property initializers have a `kind` value `"init"`; getters and setters have the kind values `"get"` and `"set"`, respectively. - */ -export interface Property extends Node { - type: 'Property'; - key: Literal | Identifier | Expression; - value: Expression; - kind: 'init' | 'get' | 'set'; - method: boolean; - shorthand: boolean; - computed: boolean; -} - -/** - * FunctionExpression - * - * A `function` expression. - */ -export interface FunctionExpression extends Function, Expression { - type: 'FunctionExpression'; -} - -/** - * ArrowFunctionExpression - * - * A fat arrow function expression, e.g., let foo = (bar) => { / body / }. - */ -export interface ArrowFunctionExpression extends Expression { - id: Identifier | null; - params: Pattern[]; - type: 'ArrowFunctionExpression'; - body: FunctionBody | Expression; - generator: boolean; - expression: boolean; -} - -/** - * Unary operations - */ - -/** - * UnaryExpression - * - * A unary operator expression. - */ -export interface UnaryExpression extends Expression { - type: 'UnaryExpression'; - operator: UnaryOperator; - prefix: boolean; - argument: Expression; -} - -/** - * UnaryOperator - * - * A unary operator token. - */ -export type UnaryOperator = - | '-' - | '+' - | '!' - | '~' - | 'typeof' - | 'void' - | 'delete'; - -/** - * UpdateExpression - * - * An update (increment or decrement) operator expression. - */ -export interface UpdateExpression extends Expression { - type: 'UpdateExpression'; - operator: UpdateOperator; - argument: Expression; - prefix: boolean; -} - -/** - * UpdateOperator - * - * An update (increment or decrement) operator token. - */ -export type UpdateOperator = '++' | '--'; - -/** - * Binary operations - */ - -/** - * BinaryExpression - * - * A binary operator expression. - */ -export interface BinaryExpression extends Expression { - type: 'BinaryExpression'; - operator: BinaryOperator; - left: Expression; - right: Expression; -} - -/** - * BinaryOperator - * - * A binary operator token. - */ -export type BinaryOperator = - | '==' - | '!=' - | '===' - | '!==' - | '<' - | '<=' - | '>' - | '>=' - | '<<' - | '>>' - | '>>>' - | '+' - | '-' - | '*' - | '/' - | '%' - | '|' - | '^' - | '&' - | 'in' - | 'instanceof' - | '**'; - -/** - * AssignmentExpression - * - * An assignment operator expression. - * - * FROM ESTREE DOCS: - * - * ``` - * FIXME: This describes the Esprima and Acorn behaviors, which is not currently aligned with the SpiderMonkey behavior. - * - * extend interface AssignmentExpression { - * left: Pattern; - * } - * - * Note that pre-ES6 code was allowed to pass references around and so left was much more liberal; an implementation might choose to continue using old definition if it needs to support such legacy code. - * ``` - */ -export interface AssignmentExpression extends Expression { - type: 'AssignmentExpression'; - operator: AssignmentOperator; - left: Pattern | Expression; - right: Expression; -} - -/** - * AssignmentOperator - * - * An assignment operator token. - */ -export type AssignmentOperator = - | '=' - | '+=' - | '-=' - | '*=' - | '/=' - | '%=' - | '<<=' - | '>>=' - | '>>>=' - | '|=' - | '^=' - | '&=' - | '**='; - -/** - * LogicalExpression - * - * A logical operator expression. - */ -export interface LogicalExpression extends Expression { - type: 'LogicalExpression'; - operator: LogicalOperator; - left: Expression; - right: Expression; -} - -/** - * LogicalOperator - * - * A logical operator token. - */ -export type LogicalOperator = '||' | '&&'; - -/** - * MemberExpression - * - * A member expression. If `computed` is `true`, the node corresponds to a computed (`a[b]`) member expression and `property` is an `Expression`. If `computed` is `false`, the node corresponds to a static (`a.b`) member expression and `property` is an `Identifier`. - */ -export interface MemberExpression extends Expression, Pattern { - type: 'MemberExpression'; - object: Expression | Super; - property: Expression; - computed: boolean; -} - -/** - * ConditionalExpression - * - * A conditional expression, i.e., a ternary `?`/`:` expression. - */ -export interface ConditionalExpression extends Expression { - type: 'ConditionalExpression'; - test: Expression; - alternate: Expression; - consequent: Expression; -} - -/** - * CallExpression - * - * A function or method call expression. - */ -export interface CallExpression extends Expression { - type: 'CallExpression'; - callee: Expression | Super; - arguments: Array; -} - -/** - * NewExpression - * - * A `new` expression. - */ -export interface NewExpression extends Expression { - type: 'NewExpression'; - callee: Expression; - arguments: Array; -} - -/** - * SequenceExpression - * - * A sequence expression, i.e., a comma-separated sequence of expressions. - */ -export interface SequenceExpression extends Expression { - type: 'SequenceExpression'; - expressions: Expression[]; -} - -/** - * YieldExpression - * - * A yield expression. - */ -export interface YieldExpression extends Expression { - type: 'YieldExpression'; - argument: Expression | null; - delegate: boolean; -} - -/** - * AwaitExpression - */ -export interface AwaitExpression extends Expression { - type: 'AwaitExpression'; - argument: Expression; -} - -/** - * Template Literals - */ - -/** - * TemplateLiteral - */ -export interface TemplateLiteral extends Expression { - type: 'TemplateLiteral'; - quasis: TemplateElement[]; - expressions: Expression[]; -} - -/** - * TaggedTemplateExpression - */ -export interface TaggedTemplateExpression extends Expression { - type: 'TaggedTemplateExpression'; - tag: Expression; - quasi: TemplateLiteral; -} - -/** - * TemplateElement - * - * If the template literal is tagged and the text has an invalid escape, cooked will be null, e.g., tag`\unicode and \u{55}` - */ -export interface TemplateElement extends Node { - type: 'TemplateElement'; - tail: boolean; - value: { - cooked: string | null; - raw: string; - }; -} - -/** - * Patterns - * - * Destructuring binding and assignment are not part of ES5, but all binding positions accept Pattern to allow for destructuring in ES6. Nevertheless, for ES5, the only Pattern subtype is Identifier. - */ -export interface Pattern extends Node {} - -/** - * AssignmentProperty - */ -export interface AssignmentProperty extends Property { - type: 'Property'; // inherited - value: Pattern; - kind: 'init'; - method: false; -} - -/** - * ObjectPattern - * - * Rest properties, e.g., {a, ...rest} = obj. - */ -export interface ObjectPattern extends Pattern { - type: 'ObjectPattern'; - properties: Array; -} - -/** - * ArrayPattern - */ -export interface ArrayPattern extends Pattern { - type: 'ArrayPattern'; - elements: Array; -} - -/** - * RestElement - */ -export interface RestElement extends Pattern { - type: 'RestElement'; - argument: Pattern; -} - -/** - * AssignmentPattern - */ -export interface AssignmentPattern extends Pattern { - type: 'AssignmentPattern'; - left: Pattern; - right: Expression; -} - -/** - * Classes - */ - -/** - * Class - */ -export interface Class extends Node { - id: Identifier | null; - superClass: Expression | null; - body: ClassBody; -} - -/** - * ClassBody - */ -export interface ClassBody extends Node { - type: 'ClassBody'; - body: MethodDefinition[]; -} - -/** - * MethodDefinition - */ -export interface MethodDefinition extends Node { - type: 'MethodDefinition'; - key: Expression; - value: FunctionExpression; - kind: 'constructor' | 'method' | 'get' | 'set'; - computed: boolean; - static: boolean; -} - -/** - * ClassDeclaration - */ -export interface ClassDeclaration extends Class, Declaration { - type: 'ClassDeclaration'; - id: Identifier; -} - -/** - * ClassExpression - */ -export interface ClassExpression extends Class, Expression { - type: 'ClassExpression'; -} - -/** - * MetaProperty - */ -export interface MetaProperty extends Expression { - type: 'MetaProperty'; - meta: Identifier; - property: Identifier; -} - -/** - * Modules - */ - -/** - * ModuleDeclaration - * - * A module `import` or `export` declaration. - */ -export interface ModuleDeclaration extends Node {} - -/** - * ModuleSpecifier - * - * A specifier in an import or export declaration. - */ -export interface ModuleSpecifier extends Node { - local: Identifier; -} - -/** - * Imports - */ - -/** - * ImportDeclaration - * - * An import declaration, e.g., `import foo from "mod";`. - */ -export interface ImportDeclaration extends ModuleDeclaration { - type: 'ImportDeclaration'; - specifiers: Array< - ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier - >; - source: Literal; -} - -/** - * ImportSpecifier - * - * An imported variable binding, e.g., `{foo}` in `import {foo} from "mod"` or `{foo as bar}` in `import {foo as bar} from "mod"`. The `imported` field refers to the name of the export imported from the module. The `local` field refers to the binding imported into the local module scope. If it is a basic named import, such as in `import {foo} from "mod"`, both `imported` and `local` are equivalent `Identifier` nodes; in this case an `Identifier` node representing `foo`. If it is an aliased import, such as in `import {foo as bar} from "mod"`, the `imported` field is an `Identifier` node representing `foo`, and the `local` field is an `Identifier` node representing `bar`. - */ -export interface ImportSpecifier extends ModuleSpecifier { - type: 'ImportSpecifier'; - imported: Identifier; -} - -/** - * ImportDefaultSpecifier - * - * A default import specifier, e.g., `foo` in `import foo from "mod.js"`. - */ -export interface ImportDefaultSpecifier extends ModuleSpecifier { - type: 'ImportDefaultSpecifier'; -} - -/** - * ImportNamespaceSpecifier - * - * A namespace import specifier, e.g., `* as foo` in `import * as foo from "mod.js"`. - */ -export interface ImportNamespaceSpecifier extends ModuleSpecifier { - type: 'ImportNamespaceSpecifier'; -} - -/** - * Exports - */ - -/** - * ExportNamedDeclaration - * - * An export named declaration, e.g., `export {foo, bar};`, `export {foo} from "mod";` or `export var foo = 1;`. - * - * _Note: Having `declaration` populated with non-empty `specifiers` or non-null `source` results in an invalid state._ - */ -export interface ExportNamedDeclaration extends ModuleDeclaration { - type: 'ExportNamedDeclaration'; - declaration: Declaration | null; - specifiers: [ExportSpecifier]; - source: Literal | null; -} - -/** - * ExportSpecifier - * - * An exported variable binding, e.g., `{foo}` in `export {foo}` or `{bar as foo}` in `export {bar as foo}`. The `exported` field refers to the name exported in the module. The `local` field refers to the binding into the local module scope. If it is a basic named export, such as in `export {foo}`, both `exported` and `local` are equivalent `Identifier` nodes; in this case an `Identifier` node representing `foo`. If it is an aliased export, such as in `export {bar as foo}`, the `exported` field is an `Identifier` node representing `foo`, and the `local` field is an `Identifier` node representing `bar`. - */ -export interface ExportSpecifier extends ModuleSpecifier { - type: 'ExportSpecifier'; - exported: Identifier; -} - -/** - * ExportDefaultDeclaration - * - * An export default declaration, e.g., `export default function () {};` or `export default 1;`. - */ -export interface ExportDefaultDeclaration extends ModuleDeclaration { - type: 'ExportDefaultDeclaration'; - declaration: Declaration | Expression; -} - -/** - * ExportAllDeclaration - * - * An export batch declaration, e.g., `export * from "mod";`. - */ -export interface ExportAllDeclaration extends ModuleDeclaration { - type: 'ExportAllDeclaration'; - source: Literal; -} diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index d79353f755e6..aa5a10418c76 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -6,12 +6,7 @@ */ import ts from 'typescript'; import unescape from 'lodash.unescape'; -import { - ESTreeNodeLoc, - ESTreeNode, - ESTreeToken, - LineAndColumnData -} from './temp-types-based-on-js-source'; +import * as es from './typedefs'; import { AST_NODE_TYPES } from './ast-node-types'; const SyntaxKind = ts.SyntaxKind; @@ -102,8 +97,8 @@ const TOKEN_TO_TEXT: { readonly [P in ts.SyntaxKind]?: string } = { /** * Returns true if the given ts.Token is the assignment operator - * @param {ts.Token} operator the operator token - * @returns {boolean} is assignment + * @param operator the operator token + * @returns is assignment */ export function isAssignmentOperator( operator: ts.Token @@ -113,8 +108,8 @@ export function isAssignmentOperator( /** * Returns true if the given ts.Token is a logical operator - * @param {ts.Token} operator the operator token - * @returns {boolean} is a logical operator + * @param operator the operator token + * @returns is a logical operator */ export function isLogicalOperator( operator: ts.Token @@ -124,8 +119,8 @@ export function isLogicalOperator( /** * Returns the string form of the given TSToken SyntaxKind - * @param {number} kind the token's SyntaxKind - * @returns {string} the token applicable token as a string + * @param kind the token's SyntaxKind + * @returns the token applicable token as a string */ export function getTextForTokenKind(kind: ts.SyntaxKind): string | undefined { return TOKEN_TO_TEXT[kind]; @@ -133,8 +128,8 @@ export function getTextForTokenKind(kind: ts.SyntaxKind): string | undefined { /** * Returns true if the given ts.Node is a valid ESTree class member - * @param {ts.Node} node TypeScript AST node - * @returns {boolean} is valid ESTree class member + * @param node TypeScript AST node + * @returns is valid ESTree class member */ export function isESTreeClassMember(node: ts.Node): boolean { return node.kind !== SyntaxKind.SemicolonClassElement; @@ -142,9 +137,9 @@ export function isESTreeClassMember(node: ts.Node): boolean { /** * Checks if a ts.Node has a modifier - * @param {ts.KeywordSyntaxKind} modifierKind TypeScript SyntaxKind modifier - * @param {ts.Node} node TypeScript AST node - * @returns {boolean} has the modifier specified + * @param modifierKind TypeScript SyntaxKind modifier + * @param node TypeScript AST node + * @returns has the modifier specified */ export function hasModifier( modifierKind: ts.KeywordSyntaxKind, @@ -173,8 +168,8 @@ export function getLastModifier(node: ts.Node): ts.Modifier | null { /** * Returns true if the given ts.Token is a comma - * @param {ts.Node} token the TypeScript token - * @returns {boolean} is comma + * @param token the TypeScript token + * @returns is comma */ export function isComma(token: ts.Node): boolean { return token.kind === SyntaxKind.CommaToken; @@ -182,8 +177,8 @@ export function isComma(token: ts.Node): boolean { /** * Returns true if the given ts.Node is a comment - * @param {ts.Node} node the TypeScript node - * @returns {boolean} is comment + * @param node the TypeScript node + * @returns is comment */ export function isComment(node: ts.Node): boolean { return ( @@ -194,8 +189,8 @@ export function isComment(node: ts.Node): boolean { /** * Returns true if the given ts.Node is a JSDoc comment - * @param {ts.Node} node the TypeScript node - * @returns {boolean} is JSDoc comment + * @param node the TypeScript node + * @returns is JSDoc comment */ export function isJSDocComment(node: ts.Node): boolean { return node.kind === SyntaxKind.JSDocComment; @@ -203,8 +198,8 @@ export function isJSDocComment(node: ts.Node): boolean { /** * Returns the binary expression type of the given ts.Token - * @param {ts.Token} operator the operator token - * @returns {string} the binary expression type + * @param operator the operator token + * @returns the binary expression type */ export function getBinaryExpressionType( operator: ts.Token @@ -229,7 +224,7 @@ export function getBinaryExpressionType( export function getLineAndCharacterFor( pos: number, ast: ts.SourceFile -): LineAndColumnData { +): es.LineAndColumnData { const loc = ast.getLineAndCharacterOfPosition(pos); return { line: loc.line + 1, @@ -240,16 +235,16 @@ export function getLineAndCharacterFor( /** * Returns line and column data for the given start and end positions, * for the given AST - * @param {number} start start data - * @param {number} end end data - * @param {ts.SourceFile} ast the AST object - * @returns {ESTreeNodeLoc} the loc data + * @param start start data + * @param end end data + * @param ast the AST object + * @returns the loc data */ export function getLocFor( start: number, end: number, ast: ts.SourceFile -): ESTreeNodeLoc { +): es.SourceLocation { return { start: getLineAndCharacterFor(start, ast), end: getLineAndCharacterFor(end, ast) @@ -258,8 +253,8 @@ export function getLocFor( /** * Check whatever node can contain directive - * @param {ts.Node} node - * @returns {boolean} returns true if node can contain directive + * @param node + * @returns returns true if node can contain directive */ export function canContainDirective(node: ts.Node): boolean { switch (node.kind) { @@ -285,23 +280,19 @@ export function canContainDirective(node: ts.Node): boolean { } /** - * Returns line and column data for the given ts.Node or ts.Token, - * for the given AST - * @param {ts.Node} nodeOrToken the ts.Node or ts.Token - * @param {ts.SourceFile} ast the AST object - * @returns {ESTreeLoc} the loc data + * Returns range for the given ts.Node + * @param node the ts.Node or ts.Token + * @param ast the AST object + * @returns the range data */ -export function getLoc( - nodeOrToken: ts.Node, - ast: ts.SourceFile -): ESTreeNodeLoc { - return getLocFor(nodeOrToken.getStart(ast), nodeOrToken.end, ast); +export function getRange(node: ts.Node, ast: ts.SourceFile): [number, number] { + return [node.getStart(ast), node.getEnd()]; } /** * Returns true if a given ts.Node is a token - * @param {ts.Node} node the ts.Node - * @returns {boolean} is a token + * @param node the ts.Node + * @returns is a token */ export function isToken(node: ts.Node): boolean { return ( @@ -311,8 +302,8 @@ export function isToken(node: ts.Node): boolean { /** * Returns true if a given ts.Node is a JSX token - * @param {ts.Node} node ts.Node to be checked - * @returns {boolean} is a JSX token + * @param node ts.Node to be checked + * @returns is a JSX token */ export function isJSXToken(node: ts.Node): boolean { return ( @@ -322,8 +313,8 @@ export function isJSXToken(node: ts.Node): boolean { /** * Returns the declaration kind of the given ts.Node - * @param {ts.VariableDeclarationList} node TypeScript AST node - * @returns {string} declaration kind + * @param node TypeScript AST node + * @returns declaration kind */ export function getDeclarationKind( node: ts.VariableDeclarationList @@ -339,8 +330,8 @@ export function getDeclarationKind( /** * Gets a ts.Node's accessibility level - * @param {ts.Node} node The ts.Node - * @returns {string | null} accessibility "public", "protected", "private", or null + * @param node The ts.Node + * @returns accessibility "public", "protected", "private", or null */ export function getTSNodeAccessibility( node: ts.Node @@ -368,10 +359,10 @@ export function getTSNodeAccessibility( /** * Finds the next token based on the previous one and its parent * Had to copy this from TS instead of using TS's version because theirs doesn't pass the ast to getChildren - * @param {ts.TextRange} previousToken The previous TSToken - * @param {ts.Node} parent The parent TSNode - * @param {ts.SourceFile} ast The TS AST - * @returns {ts.Node|undefined} the next TSToken + * @param previousToken The previous TSToken + * @param parent The parent TSNode + * @param ast The TS AST + * @returns the next TSToken */ export function findNextToken( previousToken: ts.TextRange, @@ -400,9 +391,9 @@ export function findNextToken( /** * Find the first matching ancestor based on the given predicate function. - * @param {ts.Node} node The current ts.Node - * @param {Function} predicate The predicate function to apply to each checked ancestor - * @returns {ts.Node|undefined} a matching parent ts.Node + * @param node The current ts.Node + * @param predicate The predicate function to apply to each checked ancestor + * @returns a matching parent ts.Node */ export function findFirstMatchingAncestor( node: ts.Node, @@ -419,8 +410,8 @@ export function findFirstMatchingAncestor( /** * Returns true if a given ts.Node has a JSX token within its hierarchy - * @param {ts.Node} node ts.Node to be checked - * @returns {boolean} has JSX ancestor + * @param node ts.Node to be checked + * @returns has JSX ancestor */ export function hasJSXAncestor(node: ts.Node): boolean { return !!findFirstMatchingAncestor(node, isJSXToken); @@ -428,8 +419,8 @@ export function hasJSXAncestor(node: ts.Node): boolean { /** * Unescape the text content of string literals, e.g. & -> & - * @param {string} text The escaped string literal text. - * @returns {string} The unescaped string literal text. + * @param text The escaped string literal text. + * @returns The unescaped string literal text. */ export function unescapeStringLiteralText(text: string): string { return unescape(text); @@ -437,8 +428,8 @@ export function unescapeStringLiteralText(text: string): string { /** * Returns true if a given ts.Node is a computed property - * @param {ts.Node} node ts.Node to be checked - * @returns {boolean} is Computed Property + * @param node ts.Node to be checked + * @returns is Computed Property */ export function isComputedProperty(node: ts.Node): boolean { return node.kind === SyntaxKind.ComputedPropertyName; @@ -446,8 +437,8 @@ export function isComputedProperty(node: ts.Node): boolean { /** * Returns true if a given ts.Node is optional (has QuestionToken) - * @param {ts.Node} node ts.Node to be checked - * @returns {boolean} is Optional + * @param node ts.Node to be checked + * @returns is Optional */ export function isOptional(node: { questionToken?: ts.QuestionToken; @@ -459,16 +450,16 @@ export function isOptional(node: { /** * Fixes the exports of the given ts.Node - * @param {ts.Node} node the ts.Node - * @param {ESTreeNode} result result - * @param {ts.SourceFile} ast the AST - * @returns {ESTreeNode} the ESTreeNode with fixed exports + * @param node the ts.Node + * @param result result + * @param ast the AST + * @returns the ESTreeNode with fixed exports */ -export function fixExports( +export function fixExports( node: ts.Node, - result: ESTreeNode, + result: T, ast: ts.SourceFile -): ESTreeNode { +): es.ExportDefaultDeclaration | es.ExportNamedDeclaration | T { // check for exports if (node.modifiers && node.modifiers[0].kind === SyntaxKind.ExportKeyword) { const exportKeyword = node.modifiers[0]; @@ -480,26 +471,26 @@ export function fixExports( ? findNextToken(nextModifier, ast, ast) : findNextToken(exportKeyword, ast, ast); - result.range[0] = varToken!.getStart(ast); - result.loc = getLocFor(result.range[0], result.range[1], ast); - - const declarationType = declarationIsDefault - ? AST_NODE_TYPES.ExportDefaultDeclaration - : AST_NODE_TYPES.ExportNamedDeclaration; + result.range![0] = varToken!.getStart(ast); + result.loc = getLocFor(result.range![0], result.range![1], ast); - const newResult: any = { - type: declarationType, - declaration: result, - range: [exportKeyword.getStart(ast), result.range[1]], - loc: getLocFor(exportKeyword.getStart(ast), result.range[1], ast) - }; - - if (!declarationIsDefault) { - newResult.specifiers = []; - newResult.source = null; + if (declarationIsDefault) { + return { + type: AST_NODE_TYPES.ExportDefaultDeclaration, + declaration: result as any, + range: [exportKeyword.getStart(ast), result.range![1]], + loc: getLocFor(exportKeyword.getStart(ast), result.range![1], ast) + }; + } else { + return { + type: AST_NODE_TYPES.ExportNamedDeclaration, + declaration: result as any, + range: [exportKeyword.getStart(ast), result.range![1]], + loc: getLocFor(exportKeyword.getStart(ast), result.range![1], ast), + specifiers: [], + source: null + }; } - - return newResult; } return result; @@ -507,10 +498,10 @@ export function fixExports( /** * Returns the type of a given ts.Token - * @param {ts.Token} token the ts.Token - * @returns {string} the token type + * @param token the ts.Token + * @returns the token type */ -export function getTokenType(token: any): string { +export function getTokenType(token: any): es.TokenType { // Need two checks for keywords since some are also identifiers if (token.originalKeywordKind) { switch (token.originalKeywordKind) { @@ -614,18 +605,18 @@ export function getTokenType(token: any): string { /** * Extends and formats a given ts.Token, for a given AST - * @param {ts.Node} token the ts.Token - * @param {ts.SourceFile} ast the AST object - * @returns {ESTreeToken} the converted ESTreeToken + * @param token the ts.Token + * @param ast the AST object + * @returns the converted es.Token */ -export function convertToken(token: ts.Node, ast: ts.SourceFile): ESTreeToken { +export function convertToken(token: ts.Node, ast: ts.SourceFile): es.Token { const start = token.kind === SyntaxKind.JsxText ? token.getFullStart() : token.getStart(ast), end = token.getEnd(), value = ast.text.slice(start, end), - newToken: any = { + newToken: es.Token = { type: getTokenType(token), value, range: [start, end], @@ -644,14 +635,13 @@ export function convertToken(token: ts.Node, ast: ts.SourceFile): ESTreeToken { /** * Converts all tokens for the given AST - * @param {ts.SourceFile} ast the AST object - * @returns {ESTreeToken[]} the converted ESTreeTokens + * @param ast the AST object + * @returns the converted Tokens */ -export function convertTokens(ast: ts.SourceFile): ESTreeToken[] { - const result: ESTreeToken[] = []; +export function convertTokens(ast: ts.SourceFile): es.Token[] { + const result: es.Token[] = []; /** - * @param {ts.Node} node the ts.Node - * @returns {void} + * @param node the ts.Node */ function walk(node: ts.Node): void { // TypeScript generates tokens for types in JSDoc blocks. Comment tokens @@ -676,10 +666,10 @@ export function convertTokens(ast: ts.SourceFile): ESTreeToken[] { /** * Get container token node between range - * @param {ts.SourceFile} ast the AST object - * @param {number} start The index at which the comment starts. - * @param {number} end The index at which the comment ends. - * @returns {ts.Node} typescript container token + * @param ast the AST object + * @param start The index at which the comment starts. + * @param end The index at which the comment ends. + * @returns typescript container token * @private */ export function getNodeContainer( @@ -690,8 +680,7 @@ export function getNodeContainer( let container: ts.Node | null = null; /** - * @param {ts.Node} node the ts.Node - * @returns {void} + * @param node the ts.Node */ function walk(node: ts.Node): void { const nodeStart = node.pos; @@ -711,10 +700,10 @@ export function getNodeContainer( } /** - * @param {ts.SourceFile} ast the AST object - * @param {number} start the index at which the error starts - * @param {string} message the error message - * @returns {Object} converted error object + * @param ast the AST object + * @param start the index at which the error starts + * @param message the error message + * @returns converted error object */ export function createError( ast: ts.SourceFile, @@ -731,8 +720,8 @@ export function createError( } /** - * @param {ts.Node} n the TSNode - * @param {ts.SourceFile} ast the TS AST + * @param n the TSNode + * @param ast the TS AST */ export function nodeHasTokens(n: ts.Node, ast: ts.SourceFile) { // If we have a token or node that has a non-zero width, it must have tokens. @@ -746,9 +735,8 @@ export function nodeHasTokens(n: ts.Node, ast: ts.SourceFile) { * Like `forEach`, but suitable for use with numbers and strings (which may be falsy). * @template T * @template U - * @param {ReadonlyArray|undefined} array - * @param {(element: T, index: number) => (U|undefined)} callback - * @returns {U|undefined} + * @param array + * @param callback */ export function firstDefined( array: ReadonlyArray | undefined, diff --git a/packages/typescript-estree/src/parser-options.ts b/packages/typescript-estree/src/parser-options.ts new file mode 100644 index 000000000000..a838db4af139 --- /dev/null +++ b/packages/typescript-estree/src/parser-options.ts @@ -0,0 +1,35 @@ +import { Token, Comment } from './typedefs'; + +export interface Extra { + errorOnUnknownASTType: boolean; + errorOnTypeScriptSyntacticAndSemanticIssues: boolean; + useJSXTextNode: boolean; + tokens: null | Token[]; + comment: boolean; + code: string; + range: boolean; + loc: boolean; + comments: Comment[]; + strict: boolean; + jsx: boolean; + log: Function; + projects: string[]; + tsconfigRootDir: string; + extraFileExtensions: string[]; +} + +export interface ParserOptions { + range?: boolean; + loc?: boolean; + tokens?: boolean; + comment?: boolean; + jsx?: boolean; + errorOnUnknownASTType?: boolean; + errorOnTypeScriptSyntacticAndSemanticIssues?: boolean; + useJSXTextNode?: boolean; + loggerFn?: Function | false; + project?: string | string[]; + filePath?: string; + tsconfigRootDir?: string; + extraFileExtensions?: string[]; +} diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index 225899a106f9..3c9680df06d4 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -13,14 +13,9 @@ import semver from 'semver'; import ts from 'typescript'; import convert from './ast-converter'; import { convertError } from './convert'; -import { Program } from './estree/spec'; import { firstDefined } from './node-utils'; -import { - ESTreeComment, - ESTreeToken, - Extra, - ParserOptions -} from './temp-types-based-on-js-source'; +import * as es from './typedefs'; +import { Extra, ParserOptions } from './parser-options'; import { getFirstSemanticOrSyntacticError } from './semantic-errors'; const packageJSON = require('../package.json'); @@ -49,7 +44,6 @@ function getFileName({ jsx }: { jsx?: boolean }) { /** * Resets the extra config object - * @returns {void} */ function resetExtra(): void { extra = { @@ -72,9 +66,9 @@ function resetExtra(): void { } /** - * @param {string} code The code of the file being linted - * @param {Object} options The config object - * @returns {{ast: ts.SourceFile, program: ts.Program} | undefined} If found, returns the source file corresponding to the code and the containing program + * @param code The code of the file being linted + * @param options The config object + * @returns If found, returns the source file corresponding to the code and the containing program */ function getASTFromProject(code: string, options: ParserOptions) { return firstDefined( @@ -93,9 +87,9 @@ function getASTFromProject(code: string, options: ParserOptions) { } /** - * @param {string} code The code of the file being linted - * @param {Object} options The config object - * @returns {{ast: ts.SourceFile, program: ts.Program} | undefined} If found, returns the source file corresponding to the code and the containing program + * @param code The code of the file being linted + * @param options The config object + * @returns If found, returns the source file corresponding to the code and the containing program */ function getASTAndDefaultProject(code: string, options: ParserOptions) { const fileName = options.filePath || getFileName(options); @@ -105,8 +99,8 @@ function getASTAndDefaultProject(code: string, options: ParserOptions) { } /** - * @param {string} code The code of the file being linted - * @returns {{ast: ts.SourceFile, program: ts.Program}} Returns a new source file and program corresponding to the linted code + * @param code The code of the file being linted + * @returns Returns a new source file and program corresponding to the linted code */ function createNewProgram(code: string) { const FILENAME = getFileName(extra); @@ -162,10 +156,10 @@ function createNewProgram(code: string) { } /** - * @param {string} code The code of the file being linted - * @param {Object} options The config object - * @param {boolean} shouldProvideParserServices True iff the program should be attempted to be calculated from provided tsconfig files - * @returns {{ast: ts.SourceFile, program: ts.Program}} Returns a source file and program corresponding to the linted code + * @param code The code of the file being linted + * @param options The config object + * @param shouldProvideParserServices True iff the program should be attempted to be calculated from provided tsconfig files + * @returns Returns a source file and program corresponding to the linted code */ function getProgramAndAST( code: string, @@ -275,10 +269,10 @@ function warnAboutTSVersion(): void { // Parser //------------------------------------------------------------------------------ -type AST = Program & +type AST = es.Program & (T['range'] extends true ? { range: [number, number] } : {}) & - (T['tokens'] extends true ? { tokens: ESTreeToken[] } : {}) & - (T['comment'] extends true ? { comments: ESTreeComment[] } : {}); + (T['tokens'] extends true ? { tokens: es.Token[] } : {}) & + (T['comment'] extends true ? { comments: es.Comment[] } : {}); interface ParseAndGenerateServicesResult { ast: AST; @@ -342,7 +336,7 @@ export function parse( * Convert the TypeScript AST to an ESTree-compatible one */ const { estree } = convert(ast, extra, false); - return estree; + return estree as AST; } export function parseAndGenerateServices< @@ -406,7 +400,7 @@ export function parseAndGenerateServices< * Return the converted AST and additional parser services */ return { - ast: estree, + ast: estree as AST, services: { program: shouldProvideParserServices ? program : undefined, esTreeNodeToTSNodeMap: diff --git a/packages/typescript-estree/src/temp-types-based-on-js-source.ts b/packages/typescript-estree/src/temp-types-based-on-js-source.ts deleted file mode 100644 index a2234fc1308a..000000000000 --- a/packages/typescript-estree/src/temp-types-based-on-js-source.ts +++ /dev/null @@ -1,106 +0,0 @@ -/** - * NOTE: The following types are inferred from usage within the original JavaScript source. - * - * They will be gradually replaced with the more accurate types derived from the ESTree spec, and its - * applicable extensions - */ -import { AST_NODE_TYPES } from './ast-node-types'; - -export interface ESTreeToken { - type: AST_NODE_TYPES; - range: [number, number]; - loc: ESTreeNodeLoc; - value: string; - regex?: { - pattern: string; - flags: string; - }; - object?: any; - property?: any; - name?: any; -} - -export interface ESTreeNode { - type: AST_NODE_TYPES; - range: [number, number]; - loc: ESTreeNodeLoc; - declaration?: ESTreeNode; - specifiers?: (ESTreeNode | null)[]; - source?: any; - typeAnnotation?: ESTreeNode | null; - typeParameters?: ESTreeNode | null; - id?: ESTreeNode | null; - raw?: string; - value?: string; - expression?: ESTreeNode | null; - decorators?: (ESTreeNode | null)[]; - implements?: (ESTreeNode | null)[]; - extends?: (ESTreeNode | null)[]; - const?: boolean; - declare?: boolean; - global?: boolean; - modifiers?: any; - body?: any; - params?: any; - accessibility?: 'public' | 'protected' | 'private'; - readonly?: boolean | string; - static?: boolean; - export?: boolean; - parameter?: any; - abstract?: boolean; - typeName?: ESTreeNode | null; - directive?: string; - returnType?: ESTreeNode; - optional?: boolean | string; -} - -export interface ESTreeComment { - type: 'Block' | 'Line'; - range?: [number, number]; - loc?: ESTreeNodeLoc; - value: string; -} - -export interface LineAndColumnData { - line: number; - column: number; -} - -export interface ESTreeNodeLoc { - start: LineAndColumnData; - end: LineAndColumnData; -} - -export interface Extra { - errorOnUnknownASTType: boolean; - errorOnTypeScriptSyntacticAndSemanticIssues: boolean; - useJSXTextNode: boolean; - tokens: null | ESTreeToken[]; - comment: boolean; - code: string; - range: boolean; - loc: boolean; - comments: ESTreeComment[]; - strict: boolean; - jsx: boolean; - log: Function; - projects: string[]; - tsconfigRootDir: string; - extraFileExtensions: string[]; -} - -export interface ParserOptions { - range?: boolean; - loc?: boolean; - tokens?: boolean; - comment?: boolean; - jsx?: boolean; - errorOnUnknownASTType?: boolean; - errorOnTypeScriptSyntacticAndSemanticIssues?: boolean; - useJSXTextNode?: boolean; - loggerFn?: Function | false; - project?: string | string[]; - filePath?: string; - tsconfigRootDir?: string; - extraFileExtensions?: string[]; -} diff --git a/packages/typescript-estree/src/tsconfig-parser.ts b/packages/typescript-estree/src/tsconfig-parser.ts index 2212c4d0b1d0..3d68a034c16e 100644 --- a/packages/typescript-estree/src/tsconfig-parser.ts +++ b/packages/typescript-estree/src/tsconfig-parser.ts @@ -2,7 +2,7 @@ import path from 'path'; import ts from 'typescript'; -import { Extra } from './temp-types-based-on-js-source'; +import { Extra } from './parser-options'; //------------------------------------------------------------------------------ // Environment calculation @@ -10,7 +10,6 @@ import { Extra } from './temp-types-based-on-js-source'; /** * Default compiler options for program generation from single root file - * @type {ts.CompilerOptions} */ const defaultCompilerOptions: ts.CompilerOptions = { allowNonTsExtensions: true, @@ -19,7 +18,6 @@ const defaultCompilerOptions: ts.CompilerOptions = { /** * Maps tsconfig paths to their corresponding file contents and resulting watches - * @type {Map>} */ const knownWatchProgramMap = new Map< string, @@ -29,13 +27,11 @@ const knownWatchProgramMap = new Map< /** * Maps file paths to their set of corresponding watch callbacks * There may be more than one per file if a file is shared between projects - * @type {Map} */ const watchCallbackTrackingMap = new Map(); /** * Holds information about the file currently being linted - * @type {{code: string, filePath: string}} */ const currentLintOperationState = { code: '', @@ -44,8 +40,7 @@ const currentLintOperationState = { /** * Appropriately report issues found when reading a config file - * @param {ts.Diagnostic} diagnostic The diagnostic raised when creating a program - * @returns {void} + * @param diagnostic The diagnostic raised when creating a program */ function diagnosticReporter(diagnostic: ts.Diagnostic): void { throw new Error( @@ -57,11 +52,11 @@ const noopFileWatcher = { close: () => {} }; /** * Calculate project environments using options provided by consumer and paths from config - * @param {string} code The code being linted - * @param {string} filePath The path of the file being parsed - * @param {string} extra.tsconfigRootDir The root directory for relative tsconfig paths - * @param {string[]} extra.project Provided tsconfig paths - * @returns {ts.Program[]} The programs corresponding to the supplied tsconfig paths + * @param code The code being linted + * @param filePath The path of the file being parsed + * @param extra.tsconfigRootDir The root directory for relative tsconfig paths + * @param extra.project Provided tsconfig paths + * @returns The programs corresponding to the supplied tsconfig paths */ export function calculateProjectParserOptions( code: string, @@ -187,9 +182,9 @@ export function calculateProjectParserOptions( * Create program from single root file. Requires a single tsconfig to be specified. * @param code The code being linted * @param filePath The file being linted - * @param {string} extra.tsconfigRootDir The root directory for relative tsconfig paths - * @param {string[]} extra.project Provided tsconfig paths - * @returns {ts.Program} The program containing just the file being linted and associated library files + * @param extra.tsconfigRootDir The root directory for relative tsconfig paths + * @param extra.project Provided tsconfig paths + * @returns The program containing just the file being linted and associated library files */ export function createProgram(code: string, filePath: string, extra: Extra) { if (!extra.projects || extra.projects.length !== 1) { diff --git a/packages/typescript-estree/src/typedefs.ts b/packages/typescript-estree/src/typedefs.ts new file mode 100644 index 000000000000..140ed6e09a49 --- /dev/null +++ b/packages/typescript-estree/src/typedefs.ts @@ -0,0 +1,1409 @@ +import { AST_NODE_TYPES } from './ast-node-types'; + +export interface LineAndColumnData { + /** + * Line number (1-indexed) + */ + line: number; + /** + * Column number on the line (0-indexed) + */ + column: number; +} +export interface SourceLocation { + /** + * The position of the first character of the parsed source region + */ + start: LineAndColumnData; + /** + * The position of the first character after the parsed source region + */ + end: LineAndColumnData; +} + +export interface BaseNode { + /** + * The source location information of the node. + */ + loc: SourceLocation; + /** + * An array of two numbers. + * Both numbers are a 0-based index which is the position in the array of source code characters. + * The first is the start position of the node, the second is the end position of the node. + */ + range: [number, number]; + /** + * The parent node of the current node + */ + parent?: Node; + + // every node *will* have a type, but let the nodes define their own exact string + // type: string; + + // we don't ever set this from within ts-estree + // source?: string | null; +} + +/* + * Token and Comment are pseudo-nodes to represent pieces of source code + * + * NOTE: + * They are not included in the `Node` union below on purpose because they + * are not ever included as part of the standard AST tree. + */ + +export type TokenType = + | 'Boolean' + | 'Identifier' + | 'JSXIdentifier' + | 'JSXMemberExpression' + | 'JSXText' + | 'Keyword' + | 'Null' + | 'Numeric' + | 'Punctuator' + | 'RegularExpression' + | 'String' + | 'Template'; + +export interface Token extends BaseNode { + type: TokenType; + value: string; + regex?: { + pattern: string; + flags: string; + }; +} +export interface Comment extends BaseNode { + type: 'Line' | 'Block'; + value: string; +} + +export type OptionalRangeAndLoc = Pick< + T, + Exclude +> & { + range?: [number, number]; + loc?: SourceLocation; +}; + +// Every single valid AST Node +// Please keep it sorted alphabetically. +export type Node = + | ArrayExpression + | ArrayPattern + | ArrowFunctionExpression + | AssignmentExpression + | AssignmentPattern + | AwaitExpression + | BigIntLiteral + | BinaryExpression + | BlockStatement + | BreakStatement + | CallExpression + | CatchClause + | ClassBody + | ClassDeclaration + | ClassExpression + | ClassProperty + | ConditionalExpression + | ContinueStatement + | DebuggerStatement + | Decorator + | DoWhileStatement + | EmptyStatement + | ExportAllDeclaration + | ExportDefaultDeclaration + | ExportNamedDeclaration + | ExportSpecifier + | ExpressionStatement + | ForInStatement + | ForOfStatement + | ForStatement + | FunctionDeclaration + | FunctionExpression + | Identifier + | IfStatement + | Import + | ImportDeclaration + | ImportDefaultSpecifier + | ImportNamespaceSpecifier + | ImportSpecifier + | JSXAttribute + | JSXClosingElement + | JSXClosingFragment + | JSXElement + | JSXEmptyExpression + | JSXExpressionContainer + | JSXFragment + | JSXIdentifier + | JSXOpeningElement + | JSXOpeningFragment + | JSXSpreadAttribute + | JSXSpreadChild + | JSXText + | LabeledStatement + | Literal + | LogicalExpression + | MemberExpression + | MetaProperty + | MethodDefinition + | NewExpression + | ObjectExpression + | ObjectPattern + | Program + | Property + | RestElement + | ReturnStatement + | SequenceExpression + | SpreadElement + | Super + | SwitchCase + | SwitchStatement + | TaggedTemplateExpression + | TemplateElement + | TemplateLiteral + | ThisExpression + | ThrowStatement + | TryStatement + | TSAbstractClassProperty + | TSAbstractKeyword + | TSAbstractMethodDefinition + | TSAnyKeyword + | TSArrayType + | TSAsExpression + | TSAsyncKeyword + | TSBigIntKeyword + | TSBooleanKeyword + | TSCallSignatureDeclaration + | TSClassImplements + | TSConditionalType + | TSConstructorType + | TSConstructSignatureDeclaration + | TSDeclareFunction + | TSDeclareKeyword + | TSEnumDeclaration + | TSEnumMember + | TSExportAssignment + | TSExportKeyword + | TSExternalModuleReference + | TSFunctionType + | TSImportEqualsDeclaration + | TSImportType + | TSIndexedAccessType + | TSIndexSignature + | TSInferType + | TSInterfaceDeclaration + | TSInterfaceBody + | TSInterfaceHeritage + | TSIntersectionType + | TSLiteralType + | TSMappedType + | TSMethodSignature + | TSModuleBlock + | TSModuleDeclaration + | TSNamespaceExportDeclaration + | TSNeverKeyword + | TSNonNullExpression + | TSNullKeyword + | TSNumberKeyword + | TSObjectKeyword + | TSOptionalType + | TSParameterProperty + | TSParenthesizedType + | TSPropertySignature + | TSPublicKeyword + | TSPrivateKeyword + | TSProtectedKeyword + | TSQualifiedName + | TSReadonlyKeyword + | TSRestType + | TSStaticKeyword + | TSStringKeyword + | TSSymbolKeyword + | TSThisType + | TSTupleType + | TSTypeAliasDeclaration + | TSTypeAnnotation + | TSTypeAssertion + | TSTypeLiteral + | TSTypeOperator + | TSTypeParameter + | TSTypeParameterDeclaration + | TSTypeParameterInstantiation + | TSTypePredicate + | TSTypeQuery + | TSTypeReference + | TSUndefinedKeyword + | TSUnionType + | TSUnknownKeyword + | TSVoidKeyword + | UpdateExpression + | UnaryExpression + | VariableDeclaration + | VariableDeclarator + | WhileStatement + | WithStatement + | YieldExpression; + +////////// +// Reusable Unions +// These are based off of types used in the Typescript AST definitions +// **Ensure you sort the union members alphabetically** +////////// + +export type Accessibility = 'public' | 'protected' | 'private'; +export type BindingPattern = ArrayPattern | ObjectPattern; +export type BindingName = BindingPattern | Identifier; +export type ClassElement = + | ClassProperty + | FunctionExpression + | MethodDefinition + | TSAbstractClassProperty + | TSAbstractMethodDefinition + | TSIndexSignature; +export type DeclarationStatement = + | ClassDeclaration + | ClassExpression + | ExportAllDeclaration + | ExportNamedDeclaration + | FunctionDeclaration + | TSDeclareFunction + | TSImportEqualsDeclaration + | TSInterfaceDeclaration + | TSModuleDeclaration + | TSNamespaceExportDeclaration + | TSTypeAliasDeclaration + | TSEnumDeclaration; +export type EntityName = Identifier | TSQualifiedName; +export type ExportDeclaration = + | ClassDeclaration + | ClassExpression + | FunctionDeclaration + | TSDeclareFunction + | TSEnumDeclaration + | TSInterfaceDeclaration + | TSModuleDeclaration + | TSTypeAliasDeclaration + | VariableDeclarator; +export type Expression = + | ArrowFunctionExpression + | AssignmentExpression + | BinaryExpression + | ConditionalExpression + | JSXClosingElement + | JSXClosingFragment + | JSXExpressionContainer + | JSXOpeningElement + | JSXOpeningFragment + | JSXSpreadChild + | LogicalExpression + | RestElement + | SequenceExpression + | SpreadElement + | TSAsExpression + | TSUnaryExpression + | YieldExpression; +export type ExpressionWithTypeArguments = + | TSClassImplements + | TSInterfaceHeritage; +export type ForInitialiser = Expression | VariableDeclaration; +export type ImportClause = + | ImportDefaultSpecifier + | ImportNamespaceSpecifier + | ImportSpecifier; +export type IterationStatement = + | DoWhileStatement + | ForInStatement + | ForOfStatement + | ForStatement + | WhileStatement; +export type JSXChild = JSXElement | JSXExpression | JSXFragment | JSXText; +export type JSXExpression = + | JSXEmptyExpression + | JSXSpreadChild + | JSXExpressionContainer; +export type JSXTagNameExpression = JSXIdentifier | JSXMemberExpression; +export type LeftHandSideExpression = + | CallExpression + | ClassExpression + | ClassDeclaration + | FunctionExpression + | LiteralExpression + | MemberExpression + | PrimaryExpression + | TaggedTemplateExpression + | TSNonNullExpression; +export type LiteralExpression = BigIntLiteral | Literal | TemplateLiteral; +export type Modifier = + | TSAbstractKeyword + | TSAsyncKeyword + | TSDeclareKeyword + | TSExportKeyword + | TSPublicKeyword + | TSPrivateKeyword + | TSProtectedKeyword + | TSReadonlyKeyword + | TSStaticKeyword; +export type ObjectLiteralElementLike = + | MethodDefinition + | Property + | RestElement + | SpreadElement + | TSAbstractMethodDefinition; +export type Parameter = AssignmentPattern | RestElement | TSParameterProperty; +export type PrimaryExpression = + | ArrayExpression + | ArrayPattern + | ClassExpression + | FunctionExpression + | Identifier + | Import + | JSXElement + | JSXFragment + | JSXOpeningElement + | Literal + | LiteralExpression + | MetaProperty + | ObjectExpression + | ObjectPattern + | Super + | TemplateLiteral + | ThisExpression + | TSNullKeyword; +export type PropertyName = Identifier | Literal; +export type Statement = + | BlockStatement + | BreakStatement + | ContinueStatement + | DebuggerStatement + | DeclarationStatement + | EmptyStatement + | ExpressionStatement + | IfStatement + | IterationStatement + | ImportDeclaration + | LabeledStatement + | TSModuleBlock + | ReturnStatement + | SwitchStatement + | ThrowStatement + | TryStatement + | VariableDeclaration + | WithStatement; +export type TypeElement = + | TSCallSignatureDeclaration + | TSConstructSignatureDeclaration + | TSIndexSignature + | TSMethodSignature + | TSPropertySignature; +export type TypeNode = + | ThisExpression + | TSAnyKeyword + | TSArrayType + | TSBigIntKeyword + | TSBooleanKeyword + | TSClassImplements + | TSConditionalType + | TSConstructorType + | TSFunctionType + | TSImportType + | TSIndexedAccessType + | TSInferType + | TSInterfaceHeritage + | TSIntersectionType + | TSLiteralType + | TSMappedType + | TSNeverKeyword + | TSNullKeyword + | TSNumberKeyword + | TSObjectKeyword + | TSOptionalType + | TSParenthesizedType + | TSRestType + | TSStringKeyword + | TSSymbolKeyword + | TSThisType + | TSTupleType + | TSTypeLiteral + | TSTypeOperator + | TSTypeReference + | TSTypePredicate + | TSTypeQuery + | TSUndefinedKeyword + | TSUnionType + | TSUnknownKeyword + | TSVoidKeyword; +export type TSUnaryExpression = + | AwaitExpression + | LeftHandSideExpression + | TSTypeAssertion + | UnaryExpression + | UpdateExpression; + +/////////////// +// Base, common types +// **Ensure you sort the interfaces alphabetically** +/////////////// + +interface BinaryExpressionBase extends BaseNode { + operator: string; + left: Expression; + right: Expression; +} + +interface ClassDeclarationBase extends BaseNode { + typeParameters?: TSTypeParameterDeclaration; + superTypeParameters?: TSTypeParameterInstantiation; + id?: Identifier; + body: ClassBody; + superClass?: LeftHandSideExpression; + implements?: ExpressionWithTypeArguments[]; + abstract?: boolean; + declare?: boolean; + decorators?: Decorator[]; +} + +interface ClassPropertyBase extends BaseNode { + key: PropertyName; + value: Expression; + computed: boolean; + static: boolean; + readonly?: boolean; + decorators?: Decorator[]; + accessibility?: Accessibility; + optional?: boolean; + definite?: boolean; + typeAnnotation?: TSTypeAnnotation; +} + +interface FunctionDeclarationBase extends BaseNode { + id: Identifier | null; + generator: boolean; + expression: boolean; + async: boolean; + params: Parameter[]; + body?: BlockStatement | null; + returnType?: TSTypeAnnotation; + typeParameters?: TSTypeParameterDeclaration; + declare?: boolean; +} + +interface FunctionSignatureBase extends BaseNode { + params: Parameter[]; + returnType?: TSTypeAnnotation; + typeParameters?: TSTypeParameterDeclaration; +} + +interface LiteralBase extends BaseNode { + raw: string; + value: boolean | number | RegExp | string | null; + regex?: { + pattern: string; + flags: string; + }; +} + +interface MethodDefinitionBase extends BaseNode { + key: PropertyName; + value: FunctionExpression; + computed: boolean; + static: boolean; + kind: 'method' | 'get' | 'set' | 'constructor'; + decorators?: Decorator[]; + accessibility?: Accessibility; + typeParameters?: TSTypeParameterDeclaration; +} + +interface TSHeritageBase extends BaseNode { + expression: Expression; + typeParameters?: TSTypeParameterInstantiation; +} + +interface UnaryExpressionBase extends BaseNode { + operator: string; + prefix: boolean; + argument: LeftHandSideExpression | Literal | UnaryExpression; +} + +/////////////// +// Typescript ESTree Nodes +// **Ensure you sort the interfaces alphabetically** +/////////////// + +export interface ArrayExpression extends BaseNode { + type: AST_NODE_TYPES.ArrayExpression; + elements: Expression[]; +} + +export interface ArrayPattern extends BaseNode { + type: AST_NODE_TYPES.ArrayPattern; + elements: Expression[]; + typeAnnotation?: TSTypeAnnotation; + optional?: boolean; +} + +export interface ArrowFunctionExpression extends BaseNode { + type: AST_NODE_TYPES.ArrowFunctionExpression; + generator: boolean; + id: null; + params: Parameter[]; + body: Expression | BlockStatement; + async: boolean; + expression: boolean; + returnType?: TSTypeAnnotation; + typeParameters?: TSTypeParameterDeclaration; +} + +export interface AssignmentExpression extends BinaryExpressionBase { + type: AST_NODE_TYPES.AssignmentExpression; +} + +export interface AssignmentPattern extends BaseNode { + type: AST_NODE_TYPES.AssignmentPattern; + left: BindingName; + right?: Expression; + typeAnnotation?: TSTypeAnnotation; + optional?: boolean; +} + +export interface AwaitExpression extends BaseNode { + type: AST_NODE_TYPES.AwaitExpression; + argument: TSUnaryExpression; +} + +export interface BigIntLiteral extends LiteralBase { + type: AST_NODE_TYPES.BigIntLiteral; +} + +export interface BinaryExpression extends BinaryExpressionBase { + type: AST_NODE_TYPES.BinaryExpression; +} + +export interface BlockStatement extends BaseNode { + type: AST_NODE_TYPES.BlockStatement; + body: Statement[]; +} + +export interface BreakStatement extends BaseNode { + type: AST_NODE_TYPES.BreakStatement; + label: Identifier | null; +} + +export interface CallExpression extends BaseNode { + type: AST_NODE_TYPES.CallExpression; + callee: LeftHandSideExpression; + arguments: Expression[]; + typeParameters?: TSTypeParameterInstantiation; +} + +export interface CatchClause extends BaseNode { + type: AST_NODE_TYPES.CatchClause; + param: BindingName | null; + body: BlockStatement; +} + +export interface ClassBody extends BaseNode { + type: AST_NODE_TYPES.ClassBody; + body: ClassElement[]; +} + +export interface ClassDeclaration extends ClassDeclarationBase { + type: AST_NODE_TYPES.ClassDeclaration; +} + +export interface ClassExpression extends ClassDeclarationBase { + type: AST_NODE_TYPES.ClassExpression; +} + +export interface ClassProperty extends ClassPropertyBase { + type: AST_NODE_TYPES.ClassProperty; +} + +export interface ConditionalExpression extends BaseNode { + type: AST_NODE_TYPES.ConditionalExpression; + test: Expression; + consequent: Expression; + alternate: Expression; +} + +export interface ContinueStatement extends BaseNode { + type: AST_NODE_TYPES.ContinueStatement; + label: Identifier | null; +} + +export interface DebuggerStatement extends BaseNode { + type: AST_NODE_TYPES.DebuggerStatement; +} + +export interface Decorator extends BaseNode { + type: AST_NODE_TYPES.Decorator; + expression: LeftHandSideExpression; +} + +export interface DoWhileStatement extends BaseNode { + type: AST_NODE_TYPES.DoWhileStatement; + test: Expression; + body: Statement; +} + +export interface EmptyStatement extends BaseNode { + type: AST_NODE_TYPES.EmptyStatement; +} + +export interface ExportAllDeclaration extends BaseNode { + type: AST_NODE_TYPES.ExportAllDeclaration; + source: Expression | null; +} + +export interface ExportDefaultDeclaration extends BaseNode { + type: AST_NODE_TYPES.ExportDefaultDeclaration; + declaration: ExportDeclaration; +} + +export interface ExportNamedDeclaration extends BaseNode { + type: AST_NODE_TYPES.ExportNamedDeclaration; + declaration: ExportDeclaration | null; + specifiers: ExportSpecifier[]; + source: Expression | null; +} + +export interface ExportSpecifier extends BaseNode { + type: AST_NODE_TYPES.ExportSpecifier; + local: Identifier; + exported: Identifier; +} + +export interface ExpressionStatement extends BaseNode { + type: AST_NODE_TYPES.ExpressionStatement; + expression: Expression; +} + +export interface ForInStatement extends BaseNode { + type: AST_NODE_TYPES.ForInStatement; + left: ForInitialiser; + right: Expression; + body: Statement; +} + +export interface ForOfStatement extends BaseNode { + type: AST_NODE_TYPES.ForOfStatement; + left: ForInitialiser; + right: Expression; + body: Statement; + await: boolean; +} + +export interface ForStatement extends BaseNode { + type: AST_NODE_TYPES.ForStatement; + init: Expression | ForInitialiser | null; + test: Expression | null; + update: Expression | null; + body: Statement; +} + +export interface FunctionDeclaration extends FunctionDeclarationBase { + type: AST_NODE_TYPES.FunctionDeclaration; +} + +export interface FunctionExpression extends FunctionDeclarationBase { + type: AST_NODE_TYPES.FunctionExpression; +} + +export interface Identifier extends BaseNode { + type: AST_NODE_TYPES.Identifier; + name: string; + typeAnnotation?: TSTypeAnnotation; + optional?: boolean; +} + +export interface IfStatement extends BaseNode { + type: AST_NODE_TYPES.IfStatement; + test: Expression; + consequent: Statement; + alternate: Statement | null; +} + +export interface Import extends BaseNode { + type: AST_NODE_TYPES.Import; +} + +export interface ImportDeclaration extends BaseNode { + type: AST_NODE_TYPES.ImportDeclaration; + source: Expression; + specifiers: ImportClause[]; +} + +export interface ImportDefaultSpecifier extends BaseNode { + type: AST_NODE_TYPES.ImportDefaultSpecifier; + local: Identifier; +} + +export interface ImportNamespaceSpecifier extends BaseNode { + type: AST_NODE_TYPES.ImportNamespaceSpecifier; + local: Identifier; +} + +export interface ImportSpecifier extends BaseNode { + type: AST_NODE_TYPES.ImportSpecifier; + local: Identifier; + imported: Identifier; +} + +export interface JSXAttribute extends BaseNode { + type: AST_NODE_TYPES.JSXAttribute; + name: JSXIdentifier; + value: Literal | JSXExpression | null; +} + +export interface JSXClosingElement extends BaseNode { + type: AST_NODE_TYPES.JSXClosingElement; + name: JSXTagNameExpression; +} + +export interface JSXClosingFragment extends BaseNode { + type: AST_NODE_TYPES.JSXClosingFragment; +} + +export interface JSXElement extends BaseNode { + type: AST_NODE_TYPES.JSXElement; + openingElement: JSXOpeningElement; + closingElement: JSXClosingElement | null; + children: JSXChild[]; +} + +export interface JSXEmptyExpression extends BaseNode { + type: AST_NODE_TYPES.JSXEmptyExpression; +} + +export interface JSXExpressionContainer extends BaseNode { + type: AST_NODE_TYPES.JSXExpressionContainer; + expression: Expression | JSXEmptyExpression; +} + +export interface JSXFragment extends BaseNode { + type: AST_NODE_TYPES.JSXFragment; + openingFragment: JSXOpeningFragment; + closingFragment: JSXClosingFragment; + children: JSXChild[]; +} + +export interface JSXIdentifier extends BaseNode { + type: AST_NODE_TYPES.JSXIdentifier; + name: string; +} + +export interface JSXMemberExpression extends BaseNode { + type: AST_NODE_TYPES.JSXMemberExpression; + object: JSXTagNameExpression; + property: JSXIdentifier; +} + +export interface JSXOpeningElement extends BaseNode { + type: AST_NODE_TYPES.JSXOpeningElement; + typeParameters?: TSTypeParameterInstantiation; + selfClosing: boolean; + name: JSXTagNameExpression; + attributes: JSXAttribute[]; +} + +export interface JSXOpeningFragment extends BaseNode { + type: AST_NODE_TYPES.JSXOpeningFragment; +} + +export interface JSXSpreadAttribute extends BaseNode { + type: AST_NODE_TYPES.JSXSpreadAttribute; + argument: Expression; +} + +export interface JSXSpreadChild extends BaseNode { + type: AST_NODE_TYPES.JSXSpreadChild; + expression: Expression | JSXEmptyExpression; +} + +export interface JSXText extends BaseNode { + type: AST_NODE_TYPES.JSXText; + value: string; + raw: string; +} + +export interface LabeledStatement extends BaseNode { + type: AST_NODE_TYPES.LabeledStatement; + label: Identifier; + body: Statement; +} + +export interface Literal extends LiteralBase { + type: AST_NODE_TYPES.Literal; +} + +export interface LogicalExpression extends BinaryExpressionBase { + type: AST_NODE_TYPES.LogicalExpression; +} + +export interface MemberExpression extends BaseNode { + type: AST_NODE_TYPES.MemberExpression; + object: LeftHandSideExpression; + property: Expression | Identifier; + computed?: boolean; +} + +export interface MetaProperty extends BaseNode { + type: AST_NODE_TYPES.MetaProperty; + meta: Identifier; + property: Identifier; +} + +export interface MethodDefinition extends MethodDefinitionBase { + type: AST_NODE_TYPES.MethodDefinition; +} + +export interface NewExpression extends BaseNode { + type: AST_NODE_TYPES.NewExpression; + callee: LeftHandSideExpression; + arguments: Expression[]; + typeParameters?: TSTypeParameterInstantiation; +} + +export interface ObjectExpression extends BaseNode { + type: AST_NODE_TYPES.ObjectExpression; + properties: ObjectLiteralElementLike[]; +} + +export interface ObjectPattern extends BaseNode { + type: AST_NODE_TYPES.ObjectPattern; + properties: ObjectLiteralElementLike[]; + typeAnnotation?: TSTypeAnnotation; + optional?: boolean; +} + +export interface Program extends BaseNode { + type: AST_NODE_TYPES.Program; + body: Statement[]; + sourceType: 'module' | 'script'; + comments?: Comment[]; + tokens?: Token[]; +} + +export interface Property extends BaseNode { + type: AST_NODE_TYPES.Property; + key: PropertyName; + value: Expression | AssignmentPattern | BindingName; + computed: boolean; + method: boolean; + shorthand: boolean; + kind: 'init'; + typeParameters?: TSTypeParameterDeclaration; +} + +export interface RestElement extends BaseNode { + type: AST_NODE_TYPES.RestElement; + argument: BindingName | Expression | PropertyName; + typeAnnotation?: TSTypeAnnotation; + optional?: boolean; + value?: AssignmentPattern; +} + +export interface ReturnStatement extends BaseNode { + type: AST_NODE_TYPES.ReturnStatement; + argument: Expression | null; +} + +export interface SequenceExpression extends BaseNode { + type: AST_NODE_TYPES.SequenceExpression; + expressions: Expression[]; +} + +export interface SpreadElement extends BaseNode { + type: AST_NODE_TYPES.SpreadElement; + argument: BindingName | Expression | PropertyName; +} + +export interface Super extends BaseNode { + type: AST_NODE_TYPES.Super; +} + +export interface SwitchCase extends BaseNode { + type: AST_NODE_TYPES.SwitchCase; + test: Expression; + consequent: Statement[]; +} + +export interface SwitchStatement extends BaseNode { + type: AST_NODE_TYPES.SwitchStatement; + discriminant: Expression; + cases: SwitchCase[]; +} + +export interface TaggedTemplateExpression extends BaseNode { + type: AST_NODE_TYPES.TaggedTemplateExpression; + typeParameters?: TSTypeParameterInstantiation; + tag: LeftHandSideExpression; + quasi: TemplateLiteral; +} + +export interface TemplateElement extends BaseNode { + type: AST_NODE_TYPES.TemplateElement; + value: { + raw: string; + cooked: string; + }; + tail: boolean; +} + +export interface TemplateLiteral extends BaseNode { + type: AST_NODE_TYPES.TemplateLiteral; + quasis: TemplateElement[]; + expressions: Expression[]; +} + +export interface ThisExpression extends BaseNode { + type: AST_NODE_TYPES.ThisExpression; +} + +export interface ThrowStatement extends BaseNode { + type: AST_NODE_TYPES.ThrowStatement; + argument: Statement | null; +} + +export interface TryStatement extends BaseNode { + type: AST_NODE_TYPES.TryStatement; + block: BlockStatement; + handler: CatchClause | null; + finalizer: BlockStatement; +} + +export interface TSAbstractClassProperty extends ClassPropertyBase { + type: AST_NODE_TYPES.TSAbstractClassProperty; +} + +export interface TSAbstractKeyword extends BaseNode { + type: AST_NODE_TYPES.TSAbstractKeyword; +} + +export interface TSAbstractMethodDefinition extends MethodDefinitionBase { + type: AST_NODE_TYPES.TSAbstractMethodDefinition; +} + +export interface TSAnyKeyword extends BaseNode { + type: AST_NODE_TYPES.TSAnyKeyword; +} + +export interface TSArrayType extends BaseNode { + type: AST_NODE_TYPES.TSArrayType; + elementType: TypeNode; +} + +export interface TSAsExpression extends BaseNode { + type: AST_NODE_TYPES.TSAsExpression; + expression: Expression; + typeAnnotation: TypeNode; +} + +export interface TSAsyncKeyword extends BaseNode { + type: AST_NODE_TYPES.TSAsyncKeyword; +} + +export interface TSBigIntKeyword extends BaseNode { + type: AST_NODE_TYPES.TSBigIntKeyword; +} + +export interface TSBooleanKeyword extends BaseNode { + type: AST_NODE_TYPES.TSBooleanKeyword; +} + +export interface TSCallSignatureDeclaration extends FunctionSignatureBase { + type: AST_NODE_TYPES.TSCallSignatureDeclaration; +} + +export interface TSClassImplements extends TSHeritageBase { + type: AST_NODE_TYPES.TSClassImplements; +} + +export interface TSConditionalType extends BaseNode { + type: AST_NODE_TYPES.TSConditionalType; + checkType: TypeNode; + extendsType: TypeNode; + trueType: TypeNode; + falseType: TypeNode; +} + +export interface TSConstructorType extends FunctionSignatureBase { + type: AST_NODE_TYPES.TSConstructorType; +} + +export interface TSConstructSignatureDeclaration extends FunctionSignatureBase { + type: AST_NODE_TYPES.TSConstructSignatureDeclaration; +} + +export interface TSDeclareFunction extends FunctionDeclarationBase { + type: AST_NODE_TYPES.TSDeclareFunction; +} + +export interface TSDeclareKeyword extends BaseNode { + type: AST_NODE_TYPES.TSDeclareKeyword; +} + +export interface TSEnumDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSEnumDeclaration; + id: Identifier; + members: TSEnumMember[]; + const?: boolean; + declare?: boolean; + modifiers?: Modifier[]; + decorators?: Decorator[]; +} + +export interface TSEnumMember extends BaseNode { + type: AST_NODE_TYPES.TSEnumMember; + id: PropertyName; + initializer?: Expression; +} + +export interface TSExportAssignment extends BaseNode { + type: AST_NODE_TYPES.TSExportAssignment; + expression: Expression; +} + +export interface TSExportKeyword extends BaseNode { + type: AST_NODE_TYPES.TSExportKeyword; +} + +export interface TSExternalModuleReference extends BaseNode { + type: AST_NODE_TYPES.TSExternalModuleReference; + expression: Expression; +} + +export interface TSFunctionType extends FunctionSignatureBase { + type: AST_NODE_TYPES.TSFunctionType; +} + +export interface TSImportEqualsDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSImportEqualsDeclaration; + id: Identifier; + moduleReference: EntityName | TSExternalModuleReference; + isExport: boolean; +} + +export interface TSImportType extends BaseNode { + type: AST_NODE_TYPES.TSImportType; + isTypeOf: boolean; + parameter: TypeNode; + qualifier: EntityName | null; + typeParameters: TSTypeParameterInstantiation | null; +} + +export interface TSIndexedAccessType extends BaseNode { + type: AST_NODE_TYPES.TSIndexedAccessType; + objectType: TypeNode; + indexType: TypeNode; +} + +export interface TSIndexSignature extends BaseNode { + type: AST_NODE_TYPES.TSIndexSignature; + parameters: Parameter[]; + typeAnnotation?: TSTypeAnnotation; + readonly?: boolean; + accessibility?: Accessibility; + export?: boolean; + static?: boolean; +} + +export interface TSInferType extends BaseNode { + type: AST_NODE_TYPES.TSInferType; + typeParameter: TSTypeParameterDeclaration; +} + +export interface TSInterfaceDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSInterfaceDeclaration; + body: TSInterfaceBody; + id: Identifier; + typeParameters?: TSTypeParameterDeclaration; + extends?: ExpressionWithTypeArguments[]; + implements?: ExpressionWithTypeArguments[]; + decorators?: Decorator[]; + abstract?: boolean; + declare?: boolean; +} + +export interface TSInterfaceBody extends BaseNode { + type: AST_NODE_TYPES.TSInterfaceBody; + body: TypeElement[]; +} + +export interface TSInterfaceHeritage extends TSHeritageBase { + type: AST_NODE_TYPES.TSInterfaceHeritage; +} + +export interface TSIntersectionType extends BaseNode { + type: AST_NODE_TYPES.TSIntersectionType; + types: TypeNode[]; +} + +export interface TSLiteralType extends BaseNode { + type: AST_NODE_TYPES.TSLiteralType; + literal: LiteralExpression | UnaryExpression | UpdateExpression; +} + +export interface TSMappedType extends BaseNode { + type: AST_NODE_TYPES.TSMappedType; + typeParameter: TSTypeParameterDeclaration; + readonly?: boolean | '-' | '+'; + optional?: boolean | '-' | '+'; + typeAnnotation?: TypeNode; +} + +export interface TSMethodSignature extends BaseNode { + type: AST_NODE_TYPES.TSMethodSignature; + computed: boolean; + key: PropertyName; + params: Parameter[]; + optional?: boolean; + returnType?: TSTypeAnnotation; + readonly?: boolean; + typeParameters?: TSTypeParameterDeclaration; + accessibility?: Accessibility; + export?: boolean; + static?: boolean; +} + +export interface TSModuleBlock extends BaseNode { + type: AST_NODE_TYPES.TSModuleBlock; + body: Statement[]; +} + +export interface TSModuleDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSModuleDeclaration; + id: Identifier | Literal; + body?: TSModuleBlock | Identifier; + global?: boolean; + declare?: boolean; + modifiers?: Modifier[]; +} + +export interface TSNamespaceExportDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSNamespaceExportDeclaration; + id: Identifier; +} + +export interface TSNeverKeyword extends BaseNode { + type: AST_NODE_TYPES.TSNeverKeyword; +} + +export interface TSNonNullExpression extends BaseNode { + type: AST_NODE_TYPES.TSNonNullExpression; + expression: Expression; +} + +export interface TSNullKeyword extends BaseNode { + type: AST_NODE_TYPES.TSNullKeyword; +} + +export interface TSNumberKeyword extends BaseNode { + type: AST_NODE_TYPES.TSNumberKeyword; +} + +export interface TSObjectKeyword extends BaseNode { + type: AST_NODE_TYPES.TSObjectKeyword; +} + +export interface TSOptionalType extends BaseNode { + type: AST_NODE_TYPES.TSOptionalType; + typeAnnotation: TypeNode; +} + +export interface TSParameterProperty extends BaseNode { + type: AST_NODE_TYPES.TSParameterProperty; + accessibility?: Accessibility; + readonly?: boolean; + static?: boolean; + export?: boolean; + parameter: AssignmentPattern | BindingName | RestElement; +} + +export interface TSParenthesizedType extends BaseNode { + type: AST_NODE_TYPES.TSParenthesizedType; + typeAnnotation: TypeNode; +} + +export interface TSPropertySignature extends BaseNode { + type: AST_NODE_TYPES.TSPropertySignature; + optional?: boolean; + computed: boolean; + key: PropertyName; + typeAnnotation?: TSTypeAnnotation; + initializer?: Expression; + readonly?: boolean; + static?: boolean; + export?: boolean; + accessibility?: Accessibility; +} + +export interface TSPublicKeyword extends BaseNode { + type: AST_NODE_TYPES.TSPublicKeyword; +} + +export interface TSPrivateKeyword extends BaseNode { + type: AST_NODE_TYPES.TSPrivateKeyword; +} + +export interface TSProtectedKeyword extends BaseNode { + type: AST_NODE_TYPES.TSProtectedKeyword; +} + +export interface TSQualifiedName extends BaseNode { + type: AST_NODE_TYPES.TSQualifiedName; + left: EntityName; + right: Identifier; +} + +export interface TSReadonlyKeyword extends BaseNode { + type: AST_NODE_TYPES.TSReadonlyKeyword; +} + +export interface TSRestType extends BaseNode { + type: AST_NODE_TYPES.TSRestType; + typeAnnotation: TypeNode; +} + +export interface TSStaticKeyword extends BaseNode { + type: AST_NODE_TYPES.TSStaticKeyword; +} + +export interface TSStringKeyword extends BaseNode { + type: AST_NODE_TYPES.TSStringKeyword; +} + +export interface TSSymbolKeyword extends BaseNode { + type: AST_NODE_TYPES.TSSymbolKeyword; +} + +export interface TSThisType extends BaseNode { + type: AST_NODE_TYPES.TSThisType; +} + +export interface TSTupleType extends BaseNode { + type: AST_NODE_TYPES.TSTupleType; + elementTypes: TypeNode[]; +} + +export interface TSTypeAliasDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSTypeAliasDeclaration; + id: Identifier; + typeAnnotation: TypeNode; + declare?: boolean; + typeParameters?: TSTypeParameterDeclaration; +} + +export interface TSTypeAnnotation extends BaseNode { + type: AST_NODE_TYPES.TSTypeAnnotation; + typeAnnotation: TypeNode; +} + +export interface TSTypeAssertion extends BaseNode { + type: AST_NODE_TYPES.TSTypeAssertion; + typeAnnotation: TypeNode; + expression: UnaryExpression; +} + +export interface TSTypeLiteral extends BaseNode { + type: AST_NODE_TYPES.TSTypeLiteral; + members: TypeElement[]; +} + +export interface TSTypeOperator extends BaseNode { + type: AST_NODE_TYPES.TSTypeOperator; + operator: 'keyof' | 'unique'; + typeAnnotation?: TSTypeAnnotation; +} + +export interface TSTypeParameter extends BaseNode { + type: AST_NODE_TYPES.TSTypeParameter; + name: Identifier; + constraint?: TypeNode; + default?: TypeNode; +} + +export interface TSTypeParameterDeclaration extends BaseNode { + type: AST_NODE_TYPES.TSTypeParameterDeclaration; + params: TSTypeParameter[]; +} + +export interface TSTypeParameterInstantiation extends BaseNode { + type: AST_NODE_TYPES.TSTypeParameterInstantiation; + params: TypeNode[]; +} + +export interface TSTypePredicate extends BaseNode { + type: AST_NODE_TYPES.TSTypePredicate; + parameterName: Identifier | TSThisType; + typeAnnotation: TSTypeAnnotation; +} + +export interface TSTypeQuery extends BaseNode { + type: AST_NODE_TYPES.TSTypeQuery; + exprName: EntityName; +} + +export interface TSTypeReference extends BaseNode { + type: AST_NODE_TYPES.TSTypeReference; + typeName: EntityName; + typeParameters?: TSTypeParameterInstantiation; +} + +export interface TSUndefinedKeyword extends BaseNode { + type: AST_NODE_TYPES.TSUndefinedKeyword; +} + +export interface TSUnionType extends BaseNode { + type: AST_NODE_TYPES.TSUnionType; + types: TypeNode[]; +} + +export interface TSUnknownKeyword extends BaseNode { + type: AST_NODE_TYPES.TSUnknownKeyword; +} + +export interface TSVoidKeyword extends BaseNode { + type: AST_NODE_TYPES.TSVoidKeyword; +} + +export interface UpdateExpression extends UnaryExpressionBase { + type: AST_NODE_TYPES.UpdateExpression; +} + +export interface UnaryExpression extends UnaryExpressionBase { + type: AST_NODE_TYPES.UnaryExpression; +} + +export interface VariableDeclaration extends BaseNode { + type: AST_NODE_TYPES.VariableDeclaration; + declarations: VariableDeclarator[]; + kind: 'let' | 'const' | 'var'; + declare?: boolean; +} + +export interface VariableDeclarator extends BaseNode { + type: AST_NODE_TYPES.VariableDeclarator; + id: BindingName; + init: Expression | null; + definite?: boolean; +} + +export interface WhileStatement extends BaseNode { + type: AST_NODE_TYPES.WhileStatement; + test: Expression; + body: Statement; +} + +export interface WithStatement extends BaseNode { + type: AST_NODE_TYPES.WithStatement; + object: Expression; + body: Statement; +} + +export interface YieldExpression extends BaseNode { + type: AST_NODE_TYPES.YieldExpression; + delegate: boolean; + argument?: Expression; +} diff --git a/packages/typescript-estree/tests/lib/comments.ts b/packages/typescript-estree/tests/lib/comments.ts index e469c39f00ef..1d02e2fa6715 100644 --- a/packages/typescript-estree/tests/lib/comments.ts +++ b/packages/typescript-estree/tests/lib/comments.ts @@ -8,7 +8,7 @@ import { readFileSync } from 'fs'; import glob from 'glob'; import { extname } from 'path'; -import { ParserOptions } from '../../src/temp-types-based-on-js-source'; +import { ParserOptions } from '../../src/parser-options'; import { createSnapshotTestBlock, formatSnapshotName diff --git a/packages/typescript-estree/tests/lib/javascript.ts b/packages/typescript-estree/tests/lib/javascript.ts index aca646998b3b..d254f8fd612c 100644 --- a/packages/typescript-estree/tests/lib/javascript.ts +++ b/packages/typescript-estree/tests/lib/javascript.ts @@ -7,7 +7,7 @@ */ import { readFileSync } from 'fs'; import glob from 'glob'; -import { ParserOptions } from '../../src/temp-types-based-on-js-source'; +import { ParserOptions } from '../../src/parser-options'; import { createSnapshotTestBlock, formatSnapshotName diff --git a/packages/typescript-estree/tests/lib/jsx.ts b/packages/typescript-estree/tests/lib/jsx.ts index 8b2f9f2c19de..b887911ab008 100644 --- a/packages/typescript-estree/tests/lib/jsx.ts +++ b/packages/typescript-estree/tests/lib/jsx.ts @@ -7,7 +7,7 @@ */ import { readFileSync } from 'fs'; import glob from 'glob'; -import { ParserOptions } from '../../src/temp-types-based-on-js-source'; +import { ParserOptions } from '../../src/parser-options'; import { createSnapshotTestBlock, formatSnapshotName diff --git a/packages/typescript-estree/tests/lib/parse.ts b/packages/typescript-estree/tests/lib/parse.ts index 6bed7ce8bcef..2f8463cc0a2b 100644 --- a/packages/typescript-estree/tests/lib/parse.ts +++ b/packages/typescript-estree/tests/lib/parse.ts @@ -7,7 +7,7 @@ */ import * as parser from '../../src/parser'; import * as astConverter from '../../src/ast-converter'; -import { ParserOptions } from '../../src/temp-types-based-on-js-source'; +import { ParserOptions } from '../../src/parser-options'; import { createSnapshotTestBlock } from '../../tools/test-utils'; //------------------------------------------------------------------------------ diff --git a/packages/typescript-estree/tests/lib/semanticInfo.ts b/packages/typescript-estree/tests/lib/semanticInfo.ts index f5612f191cc5..a164288ceb0f 100644 --- a/packages/typescript-estree/tests/lib/semanticInfo.ts +++ b/packages/typescript-estree/tests/lib/semanticInfo.ts @@ -11,7 +11,7 @@ import { readFileSync } from 'fs'; import glob from 'glob'; import { extname, join, resolve } from 'path'; import ts from 'typescript'; -import { ParserOptions } from '../../src/temp-types-based-on-js-source'; +import { ParserOptions } from '../../src/parser-options'; import { createSnapshotTestBlock, formatSnapshotName, diff --git a/packages/typescript-estree/tests/lib/tsx.ts b/packages/typescript-estree/tests/lib/tsx.ts index 8d4230a2c91f..21dbbd57efe0 100644 --- a/packages/typescript-estree/tests/lib/tsx.ts +++ b/packages/typescript-estree/tests/lib/tsx.ts @@ -7,7 +7,7 @@ import { readFileSync } from 'fs'; import glob from 'glob'; import { extname } from 'path'; -import { ParserOptions } from '../../src/temp-types-based-on-js-source'; +import { ParserOptions } from '../../src/parser-options'; import { createSnapshotTestBlock, formatSnapshotName diff --git a/packages/typescript-estree/tests/lib/typescript.ts b/packages/typescript-estree/tests/lib/typescript.ts index dabfac14def4..9740c4570e74 100644 --- a/packages/typescript-estree/tests/lib/typescript.ts +++ b/packages/typescript-estree/tests/lib/typescript.ts @@ -8,7 +8,7 @@ import { readFileSync } from 'fs'; import glob from 'glob'; import { extname } from 'path'; -import { ParserOptions } from '../../src/temp-types-based-on-js-source'; +import { ParserOptions } from '../../src/parser-options'; import { createSnapshotTestBlock, formatSnapshotName diff --git a/packages/typescript-estree/tools/test-utils.ts b/packages/typescript-estree/tools/test-utils.ts index 9191ae5e518a..c2d57246ca09 100644 --- a/packages/typescript-estree/tools/test-utils.ts +++ b/packages/typescript-estree/tools/test-utils.ts @@ -6,7 +6,7 @@ * MIT License */ import * as parser from '../src/parser'; -import { ParserOptions } from '../src/temp-types-based-on-js-source'; +import { ParserOptions } from '../src/parser-options'; /** * Returns a raw copy of the given AST From 2e5b46ec901edc9d855f2b75e49f19b5955a5563 Mon Sep 17 00:00:00 2001 From: Andrew Boyton Date: Tue, 5 Feb 2019 00:48:13 +1100 Subject: [PATCH 68/88] docs(eslint-plugin): add instructions for using Airbnb's config (#177) --- packages/eslint-plugin/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 1ec6df216048..cacb6666fddf 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -84,6 +84,22 @@ Install [`eslint-config-prettier`](https://github.com/prettier/eslint-config-pre **Note: Make sure you have `eslint-config-prettier@4.0.0` or newer.** +## Usage with Airbnb + +Airbnb has two configs, a base one [`eslint-config-airbnb-base`](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base) and one that includes rules for React [`eslint-config-airbnb`](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb). + +First you'll need to install the config according to the instructions in one of the links above. `npx install-peerdeps --dev eslint-config-airbnb` or `npx install-peerdeps --dev eslint-config-airbnb-base` should work if you are using **npm 5+**. + +Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.eslintrc`. You might also want to turn on `plugin:@typescript-eslint/recommended` as well to enable all of the recommended rules. + +```json +{ + "extends": ["airbnb-base", "plugin:@typescript-eslint/recommended"] +} +``` + +**Note: You can use Airbnb's rules alongside Prettier, see [Usage with Prettier](#usage-with-prettier)** + ## Supported Rules From e37a1edb66160e64a3a5b15db8c294905ccc6d02 Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 4 Feb 2019 14:48:54 +0100 Subject: [PATCH 69/88] fix(ts-estree): fix issue with nested jsx tag names (#197) --- .../tests/lib/__snapshots__/jsx.ts.snap | 50 +- packages/typescript-estree/src/convert.ts | 123 ++--- .../tests/ast-alignment/fixtures-to-test.ts | 7 +- .../tests/lib/__snapshots__/convert.ts.snap | 519 ++++++++++++++++++ .../tests/lib/__snapshots__/jsx.ts.snap | 50 +- .../typescript-estree/tests/lib/convert.ts | 128 +++++ 6 files changed, 736 insertions(+), 141 deletions(-) create mode 100644 packages/typescript-estree/tests/lib/__snapshots__/convert.ts.snap create mode 100644 packages/typescript-estree/tests/lib/convert.ts diff --git a/packages/parser/tests/lib/__snapshots__/jsx.ts.snap b/packages/parser/tests/lib/__snapshots__/jsx.ts.snap index 02d917e3fb56..a9b76778c344 100644 --- a/packages/parser/tests/lib/__snapshots__/jsx.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/jsx.ts.snap @@ -9526,7 +9526,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 41, @@ -9548,11 +9547,12 @@ Object { "line": 2, }, }, + "name": "this", "range": Array [ 45, 49, ], - "type": "ThisExpression", + "type": "JSXIdentifier", }, "property": Object { "loc": Object { @@ -9570,13 +9570,13 @@ Object { 50, 55, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 45, 55, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -9677,7 +9677,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 13, @@ -9699,11 +9698,12 @@ Object { "line": 2, }, }, + "name": "this", "range": Array [ 17, 21, ], - "type": "ThisExpression", + "type": "JSXIdentifier", }, "property": Object { "loc": Object { @@ -9721,13 +9721,13 @@ Object { 22, 27, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 17, 27, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -9846,7 +9846,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 9, @@ -9858,7 +9857,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 7, @@ -9870,7 +9868,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 5, @@ -9897,7 +9894,7 @@ Object { 74, 75, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "property": Object { "loc": Object { @@ -9915,13 +9912,13 @@ Object { 76, 77, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 74, 77, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -9939,13 +9936,13 @@ Object { 78, 79, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 74, 79, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -9963,13 +9960,13 @@ Object { 80, 81, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 74, 81, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -10070,7 +10067,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 8, @@ -10082,7 +10078,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 6, @@ -10094,7 +10089,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 4, @@ -10121,7 +10115,7 @@ Object { 1, 2, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "property": Object { "loc": Object { @@ -10139,13 +10133,13 @@ Object { 3, 4, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 1, 4, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -10163,13 +10157,13 @@ Object { 5, 6, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 1, 6, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -10187,13 +10181,13 @@ Object { 7, 8, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 1, 8, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 8e2d6a876a15..2a1703920307 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -9,7 +9,6 @@ import ts from 'typescript'; import * as es from './typedefs'; import { canContainDirective, - convertToken, createError, findNextToken, fixExports, @@ -25,7 +24,6 @@ import { isComma, isComputedProperty, isESTreeClassMember, - isJSXToken, isOptional, unescapeStringLiteralText } from './node-utils'; @@ -369,50 +367,47 @@ export class Converter { /** * Converts a TypeScript JSX node.tagName into an ESTree node.name - * @param tagName the tagName object from a JSX ts.Node + * @param node the tagName object from a JSX ts.Node * @param parent * @returns the converted ESTree name object */ - private convertTypeScriptJSXTagNameToESTreeName( - tagName: ts.JsxTagNameExpression, + private convertJSXTagName( + node: ts.JsxTagNameExpression, parent: ts.Node ): es.JSXMemberExpression | es.JSXIdentifier { - // TODO: remove convertToken call - const tagNameToken = convertToken(tagName, this.ast); - - if (tagName.kind === SyntaxKind.PropertyAccessExpression) { - const isNestedMemberExpression = - tagName.expression.kind === SyntaxKind.PropertyAccessExpression; - - // Convert TSNode left and right objects into ESTreeNode object - // and property objects - const object = this.convertChild(tagName.expression, parent); - const property = this.convertChild(tagName.name, parent); - - // Assign the appropriate types - object.type = isNestedMemberExpression - ? AST_NODE_TYPES.JSXMemberExpression - : AST_NODE_TYPES.JSXIdentifier; - property.type = AST_NODE_TYPES.JSXIdentifier; - if ((tagName as any).expression.kind === SyntaxKind.ThisKeyword) { - object.name = 'this'; - } - - return this.createNode(tagName, { - type: AST_NODE_TYPES.JSXMemberExpression, - range: tagNameToken.range, - loc: tagNameToken.loc, - object: object, - property: property - }); - } else { - return this.createNode(tagName, { - type: AST_NODE_TYPES.JSXIdentifier, - range: tagNameToken.range, - loc: tagNameToken.loc, - name: tagNameToken.value - }); + let result: es.JSXMemberExpression | es.JSXIdentifier; + switch (node.kind) { + case SyntaxKind.PropertyAccessExpression: + result = this.createNode(node, { + type: AST_NODE_TYPES.JSXMemberExpression, + object: this.convertJSXTagName(node.expression, parent), + property: this.convertJSXTagName( + node.name, + parent + ) as es.JSXIdentifier + }); + break; + case SyntaxKind.ThisKeyword: + result = this.createNode(node, { + type: AST_NODE_TYPES.JSXIdentifier, + name: 'this' + }); + break; + case SyntaxKind.Identifier: + default: + result = this.createNode(node, { + type: AST_NODE_TYPES.JSXIdentifier, + name: node.text + }); + break; + } + + if (result && this.options.shouldProvideParserServices) { + this.tsNodeToESTreeNodeMap.set(node, result); + this.esTreeNodeToTSNodeMap.set(result, node); } + + return result; } /** @@ -1617,36 +1612,12 @@ export class Converter { } case SyntaxKind.PropertyAccessExpression: - if (isJSXToken(parent)) { - const jsxMemberExpression = this.createNode( - node, - { - type: AST_NODE_TYPES.MemberExpression, - object: this.convertChild(node.expression), - property: this.convertChild(node.name) - } - ); - // TODO: refactor this - const isNestedMemberExpression = - node.expression.kind === SyntaxKind.PropertyAccessExpression; - if (node.expression.kind === SyntaxKind.ThisKeyword) { - (jsxMemberExpression.object as any).name = 'this'; - } - - (jsxMemberExpression.object as any).type = isNestedMemberExpression - ? AST_NODE_TYPES.MemberExpression - : AST_NODE_TYPES.JSXIdentifier; - (jsxMemberExpression as any).property.type = - AST_NODE_TYPES.JSXIdentifier; - return jsxMemberExpression; - } else { - return this.createNode(node, { - type: AST_NODE_TYPES.MemberExpression, - object: this.convertChild(node.expression), - property: this.convertChild(node.name), - computed: false - }); - } + return this.createNode(node, { + type: AST_NODE_TYPES.MemberExpression, + object: this.convertChild(node.expression), + property: this.convertChild(node.name), + computed: false + }); case SyntaxKind.ElementAccessExpression: return this.createNode(node, { @@ -1844,10 +1815,7 @@ export class Converter { ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) : undefined, selfClosing: true, - name: this.convertTypeScriptJSXTagNameToESTreeName( - node.tagName, - node - ), + name: this.convertJSXTagName(node.tagName, node), attributes: node.attributes.properties.map(el => this.convertChild(el) ), @@ -1865,10 +1833,7 @@ export class Converter { ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) : undefined, selfClosing: false, - name: this.convertTypeScriptJSXTagNameToESTreeName( - node.tagName, - node - ), + name: this.convertJSXTagName(node.tagName, node), attributes: node.attributes.properties.map(el => this.convertChild(el) ) @@ -1877,7 +1842,7 @@ export class Converter { case SyntaxKind.JsxClosingElement: return this.createNode(node, { type: AST_NODE_TYPES.JSXClosingElement, - name: this.convertTypeScriptJSXTagNameToESTreeName(node.tagName, node) + name: this.convertJSXTagName(node.tagName, node) }); case SyntaxKind.JsxOpeningFragment: 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 ede45e93fcda..e92f68f968f4 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -284,12 +284,7 @@ tester.addFixturePatternConfig('javascript/unicodeCodePointEscapes'); /* ================================================== */ tester.addFixturePatternConfig('jsx', { - ignore: jsxFilesWithKnownIssues.concat([ - /** - * ts-estree: nested jsx tag names are not correctly converted - */ - 'tag-names-with-multi-dots-multi' - ]) + ignore: jsxFilesWithKnownIssues }); tester.addFixturePatternConfig('jsx-useJSXTextNode'); diff --git a/packages/typescript-estree/tests/lib/__snapshots__/convert.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/convert.ts.snap new file mode 100644 index 000000000000..05a20300876e --- /dev/null +++ b/packages/typescript-estree/tests/lib/__snapshots__/convert.ts.snap @@ -0,0 +1,519 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`convert deeplyCopy should convert node correctly 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 35, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 35, + ], + "transformFlags": undefined, + "type": "TSJSDocNullableType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 35, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 35, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 16, + 17, + ], + "type": "Identifier", + }, + "typeParameters": undefined, + }, + ], + "range": Array [ + 15, + 18, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 35, + ], + "transformFlags": undefined, + "type": "TSJSDocNullableType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 35, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 35, + ], + "transformFlags": undefined, + "type": "TSJSDocNullableType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 34, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 34, + ], + "type": "TSParenthesizedType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 23, + 33, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 33, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 33, + ], + "type": "TSVoidKeyword", + }, + }, + "type": "TSFunctionType", + }, + }, + }, + }, + }, + }, + ], + }, + }, + }, + }, + ], + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 35, + ], + "sourceType": "script", + "type": "Program", +} +`; + +exports[`convert deeplyCopy should convert node with decorators correctly 1`] = ` +Object { + "decorators": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "name": "test", + "range": Array [ + 1, + 5, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Decorator", + }, + ], + "heritageClauses": undefined, + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "members": Array [], + "modifiers": undefined, + "name": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + "range": Array [ + 0, + 18, + ], + "transformFlags": undefined, + "type": "TSClassDeclaration", + "typeParameters": null, +} +`; + +exports[`convert deeplyCopy should convert node with type parameters correctly 1`] = ` +Object { + "heritageClauses": undefined, + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "members": Array [], + "name": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "range": Array [ + 0, + 15, + ], + "transformFlags": undefined, + "type": "TSClassDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "params": Array [ + Object { + "constraint": undefined, + "default": undefined, + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 10, + 11, + ], + "type": "Identifier", + }, + "range": Array [ + 10, + 11, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 9, + 12, + ], + "type": "TSTypeParameterDeclaration", + }, +} +`; diff --git a/packages/typescript-estree/tests/lib/__snapshots__/jsx.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/jsx.ts.snap index cb1f698c267c..d0d092c78411 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/jsx.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/jsx.ts.snap @@ -9486,7 +9486,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 41, @@ -9508,11 +9507,12 @@ Object { "line": 2, }, }, + "name": "this", "range": Array [ 45, 49, ], - "type": "ThisExpression", + "type": "JSXIdentifier", }, "property": Object { "loc": Object { @@ -9530,13 +9530,13 @@ Object { 50, 55, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 45, 55, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -9637,7 +9637,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 13, @@ -9659,11 +9658,12 @@ Object { "line": 2, }, }, + "name": "this", "range": Array [ 17, 21, ], - "type": "ThisExpression", + "type": "JSXIdentifier", }, "property": Object { "loc": Object { @@ -9681,13 +9681,13 @@ Object { 22, 27, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 17, 27, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -9806,7 +9806,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 9, @@ -9818,7 +9817,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 7, @@ -9830,7 +9828,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 5, @@ -9857,7 +9854,7 @@ Object { 74, 75, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "property": Object { "loc": Object { @@ -9875,13 +9872,13 @@ Object { 76, 77, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 74, 77, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -9899,13 +9896,13 @@ Object { 78, 79, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 74, 79, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -9923,13 +9920,13 @@ Object { 80, 81, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 74, 81, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -10030,7 +10027,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 8, @@ -10042,7 +10038,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 6, @@ -10054,7 +10049,6 @@ Object { }, }, "object": Object { - "computed": false, "loc": Object { "end": Object { "column": 4, @@ -10081,7 +10075,7 @@ Object { 1, 2, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "property": Object { "loc": Object { @@ -10099,13 +10093,13 @@ Object { 3, 4, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 1, 4, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -10123,13 +10117,13 @@ Object { 5, 6, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 1, 6, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { @@ -10147,13 +10141,13 @@ Object { 7, 8, ], - "type": "Identifier", + "type": "JSXIdentifier", }, "range": Array [ 1, 8, ], - "type": "MemberExpression", + "type": "JSXMemberExpression", }, "property": Object { "loc": Object { diff --git a/packages/typescript-estree/tests/lib/convert.ts b/packages/typescript-estree/tests/lib/convert.ts new file mode 100644 index 000000000000..ee2a44f7b7ce --- /dev/null +++ b/packages/typescript-estree/tests/lib/convert.ts @@ -0,0 +1,128 @@ +import { Converter } from '../../src/convert'; +import ts from 'typescript'; + +describe('convert', () => { + function convertCode(code: string): ts.SourceFile { + return ts.createSourceFile( + 'text.ts', + code, + ts.ScriptTarget.ESNext, + true, + ts.ScriptKind.TSX + ); + } + + it('deeplyCopy should convert node correctly', () => { + const ast = convertCode('type foo = ?foo | ?(() => void)?'); + + const instance = new Converter(ast, { + errorOnUnknownASTType: false, + useJSXTextNode: false, + shouldProvideParserServices: false + }); + expect(instance.convertProgram()).toMatchSnapshot(); + }); + + it('deeplyCopy should convert node with decorators correctly', () => { + const ast = convertCode('@test class foo {}'); + + const instance = new Converter(ast, { + errorOnUnknownASTType: false, + useJSXTextNode: false, + shouldProvideParserServices: false + }); + expect((instance as any).deeplyCopy(ast.statements[0])).toMatchSnapshot(); + }); + + it('deeplyCopy should convert node with type parameters correctly', () => { + const ast = convertCode('class foo {}'); + + const instance = new Converter(ast, { + errorOnUnknownASTType: false, + useJSXTextNode: false, + shouldProvideParserServices: false + }); + expect((instance as any).deeplyCopy(ast.statements[0])).toMatchSnapshot(); + }); + + it('deeplyCopy should fail on unknown node', () => { + const ast = convertCode('type foo = ?foo | ?(() => void)?'); + + const instance = new Converter(ast, { + errorOnUnknownASTType: true, + useJSXTextNode: false, + shouldProvideParserServices: false + }); + expect(() => instance.convertProgram()).toThrow( + 'Unknown AST_NODE_TYPE: "TSJSDocNullableType"' + ); + }); + + it('nodeMaps should contain basic nodes', () => { + const ast = convertCode(` + 'test'; + 2; + class foo {}; + type bar = {}; + `); + + const instance = new Converter(ast, { + errorOnUnknownASTType: false, + useJSXTextNode: false, + shouldProvideParserServices: true + }); + instance.convertProgram(); + const maps = instance.getASTMaps(); + + function checkMaps(child: any) { + child.forEachChild((node: any) => { + if ( + node.kind !== ts.SyntaxKind.EndOfFileToken && + node.kind !== ts.SyntaxKind.JsxAttributes && + node.kind !== ts.SyntaxKind.VariableDeclaration + ) { + expect(node).toBe( + maps.esTreeNodeToTSNodeMap.get(maps.tsNodeToESTreeNodeMap.get(node)) + ); + } + checkMaps(node); + }); + } + + expect(ast).toBe( + maps.esTreeNodeToTSNodeMap.get(maps.tsNodeToESTreeNodeMap.get(ast)) + ); + checkMaps(ast); + }); + + it('nodeMaps should contain jsx nodes', () => { + const ast = convertCode(``); + + const instance = new Converter(ast, { + errorOnUnknownASTType: false, + useJSXTextNode: false, + shouldProvideParserServices: true + }); + instance.convertProgram(); + const maps = instance.getASTMaps(); + + function checkMaps(child: any) { + child.forEachChild((node: any) => { + if ( + node.kind !== ts.SyntaxKind.EndOfFileToken && + node.kind !== ts.SyntaxKind.JsxAttributes + ) { + expect(node).toBe( + maps.esTreeNodeToTSNodeMap.get(maps.tsNodeToESTreeNodeMap.get(node)) + ); + } + checkMaps(node); + }); + } + + expect(ast).toBe( + maps.esTreeNodeToTSNodeMap.get(maps.tsNodeToESTreeNodeMap.get(ast)) + ); + checkMaps(ast); + }); +}); From f513a143f549f8ccc8ec4851f245364c4542af73 Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 4 Feb 2019 11:49:05 -0500 Subject: [PATCH 70/88] feat(*): change TypeScript version range to >=3.2.1 <3.4.0 (#184) --- README.md | 8 +++++--- package.json | 2 +- packages/eslint-plugin/package.json | 2 +- packages/parser/README.md | 2 ++ packages/parser/src/parser-options.ts | 1 + packages/parser/src/parser.ts | 12 ++++++++++++ packages/parser/tests/lib/parser.ts | 21 +++++++++++++++++++++ packages/typescript-estree/package.json | 3 +-- packages/typescript-estree/src/parser.ts | 10 ++++++---- yarn.lock | 8 ++++---- 10 files changed, 54 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 75e75658d069..fb5dbbcababd 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,13 @@ The `canary` (latest master) version is: ## Supported TypeScript Version -We will always endeavor to support the latest stable version of TypeScript. +We will always endeavor to support the latest stable version of TypeScript. Sometimes, but not always, changes in TypeScript will not require breaking changes in this project, and so we are able to support more than one version of TypeScript. -The version of TypeScript currently supported by this parser is `~3.2.1`. This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript. +**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.4.0`.** -If you use a non-supported version of TypeScript, the parser will log a warning to the console. +This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript. + +If you use a non-supported version of TypeScript, the parser will log a warning to the console. If you want to disable this warning, you can configure this in your `parserOptions`. See: [`@typescript-eslint/parser`](./packages/parser/) and [`@typescript-eslint/typescript-estree`](./packages/typescript-estree/). **Please ensure that you are using a supported version before submitting any issues/bug reports.** diff --git a/package.json b/package.json index a95c4a1a5710..db01c0bf521c 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,6 @@ "rimraf": "^2.6.3", "ts-jest": "^23.10.4", "tslint": "^5.11.0", - "typescript": "~3.2.1" + "typescript": ">=3.2.1 <3.4.0" } } diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index b0bf9f288e0e..e710176c4250 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -34,6 +34,6 @@ }, "peerDependencies": { "eslint": "^5.0.0", - "typescript": "~3.2.1" + "typescript": "*" } } diff --git a/packages/parser/README.md b/packages/parser/README.md index d0a6879b4e57..78d17e6388fb 100644 --- a/packages/parser/README.md +++ b/packages/parser/README.md @@ -54,6 +54,8 @@ The following additional configuration options are available by specifying them - **`extraFileExtensions`** - default `undefined`. This option allows you to provide one or more additional file extensions which should be considered in the TypeScript Program compilation. E.g. a `.vue` file +- **`warnOnUnsupportedTypeScriptVersion`** - default `true`. This option allows you to toggle the warning that the parser will give you if you use a version of TypeScript which is not explicitly supported + ### .eslintrc.json ```json diff --git a/packages/parser/src/parser-options.ts b/packages/parser/src/parser-options.ts index 95d6e54c182c..d374ac57b912 100644 --- a/packages/parser/src/parser-options.ts +++ b/packages/parser/src/parser-options.ts @@ -17,4 +17,5 @@ export interface ParserOptions { errorOnTypeScriptSyntacticAndSemanticIssues?: boolean; tsconfigRootDir?: string; extraFileExtensions?: string[]; + warnOnUnsupportedTypeScriptVersion?: boolean; } diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 2dd32b383625..be3c3e7506ef 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -75,6 +75,18 @@ export function parseForESLint( } } + /** + * Allow the user to suppress the warning from typescript-estree if they are using an unsupported + * version of TypeScript + */ + const warnOnUnsupportedTypeScriptVersion = validateBoolean( + options.warnOnUnsupportedTypeScriptVersion, + true + ); + if (!warnOnUnsupportedTypeScriptVersion) { + parserOptions.loggerFn = false; + } + const { ast, services } = parseAndGenerateServices(code, parserOptions); ast.sourceType = options.sourceType; diff --git a/packages/parser/tests/lib/parser.ts b/packages/parser/tests/lib/parser.ts index 332be8b6e43c..6a844baae22e 100644 --- a/packages/parser/tests/lib/parser.ts +++ b/packages/parser/tests/lib/parser.ts @@ -84,4 +84,25 @@ describe('parser', () => { `"Cannot assign to read only property 'ArrayExpression' of object '#'"` ); }); + + it('`warnOnUnsupportedTypeScriptVersion: false` should set `loggerFn: false` on typescript-estree', () => { + const code = 'const valid = true;'; + const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices'); + parseForESLint(code, { warnOnUnsupportedTypeScriptVersion: true }); + expect(spy).toHaveBeenCalledWith(code, { + ecmaFeatures: {}, + jsx: false, + sourceType: 'script', + useJSXTextNode: true + }); + parseForESLint(code, { warnOnUnsupportedTypeScriptVersion: false }); + expect(spy).toHaveBeenCalledWith(code, { + ecmaFeatures: {}, + jsx: false, + sourceType: 'script', + useJSXTextNode: true, + loggerFn: false, + warnOnUnsupportedTypeScriptVersion: false + }); + }); }); diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 5c7f52edf274..50432ba4d214 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -42,7 +42,6 @@ "typescript": "*" }, "devDependencies": { - "@typescript-eslint/shared-fixtures": "1.2.0", - "typescript": "~3.2.1" + "@typescript-eslint/shared-fixtures": "1.2.0" } } diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index 3c9680df06d4..ca3d27db77e1 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -18,9 +18,11 @@ import * as es from './typedefs'; import { Extra, ParserOptions } from './parser-options'; import { getFirstSemanticOrSyntacticError } from './semantic-errors'; -const packageJSON = require('../package.json'); - -const SUPPORTED_TYPESCRIPT_VERSIONS = packageJSON.devDependencies.typescript; +/** + * This needs to be kept in sync with the top-level README.md in the + * typescript-eslint monorepo + */ +const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.2.1 <3.4.0'; const ACTIVE_TYPESCRIPT_VERSION = ts.version; const isRunningSupportedTypeScriptVersion = semver.satisfies( ACTIVE_TYPESCRIPT_VERSION, @@ -287,7 +289,7 @@ interface ParseAndGenerateServicesResult { // Public //------------------------------------------------------------------------------ -export const version: string = packageJSON.version; +export const version: string = require('../package.json').version; export function parse( code: string, diff --git a/yarn.lock b/yarn.lock index 1969160e6c41..51d8518fb375 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7056,10 +7056,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@~3.2.1: - version "3.2.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.2.tgz#fe8101c46aa123f8353523ebdcf5730c2ae493e5" - integrity sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg== +"typescript@>=3.2.1 <3.4.0": + version "3.3.1" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.1.tgz#6de14e1db4b8a006ac535e482c8ba018c55f750b" + integrity sha512-cTmIDFW7O0IHbn1DPYjkiebHxwtCMU+eTy30ZtJNBPF9j2O1ITu5XH2YnBeVRKWHqF+3JQwWJv0Q0aUgX8W7IA== uglify-js@^3.1.4: version "3.4.9" From d4dfa3bb78365222055fb18b266416439c40deaf Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 5 Feb 2019 00:49:48 +0100 Subject: [PATCH 71/88] fix(ts-estree): fix issues with typeParams in FunctionExpression (#208) --- .../lib/__snapshots__/typescript.ts.snap | 252 +++++++++--------- packages/typescript-estree/src/convert.ts | 52 ++-- packages/typescript-estree/src/typedefs.ts | 1 - .../tests/ast-alignment/utils.ts | 15 ++ .../lib/__snapshots__/typescript.ts.snap | 252 +++++++++--------- 5 files changed, 292 insertions(+), 280 deletions(-) diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index f57d7523a358..a6058f009bef 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -11047,13 +11047,13 @@ Object { "line": 2, }, "start": Object { - "column": 16, + "column": 13, "line": 2, }, }, "params": Array [], "range": Array [ - 26, + 23, 32, ], "type": "FunctionExpression", @@ -11180,13 +11180,13 @@ Object { "line": 4, }, "start": Object { - "column": 20, + "column": 17, "line": 4, }, }, "params": Array [], "range": Array [ - 54, + 51, 60, ], "type": "FunctionExpression", @@ -13831,13 +13831,13 @@ Object { "line": 2, }, "start": Object { - "column": 11, + "column": 8, "line": 2, }, }, "params": Array [], "range": Array [ - 23, + 20, 28, ], "type": "FunctionExpression", @@ -14260,13 +14260,13 @@ Object { "line": 2, }, "start": Object { - "column": 17, + "column": 8, "line": 2, }, }, "params": Array [], "range": Array [ - 29, + 20, 34, ], "type": "FunctionExpression", @@ -16112,13 +16112,13 @@ Object { "line": 3, }, "start": Object { - "column": 8, + "column": 5, "line": 3, }, }, "params": Array [], "range": Array [ - 38, + 35, 44, ], "type": "FunctionExpression", @@ -28360,13 +28360,13 @@ Object { "line": 3, }, "start": Object { - "column": 18, + "column": 15, "line": 2, }, }, "params": Array [], "range": Array [ - 28, + 25, 44, ], "returnType": Object { @@ -28527,13 +28527,13 @@ Object { "line": 6, }, "start": Object { - "column": 20, + "column": 17, "line": 5, }, }, "params": Array [], "range": Array [ - 66, + 63, 82, ], "returnType": Object { @@ -58372,60 +58372,6 @@ Object { ], "shorthand": false, "type": "Property", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 2, - }, - "start": Object { - "column": 15, - "line": 2, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "name": "T", - "range": Array [ - 30, - 31, - ], - "type": "Identifier", - }, - "range": Array [ - 30, - 31, - ], - "type": "TSTypeParameter", - }, - ], - "range": Array [ - 29, - 32, - ], - "type": "TSTypeParameterDeclaration", - }, "value": Object { "async": false, "body": Object { @@ -58492,13 +58438,13 @@ Object { "line": 4, }, "start": Object { - "column": 18, + "column": 15, "line": 2, }, }, "params": Array [], "range": Array [ - 32, + 29, 61, ], "returnType": Object { @@ -58536,6 +58482,60 @@ Object { }, }, "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": "T", + "range": Array [ + 30, + 31, + ], + "type": "Identifier", + }, + "range": Array [ + 30, + 31, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 29, + 32, + ], + "type": "TSTypeParameterDeclaration", + }, }, }, Object { @@ -58576,60 +58576,6 @@ Object { ], "shorthand": false, "type": "Property", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 5, - }, - "start": Object { - "column": 5, - "line": 5, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 7, - "line": 5, - }, - "start": Object { - "column": 6, - "line": 5, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 7, - "line": 5, - }, - "start": Object { - "column": 6, - "line": 5, - }, - }, - "name": "T", - "range": Array [ - 69, - 70, - ], - "type": "Identifier", - }, - "range": Array [ - 69, - 70, - ], - "type": "TSTypeParameter", - }, - ], - "range": Array [ - 68, - 71, - ], - "type": "TSTypeParameterDeclaration", - }, "value": Object { "async": false, "body": Object { @@ -58696,13 +58642,13 @@ Object { "line": 7, }, "start": Object { - "column": 8, + "column": 5, "line": 5, }, }, "params": Array [], "range": Array [ - 71, + 68, 100, ], "returnType": Object { @@ -58740,6 +58686,60 @@ Object { }, }, "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 5, + }, + "start": Object { + "column": 5, + "line": 5, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 5, + }, + "start": Object { + "column": 6, + "line": 5, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 5, + }, + "start": Object { + "column": 6, + "line": 5, + }, + }, + "name": "T", + "range": Array [ + 69, + 70, + ], + "type": "Identifier", + }, + "range": Array [ + 69, + 70, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 68, + 71, + ], + "type": "TSTypeParameterDeclaration", + }, }, }, Object { diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 2a1703920307..6f9465c15139 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -468,20 +468,22 @@ export class Converter { } /** - * Uses the current TSNode's end location for its `type` to adjust the location data of the given - * ESTreeNode, which should be the parent of the final typeAnnotation node - * @param typeAnnotationParent The node that will have its location data mutated - * @param node + * Uses the provided range location to adjust the location data of the given Node + * @param result The node that will have its location data mutated + * @param childRange The child node range used to expand location */ - private fixTypeAnnotationParentLocation( - typeAnnotationParent: es.BaseNode, - node: ts.TypeNode + private fixParentLocation( + result: es.BaseNode, + childRange: [number, number] ): void { - typeAnnotationParent.range[1] = node.getEnd(); - typeAnnotationParent.loc.end = getLineAndCharacterFor( - typeAnnotationParent.range[1], - this.ast - ); + if (childRange[0] < result.range[0]) { + result.range[0] = childRange[0]; + result.loc.start = getLineAndCharacterFor(result.range[0], this.ast); + } + if (childRange[1] > result.range[1]) { + result.range[1] = childRange[1]; + result.loc.end = getLineAndCharacterFor(result.range[1], this.ast); + } } /** @@ -713,7 +715,7 @@ export class Converter { node.type, node ); - this.fixTypeAnnotationParentLocation(result.id, node.type); + this.fixParentLocation(result.id, result.id.typeAnnotation.range); } return result; } @@ -893,6 +895,14 @@ export class Converter { method.returnType = this.convertTypeAnnotation(node.type, node); } + // Process typeParameters + if (node.typeParameters && node.typeParameters.length) { + method.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters + ); + this.fixParentLocation(method, method.typeParameters.range); + } + let result: | es.Property | es.TSAbstractMethodDefinition @@ -970,19 +980,6 @@ export class Converter { ) { result.kind = 'constructor'; } - - // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { - if (result.type !== AST_NODE_TYPES.Property) { - method.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); - } else { - result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters - ); - } - } return result; } @@ -1009,6 +1006,7 @@ export class Converter { constructor.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( node.typeParameters ); + this.fixParentLocation(constructor, constructor.typeParameters.range); } // Process returnType @@ -1291,7 +1289,7 @@ export class Converter { node.type, node ); - this.fixTypeAnnotationParentLocation(parameter, node.type); + this.fixParentLocation(parameter, parameter.typeAnnotation.range); } if (node.questionToken) { diff --git a/packages/typescript-estree/src/typedefs.ts b/packages/typescript-estree/src/typedefs.ts index 140ed6e09a49..f5fecea9ef7f 100644 --- a/packages/typescript-estree/src/typedefs.ts +++ b/packages/typescript-estree/src/typedefs.ts @@ -893,7 +893,6 @@ export interface Property extends BaseNode { method: boolean; shorthand: boolean; kind: 'init'; - typeParameters?: TSTypeParameterDeclaration; } export interface RestElement extends BaseNode { diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index ee0a2b7d72f9..f00b7d9ad16b 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -251,6 +251,21 @@ export function preprocessBabylonAST(ast: any): any { ) { node.type = 'TSClassImplements'; } + }, + // https://github.com/prettier/prettier/issues/5817 + FunctionExpression(node: any, parent: any) { + if (parent.typeParameters && parent.type === 'Property') { + node.typeParameters = parent.typeParameters; + delete parent.typeParameters; + } + + /** + * babel issue: ranges of typeParameters are not included in FunctionExpression range + */ + if (node.typeParameters) { + node.range[0] = node.typeParameters.range[0]; + node.loc.start = Object.assign({}, node.typeParameters.loc.start); + } } } ); diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index 0c1e0c5afe60..b9d07faaa475 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -11023,13 +11023,13 @@ Object { "line": 2, }, "start": Object { - "column": 16, + "column": 13, "line": 2, }, }, "params": Array [], "range": Array [ - 26, + 23, 32, ], "type": "FunctionExpression", @@ -11156,13 +11156,13 @@ Object { "line": 4, }, "start": Object { - "column": 20, + "column": 17, "line": 4, }, }, "params": Array [], "range": Array [ - 54, + 51, 60, ], "type": "FunctionExpression", @@ -13801,13 +13801,13 @@ Object { "line": 2, }, "start": Object { - "column": 11, + "column": 8, "line": 2, }, }, "params": Array [], "range": Array [ - 23, + 20, 28, ], "type": "FunctionExpression", @@ -14229,13 +14229,13 @@ Object { "line": 2, }, "start": Object { - "column": 17, + "column": 8, "line": 2, }, }, "params": Array [], "range": Array [ - 29, + 20, 34, ], "type": "FunctionExpression", @@ -16076,13 +16076,13 @@ Object { "line": 3, }, "start": Object { - "column": 8, + "column": 5, "line": 3, }, }, "params": Array [], "range": Array [ - 38, + 35, 44, ], "type": "FunctionExpression", @@ -28309,13 +28309,13 @@ Object { "line": 3, }, "start": Object { - "column": 18, + "column": 15, "line": 2, }, }, "params": Array [], "range": Array [ - 28, + 25, 44, ], "returnType": Object { @@ -28476,13 +28476,13 @@ Object { "line": 6, }, "start": Object { - "column": 20, + "column": 17, "line": 5, }, }, "params": Array [], "range": Array [ - 66, + 63, 82, ], "returnType": Object { @@ -58224,60 +58224,6 @@ Object { ], "shorthand": false, "type": "Property", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 2, - }, - "start": Object { - "column": 15, - "line": 2, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "name": "T", - "range": Array [ - 30, - 31, - ], - "type": "Identifier", - }, - "range": Array [ - 30, - 31, - ], - "type": "TSTypeParameter", - }, - ], - "range": Array [ - 29, - 32, - ], - "type": "TSTypeParameterDeclaration", - }, "value": Object { "async": false, "body": Object { @@ -58344,13 +58290,13 @@ Object { "line": 4, }, "start": Object { - "column": 18, + "column": 15, "line": 2, }, }, "params": Array [], "range": Array [ - 32, + 29, 61, ], "returnType": Object { @@ -58388,6 +58334,60 @@ Object { }, }, "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": "T", + "range": Array [ + 30, + 31, + ], + "type": "Identifier", + }, + "range": Array [ + 30, + 31, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 29, + 32, + ], + "type": "TSTypeParameterDeclaration", + }, }, }, Object { @@ -58428,60 +58428,6 @@ Object { ], "shorthand": false, "type": "Property", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 5, - }, - "start": Object { - "column": 5, - "line": 5, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 7, - "line": 5, - }, - "start": Object { - "column": 6, - "line": 5, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 7, - "line": 5, - }, - "start": Object { - "column": 6, - "line": 5, - }, - }, - "name": "T", - "range": Array [ - 69, - 70, - ], - "type": "Identifier", - }, - "range": Array [ - 69, - 70, - ], - "type": "TSTypeParameter", - }, - ], - "range": Array [ - 68, - 71, - ], - "type": "TSTypeParameterDeclaration", - }, "value": Object { "async": false, "body": Object { @@ -58548,13 +58494,13 @@ Object { "line": 7, }, "start": Object { - "column": 8, + "column": 5, "line": 5, }, }, "params": Array [], "range": Array [ - 71, + 68, 100, ], "returnType": Object { @@ -58592,6 +58538,60 @@ Object { }, }, "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 5, + }, + "start": Object { + "column": 5, + "line": 5, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 5, + }, + "start": Object { + "column": 6, + "line": 5, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 5, + }, + "start": Object { + "column": 6, + "line": 5, + }, + }, + "name": "T", + "range": Array [ + 69, + 70, + ], + "type": "Identifier", + }, + "range": Array [ + 69, + 70, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 68, + 71, + ], + "type": "TSTypeParameterDeclaration", + }, }, }, Object { From c1abae9cbe05a6ae750a3ea6dd21e9a71b56bf41 Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 5 Feb 2019 01:38:55 +0100 Subject: [PATCH 72/88] refactor(ts-estree): improve definition of parameters (#209) - add missing tests for decorators --- .../lib/__snapshots__/typescript.ts.snap | 4876 ++++++++++++----- .../parameter-array-pattern-decorator.src.ts | 3 + .../parameter-object-pattern-decorator.src.ts | 3 + .../parameter-rest-element-decorator.src.ts | 3 + .../decorator-on-function.src.ts | 2 + packages/typescript-estree/src/convert.ts | 15 +- packages/typescript-estree/src/typedefs.ts | 14 +- .../tests/ast-alignment/fixtures-to-test.ts | 10 +- .../semantic-diagnostics-enabled.ts.snap | 15 + .../lib/__snapshots__/typescript.ts.snap | 4872 +++++++++++----- 10 files changed, 7118 insertions(+), 2695 deletions(-) create mode 100644 packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-array-pattern-decorator.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-object-pattern-decorator.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-rest-element-decorator.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-function.src.ts diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index a6058f009bef..6f4ae3ff2035 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -82288,7 +82288,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-constructor.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-array-pattern-decorator.src 1`] = ` Object { "body": Array [ Object { @@ -82299,198 +82299,55 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 15, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, - "name": "constructor", + "name": "bar", "range": Array [ - 20, - 31, + 14, + 17, ], "type": "Identifier", }, - "kind": "constructor", + "kind": "method", "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 113, + 14, + 49, ], "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [ - Object { - "expression": Object { - "left": Object { - "computed": false, - "loc": Object { - "end": Object { - "column": 18, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "object": Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 81, - 85, - ], - "type": "ThisExpression", - }, - "property": Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 3, - }, - "start": Object { - "column": 13, - "line": 3, - }, - }, - "name": "title", - "range": Array [ - 86, - 91, - ], - "type": "Identifier", - }, - "range": Array [ - 81, - 91, - ], - "type": "MemberExpression", - }, - "loc": Object { - "end": Object { - "column": 33, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "operator": "=", - "range": Array [ - 81, - 106, - ], - "right": Object { - "computed": false, - "loc": Object { - "end": Object { - "column": 33, - "line": 3, - }, - "start": Object { - "column": 21, - "line": 3, - }, - }, - "object": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 3, - }, - "start": Object { - "column": 21, - "line": 3, - }, - }, - "name": "config", - "range": Array [ - 94, - 100, - ], - "type": "Identifier", - }, - "property": Object { - "loc": Object { - "end": Object { - "column": 33, - "line": 3, - }, - "start": Object { - "column": 28, - "line": 3, - }, - }, - "name": "title", - "range": Array [ - 101, - 106, - ], - "type": "Identifier", - }, - "range": Array [ - 94, - 106, - ], - "type": "MemberExpression", - }, - "type": "AssignmentExpression", - }, - "loc": Object { - "end": Object { - "column": 34, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 81, - 107, - ], - "type": "ExpressionStatement", - }, - ], + "body": Array [], "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 55, + "column": 35, "line": 2, }, }, "range": Array [ - 71, - 113, + 47, + 49, ], "type": "BlockStatement", }, @@ -82499,11 +82356,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 15, + "column": 5, "line": 2, }, }, @@ -82516,146 +82373,148 @@ Object { Object { "loc": Object { "end": Object { - "column": 34, + "column": 19, "line": 2, }, "start": Object { - "column": 24, + "column": 15, "line": 2, }, }, - "name": "APP_CONFIG", "range": Array [ - 40, - 50, + 27, + 31, ], - "type": "Identifier", + "raw": "true", + "type": "Literal", + "value": true, }, ], "callee": Object { "loc": Object { "end": Object { - "column": 23, + "column": 14, "line": 2, }, "start": Object { - "column": 17, + "column": 7, "line": 2, }, }, - "name": "Inject", + "name": "special", "range": Array [ - 33, - 39, + 19, + 26, ], "type": "Identifier", }, "loc": Object { "end": Object { - "column": 35, + "column": 20, "line": 2, }, "start": Object { - "column": 17, + "column": 7, "line": 2, }, }, "range": Array [ - 33, - 51, + 19, + 32, ], "type": "CallExpression", }, "loc": Object { "end": Object { - "column": 35, + "column": 20, "line": 2, }, "start": Object { - "column": 16, + "column": 6, "line": 2, }, }, "range": Array [ + 18, 32, - 51, ], "type": "Decorator", }, ], + "elements": Array [ + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + }, + ], "loc": Object { "end": Object { - "column": 53, + "column": 33, "line": 2, }, "start": Object { - "column": 36, + "column": 21, "line": 2, }, }, - "name": "config", "range": Array [ - 52, - 69, + 33, + 45, ], - "type": "Identifier", + "type": "ArrayPattern", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 53, + "column": 33, "line": 2, }, "start": Object { - "column": 42, + "column": 28, "line": 2, }, }, "range": Array [ - 58, - 69, + 40, + 45, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 53, + "column": 33, "line": 2, }, "start": Object { - "column": 44, + "column": 30, "line": 2, }, }, "range": Array [ - 60, - 69, + 42, + 45, ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 53, - "line": 2, - }, - "start": Object { - "column": 44, - "line": 2, - }, - }, - "name": "AppConfig", - "range": Array [ - 60, - 69, - ], - "type": "Identifier", - }, + "type": "TSAnyKeyword", }, }, }, ], "range": Array [ - 31, - 113, + 17, + 49, ], "type": "FunctionExpression", }, @@ -82664,23 +82523,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 115, + 10, + 51, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -82688,17 +82547,17 @@ Object { "line": 1, }, }, - "name": "Service", + "name": "Foo", "range": Array [ 6, - 13, + 9, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, @@ -82707,7 +82566,7 @@ Object { }, "range": Array [ 0, - 115, + 51, ], "superClass": null, "type": "ClassDeclaration", @@ -82717,7 +82576,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 4, }, "start": Object { "column": 0, @@ -82726,7 +82585,7 @@ Object { }, "range": Array [ 0, - 116, + 52, ], "sourceType": "module", "tokens": Array [ @@ -82751,7 +82610,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -82761,25 +82620,25 @@ Object { }, "range": Array [ 6, - 13, + 9, ], "type": "Identifier", - "value": "Service", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 11, "line": 1, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 15, + 10, + 11, ], "type": "Punctuator", "value": "{", @@ -82787,35 +82646,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 31, + 14, + 17, ], "type": "Identifier", - "value": "constructor", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 6, "line": 2, }, "start": Object { - "column": 15, + "column": 5, "line": 2, }, }, "range": Array [ - 31, - 32, + 17, + 18, ], "type": "Punctuator", "value": "(", @@ -82823,17 +82682,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 17, + "column": 7, "line": 2, }, "start": Object { - "column": 16, + "column": 6, "line": 2, }, }, "range": Array [ - 32, - 33, + 18, + 19, ], "type": "Punctuator", "value": "@", @@ -82841,35 +82700,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 23, + "column": 14, "line": 2, }, "start": Object { - "column": 17, + "column": 7, "line": 2, }, }, "range": Array [ - 33, - 39, + 19, + 26, ], "type": "Identifier", - "value": "Inject", + "value": "special", }, Object { "loc": Object { "end": Object { - "column": 24, + "column": 15, "line": 2, }, "start": Object { - "column": 23, + "column": 14, "line": 2, }, }, "range": Array [ - 39, - 40, + 26, + 27, ], "type": "Punctuator", "value": "(", @@ -82877,35 +82736,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 34, + "column": 19, "line": 2, }, "start": Object { - "column": 24, + "column": 15, "line": 2, }, }, "range": Array [ - 40, - 50, + 27, + 31, ], - "type": "Identifier", - "value": "APP_CONFIG", + "type": "Boolean", + "value": "true", }, Object { "loc": Object { "end": Object { - "column": 35, + "column": 20, "line": 2, }, "start": Object { - "column": 34, + "column": 19, "line": 2, }, }, "range": Array [ - 50, - 51, + 31, + 32, ], "type": "Punctuator", "value": ")", @@ -82913,251 +82772,2244 @@ Object { Object { "loc": Object { "end": Object { - "column": 42, + "column": 22, "line": 2, }, "start": Object { - "column": 36, + "column": 21, "line": 2, }, }, "range": Array [ - 52, - 58, + 33, + 34, ], - "type": "Identifier", - "value": "config", + "type": "Punctuator", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 43, + "column": 26, "line": 2, }, "start": Object { - "column": 42, + "column": 23, "line": 2, }, }, "range": Array [ - 58, - 59, + 35, + 38, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 53, + "column": 28, "line": 2, }, "start": Object { - "column": 44, + "column": 27, "line": 2, }, }, "range": Array [ - 60, - 69, + 39, + 40, ], - "type": "Identifier", - "value": "AppConfig", + "type": "Punctuator", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 54, + "column": 29, "line": 2, }, "start": Object { - "column": 53, + "column": 28, "line": 2, }, }, "range": Array [ - 69, - 70, + 40, + 41, ], "type": "Punctuator", - "value": ")", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 56, + "column": 33, "line": 2, }, "start": Object { - "column": 55, + "column": 30, "line": 2, }, }, "range": Array [ - 71, - 72, + 42, + 45, ], - "type": "Punctuator", - "value": "{", + "type": "Identifier", + "value": "any", }, Object { "loc": Object { "end": Object { - "column": 12, - "line": 3, + "column": 34, + "line": 2, }, "start": Object { - "column": 8, - "line": 3, + "column": 33, + "line": 2, }, }, "range": Array [ - 81, - 85, + 45, + 46, ], - "type": "Keyword", - "value": "this", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 13, - "line": 3, + "column": 36, + "line": 2, }, "start": Object { - "column": 12, - "line": 3, + "column": 35, + "line": 2, }, }, "range": Array [ - 85, - 86, + 47, + 48, ], "type": "Punctuator", - "value": ".", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 18, - "line": 3, + "column": 37, + "line": 2, }, "start": Object { - "column": 13, - "line": 3, + "column": 36, + "line": 2, }, }, "range": Array [ - 86, - 91, + 48, + 49, ], - "type": "Identifier", - "value": "title", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 1, "line": 3, }, "start": Object { - "column": 19, + "column": 0, "line": 3, }, }, "range": Array [ - 92, - 93, + 50, + 51, ], "type": "Punctuator", - "value": "=", + "value": "}", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-constructor.src 1`] = ` +Object { + "body": Array [ Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 3, - }, + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "name": "constructor", + "range": Array [ + 20, + 31, + ], + "type": "Identifier", + }, + "kind": "constructor", + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 20, + 113, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "expression": Object { + "left": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 81, + 85, + ], + "type": "ThisExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 13, + "line": 3, + }, + }, + "name": "title", + "range": Array [ + 86, + 91, + ], + "type": "Identifier", + }, + "range": Array [ + 81, + 91, + ], + "type": "MemberExpression", + }, + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "operator": "=", + "range": Array [ + 81, + 106, + ], + "right": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "name": "config", + "range": Array [ + 94, + 100, + ], + "type": "Identifier", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 28, + "line": 3, + }, + }, + "name": "title", + "range": Array [ + 101, + 106, + ], + "type": "Identifier", + }, + "range": Array [ + 94, + 106, + ], + "type": "MemberExpression", + }, + "type": "AssignmentExpression", + }, + "loc": Object { + "end": Object { + "column": 34, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 81, + 107, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 55, + "line": 2, + }, + }, + "range": Array [ + 71, + 113, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "params": Array [ + Object { + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "name": "APP_CONFIG", + "range": Array [ + 40, + 50, + ], + "type": "Identifier", + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "name": "Inject", + "range": Array [ + 33, + 39, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 33, + 51, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 32, + 51, + ], + "type": "Decorator", + }, + ], + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "name": "config", + "range": Array [ + 52, + 69, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 42, + "line": 2, + }, + }, + "range": Array [ + 58, + 69, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "range": Array [ + 60, + 69, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "name": "AppConfig", + "range": Array [ + 60, + 69, + ], + "type": "Identifier", + }, + }, + }, + }, + ], + "range": Array [ + 31, + 113, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 115, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Service", + "range": Array [ + 6, + 13, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 115, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 6, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 116, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 13, + ], + "type": "Identifier", + "value": "Service", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 20, + 31, + ], + "type": "Identifier", + "value": "constructor", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 33, + 39, + ], + "type": "Identifier", + "value": "Inject", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 40, + 50, + ], + "type": "Identifier", + "value": "APP_CONFIG", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 34, + "line": 2, + }, + }, + "range": Array [ + 50, + 51, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 52, + 58, + ], + "type": "Identifier", + "value": "config", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 2, + }, + "start": Object { + "column": 42, + "line": 2, + }, + }, + "range": Array [ + 58, + 59, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "range": Array [ + 60, + 69, + ], + "type": "Identifier", + "value": "AppConfig", + }, + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 2, + }, + "start": Object { + "column": 53, + "line": 2, + }, + }, + "range": Array [ + 69, + 70, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 2, + }, + "start": Object { + "column": 55, + "line": 2, + }, + }, + "range": Array [ + 71, + 72, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 81, + 85, + ], + "type": "Keyword", + "value": "this", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 12, + "line": 3, + }, + }, + "range": Array [ + 85, + 86, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 13, + "line": 3, + }, + }, + "range": Array [ + 86, + 91, + ], + "type": "Identifier", + "value": "title", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 3, + }, + "start": Object { + "column": 19, + "line": 3, + }, + }, + "range": Array [ + 92, + 93, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "range": Array [ + 94, + 100, + ], + "type": "Identifier", + "value": "config", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 3, + }, + "start": Object { + "column": 27, + "line": 3, + }, + }, + "range": Array [ + 100, + 101, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 28, + "line": 3, + }, + }, + "range": Array [ + 101, + 106, + ], + "type": "Identifier", + "value": "title", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 106, + 107, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 114, + 115, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 16, + 19, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 16, + 50, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 48, + 50, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "params": Array [ + Object { + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 29, + 33, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 21, + 28, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 21, + 34, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 34, + ], + "type": "Decorator", + }, + ], + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "baz", + "range": Array [ + 35, + 46, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 26, + "line": 2, + }, + }, + "range": Array [ + 38, + 46, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 40, + 46, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 19, + 50, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 52, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 52, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 53, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 16, + 19, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 21, + 28, + ], + "type": "Identifier", + "value": "special", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 29, + 33, + ], + "type": "Boolean", + "value": "true", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 21, + "line": 2, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + "value": "baz", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 26, + "line": 2, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 40, + 46, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 34, + "line": 2, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 48, + 49, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 37, + "line": 2, + }, + }, + "range": Array [ + 49, + 50, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 51, + 52, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 29, + 32, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 22, + 63, + ], + "static": true, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 43, + "line": 2, + }, + }, + "range": Array [ + 61, + 63, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "params": Array [ + Object { + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 42, + 46, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 34, + 41, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 34, + 47, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 33, + 47, + ], + "type": "Decorator", + }, + ], + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "name": "baz", + "range": Array [ + 48, + 59, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 33, + "line": 2, + }, + }, + "range": Array [ + 51, + 59, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 35, + "line": 2, + }, + }, + "range": Array [ + 53, + 59, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 32, + 63, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 65, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "StaticFoo", + "range": Array [ + 6, + 15, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 65, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 66, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, "start": Object { - "column": 21, - "line": 3, + "column": 6, + "line": 1, }, }, "range": Array [ - 94, - 100, + 6, + 15, ], "type": "Identifier", - "value": "config", + "value": "StaticFoo", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "Keyword", + "value": "static", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 29, + 32, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 34, + 41, + ], + "type": "Identifier", + "value": "special", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Punctuator", + "value": "(", }, Object { "loc": Object { "end": Object { "column": 28, - "line": 3, + "line": 2, }, "start": Object { - "column": 27, - "line": 3, + "column": 24, + "line": 2, }, }, "range": Array [ - 100, - 101, + 42, + 46, + ], + "type": "Boolean", + "value": "true", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 46, + 47, ], "type": "Punctuator", - "value": ".", + "value": ")", }, Object { "loc": Object { "end": Object { "column": 33, - "line": 3, + "line": 2, }, "start": Object { - "column": 28, - "line": 3, + "column": 30, + "line": 2, }, }, "range": Array [ - 101, - 106, + 48, + 51, ], "type": "Identifier", - "value": "title", + "value": "baz", }, Object { "loc": Object { "end": Object { "column": 34, - "line": 3, + "line": 2, }, "start": Object { "column": 33, - "line": 3, + "line": 2, }, }, "range": Array [ - 106, - 107, + 51, + 52, ], "type": "Punctuator", - "value": ";", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 35, + "line": 2, + }, + }, + "range": Array [ + 53, + 59, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 2, + }, + "start": Object { + "column": 41, + "line": 2, + }, + }, + "range": Array [ + 59, + 60, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 2, + }, + "start": Object { + "column": 43, + "line": 2, + }, + }, + "range": Array [ + 61, + 62, + ], + "type": "Punctuator", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 45, + "line": 2, }, "start": Object { - "column": 4, - "line": 4, + "column": 44, + "line": 2, }, }, "range": Array [ - 112, - 113, + 62, + 63, ], "type": "Punctuator", "value": "}", @@ -83166,16 +85018,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, - "line": 5, + "line": 3, }, }, "range": Array [ - 114, - 115, + 64, + 65, ], "type": "Punctuator", "value": "}", @@ -83185,7 +85037,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-instance-member.src 1`] = ` Object { "body": Array [ Object { @@ -83196,7 +85048,7 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 7, + "column": 9, "line": 2, }, "start": Object { @@ -83204,18 +85056,18 @@ Object { "line": 2, }, }, - "name": "bar", + "name": "greet", "range": Array [ - 16, - 19, + 20, + 25, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { "column": 4, @@ -83223,28 +85075,138 @@ Object { }, }, "range": Array [ - 16, - 50, + 20, + 95, ], "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [], + "body": Array [ + Object { + "argument": Object { + "left": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 67, + 75, + ], + "raw": "\\"Hello \\"", + "type": "Literal", + "value": "Hello ", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 67, + 82, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "name": "name", + "range": Array [ + 78, + 82, + ], + "type": "Identifier", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 67, + 88, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 85, + 88, + ], + "raw": "\\"!\\"", + "type": "Literal", + "value": "!", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 60, + 89, + ], + "type": "ReturnStatement", + }, + ], "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 36, + "column": 34, "line": 2, }, }, "range": Array [ - 48, 50, + 95, ], "type": "BlockStatement", }, @@ -83253,11 +85215,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 7, + "column": 9, "line": 2, }, }, @@ -83266,133 +85228,95 @@ Object { "decorators": Array [ Object { "expression": Object { - "arguments": Array [ - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 2, - }, - "start": Object { - "column": 17, - "line": 2, - }, - }, - "range": Array [ - 29, - 33, - ], - "raw": "true", - "type": "Literal", - "value": true, - }, - ], - "callee": Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 2, - }, - "start": Object { - "column": 9, - "line": 2, - }, - }, - "name": "special", - "range": Array [ - 21, - 28, - ], - "type": "Identifier", - }, "loc": Object { "end": Object { - "column": 22, + "column": 19, "line": 2, }, "start": Object { - "column": 9, + "column": 11, "line": 2, }, }, + "name": "required", "range": Array [ - 21, - 34, + 27, + 35, ], - "type": "CallExpression", + "type": "Identifier", }, "loc": Object { "end": Object { - "column": 22, + "column": 19, "line": 2, }, "start": Object { - "column": 8, + "column": 10, "line": 2, }, }, "range": Array [ - 20, - 34, + 26, + 35, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 34, + "column": 32, "line": 2, }, "start": Object { - "column": 23, + "column": 20, "line": 2, }, }, - "name": "baz", + "name": "name", "range": Array [ - 35, - 46, + 36, + 48, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 34, + "column": 32, "line": 2, }, "start": Object { - "column": 26, + "column": 24, "line": 2, }, }, "range": Array [ - 38, - 46, + 40, + 48, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 34, + "column": 32, "line": 2, }, "start": Object { - "column": 28, + "column": 26, "line": 2, }, }, "range": Array [ - 40, - 46, + 42, + 48, ], - "type": "TSNumberKeyword", + "type": "TSStringKeyword", }, }, }, ], "range": Array [ - 19, - 50, + 25, + 95, ], "type": "FunctionExpression", }, @@ -83401,23 +85325,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { - "column": 10, + "column": 14, "line": 1, }, }, "range": Array [ - 10, - 52, + 14, + 97, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 9, + "column": 13, "line": 1, }, "start": Object { @@ -83425,17 +85349,17 @@ Object { "line": 1, }, }, - "name": "Foo", + "name": "Greeter", "range": Array [ 6, - 9, + 13, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, @@ -83444,7 +85368,7 @@ Object { }, "range": Array [ 0, - 52, + 97, ], "superClass": null, "type": "ClassDeclaration", @@ -83454,7 +85378,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 4, + "line": 6, }, "start": Object { "column": 0, @@ -83463,7 +85387,7 @@ Object { }, "range": Array [ 0, - 53, + 98, ], "sourceType": "module", "tokens": Array [ @@ -83488,7 +85412,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, + "column": 13, "line": 1, }, "start": Object { @@ -83498,25 +85422,25 @@ Object { }, "range": Array [ 6, - 9, + 13, ], "type": "Identifier", - "value": "Foo", + "value": "Greeter", }, Object { "loc": Object { "end": Object { - "column": 11, + "column": 15, "line": 1, }, "start": Object { - "column": 10, + "column": 14, "line": 1, }, }, "range": Array [ - 10, - 11, + 14, + 15, ], "type": "Punctuator", "value": "{", @@ -83524,7 +85448,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 7, + "column": 9, "line": 2, }, "start": Object { @@ -83533,26 +85457,26 @@ Object { }, }, "range": Array [ - 16, - 19, + 20, + 25, ], "type": "Identifier", - "value": "bar", + "value": "greet", }, Object { "loc": Object { "end": Object { - "column": 8, + "column": 10, "line": 2, }, "start": Object { - "column": 7, + "column": 9, "line": 2, }, }, "range": Array [ - 19, - 20, + 25, + 26, ], "type": "Punctuator", "value": "(", @@ -83560,17 +85484,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, + "column": 11, "line": 2, }, "start": Object { - "column": 8, + "column": 10, "line": 2, }, }, "range": Array [ - 20, - 21, + 26, + 27, ], "type": "Punctuator", "value": "@", @@ -83578,71 +85502,89 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 19, "line": 2, }, "start": Object { - "column": 9, + "column": 11, "line": 2, }, }, "range": Array [ - 21, - 28, + 27, + 35, ], "type": "Identifier", - "value": "special", + "value": "required", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 24, "line": 2, }, "start": Object { - "column": 16, + "column": 20, "line": 2, }, }, "range": Array [ - 28, - 29, + 36, + 40, + ], + "type": "Identifier", + "value": "name", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 40, + 41, ], "type": "Punctuator", - "value": "(", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 32, "line": 2, }, "start": Object { - "column": 17, + "column": 26, "line": 2, }, }, "range": Array [ - 29, - 33, + 42, + 48, ], - "type": "Boolean", - "value": "true", + "type": "Identifier", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 22, + "column": 33, "line": 2, }, "start": Object { - "column": 21, + "column": 32, "line": 2, }, }, "range": Array [ - 33, - 34, + 48, + 49, ], "type": "Punctuator", "value": ")", @@ -83650,107 +85592,161 @@ Object { Object { "loc": Object { "end": Object { - "column": 26, + "column": 35, "line": 2, }, "start": Object { - "column": 23, + "column": 34, "line": 2, }, }, "range": Array [ - 35, - 38, + 50, + 51, ], - "type": "Identifier", - "value": "baz", + "type": "Punctuator", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 27, - "line": 2, + "column": 14, + "line": 3, }, "start": Object { - "column": 26, - "line": 2, + "column": 8, + "line": 3, }, }, "range": Array [ - 38, - 39, + 60, + 66, + ], + "type": "Keyword", + "value": "return", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 67, + 75, + ], + "type": "String", + "value": "\\"Hello \\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 3, + }, + "start": Object { + "column": 24, + "line": 3, + }, + }, + "range": Array [ + 76, + 77, ], "type": "Punctuator", - "value": ":", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 34, - "line": 2, + "column": 30, + "line": 3, }, "start": Object { - "column": 28, - "line": 2, + "column": 26, + "line": 3, }, }, "range": Array [ - 40, - 46, + 78, + 82, ], "type": "Identifier", - "value": "number", + "value": "name", }, Object { "loc": Object { "end": Object { - "column": 35, - "line": 2, + "column": 32, + "line": 3, }, "start": Object { - "column": 34, - "line": 2, + "column": 31, + "line": 3, }, }, "range": Array [ - 46, - 47, + 83, + 84, ], "type": "Punctuator", - "value": ")", + "value": "+", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 85, + 88, + ], + "type": "String", + "value": "\\"!\\"", }, Object { "loc": Object { "end": Object { "column": 37, - "line": 2, + "line": 3, }, "start": Object { "column": 36, - "line": 2, + "line": 3, }, }, "range": Array [ - 48, - 49, + 88, + 89, ], "type": "Punctuator", - "value": "{", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 37, - "line": 2, + "column": 4, + "line": 4, }, }, "range": Array [ - 49, - 50, + 94, + 95, ], "type": "Punctuator", "value": "}", @@ -83759,16 +85755,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, - "line": 3, + "line": 5, }, }, "range": Array [ - 51, - 52, + 96, + 97, ], "type": "Punctuator", "value": "}", @@ -83778,7 +85774,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-static-member.src 1`] = ` Object { "body": Array [ Object { @@ -83789,7 +85785,7 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 14, + "column": 16, "line": 2, }, "start": Object { @@ -83797,18 +85793,18 @@ Object { "line": 2, }, }, - "name": "bar", + "name": "greet", "range": Array [ - 29, - 32, + 33, + 38, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { "column": 4, @@ -83816,28 +85812,138 @@ Object { }, }, "range": Array [ - 22, - 63, + 26, + 108, ], "static": true, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [], + "body": Array [ + Object { + "argument": Object { + "left": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 80, + 88, + ], + "raw": "\\"Hello \\"", + "type": "Literal", + "value": "Hello ", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 80, + 95, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "name": "name", + "range": Array [ + 91, + 95, + ], + "type": "Identifier", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 80, + 101, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 98, + 101, + ], + "raw": "\\"!\\"", + "type": "Literal", + "value": "!", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 73, + 102, + ], + "type": "ReturnStatement", + }, + ], "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 43, + "column": 41, "line": 2, }, }, "range": Array [ - 61, 63, + 108, ], "type": "BlockStatement", }, @@ -83846,11 +85952,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 14, + "column": 16, "line": 2, }, }, @@ -83859,133 +85965,95 @@ Object { "decorators": Array [ Object { "expression": Object { - "arguments": Array [ - Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 2, - }, - "start": Object { - "column": 24, - "line": 2, - }, - }, - "range": Array [ - 42, - 46, - ], - "raw": "true", - "type": "Literal", - "value": true, - }, - ], - "callee": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "name": "special", - "range": Array [ - 34, - 41, - ], - "type": "Identifier", - }, "loc": Object { "end": Object { - "column": 29, + "column": 26, "line": 2, }, "start": Object { - "column": 16, + "column": 18, "line": 2, }, }, + "name": "required", "range": Array [ - 34, - 47, + 40, + 48, ], - "type": "CallExpression", + "type": "Identifier", }, "loc": Object { "end": Object { - "column": 29, + "column": 26, "line": 2, }, "start": Object { - "column": 15, + "column": 17, "line": 2, }, }, "range": Array [ - 33, - 47, + 39, + 48, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 2, }, "start": Object { - "column": 30, + "column": 27, "line": 2, }, }, - "name": "baz", + "name": "name", "range": Array [ - 48, - 59, + 49, + 61, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 2, }, "start": Object { - "column": 33, + "column": 31, "line": 2, }, }, "range": Array [ - 51, - 59, + 53, + 61, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 2, }, "start": Object { - "column": 35, + "column": 33, "line": 2, }, }, "range": Array [ - 53, - 59, + 55, + 61, ], - "type": "TSNumberKeyword", + "type": "TSStringKeyword", }, }, }, ], "range": Array [ - 32, - 63, + 38, + 108, ], "type": "FunctionExpression", }, @@ -83994,23 +86062,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { - "column": 16, + "column": 20, "line": 1, }, }, "range": Array [ - 16, - 65, + 20, + 110, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 15, + "column": 19, "line": 1, }, "start": Object { @@ -84018,17 +86086,17 @@ Object { "line": 1, }, }, - "name": "StaticFoo", + "name": "StaticGreeter", "range": Array [ 6, - 15, + 19, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, @@ -84037,7 +86105,7 @@ Object { }, "range": Array [ 0, - 65, + 110, ], "superClass": null, "type": "ClassDeclaration", @@ -84047,7 +86115,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 4, + "line": 6, }, "start": Object { "column": 0, @@ -84056,7 +86124,7 @@ Object { }, "range": Array [ 0, - 66, + 111, ], "sourceType": "module", "tokens": Array [ @@ -84081,7 +86149,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 19, "line": 1, }, "start": Object { @@ -84091,25 +86159,25 @@ Object { }, "range": Array [ 6, - 15, + 19, ], "type": "Identifier", - "value": "StaticFoo", + "value": "StaticGreeter", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 21, "line": 1, }, "start": Object { - "column": 16, + "column": 20, "line": 1, }, }, "range": Array [ - 16, - 17, + 20, + 21, ], "type": "Punctuator", "value": "{", @@ -84126,8 +86194,8 @@ Object { }, }, "range": Array [ - 22, - 28, + 26, + 32, ], "type": "Keyword", "value": "static", @@ -84135,7 +86203,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, + "column": 16, "line": 2, }, "start": Object { @@ -84144,26 +86212,26 @@ Object { }, }, "range": Array [ - 29, - 32, + 33, + 38, ], "type": "Identifier", - "value": "bar", + "value": "greet", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 17, "line": 2, }, "start": Object { - "column": 14, + "column": 16, "line": 2, }, }, "range": Array [ - 32, - 33, + 38, + 39, ], "type": "Punctuator", "value": "(", @@ -84171,17 +86239,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 18, "line": 2, }, "start": Object { - "column": 15, + "column": 17, "line": 2, }, }, "range": Array [ - 33, - 34, + 39, + 40, ], "type": "Punctuator", "value": "@", @@ -84189,71 +86257,89 @@ Object { Object { "loc": Object { "end": Object { - "column": 23, + "column": 26, "line": 2, }, "start": Object { - "column": 16, + "column": 18, "line": 2, }, }, "range": Array [ - 34, - 41, + 40, + 48, ], "type": "Identifier", - "value": "special", + "value": "required", }, Object { "loc": Object { "end": Object { - "column": 24, + "column": 31, "line": 2, }, "start": Object { - "column": 23, + "column": 27, "line": 2, }, }, "range": Array [ - 41, - 42, + 49, + 53, + ], + "type": "Identifier", + "value": "name", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "range": Array [ + 53, + 54, ], "type": "Punctuator", - "value": "(", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 39, "line": 2, }, "start": Object { - "column": 24, + "column": 33, "line": 2, }, }, "range": Array [ - 42, - 46, + 55, + 61, ], - "type": "Boolean", - "value": "true", + "type": "Identifier", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 29, + "column": 40, "line": 2, }, "start": Object { - "column": 28, + "column": 39, "line": 2, }, }, "range": Array [ - 46, - 47, + 61, + 62, ], "type": "Punctuator", "value": ")", @@ -84261,107 +86347,161 @@ Object { Object { "loc": Object { "end": Object { - "column": 33, + "column": 42, "line": 2, }, "start": Object { - "column": 30, + "column": 41, "line": 2, }, }, "range": Array [ - 48, - 51, + 63, + 64, ], - "type": "Identifier", - "value": "baz", + "type": "Punctuator", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 34, - "line": 2, + "column": 14, + "line": 3, }, "start": Object { - "column": 33, - "line": 2, + "column": 8, + "line": 3, }, }, "range": Array [ - 51, - 52, + 73, + 79, + ], + "type": "Keyword", + "value": "return", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 80, + 88, + ], + "type": "String", + "value": "\\"Hello \\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 3, + }, + "start": Object { + "column": 24, + "line": 3, + }, + }, + "range": Array [ + 89, + 90, ], "type": "Punctuator", - "value": ":", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 41, - "line": 2, + "column": 30, + "line": 3, }, "start": Object { - "column": 35, - "line": 2, + "column": 26, + "line": 3, }, }, "range": Array [ - 53, - 59, + 91, + 95, ], "type": "Identifier", - "value": "number", + "value": "name", }, Object { "loc": Object { "end": Object { - "column": 42, - "line": 2, + "column": 32, + "line": 3, }, "start": Object { - "column": 41, - "line": 2, + "column": 31, + "line": 3, }, }, "range": Array [ - 59, - 60, + 96, + 97, ], "type": "Punctuator", - "value": ")", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 44, - "line": 2, + "column": 36, + "line": 3, }, "start": Object { - "column": 43, - "line": 2, + "column": 33, + "line": 3, }, }, "range": Array [ - 61, - 62, + 98, + 101, + ], + "type": "String", + "value": "\\"!\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 36, + "line": 3, + }, + }, + "range": Array [ + 101, + 102, ], "type": "Punctuator", - "value": "{", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 44, - "line": 2, + "column": 4, + "line": 4, }, }, "range": Array [ - 62, - 63, + 107, + 108, ], "type": "Punctuator", "value": "}", @@ -84370,16 +86510,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, - "line": 3, + "line": 5, }, }, "range": Array [ - 64, - 65, + 109, + 110, ], "type": "Punctuator", "value": "}", @@ -84389,7 +86529,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-instance-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-object-pattern-decorator.src 1`] = ` Object { "body": Array [ Object { @@ -84400,165 +86540,55 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 9, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, - "name": "greet", + "name": "bar", "range": Array [ - 20, - 25, + 14, + 17, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 95, + 14, + 49, ], "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [ - Object { - "argument": Object { - "left": Object { - "left": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "range": Array [ - 67, - 75, - ], - "raw": "\\"Hello \\"", - "type": "Literal", - "value": "Hello ", - }, - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 67, - 82, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 26, - "line": 3, - }, - }, - "name": "name", - "range": Array [ - 78, - 82, - ], - "type": "Identifier", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 67, - 88, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 85, - 88, - ], - "raw": "\\"!\\"", - "type": "Literal", - "value": "!", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 37, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 60, - 89, - ], - "type": "ReturnStatement", - }, - ], + "body": Array [], "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 34, + "column": 35, "line": 2, }, }, "range": Array [ - 50, - 95, + 47, + 49, ], "type": "BlockStatement", }, @@ -84567,11 +86597,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 9, + "column": 5, "line": 2, }, }, @@ -84580,95 +86610,191 @@ Object { "decorators": Array [ Object { "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 27, + 31, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 19, + 26, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 19, + "column": 20, "line": 2, }, "start": Object { - "column": 11, + "column": 7, "line": 2, }, }, - "name": "required", "range": Array [ - 27, - 35, + 19, + 32, ], - "type": "Identifier", + "type": "CallExpression", }, "loc": Object { "end": Object { - "column": 19, + "column": 20, "line": 2, }, "start": Object { - "column": 10, + "column": 6, "line": 2, }, }, "range": Array [ - 26, - 35, + 18, + 32, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 32, + "column": 33, "line": 2, }, "start": Object { - "column": 20, + "column": 21, "line": 2, }, }, - "name": "name", + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "method": false, + "range": Array [ + 35, + 38, + ], + "shorthand": true, + "type": "Property", + "value": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + }, + }, + ], "range": Array [ - 36, - 48, + 33, + 45, ], - "type": "Identifier", + "type": "ObjectPattern", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 32, + "column": 33, "line": 2, }, "start": Object { - "column": 24, + "column": 28, "line": 2, }, }, "range": Array [ 40, - 48, + 45, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 32, + "column": 33, "line": 2, }, "start": Object { - "column": 26, + "column": 30, "line": 2, }, }, "range": Array [ 42, - 48, + 45, ], - "type": "TSStringKeyword", + "type": "TSAnyKeyword", }, }, }, ], "range": Array [ - 25, - 95, + 17, + 49, ], "type": "FunctionExpression", }, @@ -84677,23 +86803,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 97, + 10, + 51, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -84701,17 +86827,17 @@ Object { "line": 1, }, }, - "name": "Greeter", + "name": "Foo", "range": Array [ 6, - 13, + 9, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, @@ -84720,7 +86846,7 @@ Object { }, "range": Array [ 0, - 97, + 51, ], "superClass": null, "type": "ClassDeclaration", @@ -84730,7 +86856,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 4, }, "start": Object { "column": 0, @@ -84739,7 +86865,7 @@ Object { }, "range": Array [ 0, - 98, + 52, ], "sourceType": "module", "tokens": Array [ @@ -84764,7 +86890,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -84774,25 +86900,25 @@ Object { }, "range": Array [ 6, - 13, + 9, ], "type": "Identifier", - "value": "Greeter", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 11, "line": 1, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 15, + 10, + 11, ], "type": "Punctuator", "value": "{", @@ -84800,35 +86926,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 25, + 14, + 17, ], "type": "Identifier", - "value": "greet", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 10, + "column": 6, "line": 2, }, "start": Object { - "column": 9, + "column": 5, "line": 2, }, }, "range": Array [ - 25, - 26, + 17, + 18, ], "type": "Punctuator", "value": "(", @@ -84836,17 +86962,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 11, + "column": 7, "line": 2, }, "start": Object { - "column": 10, + "column": 6, "line": 2, }, }, "range": Array [ - 26, - 27, + 18, + 19, ], "type": "Punctuator", "value": "@", @@ -84854,89 +86980,71 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, - "line": 2, - }, - "start": Object { - "column": 11, - "line": 2, - }, - }, - "range": Array [ - 27, - 35, - ], - "type": "Identifier", - "value": "required", - }, - Object { - "loc": Object { - "end": Object { - "column": 24, + "column": 14, "line": 2, }, "start": Object { - "column": 20, + "column": 7, "line": 2, }, }, "range": Array [ - 36, - 40, + 19, + 26, ], "type": "Identifier", - "value": "name", + "value": "special", }, Object { "loc": Object { "end": Object { - "column": 25, + "column": 15, "line": 2, }, "start": Object { - "column": 24, + "column": 14, "line": 2, }, }, "range": Array [ - 40, - 41, + 26, + 27, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 32, + "column": 19, "line": 2, }, "start": Object { - "column": 26, + "column": 15, "line": 2, }, }, "range": Array [ - 42, - 48, + 27, + 31, ], - "type": "Identifier", - "value": "string", + "type": "Boolean", + "value": "true", }, Object { "loc": Object { "end": Object { - "column": 33, + "column": 20, "line": 2, }, "start": Object { - "column": 32, + "column": 19, "line": 2, }, }, "range": Array [ - 48, - 49, + 31, + 32, ], "type": "Punctuator", "value": ")", @@ -84944,17 +87052,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 35, + "column": 22, "line": 2, }, "start": Object { - "column": 34, + "column": 21, "line": 2, }, }, "range": Array [ - 50, - 51, + 33, + 34, ], "type": "Punctuator", "value": "{", @@ -84962,143 +87070,125 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, - "line": 3, + "column": 26, + "line": 2, }, "start": Object { - "column": 8, - "line": 3, + "column": 23, + "line": 2, }, }, "range": Array [ - 60, - 66, + 35, + 38, ], - "type": "Keyword", - "value": "return", + "type": "Identifier", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 3, + "column": 28, + "line": 2, }, "start": Object { - "column": 15, - "line": 3, + "column": 27, + "line": 2, }, }, "range": Array [ - 67, - 75, + 39, + 40, ], - "type": "String", - "value": "\\"Hello \\"", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 25, - "line": 3, + "column": 29, + "line": 2, }, "start": Object { - "column": 24, - "line": 3, + "column": 28, + "line": 2, }, }, "range": Array [ - 76, - 77, + 40, + 41, ], "type": "Punctuator", - "value": "+", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 30, - "line": 3, + "column": 33, + "line": 2, }, "start": Object { - "column": 26, - "line": 3, + "column": 30, + "line": 2, }, }, "range": Array [ - 78, - 82, + 42, + 45, ], "type": "Identifier", - "value": "name", + "value": "any", }, Object { "loc": Object { "end": Object { - "column": 32, - "line": 3, + "column": 34, + "line": 2, }, "start": Object { - "column": 31, - "line": 3, + "column": 33, + "line": 2, }, }, "range": Array [ - 83, - 84, + 45, + 46, ], "type": "Punctuator", - "value": "+", + "value": ")", }, Object { "loc": Object { "end": Object { "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 85, - 88, - ], - "type": "String", - "value": "\\"!\\"", - }, - Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 3, + "line": 2, }, "start": Object { - "column": 36, - "line": 3, + "column": 35, + "line": 2, }, }, "range": Array [ - 88, - 89, + 47, + 48, ], "type": "Punctuator", - "value": ";", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, - "start": Object { - "column": 4, - "line": 4, + "start": Object { + "column": 36, + "line": 2, }, }, "range": Array [ - 94, - 95, + 48, + 49, ], "type": "Punctuator", "value": "}", @@ -85107,16 +87197,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, - "line": 5, + "line": 3, }, }, "range": Array [ - 96, - 97, + 50, + 51, ], "type": "Punctuator", "value": "}", @@ -85126,7 +87216,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-static-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-rest-element-decorator.src 1`] = ` Object { "body": Array [ Object { @@ -85137,165 +87227,55 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 16, + "column": 5, "line": 2, }, "start": Object { - "column": 11, + "column": 2, "line": 2, }, }, - "name": "greet", + "name": "bar", "range": Array [ - 33, - 38, + 14, + 17, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 26, - 108, + 14, + 48, ], - "static": true, + "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [ - Object { - "argument": Object { - "left": Object { - "left": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "range": Array [ - 80, - 88, - ], - "raw": "\\"Hello \\"", - "type": "Literal", - "value": "Hello ", - }, - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 80, - 95, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 26, - "line": 3, - }, - }, - "name": "name", - "range": Array [ - 91, - 95, - ], - "type": "Identifier", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 80, - 101, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 98, - 101, - ], - "raw": "\\"!\\"", - "type": "Literal", - "value": "!", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 37, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 73, - 102, - ], - "type": "ReturnStatement", - }, - ], + "body": Array [], "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 41, + "column": 34, "line": 2, }, }, "range": Array [ - 63, - 108, + 46, + 48, ], "type": "BlockStatement", }, @@ -85304,108 +87284,163 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 16, + "column": 5, "line": 2, }, }, "params": Array [ Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "name": "foo", + "range": Array [ + 36, + 39, + ], + "type": "Identifier", + }, "decorators": Array [ Object { "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 27, + 31, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 19, + 26, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 26, + "column": 20, "line": 2, }, "start": Object { - "column": 18, + "column": 7, "line": 2, }, }, - "name": "required", "range": Array [ - 40, - 48, + 19, + 32, ], - "type": "Identifier", + "type": "CallExpression", }, "loc": Object { "end": Object { - "column": 26, + "column": 20, "line": 2, }, "start": Object { - "column": 17, + "column": 6, "line": 2, }, }, "range": Array [ - 39, - 48, + 18, + 32, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 39, + "column": 32, "line": 2, }, "start": Object { - "column": 27, + "column": 6, "line": 2, }, }, - "name": "name", "range": Array [ - 49, - 61, + 18, + 44, ], - "type": "Identifier", + "type": "RestElement", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 39, + "column": 32, "line": 2, }, "start": Object { - "column": 31, + "column": 27, "line": 2, }, }, "range": Array [ - 53, - 61, + 39, + 44, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 39, + "column": 32, "line": 2, }, "start": Object { - "column": 33, + "column": 29, "line": 2, }, }, "range": Array [ - 55, - 61, + 41, + 44, ], - "type": "TSStringKeyword", + "type": "TSAnyKeyword", }, }, }, ], "range": Array [ - 38, - 108, + 17, + 48, ], "type": "FunctionExpression", }, @@ -85414,23 +87449,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { - "column": 20, + "column": 10, "line": 1, }, }, "range": Array [ - 20, - 110, + 10, + 50, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 19, + "column": 9, "line": 1, }, "start": Object { @@ -85438,17 +87473,17 @@ Object { "line": 1, }, }, - "name": "StaticGreeter", + "name": "Foo", "range": Array [ 6, - 19, + 9, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, @@ -85457,7 +87492,7 @@ Object { }, "range": Array [ 0, - 110, + 50, ], "superClass": null, "type": "ClassDeclaration", @@ -85467,7 +87502,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 4, }, "start": Object { "column": 0, @@ -85476,7 +87511,7 @@ Object { }, "range": Array [ 0, - 111, + 51, ], "sourceType": "module", "tokens": Array [ @@ -85501,7 +87536,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, + "column": 9, "line": 1, }, "start": Object { @@ -85511,25 +87546,25 @@ Object { }, "range": Array [ 6, - 19, + 9, ], "type": "Identifier", - "value": "StaticGreeter", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 11, "line": 1, }, "start": Object { - "column": 20, + "column": 10, "line": 1, }, }, "range": Array [ - 20, - 21, + 10, + 11, ], "type": "Punctuator", "value": "{", @@ -85537,53 +87572,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 10, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "range": Array [ - 26, - 32, - ], - "type": "Keyword", - "value": "static", - }, - Object { - "loc": Object { - "end": Object { - "column": 16, + "column": 5, "line": 2, }, "start": Object { - "column": 11, + "column": 2, "line": 2, }, }, "range": Array [ - 33, - 38, + 14, + 17, ], "type": "Identifier", - "value": "greet", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 6, "line": 2, }, "start": Object { - "column": 16, + "column": 5, "line": 2, }, }, "range": Array [ - 38, - 39, + 17, + 18, ], "type": "Punctuator", "value": "(", @@ -85591,17 +87608,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 18, + "column": 7, "line": 2, }, "start": Object { - "column": 17, + "column": 6, "line": 2, }, }, "range": Array [ - 39, - 40, + 18, + 19, ], "type": "Punctuator", "value": "@", @@ -85609,89 +87626,71 @@ Object { Object { "loc": Object { "end": Object { - "column": 26, - "line": 2, - }, - "start": Object { - "column": 18, - "line": 2, - }, - }, - "range": Array [ - 40, - 48, - ], - "type": "Identifier", - "value": "required", - }, - Object { - "loc": Object { - "end": Object { - "column": 31, + "column": 14, "line": 2, }, "start": Object { - "column": 27, + "column": 7, "line": 2, }, }, "range": Array [ - 49, - 53, + 19, + 26, ], "type": "Identifier", - "value": "name", + "value": "special", }, Object { "loc": Object { "end": Object { - "column": 32, + "column": 15, "line": 2, }, "start": Object { - "column": 31, + "column": 14, "line": 2, }, }, "range": Array [ - 53, - 54, + 26, + 27, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 39, + "column": 19, "line": 2, }, "start": Object { - "column": 33, + "column": 15, "line": 2, }, }, "range": Array [ - 55, - 61, + 27, + 31, ], - "type": "Identifier", - "value": "string", + "type": "Boolean", + "value": "true", }, Object { "loc": Object { "end": Object { - "column": 40, + "column": 20, "line": 2, }, "start": Object { - "column": 39, + "column": 19, "line": 2, }, }, "range": Array [ - 61, - 62, + 31, + 32, ], "type": "Punctuator", "value": ")", @@ -85699,161 +87698,125 @@ Object { Object { "loc": Object { "end": Object { - "column": 42, + "column": 24, "line": 2, }, "start": Object { - "column": 41, + "column": 21, "line": 2, }, }, "range": Array [ - 63, - 64, + 33, + 36, ], "type": "Punctuator", - "value": "{", - }, - Object { - "loc": Object { - "end": Object { - "column": 14, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 73, - 79, - ], - "type": "Keyword", - "value": "return", + "value": "...", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 3, + "column": 27, + "line": 2, }, "start": Object { - "column": 15, - "line": 3, + "column": 24, + "line": 2, }, }, "range": Array [ - 80, - 88, + 36, + 39, ], - "type": "String", - "value": "\\"Hello \\"", + "type": "Identifier", + "value": "foo", }, Object { "loc": Object { "end": Object { - "column": 25, - "line": 3, + "column": 28, + "line": 2, }, "start": Object { - "column": 24, - "line": 3, + "column": 27, + "line": 2, }, }, "range": Array [ - 89, - 90, + 39, + 40, ], "type": "Punctuator", - "value": "+", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 30, - "line": 3, + "column": 32, + "line": 2, }, "start": Object { - "column": 26, - "line": 3, + "column": 29, + "line": 2, }, }, "range": Array [ - 91, - 95, + 41, + 44, ], "type": "Identifier", - "value": "name", + "value": "any", }, Object { "loc": Object { "end": Object { - "column": 32, - "line": 3, + "column": 33, + "line": 2, }, "start": Object { - "column": 31, - "line": 3, + "column": 32, + "line": 2, }, }, "range": Array [ - 96, - 97, + 44, + 45, ], "type": "Punctuator", - "value": "+", - }, - Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 98, - 101, - ], - "type": "String", - "value": "\\"!\\"", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 37, - "line": 3, + "column": 35, + "line": 2, }, "start": Object { - "column": 36, - "line": 3, + "column": 34, + "line": 2, }, }, "range": Array [ - 101, - 102, + 46, + 47, ], "type": "Punctuator", - "value": ";", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 4, - "line": 4, + "column": 35, + "line": 2, }, }, "range": Array [ - 107, - 108, + 47, + 48, ], "type": "Punctuator", "value": "}", @@ -85862,16 +87825,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, - "line": 5, + "line": 3, }, }, "range": Array [ - 109, - 110, + 49, + 50, ], "type": "Punctuator", "value": "}", @@ -89263,6 +91226,233 @@ Object { } `; +exports[`typescript fixtures/errorRecovery/decorator-on-function.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 12, + "line": 2, + }, + }, + "range": Array [ + 17, + 19, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "name": "b", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 0, + 19, + ], + "type": "FunctionDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 20, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 1, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 4, + ], + "type": "Identifier", + "value": "dec", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 5, + 13, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + "value": "b", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 12, + "line": 2, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/errorRecovery/decorator-on-interface-declaration.src 1`] = ` Object { "body": Array [ diff --git a/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-array-pattern-decorator.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-array-pattern-decorator.src.ts new file mode 100644 index 000000000000..81dfc005fc92 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-array-pattern-decorator.src.ts @@ -0,0 +1,3 @@ +class Foo { + bar(@special(true) [ bar ]: any) {} +} diff --git a/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-object-pattern-decorator.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-object-pattern-decorator.src.ts new file mode 100644 index 000000000000..dc9133b3deaf --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-object-pattern-decorator.src.ts @@ -0,0 +1,3 @@ +class Foo { + bar(@special(true) { bar }: any) {} +} diff --git a/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-rest-element-decorator.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-rest-element-decorator.src.ts new file mode 100644 index 000000000000..35b2ac60bc94 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-rest-element-decorator.src.ts @@ -0,0 +1,3 @@ +class Foo { + bar(@special(true) ...foo: any) {} +} diff --git a/packages/shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-function.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-function.src.ts new file mode 100644 index 000000000000..72ed3035b15f --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/errorRecovery/decorator-on-function.src.ts @@ -0,0 +1,2 @@ +@dec +function b(){} diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 6f9465c15139..eb2e69a60ece 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -282,18 +282,19 @@ export class Converter { */ private convertParameters( parameters: ts.NodeArray - ): (es.TSParameterProperty | es.RestElement | es.AssignmentPattern)[] { + ): es.Parameter[] { if (!parameters || !parameters.length) { return []; } return parameters.map(param => { - const convertedParam = this.convertChild(param); - if (!param.decorators || !param.decorators.length) { - return convertedParam; + const convertedParam = this.convertChild(param) as es.Parameter; + + if (param.decorators && param.decorators.length) { + convertedParam.decorators = param.decorators.map(el => + this.convertChild(el) + ); } - return Object.assign(convertedParam, { - decorators: param.decorators.map(el => this.convertChild(el)) - }); + return convertedParam; }); } diff --git a/packages/typescript-estree/src/typedefs.ts b/packages/typescript-estree/src/typedefs.ts index f5fecea9ef7f..a9a100e64623 100644 --- a/packages/typescript-estree/src/typedefs.ts +++ b/packages/typescript-estree/src/typedefs.ts @@ -351,7 +351,13 @@ export type ObjectLiteralElementLike = | RestElement | SpreadElement | TSAbstractMethodDefinition; -export type Parameter = AssignmentPattern | RestElement | TSParameterProperty; +export type Parameter = + | AssignmentPattern + | RestElement + | ArrayPattern + | ObjectPattern + | Identifier + | TSParameterProperty; export type PrimaryExpression = | ArrayExpression | ArrayPattern @@ -541,6 +547,7 @@ export interface ArrayPattern extends BaseNode { elements: Expression[]; typeAnnotation?: TSTypeAnnotation; optional?: boolean; + decorators?: Decorator[]; } export interface ArrowFunctionExpression extends BaseNode { @@ -565,6 +572,7 @@ export interface AssignmentPattern extends BaseNode { right?: Expression; typeAnnotation?: TSTypeAnnotation; optional?: boolean; + decorators?: Decorator[]; } export interface AwaitExpression extends BaseNode { @@ -715,6 +723,7 @@ export interface Identifier extends BaseNode { name: string; typeAnnotation?: TSTypeAnnotation; optional?: boolean; + decorators?: Decorator[]; } export interface IfStatement extends BaseNode { @@ -875,6 +884,7 @@ export interface ObjectPattern extends BaseNode { properties: ObjectLiteralElementLike[]; typeAnnotation?: TSTypeAnnotation; optional?: boolean; + decorators?: Decorator[]; } export interface Program extends BaseNode { @@ -901,6 +911,7 @@ export interface RestElement extends BaseNode { typeAnnotation?: TSTypeAnnotation; optional?: boolean; value?: AssignmentPattern; + decorators?: Decorator[]; } export interface ReturnStatement extends BaseNode { @@ -1218,6 +1229,7 @@ export interface TSParameterProperty extends BaseNode { static?: boolean; export?: boolean; parameter: AssignmentPattern | BindingName | RestElement; + decorators?: Decorator[]; } export interface TSParenthesizedType extends BaseNode { 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 e92f68f968f4..e8dcf0aca782 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -396,7 +396,15 @@ tester.addFixturePatternConfig('typescript/decorators/method-decorators', { fileType: 'ts' }); tester.addFixturePatternConfig('typescript/decorators/parameter-decorators', { - fileType: 'ts' + fileType: 'ts', + ignore: [ + /** + * babel does not support decorators on array and rest parameters + * TODO: report this to babel + */ + 'parameter-array-pattern-decorator', + 'parameter-rest-element-decorator' + ] }); tester.addFixturePatternConfig('typescript/decorators/property-decorators', { fileType: 'ts' diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index 842757edb3df..dde844c7e15e 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -2236,6 +2236,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/method-decorators/method-decorator-static-member.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/parameter-decorators/parameter-array-pattern-decorator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/parameter-decorators/parameter-decorator-constructor.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -2246,6 +2248,10 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/parameter-decorators/parameter-decorator-static-member.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/parameter-decorators/parameter-object-pattern-decorator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/parameter-decorators/parameter-rest-element-decorator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/property-decorators/property-decorator-factory-instance-member.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/property-decorators/property-decorator-factory-static-member.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -2299,6 +2305,15 @@ Object { } `; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/decorator-on-function.src 1`] = ` +Object { + "column": 0, + "index": 0, + "lineNumber": 1, + "message": "Decorators are not valid here.", +} +`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/decorator-on-interface-declaration.src 1`] = ` Object { "column": 0, diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index b9d07faaa475..d1040b3b2957 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -81613,7 +81613,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-constructor.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-array-pattern-decorator.src 1`] = ` Object { "body": Array [ Object { @@ -81624,198 +81624,55 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 15, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, - "name": "constructor", + "name": "bar", "range": Array [ - 20, - 31, + 14, + 17, ], "type": "Identifier", }, - "kind": "constructor", + "kind": "method", "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 113, + 14, + 49, ], "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [ - Object { - "expression": Object { - "left": Object { - "computed": false, - "loc": Object { - "end": Object { - "column": 18, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "object": Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 81, - 85, - ], - "type": "ThisExpression", - }, - "property": Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 3, - }, - "start": Object { - "column": 13, - "line": 3, - }, - }, - "name": "title", - "range": Array [ - 86, - 91, - ], - "type": "Identifier", - }, - "range": Array [ - 81, - 91, - ], - "type": "MemberExpression", - }, - "loc": Object { - "end": Object { - "column": 33, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "operator": "=", - "range": Array [ - 81, - 106, - ], - "right": Object { - "computed": false, - "loc": Object { - "end": Object { - "column": 33, - "line": 3, - }, - "start": Object { - "column": 21, - "line": 3, - }, - }, - "object": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 3, - }, - "start": Object { - "column": 21, - "line": 3, - }, - }, - "name": "config", - "range": Array [ - 94, - 100, - ], - "type": "Identifier", - }, - "property": Object { - "loc": Object { - "end": Object { - "column": 33, - "line": 3, - }, - "start": Object { - "column": 28, - "line": 3, - }, - }, - "name": "title", - "range": Array [ - 101, - 106, - ], - "type": "Identifier", - }, - "range": Array [ - 94, - 106, - ], - "type": "MemberExpression", - }, - "type": "AssignmentExpression", - }, - "loc": Object { - "end": Object { - "column": 34, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 81, - 107, - ], - "type": "ExpressionStatement", - }, - ], + "body": Array [], "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 55, + "column": 35, "line": 2, }, }, "range": Array [ - 71, - 113, + 47, + 49, ], "type": "BlockStatement", }, @@ -81824,11 +81681,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 15, + "column": 5, "line": 2, }, }, @@ -81841,146 +81698,148 @@ Object { Object { "loc": Object { "end": Object { - "column": 34, + "column": 19, "line": 2, }, "start": Object { - "column": 24, + "column": 15, "line": 2, }, }, - "name": "APP_CONFIG", "range": Array [ - 40, - 50, + 27, + 31, ], - "type": "Identifier", + "raw": "true", + "type": "Literal", + "value": true, }, ], "callee": Object { "loc": Object { "end": Object { - "column": 23, + "column": 14, "line": 2, }, "start": Object { - "column": 17, + "column": 7, "line": 2, }, }, - "name": "Inject", + "name": "special", "range": Array [ - 33, - 39, + 19, + 26, ], "type": "Identifier", }, "loc": Object { "end": Object { - "column": 35, + "column": 20, "line": 2, }, "start": Object { - "column": 17, + "column": 7, "line": 2, }, }, "range": Array [ - 33, - 51, + 19, + 32, ], "type": "CallExpression", }, "loc": Object { "end": Object { - "column": 35, + "column": 20, "line": 2, }, "start": Object { - "column": 16, + "column": 6, "line": 2, }, }, "range": Array [ + 18, 32, - 51, ], "type": "Decorator", }, ], + "elements": Array [ + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + }, + ], "loc": Object { "end": Object { - "column": 53, + "column": 33, "line": 2, }, "start": Object { - "column": 36, + "column": 21, "line": 2, }, }, - "name": "config", "range": Array [ - 52, - 69, + 33, + 45, ], - "type": "Identifier", + "type": "ArrayPattern", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 53, + "column": 33, "line": 2, }, "start": Object { - "column": 42, + "column": 28, "line": 2, }, }, "range": Array [ - 58, - 69, + 40, + 45, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 53, + "column": 33, "line": 2, }, "start": Object { - "column": 44, + "column": 30, "line": 2, }, }, "range": Array [ - 60, - 69, + 42, + 45, ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 53, - "line": 2, - }, - "start": Object { - "column": 44, - "line": 2, - }, - }, - "name": "AppConfig", - "range": Array [ - 60, - 69, - ], - "type": "Identifier", - }, + "type": "TSAnyKeyword", }, }, }, ], "range": Array [ - 31, - 113, + 17, + 49, ], "type": "FunctionExpression", }, @@ -81989,23 +81848,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 115, + 10, + 51, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -82013,17 +81872,17 @@ Object { "line": 1, }, }, - "name": "Service", + "name": "Foo", "range": Array [ 6, - 13, + 9, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, @@ -82032,7 +81891,7 @@ Object { }, "range": Array [ 0, - 115, + 51, ], "superClass": null, "type": "ClassDeclaration", @@ -82041,7 +81900,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 4, }, "start": Object { "column": 0, @@ -82050,7 +81909,7 @@ Object { }, "range": Array [ 0, - 116, + 52, ], "sourceType": "script", "tokens": Array [ @@ -82075,7 +81934,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -82085,25 +81944,25 @@ Object { }, "range": Array [ 6, - 13, + 9, ], "type": "Identifier", - "value": "Service", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 11, "line": 1, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 15, + 10, + 11, ], "type": "Punctuator", "value": "{", @@ -82111,35 +81970,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 31, + 14, + 17, ], "type": "Identifier", - "value": "constructor", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 6, "line": 2, }, "start": Object { - "column": 15, + "column": 5, "line": 2, }, }, "range": Array [ - 31, - 32, + 17, + 18, ], "type": "Punctuator", "value": "(", @@ -82147,17 +82006,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 17, + "column": 7, "line": 2, }, "start": Object { - "column": 16, + "column": 6, "line": 2, }, }, "range": Array [ - 32, - 33, + 18, + 19, ], "type": "Punctuator", "value": "@", @@ -82165,35 +82024,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 23, + "column": 14, "line": 2, }, "start": Object { - "column": 17, + "column": 7, "line": 2, }, }, "range": Array [ - 33, - 39, + 19, + 26, ], "type": "Identifier", - "value": "Inject", + "value": "special", }, Object { "loc": Object { "end": Object { - "column": 24, + "column": 15, "line": 2, }, "start": Object { - "column": 23, + "column": 14, "line": 2, }, }, "range": Array [ - 39, - 40, + 26, + 27, ], "type": "Punctuator", "value": "(", @@ -82201,35 +82060,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 34, + "column": 19, "line": 2, }, "start": Object { - "column": 24, + "column": 15, "line": 2, }, }, "range": Array [ - 40, - 50, + 27, + 31, ], - "type": "Identifier", - "value": "APP_CONFIG", + "type": "Boolean", + "value": "true", }, Object { "loc": Object { "end": Object { - "column": 35, + "column": 20, "line": 2, }, "start": Object { - "column": 34, + "column": 19, "line": 2, }, }, "range": Array [ - 50, - 51, + 31, + 32, ], "type": "Punctuator", "value": ")", @@ -82237,251 +82096,2241 @@ Object { Object { "loc": Object { "end": Object { - "column": 42, + "column": 22, "line": 2, }, "start": Object { - "column": 36, + "column": 21, "line": 2, }, }, "range": Array [ - 52, - 58, + 33, + 34, ], - "type": "Identifier", - "value": "config", + "type": "Punctuator", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 43, + "column": 26, "line": 2, }, "start": Object { - "column": 42, + "column": 23, "line": 2, }, }, "range": Array [ - 58, - 59, + 35, + 38, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 53, + "column": 28, "line": 2, }, "start": Object { - "column": 44, + "column": 27, "line": 2, }, }, "range": Array [ - 60, - 69, + 39, + 40, ], - "type": "Identifier", - "value": "AppConfig", + "type": "Punctuator", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 54, + "column": 29, "line": 2, }, "start": Object { - "column": 53, + "column": 28, "line": 2, }, }, "range": Array [ - 69, - 70, + 40, + 41, ], "type": "Punctuator", - "value": ")", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 56, + "column": 33, "line": 2, }, "start": Object { - "column": 55, + "column": 30, "line": 2, }, }, "range": Array [ - 71, - 72, + 42, + 45, ], - "type": "Punctuator", - "value": "{", + "type": "Identifier", + "value": "any", }, Object { "loc": Object { "end": Object { - "column": 12, - "line": 3, + "column": 34, + "line": 2, }, "start": Object { - "column": 8, - "line": 3, + "column": 33, + "line": 2, }, }, "range": Array [ - 81, - 85, + 45, + 46, ], - "type": "Keyword", - "value": "this", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 13, - "line": 3, + "column": 36, + "line": 2, }, "start": Object { - "column": 12, - "line": 3, + "column": 35, + "line": 2, }, }, "range": Array [ - 85, - 86, + 47, + 48, ], "type": "Punctuator", - "value": ".", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 18, - "line": 3, + "column": 37, + "line": 2, }, "start": Object { - "column": 13, - "line": 3, + "column": 36, + "line": 2, }, }, "range": Array [ - 86, - 91, + 48, + 49, ], - "type": "Identifier", - "value": "title", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 1, "line": 3, }, "start": Object { - "column": 19, + "column": 0, "line": 3, }, }, "range": Array [ - 92, - 93, + 50, + 51, ], "type": "Punctuator", - "value": "=", + "value": "}", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-constructor.src 1`] = ` +Object { + "body": Array [ Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 3, - }, + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "name": "constructor", + "range": Array [ + 20, + 31, + ], + "type": "Identifier", + }, + "kind": "constructor", + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 20, + 113, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "expression": Object { + "left": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 81, + 85, + ], + "type": "ThisExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 13, + "line": 3, + }, + }, + "name": "title", + "range": Array [ + 86, + 91, + ], + "type": "Identifier", + }, + "range": Array [ + 81, + 91, + ], + "type": "MemberExpression", + }, + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "operator": "=", + "range": Array [ + 81, + 106, + ], + "right": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "name": "config", + "range": Array [ + 94, + 100, + ], + "type": "Identifier", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 28, + "line": 3, + }, + }, + "name": "title", + "range": Array [ + 101, + 106, + ], + "type": "Identifier", + }, + "range": Array [ + 94, + 106, + ], + "type": "MemberExpression", + }, + "type": "AssignmentExpression", + }, + "loc": Object { + "end": Object { + "column": 34, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 81, + 107, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 55, + "line": 2, + }, + }, + "range": Array [ + 71, + 113, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "params": Array [ + Object { + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "name": "APP_CONFIG", + "range": Array [ + 40, + 50, + ], + "type": "Identifier", + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "name": "Inject", + "range": Array [ + 33, + 39, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 33, + 51, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 32, + 51, + ], + "type": "Decorator", + }, + ], + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "name": "config", + "range": Array [ + 52, + 69, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 42, + "line": 2, + }, + }, + "range": Array [ + 58, + 69, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "range": Array [ + 60, + 69, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "name": "AppConfig", + "range": Array [ + 60, + 69, + ], + "type": "Identifier", + }, + }, + }, + }, + ], + "range": Array [ + 31, + 113, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 115, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Service", + "range": Array [ + 6, + 13, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 115, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 6, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 116, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 13, + ], + "type": "Identifier", + "value": "Service", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 20, + 31, + ], + "type": "Identifier", + "value": "constructor", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 33, + 39, + ], + "type": "Identifier", + "value": "Inject", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 40, + 50, + ], + "type": "Identifier", + "value": "APP_CONFIG", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 34, + "line": 2, + }, + }, + "range": Array [ + 50, + 51, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 52, + 58, + ], + "type": "Identifier", + "value": "config", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 2, + }, + "start": Object { + "column": 42, + "line": 2, + }, + }, + "range": Array [ + 58, + 59, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "range": Array [ + 60, + 69, + ], + "type": "Identifier", + "value": "AppConfig", + }, + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 2, + }, + "start": Object { + "column": 53, + "line": 2, + }, + }, + "range": Array [ + 69, + 70, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 2, + }, + "start": Object { + "column": 55, + "line": 2, + }, + }, + "range": Array [ + 71, + 72, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 81, + 85, + ], + "type": "Keyword", + "value": "this", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 12, + "line": 3, + }, + }, + "range": Array [ + 85, + 86, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 13, + "line": 3, + }, + }, + "range": Array [ + 86, + 91, + ], + "type": "Identifier", + "value": "title", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 3, + }, + "start": Object { + "column": 19, + "line": 3, + }, + }, + "range": Array [ + 92, + 93, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "range": Array [ + 94, + 100, + ], + "type": "Identifier", + "value": "config", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 3, + }, + "start": Object { + "column": 27, + "line": 3, + }, + }, + "range": Array [ + 100, + 101, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 28, + "line": 3, + }, + }, + "range": Array [ + 101, + 106, + ], + "type": "Identifier", + "value": "title", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 106, + 107, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 114, + 115, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 16, + 19, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 16, + 50, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 48, + 50, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "params": Array [ + Object { + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 29, + 33, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 21, + 28, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 21, + 34, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 34, + ], + "type": "Decorator", + }, + ], + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "baz", + "range": Array [ + 35, + 46, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 26, + "line": 2, + }, + }, + "range": Array [ + 38, + 46, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 40, + 46, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 19, + 50, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 52, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 52, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 53, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 16, + 19, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 21, + 28, + ], + "type": "Identifier", + "value": "special", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 29, + 33, + ], + "type": "Boolean", + "value": "true", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 21, + "line": 2, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + "value": "baz", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 26, + "line": 2, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 40, + 46, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 34, + "line": 2, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 48, + 49, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 37, + "line": 2, + }, + }, + "range": Array [ + 49, + 50, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 51, + 52, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 29, + 32, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 22, + 63, + ], + "static": true, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 43, + "line": 2, + }, + }, + "range": Array [ + 61, + 63, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "params": Array [ + Object { + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 42, + 46, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 34, + 41, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 34, + 47, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 33, + 47, + ], + "type": "Decorator", + }, + ], + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "name": "baz", + "range": Array [ + 48, + 59, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 33, + "line": 2, + }, + }, + "range": Array [ + 51, + 59, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 35, + "line": 2, + }, + }, + "range": Array [ + 53, + 59, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 32, + 63, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 65, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "StaticFoo", + "range": Array [ + 6, + 15, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 65, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 66, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, "start": Object { - "column": 21, - "line": 3, + "column": 6, + "line": 1, }, }, "range": Array [ - 94, - 100, + 6, + 15, ], "type": "Identifier", - "value": "config", + "value": "StaticFoo", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "Keyword", + "value": "static", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 29, + 32, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 34, + 41, + ], + "type": "Identifier", + "value": "special", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Punctuator", + "value": "(", }, Object { "loc": Object { "end": Object { "column": 28, - "line": 3, + "line": 2, }, "start": Object { - "column": 27, - "line": 3, + "column": 24, + "line": 2, }, }, "range": Array [ - 100, - 101, + 42, + 46, + ], + "type": "Boolean", + "value": "true", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 46, + 47, ], "type": "Punctuator", - "value": ".", + "value": ")", }, Object { "loc": Object { "end": Object { "column": 33, - "line": 3, + "line": 2, }, "start": Object { - "column": 28, - "line": 3, + "column": 30, + "line": 2, }, }, "range": Array [ - 101, - 106, + 48, + 51, ], "type": "Identifier", - "value": "title", + "value": "baz", }, Object { "loc": Object { "end": Object { "column": 34, - "line": 3, + "line": 2, }, "start": Object { "column": 33, - "line": 3, + "line": 2, }, }, "range": Array [ - 106, - 107, + 51, + 52, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 35, + "line": 2, + }, + }, + "range": Array [ + 53, + 59, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 2, + }, + "start": Object { + "column": 41, + "line": 2, + }, + }, + "range": Array [ + 59, + 60, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 2, + }, + "start": Object { + "column": 43, + "line": 2, + }, + }, + "range": Array [ + 61, + 62, ], "type": "Punctuator", - "value": ";", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 45, + "line": 2, }, "start": Object { - "column": 4, - "line": 4, + "column": 44, + "line": 2, }, }, "range": Array [ - 112, - 113, + 62, + 63, ], "type": "Punctuator", "value": "}", @@ -82490,16 +84339,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, - "line": 5, + "line": 3, }, }, "range": Array [ - 114, - 115, + 64, + 65, ], "type": "Punctuator", "value": "}", @@ -82509,7 +84358,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-instance-member.src 1`] = ` Object { "body": Array [ Object { @@ -82520,7 +84369,7 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 7, + "column": 9, "line": 2, }, "start": Object { @@ -82528,18 +84377,18 @@ Object { "line": 2, }, }, - "name": "bar", + "name": "greet", "range": Array [ - 16, - 19, + 20, + 25, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { "column": 4, @@ -82547,28 +84396,138 @@ Object { }, }, "range": Array [ - 16, - 50, + 20, + 95, ], "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [], + "body": Array [ + Object { + "argument": Object { + "left": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 67, + 75, + ], + "raw": "\\"Hello \\"", + "type": "Literal", + "value": "Hello ", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 67, + 82, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "name": "name", + "range": Array [ + 78, + 82, + ], + "type": "Identifier", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 67, + 88, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 85, + 88, + ], + "raw": "\\"!\\"", + "type": "Literal", + "value": "!", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 60, + 89, + ], + "type": "ReturnStatement", + }, + ], "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 36, + "column": 34, "line": 2, }, }, "range": Array [ - 48, 50, + 95, ], "type": "BlockStatement", }, @@ -82577,11 +84536,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 7, + "column": 9, "line": 2, }, }, @@ -82590,133 +84549,95 @@ Object { "decorators": Array [ Object { "expression": Object { - "arguments": Array [ - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 2, - }, - "start": Object { - "column": 17, - "line": 2, - }, - }, - "range": Array [ - 29, - 33, - ], - "raw": "true", - "type": "Literal", - "value": true, - }, - ], - "callee": Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 2, - }, - "start": Object { - "column": 9, - "line": 2, - }, - }, - "name": "special", - "range": Array [ - 21, - 28, - ], - "type": "Identifier", - }, "loc": Object { "end": Object { - "column": 22, + "column": 19, "line": 2, }, "start": Object { - "column": 9, + "column": 11, "line": 2, }, }, + "name": "required", "range": Array [ - 21, - 34, + 27, + 35, ], - "type": "CallExpression", + "type": "Identifier", }, "loc": Object { "end": Object { - "column": 22, + "column": 19, "line": 2, }, "start": Object { - "column": 8, + "column": 10, "line": 2, }, }, "range": Array [ - 20, - 34, + 26, + 35, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 34, + "column": 32, "line": 2, }, "start": Object { - "column": 23, + "column": 20, "line": 2, }, }, - "name": "baz", + "name": "name", "range": Array [ - 35, - 46, + 36, + 48, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 34, + "column": 32, "line": 2, }, "start": Object { - "column": 26, + "column": 24, "line": 2, }, }, "range": Array [ - 38, - 46, + 40, + 48, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 34, + "column": 32, "line": 2, }, "start": Object { - "column": 28, + "column": 26, "line": 2, }, }, "range": Array [ - 40, - 46, + 42, + 48, ], - "type": "TSNumberKeyword", + "type": "TSStringKeyword", }, }, }, ], "range": Array [ - 19, - 50, + 25, + 95, ], "type": "FunctionExpression", }, @@ -82725,23 +84646,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { - "column": 10, + "column": 14, "line": 1, }, }, "range": Array [ - 10, - 52, + 14, + 97, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 9, + "column": 13, "line": 1, }, "start": Object { @@ -82749,17 +84670,17 @@ Object { "line": 1, }, }, - "name": "Foo", + "name": "Greeter", "range": Array [ 6, - 9, + 13, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, @@ -82768,7 +84689,7 @@ Object { }, "range": Array [ 0, - 52, + 97, ], "superClass": null, "type": "ClassDeclaration", @@ -82777,7 +84698,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 4, + "line": 6, }, "start": Object { "column": 0, @@ -82786,7 +84707,7 @@ Object { }, "range": Array [ 0, - 53, + 98, ], "sourceType": "script", "tokens": Array [ @@ -82811,7 +84732,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, + "column": 13, "line": 1, }, "start": Object { @@ -82821,25 +84742,25 @@ Object { }, "range": Array [ 6, - 9, + 13, ], "type": "Identifier", - "value": "Foo", + "value": "Greeter", }, Object { "loc": Object { "end": Object { - "column": 11, + "column": 15, "line": 1, }, "start": Object { - "column": 10, + "column": 14, "line": 1, }, }, "range": Array [ - 10, - 11, + 14, + 15, ], "type": "Punctuator", "value": "{", @@ -82847,7 +84768,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 7, + "column": 9, "line": 2, }, "start": Object { @@ -82856,26 +84777,26 @@ Object { }, }, "range": Array [ - 16, - 19, + 20, + 25, ], "type": "Identifier", - "value": "bar", + "value": "greet", }, Object { "loc": Object { "end": Object { - "column": 8, + "column": 10, "line": 2, }, "start": Object { - "column": 7, + "column": 9, "line": 2, }, }, "range": Array [ - 19, - 20, + 25, + 26, ], "type": "Punctuator", "value": "(", @@ -82883,17 +84804,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, + "column": 11, "line": 2, }, "start": Object { - "column": 8, + "column": 10, "line": 2, }, }, "range": Array [ - 20, - 21, + 26, + 27, ], "type": "Punctuator", "value": "@", @@ -82901,71 +84822,89 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 19, "line": 2, }, "start": Object { - "column": 9, + "column": 11, "line": 2, }, }, "range": Array [ - 21, - 28, + 27, + 35, ], "type": "Identifier", - "value": "special", + "value": "required", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 24, "line": 2, }, "start": Object { - "column": 16, + "column": 20, "line": 2, }, }, "range": Array [ - 28, - 29, + 36, + 40, + ], + "type": "Identifier", + "value": "name", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 40, + 41, ], "type": "Punctuator", - "value": "(", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 32, "line": 2, }, "start": Object { - "column": 17, + "column": 26, "line": 2, }, }, "range": Array [ - 29, - 33, + 42, + 48, ], - "type": "Boolean", - "value": "true", + "type": "Identifier", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 22, + "column": 33, "line": 2, }, "start": Object { - "column": 21, + "column": 32, "line": 2, }, }, "range": Array [ - 33, - 34, + 48, + 49, ], "type": "Punctuator", "value": ")", @@ -82973,107 +84912,161 @@ Object { Object { "loc": Object { "end": Object { - "column": 26, + "column": 35, "line": 2, }, "start": Object { - "column": 23, + "column": 34, "line": 2, }, }, "range": Array [ - 35, - 38, + 50, + 51, ], - "type": "Identifier", - "value": "baz", + "type": "Punctuator", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 27, - "line": 2, + "column": 14, + "line": 3, }, "start": Object { - "column": 26, - "line": 2, + "column": 8, + "line": 3, }, }, "range": Array [ - 38, - 39, + 60, + 66, + ], + "type": "Keyword", + "value": "return", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 67, + 75, + ], + "type": "String", + "value": "\\"Hello \\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 3, + }, + "start": Object { + "column": 24, + "line": 3, + }, + }, + "range": Array [ + 76, + 77, ], "type": "Punctuator", - "value": ":", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 34, - "line": 2, + "column": 30, + "line": 3, }, "start": Object { - "column": 28, - "line": 2, + "column": 26, + "line": 3, }, }, "range": Array [ - 40, - 46, + 78, + 82, ], "type": "Identifier", - "value": "number", + "value": "name", }, Object { "loc": Object { "end": Object { - "column": 35, - "line": 2, + "column": 32, + "line": 3, }, "start": Object { - "column": 34, - "line": 2, + "column": 31, + "line": 3, }, }, "range": Array [ - 46, - 47, + 83, + 84, ], "type": "Punctuator", - "value": ")", + "value": "+", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 85, + 88, + ], + "type": "String", + "value": "\\"!\\"", }, Object { "loc": Object { "end": Object { "column": 37, - "line": 2, + "line": 3, }, "start": Object { "column": 36, - "line": 2, + "line": 3, }, }, "range": Array [ - 48, - 49, + 88, + 89, ], "type": "Punctuator", - "value": "{", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 37, - "line": 2, + "column": 4, + "line": 4, }, }, "range": Array [ - 49, - 50, + 94, + 95, ], "type": "Punctuator", "value": "}", @@ -83082,16 +85075,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, - "line": 3, + "line": 5, }, }, "range": Array [ - 51, - 52, + 96, + 97, ], "type": "Punctuator", "value": "}", @@ -83101,7 +85094,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-static-member.src 1`] = ` Object { "body": Array [ Object { @@ -83112,7 +85105,7 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 14, + "column": 16, "line": 2, }, "start": Object { @@ -83120,18 +85113,18 @@ Object { "line": 2, }, }, - "name": "bar", + "name": "greet", "range": Array [ - 29, - 32, + 33, + 38, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { "column": 4, @@ -83139,28 +85132,138 @@ Object { }, }, "range": Array [ - 22, - 63, + 26, + 108, ], "static": true, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [], + "body": Array [ + Object { + "argument": Object { + "left": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 80, + 88, + ], + "raw": "\\"Hello \\"", + "type": "Literal", + "value": "Hello ", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 80, + 95, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "name": "name", + "range": Array [ + 91, + 95, + ], + "type": "Identifier", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 80, + 101, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 98, + 101, + ], + "raw": "\\"!\\"", + "type": "Literal", + "value": "!", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 73, + 102, + ], + "type": "ReturnStatement", + }, + ], "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 43, + "column": 41, "line": 2, }, }, "range": Array [ - 61, 63, + 108, ], "type": "BlockStatement", }, @@ -83169,11 +85272,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 14, + "column": 16, "line": 2, }, }, @@ -83182,133 +85285,95 @@ Object { "decorators": Array [ Object { "expression": Object { - "arguments": Array [ - Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 2, - }, - "start": Object { - "column": 24, - "line": 2, - }, - }, - "range": Array [ - 42, - 46, - ], - "raw": "true", - "type": "Literal", - "value": true, - }, - ], - "callee": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "name": "special", - "range": Array [ - 34, - 41, - ], - "type": "Identifier", - }, "loc": Object { "end": Object { - "column": 29, + "column": 26, "line": 2, }, "start": Object { - "column": 16, + "column": 18, "line": 2, }, }, + "name": "required", "range": Array [ - 34, - 47, + 40, + 48, ], - "type": "CallExpression", + "type": "Identifier", }, "loc": Object { "end": Object { - "column": 29, + "column": 26, "line": 2, }, "start": Object { - "column": 15, + "column": 17, "line": 2, }, }, "range": Array [ - 33, - 47, + 39, + 48, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 2, }, "start": Object { - "column": 30, + "column": 27, "line": 2, }, }, - "name": "baz", + "name": "name", "range": Array [ - 48, - 59, + 49, + 61, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 2, }, "start": Object { - "column": 33, + "column": 31, "line": 2, }, }, "range": Array [ - 51, - 59, + 53, + 61, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 2, }, "start": Object { - "column": 35, + "column": 33, "line": 2, }, }, "range": Array [ - 53, - 59, + 55, + 61, ], - "type": "TSNumberKeyword", + "type": "TSStringKeyword", }, }, }, ], "range": Array [ - 32, - 63, + 38, + 108, ], "type": "FunctionExpression", }, @@ -83317,23 +85382,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { - "column": 16, + "column": 20, "line": 1, }, }, "range": Array [ - 16, - 65, + 20, + 110, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 15, + "column": 19, "line": 1, }, "start": Object { @@ -83341,17 +85406,17 @@ Object { "line": 1, }, }, - "name": "StaticFoo", + "name": "StaticGreeter", "range": Array [ 6, - 15, + 19, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, @@ -83360,7 +85425,7 @@ Object { }, "range": Array [ 0, - 65, + 110, ], "superClass": null, "type": "ClassDeclaration", @@ -83369,7 +85434,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 4, + "line": 6, }, "start": Object { "column": 0, @@ -83378,7 +85443,7 @@ Object { }, "range": Array [ 0, - 66, + 111, ], "sourceType": "script", "tokens": Array [ @@ -83403,7 +85468,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 19, "line": 1, }, "start": Object { @@ -83413,25 +85478,25 @@ Object { }, "range": Array [ 6, - 15, + 19, ], "type": "Identifier", - "value": "StaticFoo", + "value": "StaticGreeter", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 21, "line": 1, }, "start": Object { - "column": 16, + "column": 20, "line": 1, }, }, "range": Array [ - 16, - 17, + 20, + 21, ], "type": "Punctuator", "value": "{", @@ -83448,8 +85513,8 @@ Object { }, }, "range": Array [ - 22, - 28, + 26, + 32, ], "type": "Keyword", "value": "static", @@ -83457,7 +85522,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, + "column": 16, "line": 2, }, "start": Object { @@ -83466,26 +85531,26 @@ Object { }, }, "range": Array [ - 29, - 32, + 33, + 38, ], "type": "Identifier", - "value": "bar", + "value": "greet", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 17, "line": 2, }, "start": Object { - "column": 14, + "column": 16, "line": 2, }, }, "range": Array [ - 32, - 33, + 38, + 39, ], "type": "Punctuator", "value": "(", @@ -83493,17 +85558,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 18, "line": 2, }, "start": Object { - "column": 15, + "column": 17, "line": 2, }, }, "range": Array [ - 33, - 34, + 39, + 40, ], "type": "Punctuator", "value": "@", @@ -83511,71 +85576,89 @@ Object { Object { "loc": Object { "end": Object { - "column": 23, + "column": 26, "line": 2, }, "start": Object { - "column": 16, + "column": 18, "line": 2, }, }, "range": Array [ - 34, - 41, + 40, + 48, ], "type": "Identifier", - "value": "special", + "value": "required", }, Object { "loc": Object { "end": Object { - "column": 24, + "column": 31, "line": 2, }, "start": Object { - "column": 23, + "column": 27, "line": 2, }, }, "range": Array [ - 41, - 42, + 49, + 53, + ], + "type": "Identifier", + "value": "name", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "range": Array [ + 53, + 54, ], "type": "Punctuator", - "value": "(", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 39, "line": 2, }, "start": Object { - "column": 24, + "column": 33, "line": 2, }, }, "range": Array [ - 42, - 46, + 55, + 61, ], - "type": "Boolean", - "value": "true", + "type": "Identifier", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 29, + "column": 40, "line": 2, }, "start": Object { - "column": 28, + "column": 39, "line": 2, }, }, "range": Array [ - 46, - 47, + 61, + 62, ], "type": "Punctuator", "value": ")", @@ -83583,107 +85666,161 @@ Object { Object { "loc": Object { "end": Object { - "column": 33, + "column": 42, "line": 2, }, "start": Object { - "column": 30, + "column": 41, "line": 2, }, }, "range": Array [ - 48, - 51, + 63, + 64, ], - "type": "Identifier", - "value": "baz", + "type": "Punctuator", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 34, - "line": 2, + "column": 14, + "line": 3, }, "start": Object { - "column": 33, - "line": 2, + "column": 8, + "line": 3, }, }, "range": Array [ - 51, - 52, + 73, + 79, + ], + "type": "Keyword", + "value": "return", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 80, + 88, + ], + "type": "String", + "value": "\\"Hello \\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 3, + }, + "start": Object { + "column": 24, + "line": 3, + }, + }, + "range": Array [ + 89, + 90, ], "type": "Punctuator", - "value": ":", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 41, - "line": 2, + "column": 30, + "line": 3, }, "start": Object { - "column": 35, - "line": 2, + "column": 26, + "line": 3, }, }, "range": Array [ - 53, - 59, + 91, + 95, ], "type": "Identifier", - "value": "number", + "value": "name", }, Object { "loc": Object { "end": Object { - "column": 42, - "line": 2, + "column": 32, + "line": 3, }, "start": Object { - "column": 41, - "line": 2, + "column": 31, + "line": 3, }, }, "range": Array [ - 59, - 60, + 96, + 97, ], "type": "Punctuator", - "value": ")", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 44, - "line": 2, + "column": 36, + "line": 3, }, "start": Object { - "column": 43, - "line": 2, + "column": 33, + "line": 3, }, }, "range": Array [ - 61, - 62, + 98, + 101, + ], + "type": "String", + "value": "\\"!\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 36, + "line": 3, + }, + }, + "range": Array [ + 101, + 102, ], "type": "Punctuator", - "value": "{", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 44, - "line": 2, + "column": 4, + "line": 4, }, }, "range": Array [ - 62, - 63, + 107, + 108, ], "type": "Punctuator", "value": "}", @@ -83692,16 +85829,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, - "line": 3, + "line": 5, }, }, "range": Array [ - 64, - 65, + 109, + 110, ], "type": "Punctuator", "value": "}", @@ -83711,7 +85848,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-instance-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-object-pattern-decorator.src 1`] = ` Object { "body": Array [ Object { @@ -83722,165 +85859,55 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 9, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, - "name": "greet", + "name": "bar", "range": Array [ - 20, - 25, + 14, + 17, ], "type": "Identifier", }, "kind": "method", "loc": Object { - "end": Object { - "column": 5, - "line": 4, + "end": Object { + "column": 37, + "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 95, + 14, + 49, ], "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [ - Object { - "argument": Object { - "left": Object { - "left": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "range": Array [ - 67, - 75, - ], - "raw": "\\"Hello \\"", - "type": "Literal", - "value": "Hello ", - }, - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 67, - 82, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 26, - "line": 3, - }, - }, - "name": "name", - "range": Array [ - 78, - 82, - ], - "type": "Identifier", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 67, - 88, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 85, - 88, - ], - "raw": "\\"!\\"", - "type": "Literal", - "value": "!", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 37, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 60, - 89, - ], - "type": "ReturnStatement", - }, - ], + "body": Array [], "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 34, + "column": 35, "line": 2, }, }, "range": Array [ - 50, - 95, + 47, + 49, ], "type": "BlockStatement", }, @@ -83889,11 +85916,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 9, + "column": 5, "line": 2, }, }, @@ -83902,95 +85929,191 @@ Object { "decorators": Array [ Object { "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 27, + 31, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 19, + 26, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 19, + "column": 20, "line": 2, }, "start": Object { - "column": 11, + "column": 7, "line": 2, }, }, - "name": "required", "range": Array [ - 27, - 35, + 19, + 32, ], - "type": "Identifier", + "type": "CallExpression", }, "loc": Object { "end": Object { - "column": 19, + "column": 20, "line": 2, }, "start": Object { - "column": 10, + "column": 6, "line": 2, }, }, "range": Array [ - 26, - 35, + 18, + 32, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 32, + "column": 33, "line": 2, }, "start": Object { - "column": 20, + "column": 21, "line": 2, }, }, - "name": "name", + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "method": false, + "range": Array [ + 35, + 38, + ], + "shorthand": true, + "type": "Property", + "value": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + }, + }, + ], "range": Array [ - 36, - 48, + 33, + 45, ], - "type": "Identifier", + "type": "ObjectPattern", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 32, + "column": 33, "line": 2, }, "start": Object { - "column": 24, + "column": 28, "line": 2, }, }, "range": Array [ 40, - 48, + 45, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 32, + "column": 33, "line": 2, }, "start": Object { - "column": 26, + "column": 30, "line": 2, }, }, "range": Array [ 42, - 48, + 45, ], - "type": "TSStringKeyword", + "type": "TSAnyKeyword", }, }, }, ], "range": Array [ - 25, - 95, + 17, + 49, ], "type": "FunctionExpression", }, @@ -83999,23 +86122,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 97, + 10, + 51, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -84023,17 +86146,17 @@ Object { "line": 1, }, }, - "name": "Greeter", + "name": "Foo", "range": Array [ 6, - 13, + 9, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, @@ -84042,7 +86165,7 @@ Object { }, "range": Array [ 0, - 97, + 51, ], "superClass": null, "type": "ClassDeclaration", @@ -84051,7 +86174,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 4, }, "start": Object { "column": 0, @@ -84060,7 +86183,7 @@ Object { }, "range": Array [ 0, - 98, + 52, ], "sourceType": "script", "tokens": Array [ @@ -84085,7 +86208,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -84095,25 +86218,25 @@ Object { }, "range": Array [ 6, - 13, + 9, ], "type": "Identifier", - "value": "Greeter", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 11, "line": 1, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 15, + 10, + 11, ], "type": "Punctuator", "value": "{", @@ -84121,35 +86244,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 25, + 14, + 17, ], "type": "Identifier", - "value": "greet", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 10, + "column": 6, "line": 2, }, "start": Object { - "column": 9, + "column": 5, "line": 2, }, }, "range": Array [ - 25, - 26, + 17, + 18, ], "type": "Punctuator", "value": "(", @@ -84157,17 +86280,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 11, + "column": 7, "line": 2, }, "start": Object { - "column": 10, + "column": 6, "line": 2, }, }, "range": Array [ - 26, - 27, + 18, + 19, ], "type": "Punctuator", "value": "@", @@ -84175,89 +86298,71 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, - "line": 2, - }, - "start": Object { - "column": 11, - "line": 2, - }, - }, - "range": Array [ - 27, - 35, - ], - "type": "Identifier", - "value": "required", - }, - Object { - "loc": Object { - "end": Object { - "column": 24, + "column": 14, "line": 2, }, "start": Object { - "column": 20, + "column": 7, "line": 2, }, }, "range": Array [ - 36, - 40, + 19, + 26, ], "type": "Identifier", - "value": "name", + "value": "special", }, Object { "loc": Object { "end": Object { - "column": 25, + "column": 15, "line": 2, }, "start": Object { - "column": 24, + "column": 14, "line": 2, }, }, "range": Array [ - 40, - 41, + 26, + 27, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 32, + "column": 19, "line": 2, }, "start": Object { - "column": 26, + "column": 15, "line": 2, }, }, "range": Array [ - 42, - 48, + 27, + 31, ], - "type": "Identifier", - "value": "string", + "type": "Boolean", + "value": "true", }, Object { "loc": Object { "end": Object { - "column": 33, + "column": 20, "line": 2, }, "start": Object { - "column": 32, + "column": 19, "line": 2, }, }, "range": Array [ - 48, - 49, + 31, + 32, ], "type": "Punctuator", "value": ")", @@ -84265,17 +86370,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 35, + "column": 22, "line": 2, }, "start": Object { - "column": 34, + "column": 21, "line": 2, }, }, "range": Array [ - 50, - 51, + 33, + 34, ], "type": "Punctuator", "value": "{", @@ -84283,143 +86388,125 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, - "line": 3, + "column": 26, + "line": 2, }, "start": Object { - "column": 8, - "line": 3, + "column": 23, + "line": 2, }, }, "range": Array [ - 60, - 66, + 35, + 38, ], - "type": "Keyword", - "value": "return", + "type": "Identifier", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 3, + "column": 28, + "line": 2, }, "start": Object { - "column": 15, - "line": 3, + "column": 27, + "line": 2, }, }, "range": Array [ - 67, - 75, + 39, + 40, ], - "type": "String", - "value": "\\"Hello \\"", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 25, - "line": 3, + "column": 29, + "line": 2, }, "start": Object { - "column": 24, - "line": 3, + "column": 28, + "line": 2, }, }, "range": Array [ - 76, - 77, + 40, + 41, ], "type": "Punctuator", - "value": "+", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 30, - "line": 3, + "column": 33, + "line": 2, }, "start": Object { - "column": 26, - "line": 3, + "column": 30, + "line": 2, }, }, "range": Array [ - 78, - 82, + 42, + 45, ], "type": "Identifier", - "value": "name", + "value": "any", }, Object { "loc": Object { "end": Object { - "column": 32, - "line": 3, + "column": 34, + "line": 2, }, "start": Object { - "column": 31, - "line": 3, + "column": 33, + "line": 2, }, }, "range": Array [ - 83, - 84, + 45, + 46, ], "type": "Punctuator", - "value": "+", + "value": ")", }, Object { "loc": Object { "end": Object { "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 85, - 88, - ], - "type": "String", - "value": "\\"!\\"", - }, - Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 3, + "line": 2, }, "start": Object { - "column": 36, - "line": 3, + "column": 35, + "line": 2, }, }, "range": Array [ - 88, - 89, + 47, + 48, ], "type": "Punctuator", - "value": ";", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 4, - "line": 4, + "column": 36, + "line": 2, }, }, "range": Array [ - 94, - 95, + 48, + 49, ], "type": "Punctuator", "value": "}", @@ -84428,16 +86515,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, - "line": 5, + "line": 3, }, }, "range": Array [ - 96, - 97, + 50, + 51, ], "type": "Punctuator", "value": "}", @@ -84447,7 +86534,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-static-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-rest-element-decorator.src 1`] = ` Object { "body": Array [ Object { @@ -84458,165 +86545,55 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 16, + "column": 5, "line": 2, }, "start": Object { - "column": 11, + "column": 2, "line": 2, }, }, - "name": "greet", + "name": "bar", "range": Array [ - 33, - 38, + 14, + 17, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 26, - 108, + 14, + 48, ], - "static": true, + "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [ - Object { - "argument": Object { - "left": Object { - "left": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "range": Array [ - 80, - 88, - ], - "raw": "\\"Hello \\"", - "type": "Literal", - "value": "Hello ", - }, - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 80, - 95, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 26, - "line": 3, - }, - }, - "name": "name", - "range": Array [ - 91, - 95, - ], - "type": "Identifier", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 80, - 101, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 98, - 101, - ], - "raw": "\\"!\\"", - "type": "Literal", - "value": "!", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 37, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 73, - 102, - ], - "type": "ReturnStatement", - }, - ], + "body": Array [], "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 41, + "column": 34, "line": 2, }, }, "range": Array [ - 63, - 108, + 46, + 48, ], "type": "BlockStatement", }, @@ -84625,108 +86602,163 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 16, + "column": 5, "line": 2, }, }, "params": Array [ Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "name": "foo", + "range": Array [ + 36, + 39, + ], + "type": "Identifier", + }, "decorators": Array [ Object { "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 27, + 31, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 19, + 26, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 26, + "column": 20, "line": 2, }, "start": Object { - "column": 18, + "column": 7, "line": 2, }, }, - "name": "required", "range": Array [ - 40, - 48, + 19, + 32, ], - "type": "Identifier", + "type": "CallExpression", }, "loc": Object { "end": Object { - "column": 26, + "column": 20, "line": 2, }, "start": Object { - "column": 17, + "column": 6, "line": 2, }, }, "range": Array [ - 39, - 48, + 18, + 32, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 39, + "column": 32, "line": 2, }, "start": Object { - "column": 27, + "column": 6, "line": 2, }, }, - "name": "name", "range": Array [ - 49, - 61, + 18, + 44, ], - "type": "Identifier", + "type": "RestElement", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 39, + "column": 32, "line": 2, }, "start": Object { - "column": 31, + "column": 27, "line": 2, }, }, "range": Array [ - 53, - 61, + 39, + 44, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 39, + "column": 32, "line": 2, }, "start": Object { - "column": 33, + "column": 29, "line": 2, }, }, "range": Array [ - 55, - 61, + 41, + 44, ], - "type": "TSStringKeyword", + "type": "TSAnyKeyword", }, }, }, ], "range": Array [ - 38, - 108, + 17, + 48, ], "type": "FunctionExpression", }, @@ -84735,23 +86767,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { - "column": 20, + "column": 10, "line": 1, }, }, "range": Array [ - 20, - 110, + 10, + 50, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 19, + "column": 9, "line": 1, }, "start": Object { @@ -84759,17 +86791,17 @@ Object { "line": 1, }, }, - "name": "StaticGreeter", + "name": "Foo", "range": Array [ 6, - 19, + 9, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, @@ -84778,7 +86810,7 @@ Object { }, "range": Array [ 0, - 110, + 50, ], "superClass": null, "type": "ClassDeclaration", @@ -84787,7 +86819,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 4, }, "start": Object { "column": 0, @@ -84796,7 +86828,7 @@ Object { }, "range": Array [ 0, - 111, + 51, ], "sourceType": "script", "tokens": Array [ @@ -84821,7 +86853,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, + "column": 9, "line": 1, }, "start": Object { @@ -84831,25 +86863,25 @@ Object { }, "range": Array [ 6, - 19, + 9, ], "type": "Identifier", - "value": "StaticGreeter", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 11, "line": 1, }, "start": Object { - "column": 20, + "column": 10, "line": 1, }, }, "range": Array [ - 20, - 21, + 10, + 11, ], "type": "Punctuator", "value": "{", @@ -84857,53 +86889,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 10, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "range": Array [ - 26, - 32, - ], - "type": "Keyword", - "value": "static", - }, - Object { - "loc": Object { - "end": Object { - "column": 16, + "column": 5, "line": 2, }, "start": Object { - "column": 11, + "column": 2, "line": 2, }, }, "range": Array [ - 33, - 38, + 14, + 17, ], "type": "Identifier", - "value": "greet", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 6, "line": 2, }, "start": Object { - "column": 16, + "column": 5, "line": 2, }, }, "range": Array [ - 38, - 39, + 17, + 18, ], "type": "Punctuator", "value": "(", @@ -84911,17 +86925,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 18, + "column": 7, "line": 2, }, "start": Object { - "column": 17, + "column": 6, "line": 2, }, }, "range": Array [ - 39, - 40, + 18, + 19, ], "type": "Punctuator", "value": "@", @@ -84929,89 +86943,71 @@ Object { Object { "loc": Object { "end": Object { - "column": 26, - "line": 2, - }, - "start": Object { - "column": 18, - "line": 2, - }, - }, - "range": Array [ - 40, - 48, - ], - "type": "Identifier", - "value": "required", - }, - Object { - "loc": Object { - "end": Object { - "column": 31, + "column": 14, "line": 2, }, "start": Object { - "column": 27, + "column": 7, "line": 2, }, }, "range": Array [ - 49, - 53, + 19, + 26, ], "type": "Identifier", - "value": "name", + "value": "special", }, Object { "loc": Object { "end": Object { - "column": 32, + "column": 15, "line": 2, }, "start": Object { - "column": 31, + "column": 14, "line": 2, }, }, "range": Array [ - 53, - 54, + 26, + 27, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 39, + "column": 19, "line": 2, }, "start": Object { - "column": 33, + "column": 15, "line": 2, }, }, "range": Array [ - 55, - 61, + 27, + 31, ], - "type": "Identifier", - "value": "string", + "type": "Boolean", + "value": "true", }, Object { "loc": Object { "end": Object { - "column": 40, + "column": 20, "line": 2, }, "start": Object { - "column": 39, + "column": 19, "line": 2, }, }, "range": Array [ - 61, - 62, + 31, + 32, ], "type": "Punctuator", "value": ")", @@ -85019,161 +87015,125 @@ Object { Object { "loc": Object { "end": Object { - "column": 42, + "column": 24, "line": 2, }, "start": Object { - "column": 41, + "column": 21, "line": 2, }, }, "range": Array [ - 63, - 64, + 33, + 36, ], "type": "Punctuator", - "value": "{", - }, - Object { - "loc": Object { - "end": Object { - "column": 14, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 73, - 79, - ], - "type": "Keyword", - "value": "return", + "value": "...", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 3, + "column": 27, + "line": 2, }, "start": Object { - "column": 15, - "line": 3, + "column": 24, + "line": 2, }, }, "range": Array [ - 80, - 88, + 36, + 39, ], - "type": "String", - "value": "\\"Hello \\"", + "type": "Identifier", + "value": "foo", }, Object { "loc": Object { "end": Object { - "column": 25, - "line": 3, + "column": 28, + "line": 2, }, "start": Object { - "column": 24, - "line": 3, + "column": 27, + "line": 2, }, }, "range": Array [ - 89, - 90, + 39, + 40, ], "type": "Punctuator", - "value": "+", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 30, - "line": 3, + "column": 32, + "line": 2, }, "start": Object { - "column": 26, - "line": 3, + "column": 29, + "line": 2, }, }, "range": Array [ - 91, - 95, + 41, + 44, ], "type": "Identifier", - "value": "name", + "value": "any", }, Object { "loc": Object { "end": Object { - "column": 32, - "line": 3, + "column": 33, + "line": 2, }, "start": Object { - "column": 31, - "line": 3, + "column": 32, + "line": 2, }, }, "range": Array [ - 96, - 97, + 44, + 45, ], "type": "Punctuator", - "value": "+", - }, - Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 98, - 101, - ], - "type": "String", - "value": "\\"!\\"", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 37, - "line": 3, + "column": 35, + "line": 2, }, "start": Object { - "column": 36, - "line": 3, + "column": 34, + "line": 2, }, }, "range": Array [ - 101, - 102, + 46, + 47, ], "type": "Punctuator", - "value": ";", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 4, - "line": 4, + "column": 35, + "line": 2, }, }, "range": Array [ - 107, - 108, + 47, + 48, ], "type": "Punctuator", "value": "}", @@ -85182,16 +87142,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, - "line": 5, + "line": 3, }, }, "range": Array [ - 109, - 110, + 49, + 50, ], "type": "Punctuator", "value": "}", @@ -88574,6 +90534,232 @@ Object { } `; +exports[`typescript fixtures/errorRecovery/decorator-on-function.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 12, + "line": 2, + }, + }, + "range": Array [ + 17, + 19, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "name": "b", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 0, + 19, + ], + "type": "FunctionDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 20, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 1, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 4, + ], + "type": "Identifier", + "value": "dec", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 5, + 13, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + "value": "b", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 12, + "line": 2, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/errorRecovery/decorator-on-interface-declaration.src 1`] = ` Object { "body": Array [ From fdac435e5cd53e4addc69619caa800be59c2ea0d Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 6 Feb 2019 02:45:52 +0100 Subject: [PATCH 73/88] test(parser): add missing test cases for parser options (#213) --- packages/typescript-estree/src/parser.ts | 2 +- .../tests/lib/__snapshots__/convert.ts.snap | 269 ++++++++++++++++++ .../typescript-estree/tests/lib/convert.ts | 24 ++ packages/typescript-estree/tests/lib/parse.ts | 33 +++ 4 files changed, 327 insertions(+), 1 deletion(-) diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index ca3d27db77e1..bad5cdd6fd50 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -107,7 +107,7 @@ function getASTAndDefaultProject(code: string, options: ParserOptions) { function createNewProgram(code: string) { const FILENAME = getFileName(extra); - const compilerHost = { + const compilerHost: ts.CompilerHost = { fileExists() { return true; }, diff --git a/packages/typescript-estree/tests/lib/__snapshots__/convert.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/convert.ts.snap index 05a20300876e..3049a51ae47a 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/convert.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/convert.ts.snap @@ -1,5 +1,179 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`convert deeplyCopy should convert array of nodes 1`] = ` +Object { + "amdDependencies": Array [], + "bindDiagnostics": Array [], + "bindSuggestionDiagnostics": undefined, + "checkJsDirective": undefined, + "endOfFileToken": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 12, + ], + "type": "TSEndOfFileToken", + }, + "externalModuleIndicator": undefined, + "fileName": "text.ts", + "hasNoDefaultLib": false, + "identifierCount": 2, + "identifiers": Map { + "foo" => "foo", + "T" => "T", + }, + "isDeclarationFile": false, + "languageVariant": 1, + "languageVersion": 6, + "libReferenceDirectives": Array [], + "lineMap": Array [ + null, + ], + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "nodeCount": 7, + "parseDiagnostics": Array [], + "pragmas": Map {}, + "range": Array [ + 0, + 12, + ], + "referencedFiles": Array [], + "scriptKind": 4, + "statements": Array [ + Object { + "expression": Object { + "arguments": Array [], + "callee": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 12, + ], + "type": "NewExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 8, + 9, + ], + "type": "Identifier", + }, + "typeParameters": undefined, + }, + ], + "range": Array [ + 7, + 10, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 12, + ], + "type": "ExpressionStatement", + }, + ], + "text": "new foo()", + "transformFlags": undefined, + "type": "TSSourceFile", + "typeReferenceDirectives": Array [], +} +`; + exports[`convert deeplyCopy should convert node correctly 1`] = ` Object { "body": Array [ @@ -421,6 +595,101 @@ Object { } `; +exports[`convert deeplyCopy should convert node with type arguments correctly 1`] = ` +Object { + "arguments": Array [], + "expression": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 12, + ], + "transformFlags": undefined, + "type": "TSNewExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 8, + 9, + ], + "type": "Identifier", + }, + "typeParameters": undefined, + }, + ], + "range": Array [ + 7, + 10, + ], + "type": "TSTypeParameterInstantiation", + }, +} +`; + exports[`convert deeplyCopy should convert node with type parameters correctly 1`] = ` Object { "heritageClauses": undefined, diff --git a/packages/typescript-estree/tests/lib/convert.ts b/packages/typescript-estree/tests/lib/convert.ts index ee2a44f7b7ce..6fb1077a4714 100644 --- a/packages/typescript-estree/tests/lib/convert.ts +++ b/packages/typescript-estree/tests/lib/convert.ts @@ -45,6 +45,30 @@ describe('convert', () => { expect((instance as any).deeplyCopy(ast.statements[0])).toMatchSnapshot(); }); + it('deeplyCopy should convert node with type arguments correctly', () => { + const ast = convertCode('new foo()'); + + const instance = new Converter(ast, { + errorOnUnknownASTType: false, + useJSXTextNode: false, + shouldProvideParserServices: false + }); + expect( + (instance as any).deeplyCopy((ast.statements[0] as any).expression) + ).toMatchSnapshot(); + }); + + it('deeplyCopy should convert array of nodes', () => { + const ast = convertCode('new foo()'); + + const instance = new Converter(ast, { + errorOnUnknownASTType: false, + useJSXTextNode: false, + shouldProvideParserServices: false + }); + expect((instance as any).deeplyCopy(ast)).toMatchSnapshot(); + }); + it('deeplyCopy should fail on unknown node', () => { const ast = convertCode('type foo = ?foo | ?(() => void)?'); diff --git a/packages/typescript-estree/tests/lib/parse.ts b/packages/typescript-estree/tests/lib/parse.ts index 2f8463cc0a2b..60aee02b1a06 100644 --- a/packages/typescript-estree/tests/lib/parse.ts +++ b/packages/typescript-estree/tests/lib/parse.ts @@ -104,4 +104,37 @@ describe('parse()', () => { ); }); }); + + describe('errorOnTypeScriptSyntacticAndSemanticIssues', () => { + const code = '@test const foo = 2'; + const options: ParserOptions = { + comment: true, + tokens: true, + range: true, + loc: true, + errorOnTypeScriptSyntacticAndSemanticIssues: true + }; + + it('should throw on invalid option when used in parse', () => { + expect(() => { + parser.parse(code, options); + }).toThrow( + `"errorOnTypeScriptSyntacticAndSemanticIssues" is only supported for parseAndGenerateServices()` + ); + }); + + it('should not throw when used in parseAndGenerateServices', () => { + expect(() => { + parser.parseAndGenerateServices(code, options); + }).not.toThrow( + `"errorOnTypeScriptSyntacticAndSemanticIssues" is only supported for parseAndGenerateServices()` + ); + }); + + it('should error on invalid code', () => { + expect(() => { + parser.parseAndGenerateServices(code, options); + }).toThrow('Decorators are not valid here.'); + }); + }); }); From 7777cae93e7020a606ffb8e58cba1b9020d61e73 Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 6 Feb 2019 02:51:17 +0100 Subject: [PATCH 74/88] test(ts-estree): upgrade babel to 7.3.2 (#217) --- package.json | 2 +- .../tests/ast-alignment/fixtures-to-test.ts | 30 +++++++++++++------ yarn.lock | 8 ++--- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index db01c0bf521c..301ec05cfdf1 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ }, "devDependencies": { "@babel/code-frame": "7.0.0", - "@babel/parser": "7.3.0", + "@babel/parser": "7.3.2", "@commitlint/cli": "^7.1.2", "@commitlint/config-conventional": "^7.1.2", "@commitlint/travis-cli": "^7.1.2", 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 e8dcf0aca782..ddda926b3201 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -164,7 +164,20 @@ tester.addFixturePatternConfig('javascript/arrowFunctions', { * with the same name, for example. */ 'error-dup-params', // babel parse errors - 'error-strict-dup-params' // babel parse errors + 'error-strict-dup-params', // babel parse errors + /** + * typescript reports TS1100 and babel errors on this + * 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-return', + 'error-strict-param-arguments', + 'error-strict-param-eval', + 'error-strict-param-names', + 'error-strict-param-no-paren-arguments', + 'error-strict-param-no-paren-eval' ] }); tester.addFixturePatternConfig('javascript/function', { @@ -236,7 +249,12 @@ tester.addFixturePatternConfig('javascript/modules', { */ 'invalid-export-named-default' // babel parse errors ], - ignoreSourceType: ['error-function', 'error-strict', 'error-delete'] + ignoreSourceType: [ + 'error-function', + 'error-strict', + 'error-delete', + 'invalid-await' + ] }); tester.addFixturePatternConfig('javascript/newTarget'); @@ -363,15 +381,9 @@ tester.addFixturePatternConfig('typescript/basics', { * https://github.com/babel/babel/issues/9324 */ 'type-assertion-arrow-function', - /** - * PR for range of declare keyword has been merged into Babel: https://github.com/babel/babel/pull/9406 - * TODO: remove me in next babel > 7.3.1 - */ - 'export-declare-const-named-enum', - 'export-declare-named-enum', /** * Babel does not include optional keyword into range parameter in arrow function - * TODO: report it to babel + * https://github.com/babel/babel/issues/9461 */ 'arrow-function-with-optional-parameter' ], diff --git a/yarn.lock b/yarn.lock index 51d8518fb375..00804abee1f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18,10 +18,10 @@ esutils "^2.0.2" js-tokens "^4.0.0" -"@babel/parser@7.3.0": - version "7.3.0" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.3.0.tgz#930251fe6714df47ce540a919ccdf6dcfb652b61" - integrity sha512-8M30TzMpLHGmuthHZStm4F+az5wxyYeh8U+LWK7+b2qnlQ0anXBmOQ1I8DCMV1K981wPY3C3kWZ4SA1lR3Y3xQ== +"@babel/parser@7.3.2": + version "7.3.2" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.3.2.tgz#95cdeddfc3992a6ca2a1315191c1679ca32c55cd" + integrity sha512-QzNUC2RO1gadg+fs21fi0Uu0OuGNzRKEmgCxoLNzbCdoprLwjfmZwzUrpUNfJPaVRwBpDY47A17yYEGWyRelnQ== "@commitlint/cli@^7.1.2", "@commitlint/cli@^7.3.2": version "7.3.2" From 690bff322adbebe181b3efb33c46408e2b819b9d Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 6 Feb 2019 02:53:10 +0100 Subject: [PATCH 75/88] test(ts-estree): correct jsx for semantic-diagnostics tests (#218) --- .../tests/ast-alignment/fixtures-to-test.ts | 3 +- .../semantic-diagnostics-enabled.ts.snap | 477 ++++-------------- .../typescript-estree/tests/lib/comments.ts | 5 +- .../tests/lib/semantic-diagnostics-enabled.ts | 7 +- packages/typescript-estree/tests/lib/tsx.ts | 8 +- .../typescript-estree/tests/lib/typescript.ts | 9 +- .../typescript-estree/tools/test-utils.ts | 11 + 7 files changed, 140 insertions(+), 380 deletions(-) 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 ddda926b3201..564a5ab6a1ab 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -3,6 +3,7 @@ import fs from 'fs'; import path from 'path'; import jsxKnownIssues from '../../../shared-fixtures/jsx-known-issues'; +import { isJSXFileType } from '../../tools/test-utils'; interface Fixture { filename: string; @@ -61,7 +62,7 @@ class FixturesTester { const ignore = config.ignore || []; const fileType = config.fileType || 'js'; const ignoreSourceType = config.ignoreSourceType || []; - const jsx = fileType === 'js' || fileType === 'jsx' || fileType === 'tsx'; + const jsx = isJSXFileType(fileType); /** * The TypeScript compiler gives us the "externalModuleIndicator" to allow typescript-estree do dynamically detect the "sourceType". diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index dde844c7e15e..cfc83e85d3c2 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -8,77 +8,21 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsdoc-comment.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-block-comment.src 1`] = ` -Object { - "column": 10, - "index": 84, - "lineNumber": 5, - "message": "Unterminated regular expression literal.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-block-comment.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-comment-after-jsx.src 1`] = ` -Object { - "column": 14, - "index": 48, - "lineNumber": 3, - "message": "Type expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-comment-after-jsx.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-comment-after-self-closing-jsx.src 1`] = ` -Object { - "column": 13, - "index": 47, - "lineNumber": 3, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-comment-after-self-closing-jsx.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-tag-comments.src 1`] = ` -Object { - "column": 9, - "index": 113, - "lineNumber": 7, - "message": "Type expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-tag-comments.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-text-with-multiline-non-comment.src 1`] = ` -Object { - "column": 5, - "index": 81, - "lineNumber": 7, - "message": "Type expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-text-with-multiline-non-comment.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-text-with-url.src 1`] = ` -Object { - "column": 17, - "index": 17, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-text-with-url.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-with-greather-than.src 1`] = ` -Object { - "column": 0, - "index": 69, - "lineNumber": 4, - "message": "Expression expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-with-greather-than.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-with-operators.src 1`] = ` -Object { - "column": 0, - "index": 69, - "lineNumber": 4, - "message": "Expression expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/jsx-with-operators.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/comments/line-comment-with-block-syntax.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -1330,120 +1274,71 @@ Object { } `; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/attributes.src 1`] = ` -Object { - "column": 5, - "index": 5, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/attributes.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/element-keyword-name.src 1`] = ` -Object { - "column": 12, - "index": 18, - "lineNumber": 2, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/element-keyword-name.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/embedded-comment.src 1`] = ` -Object { - "column": 30, - "index": 30, - "lineNumber": 1, - "message": "Unterminated regular expression literal.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/embedded-comment.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/embedded-conditional.src 1`] = ` -Object { - "column": 3, - "index": 3, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/embedded-conditional.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/embedded-invalid-js-identifier.src 1`] = ` -Object { - "column": 9, - "index": 9, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/embedded-invalid-js-identifier.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/embedded-tags.src 1`] = ` Object { - "column": 11, - "index": 11, + "column": 16, + "index": 16, "lineNumber": 1, - "message": "'>' expected.", + "message": "'{' expected.", } `; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/empty-placeholder.src 1`] = ` -Object { - "column": 7, - "index": 7, - "lineNumber": 1, - "message": "Unterminated regular expression literal.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/empty-placeholder.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/escape-patterns.src 1`] = ` -Object { - "column": 3, - "index": 3, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/escape-patterns.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-attribute.src 1`] = ` Object { - "column": 3, - "index": 3, + "column": 5, + "index": 5, "lineNumber": 1, - "message": "'>' expected.", + "message": "'{' expected.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-attribute-missing-equals.src 1`] = ` Object { - "column": 5, - "index": 5, + "column": 14, + "index": 14, "lineNumber": 1, - "message": "'>' expected.", + "message": "Identifier expected.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-broken-tag.src 1`] = ` Object { - "column": 3, - "index": 3, + "column": 12, + "index": 12, "lineNumber": 1, - "message": "'>' expected.", + "message": "Unterminated string literal.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-computed-end-tag-name.src 1`] = ` Object { - "column": 9, - "index": 9, + "column": 2, + "index": 2, "lineNumber": 1, - "message": "Type expected.", + "message": "Identifier expected.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-computed-string-end-tag-name.src 1`] = ` Object { - "column": 11, - "index": 11, + "column": 2, + "index": 2, "lineNumber": 1, - "message": "Type expected.", + "message": "Identifier expected.", } `; @@ -1452,23 +1347,23 @@ Object { "column": 9, "index": 9, "lineNumber": 1, - "message": "':' expected.", + "message": "'}' expected.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-leading-dot-tag-name.src 1`] = ` Object { - "column": 1, - "index": 1, + "column": 0, + "index": 0, "lineNumber": 1, - "message": "Type expected.", + "message": "Expression expected.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-matching-placeholder-in-closing-tag.src 1`] = ` Object { - "column": 5, - "index": 5, + "column": 27, + "index": 27, "lineNumber": 1, "message": "'>' expected.", } @@ -1476,28 +1371,28 @@ Object { exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-mismatched-closing-tag.src 1`] = ` Object { - "column": 4, - "index": 4, + "column": 3, + "index": 3, "lineNumber": 1, - "message": "Type expected.", + "message": "Expected corresponding JSX closing tag for 'a'.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-mismatched-closing-tags.src 1`] = ` Object { - "column": 6, - "index": 6, + "column": 1, + "index": 1, "lineNumber": 1, - "message": "'>' expected.", + "message": "JSX element 'a' has no corresponding closing tag.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-mismatched-dot-tag-name.src 1`] = ` Object { - "column": 8, - "index": 8, + "column": 7, + "index": 7, "lineNumber": 1, - "message": "Type expected.", + "message": "Expected corresponding JSX closing tag for 'a.b.c'.", } `; @@ -1506,34 +1401,34 @@ Object { "column": 2, "index": 2, "lineNumber": 1, - "message": "'>' expected.", + "message": "Identifier expected.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-missing-closing-tag.src 1`] = ` Object { - "column": 3, - "index": 3, + "column": 1, + "index": 1, "lineNumber": 1, - "message": "Expression expected.", + "message": "JSX element 'a' has no corresponding closing tag.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-missing-closing-tag-attribute-placeholder.src 1`] = ` Object { - "column": 3, - "index": 3, + "column": 1, + "index": 1, "lineNumber": 1, - "message": "'>' expected.", + "message": "JSX element 'a' has no corresponding closing tag.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-missing-namespace-name.src 1`] = ` Object { - "column": 1, - "index": 1, + "column": 0, + "index": 0, "lineNumber": 1, - "message": "Type expected.", + "message": "Expression expected.", } `; @@ -1542,16 +1437,16 @@ Object { "column": 2, "index": 2, "lineNumber": 1, - "message": "'>' expected.", + "message": "Identifier expected.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-missing-spread-operator.src 1`] = ` Object { - "column": 5, - "index": 5, + "column": 6, + "index": 6, "lineNumber": 1, - "message": "'>' expected.", + "message": "'...' expected.", } `; @@ -1560,7 +1455,7 @@ Object { "column": 4, "index": 4, "lineNumber": 1, - "message": "'>' expected.", + "message": "Identifier expected.", } `; @@ -1569,7 +1464,7 @@ Object { "column": 2, "index": 2, "lineNumber": 1, - "message": "'>' expected.", + "message": "Identifier expected.", } `; @@ -1578,43 +1473,43 @@ Object { "column": 36, "index": 36, "lineNumber": 1, - "message": "Expression expected.", + "message": "JSX expressions must have one parent element.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-no-common-parent-with-comment.src 1`] = ` Object { - "column": 38, - "index": 38, + "column": 63, + "index": 63, "lineNumber": 1, - "message": "',' expected.", + "message": "JSX expressions must have one parent element.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-no-tag-name.src 1`] = ` Object { - "column": 1, - "index": 1, + "column": 0, + "index": 0, "lineNumber": 1, - "message": "Type expected.", + "message": "Declaration or statement expected.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-placeholder-in-closing-tag.src 1`] = ` Object { - "column": 12, - "index": 12, + "column": 16, + "index": 16, "lineNumber": 1, - "message": "Unterminated regular expression literal.", + "message": "'>' expected.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-shorthand-fragment-no-closing.src 1`] = ` Object { - "column": 1, - "index": 1, + "column": 0, + "index": 0, "lineNumber": 1, - "message": "Type expected.", + "message": "JSX fragment has no corresponding closing tag.", } `; @@ -1629,64 +1524,29 @@ Object { exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/invalid-unexpected-comma.src 1`] = ` Object { - "column": 6, - "index": 6, + "column": 19, + "index": 19, "lineNumber": 1, - "message": "'>' expected.", + "message": "Identifier expected.", } `; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/japanese-characters.src 1`] = ` -Object { - "column": 6, - "index": 6, - "lineNumber": 1, - "message": "Type expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/japanese-characters.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/less-than-operator.src 1`] = ` -Object { - "column": 6, - "index": 6, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/less-than-operator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/member-expression.src 1`] = ` -Object { - "column": 6, - "index": 6, - "lineNumber": 1, - "message": "Type expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/member-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/member-expression-this.src 1`] = ` -Object { - "column": 5, - "index": 5, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/member-expression-this.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/multiple-blank-spaces.src 1`] = ` -Object { - "column": 8, - "index": 8, - "lineNumber": 1, - "message": "Type expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/multiple-blank-spaces.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/namespaced-attribute-and-value-inserted.src 1`] = ` Object { - "column": 3, - "index": 3, + "column": 4, + "index": 4, "lineNumber": 1, - "message": "'>' expected.", + "message": "Identifier expected.", } `; @@ -1695,36 +1555,22 @@ Object { "column": 2, "index": 2, "lineNumber": 1, - "message": "'>' expected.", + "message": "Identifier expected.", } `; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/newslines-and-entities.src 1`] = ` Object { - "column": 4, - "index": 4, + "column": 8, + "index": 8, "lineNumber": 1, - "message": "'>' expected.", + "message": "Invalid character.", } `; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/self-closing-tag.src 1`] = ` -Object { - "column": 3, - "index": 3, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/self-closing-tag.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/self-closing-tag-inside-tag.src 1`] = ` -Object { - "column": 9, - "index": 15, - "lineNumber": 2, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/self-closing-tag-inside-tag.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/self-closing-tag-with-newline.src 1`] = ` Object { @@ -1735,140 +1581,35 @@ Object { } `; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/shorthand-fragment.src 1`] = ` -Object { - "column": 1, - "index": 1, - "lineNumber": 1, - "message": "Type expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/shorthand-fragment.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/shorthand-fragment-with-child.src 1`] = ` -Object { - "column": 1, - "index": 1, - "lineNumber": 1, - "message": "Type expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/shorthand-fragment-with-child.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/spread-child.src 1`] = ` -Object { - "column": 15, - "index": 15, - "lineNumber": 1, - "message": "Unterminated regular expression literal.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/spread-child.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/spread-operator-attribute-and-regular-attribute.src 1`] = ` -Object { - "column": 5, - "index": 5, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/spread-operator-attribute-and-regular-attribute.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/spread-operator-attributes.src 1`] = ` -Object { - "column": 5, - "index": 5, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/spread-operator-attributes.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/tag-names-with-dots.src 1`] = ` -Object { - "column": 6, - "index": 6, - "lineNumber": 1, - "message": "Type expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/tag-names-with-dots.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/tag-names-with-multi-dots.src 1`] = ` -Object { - "column": 8, - "index": 8, - "lineNumber": 1, - "message": "Type expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/tag-names-with-multi-dots.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/tag-names-with-multi-dots-multi.src 1`] = ` -Object { - "column": 7, - "index": 21, - "lineNumber": 2, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/tag-names-with-multi-dots-multi.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/test-content.src 1`] = ` -Object { - "column": 5, - "index": 5, - "lineNumber": 1, - "message": "Expression expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/test-content.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/trailing-spread-operator-attribute.src 1`] = ` -Object { - "column": 5, - "index": 5, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/trailing-spread-operator-attribute.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/unknown-escape-pattern.src 1`] = ` -Object { - "column": 3, - "index": 3, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx/unknown-escape-pattern.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx-useJSXTextNode/self-closing-tag-inside-tag.src 1`] = ` -Object { - "column": 9, - "index": 15, - "lineNumber": 2, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx-useJSXTextNode/self-closing-tag-inside-tag.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx-useJSXTextNode/test-content.src 1`] = ` -Object { - "column": 5, - "index": 5, - "lineNumber": 1, - "message": "Expression expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/jsx-useJSXTextNode/test-content.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/tsx/generic-jsx-element.src 1`] = ` -Object { - "column": 21, - "index": 21, - "lineNumber": 1, - "message": "'>' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/tsx/generic-jsx-element.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/tsx/react-typed-props.src 1`] = ` -Object { - "column": 12, - "index": 141, - "lineNumber": 9, - "message": "',' expected.", -} -`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/tsx/react-typed-props.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/babylon-convergence/type-parameter-whitespace-loc.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; diff --git a/packages/typescript-estree/tests/lib/comments.ts b/packages/typescript-estree/tests/lib/comments.ts index 1d02e2fa6715..63b53ce9047d 100644 --- a/packages/typescript-estree/tests/lib/comments.ts +++ b/packages/typescript-estree/tests/lib/comments.ts @@ -11,7 +11,8 @@ import { extname } from 'path'; import { ParserOptions } from '../../src/parser-options'; import { createSnapshotTestBlock, - formatSnapshotName + formatSnapshotName, + isJSXFileType } from '../../tools/test-utils'; //------------------------------------------------------------------------------ @@ -35,7 +36,7 @@ describe('Comments', () => { range: true, tokens: true, comment: true, - jsx: fileExtension === '.js' + jsx: isJSXFileType(fileExtension) }; it( formatSnapshotName(filename, FIXTURES_DIR, fileExtension), diff --git a/packages/typescript-estree/tests/lib/semantic-diagnostics-enabled.ts b/packages/typescript-estree/tests/lib/semantic-diagnostics-enabled.ts index 8231b96185df..2cd5555bce71 100644 --- a/packages/typescript-estree/tests/lib/semantic-diagnostics-enabled.ts +++ b/packages/typescript-estree/tests/lib/semantic-diagnostics-enabled.ts @@ -8,7 +8,7 @@ import { readFileSync } from 'fs'; import glob from 'glob'; import * as parser from '../../src/parser'; import { extname } from 'path'; -import { formatSnapshotName } from '../../tools/test-utils'; +import { formatSnapshotName, isJSXFileType } from '../../tools/test-utils'; //------------------------------------------------------------------------------ // Setup @@ -30,12 +30,13 @@ describe('Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" testFiles.forEach(filename => { const code = readFileSync(filename, 'utf8'); const fileExtension = extname(filename); - const config = { + const config: parser.ParserOptions = { loc: true, range: true, tokens: true, errorOnUnknownASTType: true, - errorOnTypeScriptSyntacticAndSemanticIssues: true + errorOnTypeScriptSyntacticAndSemanticIssues: true, + jsx: isJSXFileType(fileExtension) }; it(formatSnapshotName(filename, FIXTURES_DIR, fileExtension), () => { expect.assertions(1); diff --git a/packages/typescript-estree/tests/lib/tsx.ts b/packages/typescript-estree/tests/lib/tsx.ts index 21dbbd57efe0..c9409877b84f 100644 --- a/packages/typescript-estree/tests/lib/tsx.ts +++ b/packages/typescript-estree/tests/lib/tsx.ts @@ -10,7 +10,8 @@ import { extname } from 'path'; import { ParserOptions } from '../../src/parser-options'; import { createSnapshotTestBlock, - formatSnapshotName + formatSnapshotName, + isJSXFileType } from '../../tools/test-utils'; //------------------------------------------------------------------------------ @@ -28,16 +29,17 @@ const testFiles = glob.sync(`${FIXTURES_DIR}/**/*.src.tsx`); describe('TSX', () => { testFiles.forEach(filename => { const code = readFileSync(filename, 'utf8'); + const fileExtension = extname(filename); const config: ParserOptions = { loc: true, range: true, tokens: true, errorOnUnknownASTType: true, useJSXTextNode: true, - jsx: true + jsx: isJSXFileType(fileExtension) }; it( - formatSnapshotName(filename, FIXTURES_DIR, extname(filename)), + formatSnapshotName(filename, FIXTURES_DIR, fileExtension), createSnapshotTestBlock(code, config) ); }); diff --git a/packages/typescript-estree/tests/lib/typescript.ts b/packages/typescript-estree/tests/lib/typescript.ts index 9740c4570e74..2ccd8cb9786b 100644 --- a/packages/typescript-estree/tests/lib/typescript.ts +++ b/packages/typescript-estree/tests/lib/typescript.ts @@ -11,7 +11,8 @@ import { extname } from 'path'; import { ParserOptions } from '../../src/parser-options'; import { createSnapshotTestBlock, - formatSnapshotName + formatSnapshotName, + isJSXFileType } from '../../tools/test-utils'; //------------------------------------------------------------------------------ @@ -29,14 +30,16 @@ const testFiles = glob.sync(`${FIXTURES_DIR}/**/*.src.ts`); describe('typescript', () => { testFiles.forEach(filename => { const code = readFileSync(filename, 'utf8'); + const fileExtension = extname(filename); const config: ParserOptions = { loc: true, range: true, tokens: true, - errorOnUnknownASTType: true + errorOnUnknownASTType: true, + jsx: isJSXFileType(fileExtension) }; it( - formatSnapshotName(filename, FIXTURES_DIR, extname(filename)), + formatSnapshotName(filename, FIXTURES_DIR, fileExtension), createSnapshotTestBlock(code, config) ); }); diff --git a/packages/typescript-estree/tools/test-utils.ts b/packages/typescript-estree/tools/test-utils.ts index c2d57246ca09..d06d229a36ed 100644 --- a/packages/typescript-estree/tools/test-utils.ts +++ b/packages/typescript-estree/tools/test-utils.ts @@ -80,3 +80,14 @@ export function formatSnapshotName( .replace(fixturesDir + '/', '') .replace(fileExtension, '')}`; } + +/** + * Check if file extension is one used for jsx + * @param fileType + */ +export function isJSXFileType(fileType: string): boolean { + if (fileType.startsWith('.')) { + fileType = fileType.slice(1); + } + return fileType === 'js' || fileType === 'jsx' || fileType === 'tsx'; +} From 33061987c0cfd235014134dfd75e28c3eb4cfc2a Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 7 Feb 2019 02:17:44 +0100 Subject: [PATCH 76/88] fix(ts-estree): align typeArguments and typeParameters across nodes (#223) --- .../lib/__snapshots__/typescript.ts.snap | 2284 +++++++++++++++++ ...y-type-arguments-in-call-expression.src.ts | 1 + ...ty-type-arguments-in-new-expression.src.ts | 1 + ...y-type-parameters-in-arrow-function.src.ts | 1 + ...mpty-type-parameters-in-constructor.src.ts | 3 + ...e-parameters-in-function-expression.src.ts | 1 + ...type-parameters-in-method-signature.src.ts | 3 + .../empty-type-parameters-in-method.src.ts | 3 + .../empty-type-parameters.src.ts | 1 + packages/typescript-estree/src/convert.ts | 22 +- .../tests/ast-alignment/utils.ts | 5 +- .../semantic-diagnostics-enabled.ts.snap | 16 + .../lib/__snapshots__/typescript.ts.snap | 2276 ++++++++++++++++ 13 files changed, 4605 insertions(+), 12 deletions(-) create mode 100644 packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-arguments-in-call-expression.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-arguments-in-new-expression.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-arrow-function.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-constructor.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-function-expression.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-method-signature.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-method.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters.src.ts diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index 6f4ae3ff2035..ef757ac0453e 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -92235,6 +92235,2290 @@ Object { } `; +exports[`typescript fixtures/errorRecovery/empty-type-arguments-in-call-expression.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "arguments": Array [], + "callee": Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 0, + 3, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 7, + ], + "type": "CallExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 3, + 5, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "ExpressionStatement", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 9, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "range": Array [ + 3, + 4, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-arguments-in-new-expression.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "arguments": Array [], + "callee": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 11, + ], + "type": "NewExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 7, + 9, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 11, + ], + "type": "ExpressionStatement", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 12, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "new", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": ")", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-parameters.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 18, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "f1", + "range": Array [ + 9, + 11, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 0, + 18, + ], + "type": "FunctionDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 11, + 13, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 11, + ], + "type": "Identifier", + "value": "f1", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-parameters-in-arrow-function.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 18, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "f1", + "range": Array [ + 9, + 11, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 0, + 18, + ], + "type": "FunctionDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 11, + 13, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 11, + ], + "type": "Identifier", + "value": "f1", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-parameters-in-constructor.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": "constructor", + "range": Array [ + 14, + 25, + ], + "type": "Identifier", + }, + "kind": "constructor", + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 32, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 30, + 32, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 25, + 32, + ], + "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 25, + 27, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 34, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 34, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 35, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 25, + ], + "type": "Identifier", + "value": "constructor", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 30, + 31, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 19, + "line": 2, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-parameters-in-function-expression.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "init": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 27, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 12, + 27, + ], + "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 20, + 22, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 27, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 27, + ], + "type": "VariableDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 20, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-parameters-in-method.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": "test", + "range": Array [ + 14, + 18, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 25, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 23, + 25, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 18, + 25, + ], + "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 18, + 20, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 27, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 27, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 18, + ], + "type": "Identifier", + "value": "test", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 12, + "line": 2, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-parameters-in-method-signature.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": "test", + "range": Array [ + 18, + 22, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 18, + 27, + ], + "type": "TSMethodSignature", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 22, + 24, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 29, + ], + "type": "TSInterfaceBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 10, + 13, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 29, + ], + "type": "TSInterfaceDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 30, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 9, + ], + "type": "Keyword", + "value": "interface", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 13, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 18, + 22, + ], + "type": "Identifier", + "value": "test", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/errorRecovery/enum-with-keywords.src 1`] = ` Object { "body": Array [ diff --git a/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-arguments-in-call-expression.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-arguments-in-call-expression.src.ts new file mode 100644 index 000000000000..8370eae3584f --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-arguments-in-call-expression.src.ts @@ -0,0 +1 @@ +foo<>(); diff --git a/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-arguments-in-new-expression.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-arguments-in-new-expression.src.ts new file mode 100644 index 000000000000..58900f001ee1 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-arguments-in-new-expression.src.ts @@ -0,0 +1 @@ +new Foo<>() diff --git a/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-arrow-function.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-arrow-function.src.ts new file mode 100644 index 000000000000..1dbabedb798c --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-arrow-function.src.ts @@ -0,0 +1 @@ +function f1<>() {} diff --git a/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-constructor.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-constructor.src.ts new file mode 100644 index 000000000000..1c24174dfb9d --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-constructor.src.ts @@ -0,0 +1,3 @@ +class foo { + constructor<>() {} +} diff --git a/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-function-expression.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-function-expression.src.ts new file mode 100644 index 000000000000..97b3b1bd5b97 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-function-expression.src.ts @@ -0,0 +1 @@ +const foo = function<>() {} diff --git a/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-method-signature.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-method-signature.src.ts new file mode 100644 index 000000000000..266c7827325d --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-method-signature.src.ts @@ -0,0 +1,3 @@ +interface foo { + test<>(); +} diff --git a/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-method.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-method.src.ts new file mode 100644 index 000000000000..5544096856d7 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters-in-method.src.ts @@ -0,0 +1,3 @@ +class foo { + test<>() {} +} diff --git a/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters.src.ts b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters.src.ts new file mode 100644 index 000000000000..1dbabedb798c --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/errorRecovery/empty-type-parameters.src.ts @@ -0,0 +1 @@ +function f1<>() {} diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index eb2e69a60ece..da34cb8e7d8a 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -690,7 +690,7 @@ export class Converter { } // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { + if (node.typeParameters) { result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( node.typeParameters ); @@ -897,7 +897,7 @@ export class Converter { } // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { + if (node.typeParameters) { method.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( node.typeParameters ); @@ -1003,7 +1003,7 @@ export class Converter { }); // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { + if (node.typeParameters) { constructor.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( node.typeParameters ); @@ -1060,7 +1060,7 @@ export class Converter { } // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { + if (node.typeParameters) { result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( node.typeParameters ); @@ -1159,7 +1159,7 @@ export class Converter { } // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { + if (node.typeParameters) { result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( node.typeParameters ); @@ -1368,7 +1368,7 @@ export class Converter { } } - if (node.typeParameters && node.typeParameters.length) { + if (node.typeParameters) { result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( node.typeParameters ); @@ -1640,7 +1640,7 @@ export class Converter { callee: this.convertChild(node.expression), arguments: node.arguments.map(el => this.convertChild(el)) }); - if (node.typeArguments && node.typeArguments.length) { + if (node.typeArguments) { result.typeParameters = this.convertTypeArgumentsToTypeParameters( node.typeArguments ); @@ -1656,7 +1656,7 @@ export class Converter { ? node.arguments.map(el => this.convertChild(el)) : [] }); - if (node.typeArguments && node.typeArguments.length) { + if (node.typeArguments) { result.typeParameters = this.convertTypeArgumentsToTypeParameters( node.typeArguments ); @@ -2060,7 +2060,7 @@ export class Converter { } // Process typeParameters - if (node.typeParameters && node.typeParameters.length) { + if (node.typeParameters) { result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( node.typeParameters ); @@ -2216,7 +2216,7 @@ export class Converter { expression: this.convertChild(node.expression) }); - if (node.typeArguments && node.typeArguments.length) { + if (node.typeArguments) { result.typeParameters = this.convertTypeArgumentsToTypeParameters( node.typeArguments ); @@ -2236,7 +2236,7 @@ export class Converter { id: this.convertChild(node.name) }); - if (node.typeParameters && node.typeParameters.length) { + if (node.typeParameters) { result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( node.typeParameters ); diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index f00b7d9ad16b..3b9cdfd087c9 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -262,7 +262,10 @@ export function preprocessBabylonAST(ast: any): any { /** * babel issue: ranges of typeParameters are not included in FunctionExpression range */ - if (node.typeParameters) { + if ( + node.typeParameters && + node.typeParameters.range[0] < node.range[0] + ) { node.range[0] = node.typeParameters.range[0]; node.loc.start = Object.assign({}, node.typeParameters.loc.start); } diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index cfc83e85d3c2..45c5544625ef 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -2075,6 +2075,22 @@ Object { exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments-in-call-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments-in-new-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-arrow-function.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-constructor.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-function-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-method.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-method-signature.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/enum-with-keywords.src 1`] = ` Object { "column": 7, diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index d1040b3b2957..38bc1e93b184 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -91539,6 +91539,2282 @@ Object { } `; +exports[`typescript fixtures/errorRecovery/empty-type-arguments-in-call-expression.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "arguments": Array [], + "callee": Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 0, + 3, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 7, + ], + "type": "CallExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 3, + 5, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 9, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "range": Array [ + 3, + 4, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-arguments-in-new-expression.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "arguments": Array [], + "callee": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 11, + ], + "type": "NewExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 7, + 9, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 11, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 12, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "new", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": ")", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-parameters.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 18, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "f1", + "range": Array [ + 9, + 11, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 0, + 18, + ], + "type": "FunctionDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 11, + 13, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 11, + ], + "type": "Identifier", + "value": "f1", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-parameters-in-arrow-function.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 18, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "f1", + "range": Array [ + 9, + 11, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 0, + 18, + ], + "type": "FunctionDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 11, + 13, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 11, + ], + "type": "Identifier", + "value": "f1", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-parameters-in-constructor.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": "constructor", + "range": Array [ + 14, + 25, + ], + "type": "Identifier", + }, + "kind": "constructor", + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 32, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 30, + 32, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 25, + 32, + ], + "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 25, + 27, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 34, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 34, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 35, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 25, + ], + "type": "Identifier", + "value": "constructor", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 30, + 31, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 19, + "line": 2, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-parameters-in-function-expression.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "init": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 27, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 12, + 27, + ], + "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 20, + 22, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 27, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 27, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 20, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-parameters-in-method.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": "test", + "range": Array [ + 14, + 18, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 25, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 23, + 25, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 18, + 25, + ], + "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 18, + 20, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 27, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 27, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 18, + ], + "type": "Identifier", + "value": "test", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 12, + "line": 2, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/errorRecovery/empty-type-parameters-in-method-signature.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": "test", + "range": Array [ + 18, + 22, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 18, + 27, + ], + "type": "TSMethodSignature", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 22, + 24, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 29, + ], + "type": "TSInterfaceBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 10, + 13, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 29, + ], + "type": "TSInterfaceDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 30, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 9, + ], + "type": "Keyword", + "value": "interface", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 13, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 18, + 22, + ], + "type": "Identifier", + "value": "test", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/errorRecovery/enum-with-keywords.src 1`] = ` Object { "body": Array [ From 7cd3bc2933bdda8239785a53f519127e0d082059 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 7 Feb 2019 02:18:31 +0100 Subject: [PATCH 77/88] refactor(parser): add ast types to parser (#205) --- packages/eslint-plugin-tslint/src/index.ts | 10 +- packages/parser/package.json | 1 - packages/parser/src/analyze-scope.ts | 279 ++++++------- .../src/{typings.d.ts => eslint-scope.d.ts} | 275 ++++++------- packages/parser/src/parser.ts | 10 +- .../typescript-estree/src/convert-comments.ts | 18 +- packages/typescript-estree/src/convert.ts | 366 +++++++++--------- packages/typescript-estree/src/node-utils.ts | 25 +- .../typescript-estree/src/parser-options.ts | 14 +- packages/typescript-estree/src/parser.ts | 18 +- packages/typescript-estree/src/ts-estree.ts | 2 + packages/typescript-estree/src/typedefs.ts | 2 +- .../tests/lib/semanticInfo.ts | 8 +- yarn.lock | 2 +- 14 files changed, 492 insertions(+), 538 deletions(-) rename packages/parser/src/{typings.d.ts => eslint-scope.d.ts} (57%) create mode 100644 packages/typescript-estree/src/ts-estree.ts diff --git a/packages/eslint-plugin-tslint/src/index.ts b/packages/eslint-plugin-tslint/src/index.ts index 78e946af6294..f2ae0e55efd3 100644 --- a/packages/eslint-plugin-tslint/src/index.ts +++ b/packages/eslint-plugin-tslint/src/index.ts @@ -3,20 +3,12 @@ import memoize from 'lodash.memoize'; import { Configuration, RuleSeverity } from 'tslint'; import { Program } from 'typescript'; import { CustomLinter } from './custom-linter'; +import { ParserServices } from '@typescript-eslint/typescript-estree'; //------------------------------------------------------------------------------ // Plugin Definition //------------------------------------------------------------------------------ -/** - * @todo share types between packages - */ -interface ParserServices { - program: Program | undefined; - esTreeNodeToTSNodeMap: WeakMap | undefined; - tsNodeToESTreeNodeMap: WeakMap | undefined; -} - type RawRuleConfig = | null | undefined diff --git a/packages/parser/package.json b/packages/parser/package.json index 26de602491a7..8cadc1c74159 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -43,7 +43,6 @@ "devDependencies": { "@types/eslint": "^4.16.5", "@types/eslint-visitor-keys": "^1.0.0", - "@types/estree": "^0.0.39", "@typescript-eslint/shared-fixtures": "1.2.0" } } diff --git a/packages/parser/src/analyze-scope.ts b/packages/parser/src/analyze-scope.ts index 2e8ae2e0a3cd..f3a6b5f78ac1 100644 --- a/packages/parser/src/analyze-scope.ts +++ b/packages/parser/src/analyze-scope.ts @@ -11,7 +11,7 @@ import { PatternVisitorCallback, PatternVisitorOptions } from 'eslint-scope/lib/options'; -import { Node } from 'estree'; +import { TSESTree } from '@typescript-eslint/typescript-estree'; /** * Define the override function of `Scope#__define` for global augmentation. @@ -35,7 +35,7 @@ class EnumScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: TSESTree.Node | null ) { // @ts-ignore super(scopeManager, 'enum', upperScope, block, false); @@ -51,7 +51,7 @@ class PatternVisitor extends OriginalPatternVisitor { super(options, rootPattern, callback); } - Identifier(node: any) { + Identifier(node: TSESTree.Identifier): void { super.Identifier(node); if (node.decorators) { this.rightHandNodes.push(...node.decorators); @@ -61,7 +61,7 @@ class PatternVisitor extends OriginalPatternVisitor { } } - ArrayPattern(node: any) { + ArrayPattern(node: TSESTree.ArrayPattern): void { node.elements.forEach(this.visit, this); if (node.decorators) { this.rightHandNodes.push(...node.decorators); @@ -71,7 +71,7 @@ class PatternVisitor extends OriginalPatternVisitor { } } - ObjectPattern(node: any) { + ObjectPattern(node: TSESTree.ObjectPattern): void { node.properties.forEach(this.visit, this); if (node.decorators) { this.rightHandNodes.push(...node.decorators); @@ -81,8 +81,11 @@ class PatternVisitor extends OriginalPatternVisitor { } } - RestElement(node: any) { + RestElement(node: TSESTree.RestElement): void { super.RestElement(node); + if (node.decorators) { + this.rightHandNodes.push(...node.decorators); + } if (node.typeAnnotation) { this.rightHandNodes.push(node.typeAnnotation); } @@ -99,16 +102,15 @@ class Referencer extends OriginalReferencer { /** * Override to use PatternVisitor we overrode. - * @param {Identifier} node The Identifier node to visit. - * @param {Object} [options] The flag to visit right-hand side nodes. - * @param {Function} callback The callback function for left-hand side nodes. - * @returns {void} + * @param node The Identifier node to visit. + * @param [options] The flag to visit right-hand side nodes. + * @param callback The callback function for left-hand side nodes. */ - visitPattern( - node: any, + visitPattern( + node: T, options: PatternVisitorOptions, callback: PatternVisitorCallback - ) { + ): void { if (!node) { return; } @@ -130,10 +132,14 @@ class Referencer extends OriginalReferencer { /** * Override. * Visit `node.typeParameters` and `node.returnType` additionally to find `typeof` expressions. - * @param {FunctionDeclaration|FunctionExpression|ArrowFunctionExpression} node The function node to visit. - * @returns {void} - */ - visitFunction(node: any) { + * @param node The function node to visit. + */ + visitFunction( + node: + | TSESTree.FunctionDeclaration + | TSESTree.FunctionExpression + | TSESTree.ArrowFunctionExpression + ): void { const { type, id, typeParameters, params, returnType, body } = node; const scopeManager = this.scopeManager; const upperScope = this.currentScope(); @@ -189,7 +195,7 @@ class Referencer extends OriginalReferencer { this.visit(returnType); // Process the body. - if (body.type === 'BlockStatement') { + if (body && body.type === 'BlockStatement') { this.visitChildren(body); } else { this.visit(body); @@ -202,10 +208,9 @@ class Referencer extends OriginalReferencer { /** * Override. * Visit decorators. - * @param {ClassDeclaration|ClassExpression} node The class node to visit. - * @returns {void} + * @param node The class node to visit. */ - visitClass(node: any) { + visitClass(node: TSESTree.ClassDeclaration | TSESTree.ClassExpression): void { this.visitDecorators(node.decorators); const upperTypeMode = this.typeMode; @@ -214,7 +219,7 @@ class Referencer extends OriginalReferencer { this.visit(node.superTypeParameters); } if (node.implements) { - this.visit(node.implements); + node.implements.forEach(this.visit, this); } this.typeMode = upperTypeMode; @@ -223,10 +228,13 @@ class Referencer extends OriginalReferencer { /** * Visit typeParameters. - * @param {*} node The node to visit. - * @returns {void} + * @param node The node to visit. */ - visitTypeParameters(node: any) { + visitTypeParameters(node: { + typeParameters?: + | TSESTree.TSTypeParameterDeclaration + | TSESTree.TSTypeParameterInstantiation; + }): void { if (node.typeParameters) { const upperTypeMode = this.typeMode; this.typeMode = true; @@ -238,7 +246,7 @@ class Referencer extends OriginalReferencer { /** * Override. */ - JSXOpeningElement(node: any) { + JSXOpeningElement(node: TSESTree.JSXOpeningElement): void { this.visit(node.name); this.visitTypeParameters(node); node.attributes.forEach(this.visit, this); @@ -247,10 +255,9 @@ class Referencer extends OriginalReferencer { /** * Override. * Don't create the reference object in the type mode. - * @param {Identifier} node The Identifier node to visit. - * @returns {void} + * @param node The Identifier node to visit. */ - Identifier(node: any) { + Identifier(node: TSESTree.Identifier): void { this.visitDecorators(node.decorators); if (!this.typeMode) { @@ -263,20 +270,22 @@ class Referencer extends OriginalReferencer { /** * Override. * Visit decorators. - * @param {MethodDefinition} node The MethodDefinition node to visit. - * @returns {void} + * @param node The MethodDefinition node to visit. */ - MethodDefinition(node: any) { + MethodDefinition( + node: TSESTree.MethodDefinition | TSESTree.TSAbstractMethodDefinition + ): void { this.visitDecorators(node.decorators); super.MethodDefinition(node); } /** * Don't create the reference object for the key if not computed. - * @param {ClassProperty} node The ClassProperty node to visit. - * @returns {void} + * @param node The ClassProperty node to visit. */ - ClassProperty(node: any) { + ClassProperty( + node: TSESTree.ClassProperty | TSESTree.TSAbstractClassProperty + ): void { const upperTypeMode = this.typeMode; const { computed, decorators, key, typeAnnotation, value } = node; @@ -295,39 +304,34 @@ class Referencer extends OriginalReferencer { /** * Visit new expression. - * @param {NewExpression} node The NewExpression node to visit. - * @returns {void} + * @param node The NewExpression node to visit. */ - NewExpression(node: any) { + NewExpression(node: TSESTree.NewExpression): void { this.visitTypeParameters(node); this.visit(node.callee); - if (node.arguments) { - node.arguments.forEach(this.visit, this); - } + + node.arguments.forEach(this.visit, this); } /** * Override. * Visit call expression. - * @param {CallExpression} node The CallExpression node to visit. - * @returns {void} + * @param node The CallExpression node to visit. */ - CallExpression(node: any) { + CallExpression(node: TSESTree.CallExpression): void { this.visitTypeParameters(node); this.visit(node.callee); - if (node.arguments) { - node.arguments.forEach(this.visit, this); - } + + node.arguments.forEach(this.visit, this); } /** * Define the variable of this function declaration only once. * Because to avoid confusion of `no-redeclare` rule by overloading. - * @param {TSDeclareFunction} node The TSDeclareFunction node to visit. - * @returns {void} + * @param node The TSDeclareFunction node to visit. */ - TSDeclareFunction(node: any) { + TSDeclareFunction(node: TSESTree.TSDeclareFunction): void { const upperTypeMode = this.typeMode; const scope = this.currentScope(); const { id, typeParameters, params, returnType } = node; @@ -355,10 +359,9 @@ class Referencer extends OriginalReferencer { /** * Create reference objects for the references in parameters and return type. - * @param {TSEmptyBodyFunctionExpression} node The TSEmptyBodyFunctionExpression node to visit. - * @returns {void} + * @param node The TSEmptyBodyFunctionExpression node to visit. */ - TSEmptyBodyFunctionExpression(node: any) { + TSEmptyBodyFunctionExpression(node: TSESTree.FunctionExpression): void { const upperTypeMode = this.typeMode; const { typeParameters, params, returnType } = node; @@ -372,39 +375,35 @@ class Referencer extends OriginalReferencer { /** * Don't make variable because it declares only types. * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. - * @param {TSInterfaceDeclaration} node The TSInterfaceDeclaration node to visit. - * @returns {void} + * @param node The TSInterfaceDeclaration node to visit. */ - TSInterfaceDeclaration(node: any) { + TSInterfaceDeclaration(node: TSESTree.TSInterfaceDeclaration): void { this.visitTypeNodes(node); } /** * Don't make variable because it declares only types. * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. - * @param {TSClassImplements} node The TSClassImplements node to visit. - * @returns {void} + * @param node The TSClassImplements node to visit. */ - TSClassImplements(node: any) { + TSClassImplements(node: TSESTree.TSClassImplements): void { this.visitTypeNodes(node); } /** * Don't make variable because it declares only types. * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. - * @param {TSIndexSignature} node The TSIndexSignature node to visit. - * @returns {void} + * @param node The TSIndexSignature node to visit. */ - TSIndexSignature(node: any) { + TSIndexSignature(node: TSESTree.TSIndexSignature): void { this.visitTypeNodes(node); } /** * Visit type assertion. - * @param {TSTypeAssertion} node The TSTypeAssertion node to visit. - * @returns {void} + * @param node The TSTypeAssertion node to visit. */ - TSTypeAssertion(node: any) { + TSTypeAssertion(node: TSESTree.TSTypeAssertion): void { if (this.typeMode) { this.visit(node.typeAnnotation); } else { @@ -418,10 +417,9 @@ class Referencer extends OriginalReferencer { /** * Visit as expression. - * @param {TSAsExpression} node The TSAsExpression node to visit. - * @returns {void} + * @param node The TSAsExpression node to visit. */ - TSAsExpression(node: any) { + TSAsExpression(node: TSESTree.TSAsExpression): void { this.visit(node.expression); if (this.typeMode) { @@ -435,28 +433,25 @@ class Referencer extends OriginalReferencer { /** * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. - * @param {TSTypeAnnotation} node The TSTypeAnnotation node to visit. - * @returns {void} + * @param node The TSTypeAnnotation node to visit. */ - TSTypeAnnotation(node: any) { + TSTypeAnnotation(node: TSESTree.TSTypeAnnotation): void { this.visitTypeNodes(node); } /** * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. - * @param {TSTypeParameterDeclaration} node The TSTypeParameterDeclaration node to visit. - * @returns {void} + * @param node The TSTypeParameterDeclaration node to visit. */ - TSTypeParameterDeclaration(node: any) { + TSTypeParameterDeclaration(node: TSESTree.TSTypeParameterDeclaration): void { this.visitTypeNodes(node); } /** * Create reference objects for the references in `typeof` expression. - * @param {TSTypeQuery} node The TSTypeQuery node to visit. - * @returns {void} + * @param node The TSTypeQuery node to visit. */ - TSTypeQuery(node: any) { + TSTypeQuery(node: TSESTree.TSTypeQuery): void { if (this.typeMode) { this.typeMode = false; this.visitChildren(node); @@ -467,124 +462,109 @@ class Referencer extends OriginalReferencer { } /** - * @param {TSTypeParameter} node The TSTypeParameter node to visit. - * @returns {void} + * @param node The TSTypeParameter node to visit. */ - TSTypeParameter(node: any) { + TSTypeParameter(node: TSESTree.TSTypeParameter): void { this.visitTypeNodes(node); } /** - * @param {TSInferType} node The TSInferType node to visit. - * @returns {void} + * @param node The TSInferType node to visit. */ - TSInferType(node: any) { + TSInferType(node: TSESTree.TSInferType): void { this.visitTypeNodes(node); } /** - * @param {TSTypeReference} node The TSTypeReference node to visit. - * @returns {void} + * @param node The TSTypeReference node to visit. */ - TSTypeReference(node: any) { + TSTypeReference(node: TSESTree.TSTypeReference): void { this.visitTypeNodes(node); } /** - * @param {TSTypeLiteral} node The TSTypeLiteral node to visit. - * @returns {void} + * @param node The TSTypeLiteral node to visit. */ - TSTypeLiteral(node: any) { + TSTypeLiteral(node: TSESTree.TSTypeLiteral): void { this.visitTypeNodes(node); } /** - * @param {TSLiteralType} node The TSLiteralType node to visit. - * @returns {void} + * @param node The TSLiteralType node to visit. */ - TSLiteralType(node: any) { + TSLiteralType(node: TSESTree.TSLiteralType): void { this.visitTypeNodes(node); } /** - * @param {TSIntersectionType} node The TSIntersectionType node to visit. - * @returns {void} + * @param node The TSIntersectionType node to visit. */ - TSIntersectionType(node: any) { + TSIntersectionType(node: TSESTree.TSIntersectionType): void { this.visitTypeNodes(node); } /** - * @param {TSConditionalType} node The TSConditionalType node to visit. - * @returns {void} + * @param node The TSConditionalType node to visit. */ - TSConditionalType(node: any) { + TSConditionalType(node: TSESTree.TSConditionalType): void { this.visitTypeNodes(node); } /** - * @param {TSIndexedAccessType} node The TSIndexedAccessType node to visit. - * @returns {void} + * @param node The TSIndexedAccessType node to visit. */ - TSIndexedAccessType(node: any) { + TSIndexedAccessType(node: TSESTree.TSIndexedAccessType): void { this.visitTypeNodes(node); } /** - * @param {TSMappedType} node The TSMappedType node to visit. - * @returns {void} + * @param node The TSMappedType node to visit. */ - TSMappedType(node: any) { + TSMappedType(node: TSESTree.TSMappedType): void { this.visitTypeNodes(node); } /** - * @param {TSOptionalType} node The TSOptionalType node to visit. - * @returns {void} + * @param node The TSOptionalType node to visit. */ - TSOptionalType(node: any) { + TSOptionalType(node: TSESTree.TSOptionalType): void { this.visitTypeNodes(node); } /** - * @param {TSParenthesizedType} node The TSParenthesizedType node to visit. - * @returns {void} + * @param node The TSParenthesizedType node to visit. */ - TSParenthesizedType(node: any) { + TSParenthesizedType(node: TSESTree.TSParenthesizedType): void { this.visitTypeNodes(node); } /** - * @param {TSRestType} node The TSRestType node to visit. - * @returns {void} + * @param node The TSRestType node to visit. */ - TSRestType(node: any) { + TSRestType(node: TSESTree.TSRestType): void { this.visitTypeNodes(node); } /** - * @param {TSTupleType} node The TSTupleType node to visit. - * @returns {void} + * @param node The TSTupleType node to visit. */ - TSTupleType(node: any) { + TSTupleType(node: TSESTree.TSTupleType): void { this.visitTypeNodes(node); } /** * Create reference objects for the object part. (This is `obj.prop`) - * @param {TSQualifiedName} node The TSQualifiedName node to visit. - * @returns {void} + * @param node The TSQualifiedName node to visit. */ - TSQualifiedName(node: any) { + TSQualifiedName(node: TSESTree.TSQualifiedName): void { this.visit(node.left); } /** * Create reference objects for the references in computed keys. - * @param {TSPropertySignature} node The TSPropertySignature node to visit. - * @returns {void} + * @param node The TSPropertySignature node to visit. */ - TSPropertySignature(node: any) { + TSPropertySignature(node: TSESTree.TSPropertySignature): void { const upperTypeMode = this.typeMode; const { computed, key, typeAnnotation, initializer } = node; @@ -604,10 +584,9 @@ class Referencer extends OriginalReferencer { /** * Create reference objects for the references in computed keys. - * @param {TSMethodSignature} node The TSMethodSignature node to visit. - * @returns {void} + * @param node The TSMethodSignature node to visit. */ - TSMethodSignature(node: any) { + TSMethodSignature(node: TSESTree.TSMethodSignature): void { const upperTypeMode = this.typeMode; const { computed, key, typeParameters, params, returnType } = node; @@ -641,10 +620,9 @@ class Referencer extends OriginalReferencer { * A = a // a is above constant. * } * - * @param {TSEnumDeclaration} node The TSEnumDeclaration node to visit. - * @returns {void} + * @param node The TSEnumDeclaration node to visit. */ - TSEnumDeclaration(node: any) { + TSEnumDeclaration(node: TSESTree.TSEnumDeclaration): void { const { id, members } = node; const scopeManager = this.scopeManager; const scope = this.currentScope(); @@ -664,10 +642,9 @@ class Referencer extends OriginalReferencer { * Create variable object for the enum member and create reference object for the initializer. * And visit the initializer. * - * @param {TSEnumMember} node The TSEnumMember node to visit. - * @returns {void} + * @param node The TSEnumMember node to visit. */ - TSEnumMember(node: any) { + TSEnumMember(node: TSESTree.TSEnumMember): void { const { id, initializer } = node; const scope = this.currentScope(); @@ -680,10 +657,9 @@ class Referencer extends OriginalReferencer { /** * Create the variable object for the module name, and visit children. - * @param {TSModuleDeclaration} node The TSModuleDeclaration node to visit. - * @returns {void} + * @param node The TSModuleDeclaration node to visit. */ - TSModuleDeclaration(node: any) { + TSModuleDeclaration(node: TSESTree.TSModuleDeclaration): void { const scope = this.currentScope(); const { id, body } = node; @@ -701,7 +677,7 @@ class Referencer extends OriginalReferencer { this.visit(body); } - TSTypeAliasDeclaration(node: any) { + TSTypeAliasDeclaration(node: TSESTree.TSTypeAliasDeclaration): void { this.typeMode = true; this.visitChildren(node); this.typeMode = false; @@ -709,28 +685,26 @@ class Referencer extends OriginalReferencer { /** * Process the module block. - * @param {TSModuleBlock} node The TSModuleBlock node to visit. - * @returns {void} + * @param node The TSModuleBlock node to visit. */ - TSModuleBlock(node: any) { + TSModuleBlock(node: TSESTree.TSModuleBlock): void { this.scopeManager.__nestBlockScope(node); this.visitChildren(node); this.close(node); } - TSAbstractClassProperty(node: any) { + TSAbstractClassProperty(node: TSESTree.TSAbstractClassProperty): void { this.ClassProperty(node); } - TSAbstractMethodDefinition(node: any) { + TSAbstractMethodDefinition(node: TSESTree.TSAbstractMethodDefinition): void { this.MethodDefinition(node); } /** * Process import equal declaration - * @param {TSImportEqualsDeclaration} node The TSImportEqualsDeclaration node to visit. - * @returns {void} + * @param node The TSImportEqualsDeclaration node to visit. */ - TSImportEqualsDeclaration(node: any) { + TSImportEqualsDeclaration(node: TSESTree.TSImportEqualsDeclaration): void { const { id, moduleReference } = node; if (id && id.type === 'Identifier') { this.currentScope().__define( @@ -745,10 +719,9 @@ class Referencer extends OriginalReferencer { * Process the global augmentation. * 1. Set the global scope as the current scope. * 2. Configure the global scope to set `variable.eslintUsed = true` for all defined variables. This means `no-unused-vars` doesn't warn those. - * @param {TSModuleDeclaration} node The TSModuleDeclaration node to visit. - * @returns {void} + * @param node The TSModuleDeclaration node to visit. */ - visitGlobalAugmentation(node: any) { + visitGlobalAugmentation(node: TSESTree.TSModuleDeclaration): void { const scopeManager = this.scopeManager; const currentScope = this.currentScope(); const globalScope = scopeManager.globalScope; @@ -758,8 +731,8 @@ class Referencer extends OriginalReferencer { scopeManager.__currentScope = globalScope; // Skip TSModuleBlock to avoid to create that block scope. - for (const moduleItem of node.body.body) { - this.visit(moduleItem); + if (node.body && node.body.type === 'TSModuleBlock') { + node.body.body.forEach(this.visit, this); } scopeManager.__currentScope = currentScope; @@ -768,10 +741,9 @@ class Referencer extends OriginalReferencer { /** * Process decorators. - * @param {Decorator[]|undefined} decorators The decorator nodes to visit. - * @returns {void} + * @param decorators The decorator nodes to visit. */ - visitDecorators(decorators?: any[]) { + visitDecorators(decorators?: TSESTree.Decorator[]): void { if (decorators) { decorators.forEach(this.visit, this); } @@ -779,10 +751,9 @@ class Referencer extends OriginalReferencer { /** * Process all child of type nodes - * @param {any} node node to be processed - * @returns {void} + * @param node node to be processed */ - visitTypeNodes(node: any) { + visitTypeNodes(node: TSESTree.Node): void { if (this.typeMode) { this.visitChildren(node); } else { diff --git a/packages/parser/src/typings.d.ts b/packages/parser/src/eslint-scope.d.ts similarity index 57% rename from packages/parser/src/typings.d.ts rename to packages/parser/src/eslint-scope.d.ts index 08f92526c823..28de7f8c759e 100644 --- a/packages/parser/src/typings.d.ts +++ b/packages/parser/src/eslint-scope.d.ts @@ -2,6 +2,7 @@ // Project: http://github.com/eslint/eslint-scope // Definitions by: Armano declare module 'eslint-scope/lib/options' { + import { TSESTree } from '@typescript-eslint/typescript-estree'; export type PatternVisitorCallback = (pattern: any, info: any) => void; export interface PatternVisitorOptions { @@ -9,76 +10,75 @@ declare module 'eslint-scope/lib/options' { } export abstract class Visitor { - visitChildren(node: Node): void; - visit(node: Node): void; + visitChildren( + node?: T + ): void; + visit(node?: T): void; } } declare module 'eslint-scope/lib/variable' { - import * as eslint from 'eslint'; - import { Identifier } from 'estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; import Reference from 'eslint-scope/lib/reference'; + import { Definition } from 'eslint-scope/lib/definition'; - class Variable implements eslint.Scope.Variable { + export default class Variable { name: string; - identifiers: Identifier[]; + identifiers: TSESTree.Identifier[]; references: Reference[]; - defs: eslint.Scope.Definition[]; + defs: Definition[]; } - export default Variable; } declare module 'eslint-scope/lib/definition' { - import { Identifier, Node } from 'estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; - class Definition { + export class Definition { type: string; - name: Identifier; - node: Node; - parent?: Node | null; + name: TSESTree.BindingName; + node: TSESTree.Node; + parent?: TSESTree.Node | null; index?: number | null; kind?: string | null; constructor( type: string, - name: Identifier, - node: Node, - parent?: Node | null, + name: TSESTree.BindingName | TSESTree.PropertyName, + node: TSESTree.Node, + parent?: TSESTree.Node | null, index?: number | null, kind?: string | null ); } - class ParameterDefinition extends Definition { + export class ParameterDefinition extends Definition { rest?: boolean; constructor( - name: Identifier, - node: Node, + name: TSESTree.BindingName | TSESTree.PropertyName, + node: TSESTree.Node, index?: number | null, rest?: boolean ); } - - export { ParameterDefinition, Definition }; } declare module 'eslint-scope/lib/pattern-visitor' { import ScopeManager from 'eslint-scope/lib/scope-manager'; - import { Node } from 'estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; import { PatternVisitorCallback, PatternVisitorOptions, Visitor } from 'eslint-scope/lib/options'; - class PatternVisitor extends Visitor { + export default class PatternVisitor extends Visitor { protected options: any; protected scopeManager: ScopeManager; - protected parent?: Node; - public rightHandNodes: Node[]; + protected parent?: TSESTree.Node; + public rightHandNodes: TSESTree.Node[]; - static isPattern(node: Node): boolean; + static isPattern(node: TSESTree.Node): boolean; constructor( options: PatternVisitorOptions, @@ -86,41 +86,39 @@ declare module 'eslint-scope/lib/pattern-visitor' { callback: PatternVisitorCallback ); - Identifier(pattern: Node): void; - Property(property: Node): void; - ArrayPattern(pattern: Node): void; - AssignmentPattern(pattern: Node): void; - RestElement(pattern: Node): void; - MemberExpression(node: Node): void; - SpreadElement(node: Node): void; - ArrayExpression(node: Node): void; - AssignmentExpression(node: Node): void; - CallExpression(node: Node): void; + Identifier(pattern: TSESTree.Node): void; + Property(property: TSESTree.Node): void; + ArrayPattern(pattern: TSESTree.Node): void; + AssignmentPattern(pattern: TSESTree.Node): void; + RestElement(pattern: TSESTree.Node): void; + MemberExpression(node: TSESTree.Node): void; + SpreadElement(node: TSESTree.Node): void; + ArrayExpression(node: TSESTree.Node): void; + AssignmentExpression(node: TSESTree.Node): void; + CallExpression(node: TSESTree.Node): void; } - - export default PatternVisitor; } declare module 'eslint-scope/lib/referencer' { import { Scope } from 'eslint-scope/lib/scope'; import ScopeManager from 'eslint-scope/lib/scope-manager'; - import { Node } from 'estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; import { PatternVisitorCallback, PatternVisitorOptions, Visitor } from 'eslint-scope/lib/options'; - class Referencer extends Visitor { + export default class Referencer extends Visitor { protected isInnerMethodDefinition: boolean; protected options: any; protected scopeManager: ScopeManager; - protected parent?: Node; + protected parent?: TSESTree.Node; constructor(options: any, scopeManager: ScopeManager); currentScope(): Scope; - close(node: Node): void; + close(node: TSESTree.Node): void; pushInnerMethodDefinition(isInnerMethodDefinition: boolean): boolean; popInnerMethodDefinition(isInnerMethodDefinition: boolean): void; @@ -131,66 +129,63 @@ declare module 'eslint-scope/lib/referencer' { init: boolean ): void; visitPattern( - node: Node, + node: TSESTree.Node, options: PatternVisitorOptions, callback: PatternVisitorCallback ): void; - visitFunction(node: Node): void; - visitClass(node: Node): void; - visitProperty(node: Node): void; - visitForIn(node: Node): void; + visitFunction(node: TSESTree.Node): void; + visitClass(node: TSESTree.Node): void; + visitProperty(node: TSESTree.Node): void; + visitForIn(node: TSESTree.Node): void; visitVariableDeclaration( variableTargetScope: any, type: any, - node: Node, + node: TSESTree.Node, index: any ): void; - AssignmentExpression(node: Node): void; - CatchClause(node: Node): void; - Program(node: Node): void; - Identifier(node: Node): void; - UpdateExpression(node: Node): void; - MemberExpression(node: Node): void; - Property(node: Node): void; - MethodDefinition(node: Node): void; + AssignmentExpression(node: TSESTree.Node): void; + CatchClause(node: TSESTree.Node): void; + Program(node: TSESTree.Node): void; + Identifier(node: TSESTree.Node): void; + UpdateExpression(node: TSESTree.Node): void; + MemberExpression(node: TSESTree.Node): void; + Property(node: TSESTree.Node): void; + MethodDefinition(node: TSESTree.Node): void; BreakStatement(): void; ContinueStatement(): void; - LabeledStatement(node: Node): void; - ForStatement(node: Node): void; - ClassExpression(node: Node): void; - ClassDeclaration(node: Node): void; - CallExpression(node: Node): void; - BlockStatement(node: Node): void; + LabeledStatement(node: TSESTree.Node): void; + ForStatement(node: TSESTree.Node): void; + ClassExpression(node: TSESTree.Node): void; + ClassDeclaration(node: TSESTree.Node): void; + CallExpression(node: TSESTree.Node): void; + BlockStatement(node: TSESTree.Node): void; ThisExpression(): void; - WithStatement(node: Node): void; - VariableDeclaration(node: Node): void; - SwitchStatement(node: Node): void; - FunctionDeclaration(node: Node): void; - FunctionExpression(node: Node): void; - ForOfStatement(node: Node): void; - ForInStatement(node: Node): void; - ArrowFunctionExpression(node: Node): void; - ImportDeclaration(node: Node): void; - visitExportDeclaration(node: Node): void; - ExportDeclaration(node: Node): void; - ExportNamedDeclaration(node: Node): void; - ExportSpecifier(node: Node): void; + WithStatement(node: TSESTree.Node): void; + VariableDeclaration(node: TSESTree.Node): void; + SwitchStatement(node: TSESTree.Node): void; + FunctionDeclaration(node: TSESTree.Node): void; + FunctionExpression(node: TSESTree.Node): void; + ForOfStatement(node: TSESTree.Node): void; + ForInStatement(node: TSESTree.Node): void; + ArrowFunctionExpression(node: TSESTree.Node): void; + ImportDeclaration(node: TSESTree.Node): void; + visitExportDeclaration(node: TSESTree.Node): void; + ExportDeclaration(node: TSESTree.Node): void; + ExportNamedDeclaration(node: TSESTree.Node): void; + ExportSpecifier(node: TSESTree.Node): void; MetaProperty(): void; } - - export default Referencer; } declare module 'eslint-scope/lib/scope' { - import * as eslint from 'eslint'; - import { Node } from 'estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; import Reference from 'eslint-scope/lib/reference'; import Variable from 'eslint-scope/lib/variable'; import ScopeManager from 'eslint-scope/lib/scope-manager'; import { Definition } from 'eslint-scope/lib/definition'; - type ScopeType = + export type ScopeType = | 'block' | 'catch' | 'class' @@ -203,13 +198,13 @@ declare module 'eslint-scope/lib/scope' { | 'with' | 'TDZ'; - class Scope implements eslint.Scope.Scope { + export class Scope { type: ScopeType; isStrict: boolean; upper: Scope | null; childScopes: Scope[]; variableScope: Scope; - block: Node; + block: TSESTree.Node; variables: Variable[]; set: Map; references: Reference[]; @@ -221,7 +216,7 @@ declare module 'eslint-scope/lib/scope' { scopeManager: ScopeManager, type: ScopeType, upperScope: Scope | null, - block: Node | null, + block: TSESTree.Node | null, isMethodDefinition: boolean ); @@ -234,7 +229,7 @@ declare module 'eslint-scope/lib/scope' { __isValidResolution(ref: any, variable: any): boolean; __resolve(ref: any): boolean; __delegateToUpperScope(ref: any): void; - __addDeclaredVariablesOfNode(variable: any, node: Node): void; + __addDeclaredVariablesOfNode(variable: any, node: TSESTree.Node): void; __defineGeneric( name: any, set: any, @@ -243,12 +238,12 @@ declare module 'eslint-scope/lib/scope' { def: Definition ): void; - __define(node: Node, def: Definition): void; + __define(node: TSESTree.Node, def: Definition): void; __referencing( - node: Node, + node: TSESTree.Node, assign: number, - writeExpr: Node, + writeExpr: TSESTree.Node, maybeImplicitGlobal: any, partial: any, init: any @@ -263,7 +258,7 @@ declare module 'eslint-scope/lib/scope' { * @param {Espree.Identifier} ident - identifier to be resolved. * @returns {Reference} reference */ - resolve(ident: Node): Reference; + resolve(ident: TSESTree.Node): Reference; /** * returns this scope is static @@ -289,109 +284,94 @@ declare module 'eslint-scope/lib/scope' { isUsedName(name: any): boolean; } - class GlobalScope extends Scope { - constructor(scopeManager: ScopeManager, block: Node | null); + export class GlobalScope extends Scope { + constructor(scopeManager: ScopeManager, block: TSESTree.Node | null); } - class ModuleScope extends Scope { + export class ModuleScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: TSESTree.Node | null ); } - class FunctionExpressionNameScope extends Scope { + export class FunctionExpressionNameScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: TSESTree.Node | null ); } - class CatchScope extends Scope { + export class CatchScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: TSESTree.Node | null ); } - class WithScope extends Scope { + export class WithScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: TSESTree.Node | null ); } - class BlockScope extends Scope { + export class BlockScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: TSESTree.Node | null ); } - class SwitchScope extends Scope { + export class SwitchScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: TSESTree.Node | null ); } - class FunctionScope extends Scope { + export class FunctionScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null, + block: TSESTree.Node | null, isMethodDefinition: boolean ); } - class ForScope extends Scope { + export class ForScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: TSESTree.Node | null ); } - class ClassScope extends Scope { + export class ClassScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: TSESTree.Node | null ); } - - export { - Scope, - GlobalScope, - ModuleScope, - FunctionExpressionNameScope, - CatchScope, - WithScope, - BlockScope, - SwitchScope, - FunctionScope, - ForScope, - ClassScope - }; } declare module 'eslint-scope/lib/reference' { - import * as eslint from 'eslint'; - import { Identifier, Node } from 'estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; import { Scope } from 'eslint-scope/lib/scope'; import Variable from 'eslint-scope/lib/variable'; - class Reference implements eslint.Scope.Reference { - identifier: Identifier; + export default class Reference { + identifier: TSESTree.Identifier; from: Scope; resolved: Variable | null; - writeExpr: Node | null; + writeExpr: TSESTree.Node | null; init: boolean; isWrite(): boolean; @@ -404,15 +384,14 @@ declare module 'eslint-scope/lib/reference' { static WRITE: 0x2; static RW: 0x3; } - export default Reference; } declare module 'eslint-scope/lib/scope-manager' { - import * as eslint from 'eslint'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; import { Scope } from 'eslint-scope/lib/scope'; import Variable from 'eslint-scope/lib/variable'; - interface ScopeManagerOptions { + export interface ScopeManagerOptions { directive?: boolean; optimistic?: boolean; ignoreEval?: boolean; @@ -422,7 +401,7 @@ declare module 'eslint-scope/lib/scope-manager' { ecmaVersion?: number; } - class ScopeManager implements eslint.Scope.ScopeManager { + export default class ScopeManager { __options: ScopeManagerOptions; __currentScope: Scope; scopes: Scope[]; @@ -439,29 +418,31 @@ declare module 'eslint-scope/lib/scope-manager' { isStrictModeSupported(): boolean; // Returns appropriate scope for this node. - __get(node: Node): Scope; - getDeclaredVariables(node: {}): Variable[]; - acquire(node: {}, inner?: boolean): Scope | null; - acquireAll(node: Node): Scope | null; - release(node: Node, inner?: boolean): Scope | null; + __get(node: TSESTree.Node): Scope; + getDeclaredVariables(node: TSESTree.Node): Variable[]; + acquire(node: TSESTree.Node, inner?: boolean): Scope | null; + acquireAll(node: TSESTree.Node): Scope | null; + release(node: TSESTree.Node, inner?: boolean): Scope | null; attach(): void; detach(): void; __nestScope(scope: Scope): Scope; - __nestGlobalScope(node: Node): Scope; - __nestBlockScope(node: Node): Scope; - __nestFunctionScope(node: Node, isMethodDefinition: boolean): Scope; - __nestForScope(node: Node): Scope; - __nestCatchScope(node: Node): Scope; - __nestWithScope(node: Node): Scope; - __nestClassScope(node: Node): Scope; - __nestSwitchScope(node: Node): Scope; - __nestModuleScope(node: Node): Scope; - __nestFunctionExpressionNameScope(node: Node): Scope; + __nestGlobalScope(node: TSESTree.Node): Scope; + __nestBlockScope(node: TSESTree.Node): Scope; + __nestFunctionScope( + node: TSESTree.Node, + isMethodDefinition: boolean + ): Scope; + __nestForScope(node: TSESTree.Node): Scope; + __nestCatchScope(node: TSESTree.Node): Scope; + __nestWithScope(node: TSESTree.Node): Scope; + __nestClassScope(node: TSESTree.Node): Scope; + __nestSwitchScope(node: TSESTree.Node): Scope; + __nestModuleScope(node: TSESTree.Node): Scope; + __nestFunctionExpressionNameScope(node: TSESTree.Node): Scope; __isES6(): boolean; } - export default ScopeManager; } declare module 'eslint-scope' { diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index be3c3e7506ef..78d71197e9f9 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -2,21 +2,15 @@ import traverser from 'eslint/lib/util/traverser'; import { AST_NODE_TYPES, parseAndGenerateServices, - ParserOptions as ParserOptionsTsESTree + ParserOptions as ParserOptionsTsESTree, + ParserServices } from '@typescript-eslint/typescript-estree'; import { analyzeScope } from './analyze-scope'; import { ParserOptions } from './parser-options'; import { visitorKeys } from './visitor-keys'; -import { Program } from 'typescript'; const packageJSON = require('../package.json'); -interface ParserServices { - program: Program | undefined; - esTreeNodeToTSNodeMap: WeakMap | undefined; - tsNodeToESTreeNodeMap: WeakMap | undefined; -} - interface ParseForESLintResult { ast: any; services: ParserServices; diff --git a/packages/typescript-estree/src/convert-comments.ts b/packages/typescript-estree/src/convert-comments.ts index 59a2326122c8..1efff92648dc 100644 --- a/packages/typescript-estree/src/convert-comments.ts +++ b/packages/typescript-estree/src/convert-comments.ts @@ -7,7 +7,7 @@ import ts from 'typescript'; import { getLocFor, getNodeContainer } from './node-utils'; -import * as es from './typedefs'; +import { TSESTree } from './ts-estree'; /** * Converts a TypeScript comment to an Esprima comment. @@ -25,10 +25,10 @@ function convertTypeScriptCommentToEsprimaComment( text: string, start: number, end: number, - startLoc: es.LineAndColumnData, - endLoc: es.LineAndColumnData -): es.Comment { - const comment: es.OptionalRangeAndLoc = { + startLoc: TSESTree.LineAndColumnData, + endLoc: TSESTree.LineAndColumnData +): TSESTree.Comment { + const comment: TSESTree.OptionalRangeAndLoc = { type: block ? 'Block' : 'Line', value: text }; @@ -44,7 +44,7 @@ function convertTypeScriptCommentToEsprimaComment( }; } - return comment as es.Comment; + return comment as TSESTree.Comment; } /** @@ -59,7 +59,7 @@ function getCommentFromTriviaScanner( triviaScanner: ts.Scanner, ast: ts.SourceFile, code: string -): es.Comment { +): TSESTree.Comment { const kind = triviaScanner.getToken(); const isBlock = kind === ts.SyntaxKind.MultiLineCommentTrivia; const range = { @@ -94,8 +94,8 @@ function getCommentFromTriviaScanner( export function convertComments( ast: ts.SourceFile, code: string -): es.Comment[] { - const comments: es.Comment[] = []; +): TSESTree.Comment[] { + const comments: TSESTree.Comment[] = []; /** * Create a TypeScript Scanner, with skipTrivia set to false so that diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index da34cb8e7d8a..3686ba919150 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -6,7 +6,7 @@ * MIT License */ import ts from 'typescript'; -import * as es from './typedefs'; +import { TSESTree } from './ts-estree'; import { canContainDirective, createError, @@ -78,8 +78,8 @@ export class Converter { }; } - convertProgram(): es.Program { - return this.converter(this.ast) as es.Program; + convertProgram(): TSESTree.Program { + return this.converter(this.ast) as TSESTree.Program; } /** @@ -112,7 +112,7 @@ export class Converter { this.allowPattern = allowPattern; } - let result: es.BaseNode | null = this.convertNode( + let result: TSESTree.BaseNode | null = this.convertNode( node as TSNode, parent || node.parent ); @@ -157,9 +157,9 @@ export class Converter { return this.converter(child, parent, true, false); } - private createNode( + private createNode( node: ts.Node, - data: es.OptionalRangeAndLoc + data: TSESTree.OptionalRangeAndLoc ): T { const result = data; if (!result.range) { @@ -182,7 +182,7 @@ export class Converter { private convertTypeAnnotation( child: ts.TypeNode, parent: ts.Node - ): es.TSTypeAnnotation { + ): TSESTree.TSTypeAnnotation { // in FunctionType and ConstructorType typeAnnotation has 2 characters `=>` and in other places is just colon const offset = parent.kind === SyntaxKind.FunctionType || @@ -244,7 +244,7 @@ export class Converter { */ private convertTypeArgumentsToTypeParameters( typeArguments: ts.NodeArray - ): es.TSTypeParameterInstantiation { + ): TSESTree.TSTypeParameterInstantiation { const greaterThanToken = findNextToken(typeArguments, this.ast, this.ast)!; return { @@ -262,7 +262,7 @@ export class Converter { */ private convertTSTypeParametersToTypeParametersDeclaration( typeParameters: ts.NodeArray - ): es.TSTypeParameterDeclaration { + ): TSESTree.TSTypeParameterDeclaration { const greaterThanToken = findNextToken(typeParameters, this.ast, this.ast)!; return { @@ -282,12 +282,12 @@ export class Converter { */ private convertParameters( parameters: ts.NodeArray - ): es.Parameter[] { + ): TSESTree.Parameter[] { if (!parameters || !parameters.length) { return []; } return parameters.map(param => { - const convertedParam = this.convertChild(param) as es.Parameter; + const convertedParam = this.convertChild(param) as TSESTree.Parameter; if (param.decorators && param.decorators.length) { convertedParam.decorators = param.decorators.map(el => @@ -375,28 +375,28 @@ export class Converter { private convertJSXTagName( node: ts.JsxTagNameExpression, parent: ts.Node - ): es.JSXMemberExpression | es.JSXIdentifier { - let result: es.JSXMemberExpression | es.JSXIdentifier; + ): TSESTree.JSXMemberExpression | TSESTree.JSXIdentifier { + let result: TSESTree.JSXMemberExpression | TSESTree.JSXIdentifier; switch (node.kind) { case SyntaxKind.PropertyAccessExpression: - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.JSXMemberExpression, object: this.convertJSXTagName(node.expression, parent), property: this.convertJSXTagName( node.name, parent - ) as es.JSXIdentifier + ) as TSESTree.JSXIdentifier }); break; case SyntaxKind.ThisKeyword: - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.JSXIdentifier, name: 'this' }); break; case SyntaxKind.Identifier: default: - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.JSXIdentifier, name: node.text }); @@ -419,7 +419,7 @@ export class Converter { * @deprecated This method adds not standardized `modifiers` property in nodes */ private applyModifiersToResult( - result: es.TSEnumDeclaration | es.TSModuleDeclaration, + result: TSESTree.TSEnumDeclaration | TSESTree.TSModuleDeclaration, modifiers?: ts.ModifiersArray ): void { if (!modifiers || !modifiers.length) { @@ -474,7 +474,7 @@ export class Converter { * @param childRange The child node range used to expand location */ private fixParentLocation( - result: es.BaseNode, + result: TSESTree.BaseNode, childRange: [number, number] ): void { if (childRange[0] < result.range[0]) { @@ -495,10 +495,10 @@ export class Converter { * @param parent parentNode * @returns the converted ESTree node */ - private convertNode(node: TSNode, parent: ts.Node): es.Node | null { + private convertNode(node: TSNode, parent: ts.Node): TSESTree.Node | null { switch (node.kind) { case SyntaxKind.SourceFile: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Program, body: this.convertBodyExpressions(node.statements, node), // externalModuleIndicator is internal field in TSC @@ -510,21 +510,21 @@ export class Converter { } case SyntaxKind.Block: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.BlockStatement, body: this.convertBodyExpressions(node.statements, node) }); } case SyntaxKind.Identifier: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Identifier, name: node.text }); } case SyntaxKind.WithStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.WithStatement, object: this.convertChild(node.expression), body: this.convertChild(node.statement) @@ -533,26 +533,26 @@ export class Converter { // Control Flow case SyntaxKind.ReturnStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ReturnStatement, argument: this.convertChild(node.expression) }); case SyntaxKind.LabeledStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.LabeledStatement, label: this.convertChild(node.label), body: this.convertChild(node.statement) }); case SyntaxKind.ContinueStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ContinueStatement, label: this.convertChild(node.label) }); case SyntaxKind.BreakStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.BreakStatement, label: this.convertChild(node.label) }); @@ -560,7 +560,7 @@ export class Converter { // Choice case SyntaxKind.IfStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.IfStatement, test: this.convertChild(node.expression), consequent: this.convertChild(node.thenStatement), @@ -568,7 +568,7 @@ export class Converter { }); case SyntaxKind.SwitchStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.SwitchStatement, discriminant: this.convertChild(node.expression), cases: node.caseBlock.clauses.map(el => this.convertChild(el)) @@ -576,7 +576,7 @@ export class Converter { case SyntaxKind.CaseClause: case SyntaxKind.DefaultClause: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.SwitchCase, // expression is present in case only test: @@ -589,13 +589,13 @@ export class Converter { // Exceptions case SyntaxKind.ThrowStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ThrowStatement, argument: this.convertChild(node.expression) }); case SyntaxKind.TryStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TryStatement, block: this.convertChild(node.tryBlock), handler: this.convertChild(node.catchClause), @@ -603,7 +603,7 @@ export class Converter { }); case SyntaxKind.CatchClause: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.CatchClause, param: node.variableDeclaration ? this.convertChild(node.variableDeclaration.name) @@ -614,7 +614,7 @@ export class Converter { // Loops case SyntaxKind.WhileStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.WhileStatement, test: this.convertChild(node.expression), body: this.convertChild(node.statement) @@ -625,14 +625,14 @@ export class Converter { * a "DoStatement" */ case SyntaxKind.DoStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.DoWhileStatement, test: this.convertChild(node.expression), body: this.convertChild(node.statement) }); case SyntaxKind.ForStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ForStatement, init: this.convertChild(node.initializer), test: this.convertChild(node.condition), @@ -641,7 +641,7 @@ export class Converter { }); case SyntaxKind.ForInStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ForInStatement, left: this.convertPattern(node.initializer), right: this.convertChild(node.expression), @@ -649,7 +649,7 @@ export class Converter { }); case SyntaxKind.ForOfStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ForOfStatement, left: this.convertPattern(node.initializer), right: this.convertChild(node.expression), @@ -666,7 +666,7 @@ export class Converter { const isDeclare = hasModifier(SyntaxKind.DeclareKeyword, node); const result = this.createNode< - es.TSDeclareFunction | es.FunctionDeclaration + TSESTree.TSDeclareFunction | TSESTree.FunctionDeclaration >(node, { type: isDeclare || !node.body @@ -701,7 +701,7 @@ export class Converter { } case SyntaxKind.VariableDeclaration: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.VariableDeclarator, id: this.convertPattern(node.name), init: this.convertChild(node.initializer) @@ -722,7 +722,7 @@ export class Converter { } case SyntaxKind.VariableStatement: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.VariableDeclaration, declarations: node.declarationList.declarations.map(el => this.convertChild(el) @@ -740,7 +740,7 @@ export class Converter { // mostly for for-of, for-in case SyntaxKind.VariableDeclarationList: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.VariableDeclaration, declarations: node.declarations.map(el => this.convertChild(el)), kind: getDeclarationKind(node) @@ -749,25 +749,25 @@ export class Converter { // Expressions case SyntaxKind.ExpressionStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ExpressionStatement, expression: this.convertChild(node.expression) }); case SyntaxKind.ThisKeyword: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ThisExpression }); case SyntaxKind.ArrayLiteralExpression: { // TypeScript uses ArrayLiteralExpression in destructuring assignment, too if (this.allowPattern) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ArrayPattern, elements: node.elements.map(el => this.convertPattern(el)) }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ArrayExpression, elements: node.elements.map(el => this.convertChild(el)) }); @@ -777,12 +777,12 @@ export class Converter { case SyntaxKind.ObjectLiteralExpression: { // TypeScript uses ObjectLiteralExpression in destructuring assignment, too if (this.allowPattern) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ObjectPattern, properties: node.properties.map(el => this.convertPattern(el)) }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ObjectExpression, properties: node.properties.map(el => this.convertChild(el)) }); @@ -790,7 +790,7 @@ export class Converter { } case SyntaxKind.PropertyAssignment: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Property, key: this.convertChild(node.name), value: this.converter( @@ -807,10 +807,10 @@ export class Converter { case SyntaxKind.ShorthandPropertyAssignment: { if (node.objectAssignmentInitializer) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Property, key: this.convertChild(node.name), - value: this.createNode(node, { + value: this.createNode(node, { type: AST_NODE_TYPES.AssignmentPattern, left: this.convertPattern(node.name), right: this.convertChild(node.objectAssignmentInitializer) @@ -821,7 +821,7 @@ export class Converter { kind: 'init' }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Property, key: this.convertChild(node.name), value: this.convertChild(node.name), @@ -839,7 +839,7 @@ export class Converter { case SyntaxKind.PropertyDeclaration: { const isAbstract = hasModifier(SyntaxKind.AbstractKeyword, node); const result = this.createNode< - es.TSAbstractClassProperty | es.ClassProperty + TSESTree.TSAbstractClassProperty | TSESTree.ClassProperty >(node, { type: isAbstract ? AST_NODE_TYPES.TSAbstractClassProperty @@ -881,7 +881,7 @@ export class Converter { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.MethodDeclaration: { - const method = this.createNode(node, { + const method = this.createNode(node, { type: AST_NODE_TYPES.FunctionExpression, id: null, generator: !!node.asteriskToken, @@ -905,14 +905,14 @@ export class Converter { } let result: - | es.Property - | es.TSAbstractMethodDefinition - | es.MethodDefinition; + | TSESTree.Property + | TSESTree.TSAbstractMethodDefinition + | TSESTree.MethodDefinition; if (parent.kind === SyntaxKind.ObjectLiteralExpression) { method.params = node.parameters.map(el => this.convertChild(el)); - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.Property, key: this.convertChild(node.name), value: method, @@ -940,7 +940,7 @@ export class Converter { : AST_NODE_TYPES.MethodDefinition; result = this.createNode< - es.TSAbstractMethodDefinition | es.MethodDefinition + TSESTree.TSAbstractMethodDefinition | TSESTree.MethodDefinition >(node, { type: methodDefinitionType, key: this.convertChild(node.name), @@ -974,7 +974,7 @@ export class Converter { } else if (node.kind === SyntaxKind.SetAccessor) { result.kind = 'set'; } else if ( - !(result as es.MethodDefinition).static && + !(result as TSESTree.MethodDefinition).static && node.name.kind === SyntaxKind.StringLiteral && node.name.text === 'constructor' && result.type !== AST_NODE_TYPES.Property @@ -991,7 +991,7 @@ export class Converter { (lastModifier && findNextToken(lastModifier, node, this.ast)) || node.getFirstToken()!; - const constructor = this.createNode(node, { + const constructor = this.createNode(node, { type: AST_NODE_TYPES.FunctionExpression, id: null, params: this.convertParameters(node.parameters), @@ -1015,7 +1015,7 @@ export class Converter { constructor.returnType = this.convertTypeAnnotation(node.type, node); } - const constructorKey = this.createNode(node, { + const constructorKey = this.createNode(node, { type: AST_NODE_TYPES.Identifier, name: 'constructor', range: [constructorToken.getStart(this.ast), constructorToken.end] @@ -1023,7 +1023,7 @@ export class Converter { const isStatic = hasModifier(SyntaxKind.StaticKeyword, node); const result = this.createNode< - es.TSAbstractMethodDefinition | es.MethodDefinition + TSESTree.TSAbstractMethodDefinition | TSESTree.MethodDefinition >(node, { type: hasModifier(SyntaxKind.AbstractKeyword, node) ? AST_NODE_TYPES.TSAbstractMethodDefinition @@ -1044,7 +1044,7 @@ export class Converter { } case SyntaxKind.FunctionExpression: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.FunctionExpression, id: this.convertChild(node.name), generator: !!node.asteriskToken, @@ -1069,12 +1069,12 @@ export class Converter { } case SyntaxKind.SuperKeyword: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Super }); case SyntaxKind.ArrayBindingPattern: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ArrayPattern, elements: node.elements.map(el => this.convertPattern(el)) }); @@ -1084,7 +1084,7 @@ export class Converter { return null; case SyntaxKind.ObjectBindingPattern: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ObjectPattern, properties: node.elements.map(el => this.convertPattern(el)) }); @@ -1094,13 +1094,13 @@ export class Converter { const arrayItem = this.convertChild(node.name, parent); if (node.initializer) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.AssignmentPattern, left: arrayItem, right: this.convertChild(node.initializer) }); } else if (node.dotDotDotToken) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.RestElement, argument: arrayItem }); @@ -1108,14 +1108,14 @@ export class Converter { return arrayItem; } } else if (parent.kind === SyntaxKind.ObjectBindingPattern) { - let result: es.RestElement | es.Property; + let result: TSESTree.RestElement | TSESTree.Property; if (node.dotDotDotToken) { - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.RestElement, argument: this.convertChild(node.propertyName || node.name) }); } else { - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.Property, key: this.convertChild(node.propertyName || node.name), value: this.convertChild(node.name), @@ -1130,7 +1130,7 @@ export class Converter { } if (node.initializer) { - result.value = this.createNode(node, { + result.value = this.createNode(node, { type: AST_NODE_TYPES.AssignmentPattern, left: this.convertChild(node.name), right: this.convertChild(node.initializer), @@ -1143,7 +1143,7 @@ export class Converter { } case SyntaxKind.ArrowFunction: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.ArrowFunctionExpression, generator: false, id: null, @@ -1168,14 +1168,14 @@ export class Converter { } case SyntaxKind.YieldExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.YieldExpression, delegate: !!node.asteriskToken, argument: this.convertChild(node.expression) }); case SyntaxKind.AwaitExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.AwaitExpression, argument: this.convertChild(node.expression) }); @@ -1183,10 +1183,10 @@ export class Converter { // Template Literals case SyntaxKind.NoSubstitutionTemplateLiteral: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TemplateLiteral, quasis: [ - this.createNode(node, { + this.createNode(node, { type: AST_NODE_TYPES.TemplateElement, value: { raw: this.ast.text.slice( @@ -1202,7 +1202,7 @@ export class Converter { }); case SyntaxKind.TemplateExpression: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TemplateLiteral, quasis: [this.convertChild(node.head)], expressions: [] @@ -1216,7 +1216,7 @@ export class Converter { } case SyntaxKind.TaggedTemplateExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TaggedTemplateExpression, typeParameters: node.typeArguments ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) @@ -1229,7 +1229,7 @@ export class Converter { case SyntaxKind.TemplateMiddle: case SyntaxKind.TemplateTail: { const tail = node.kind === SyntaxKind.TemplateTail; - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TemplateElement, value: { raw: this.ast.text.slice( @@ -1247,12 +1247,12 @@ export class Converter { case SyntaxKind.SpreadAssignment: case SyntaxKind.SpreadElement: { if (this.allowPattern) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.RestElement, argument: this.convertPattern(node.expression) }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.SpreadElement, argument: this.convertChild(node.expression) }); @@ -1261,16 +1261,16 @@ export class Converter { case SyntaxKind.Parameter: { let parameter: any; - let result: es.RestElement | es.AssignmentPattern; + let result: TSESTree.RestElement | TSESTree.AssignmentPattern; if (node.dotDotDotToken) { - parameter = result = this.createNode(node, { + parameter = result = this.createNode(node, { type: AST_NODE_TYPES.RestElement, argument: this.convertChild(node.name) }); } else if (node.initializer) { parameter = this.convertChild(node.name); - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.AssignmentPattern, left: parameter, right: this.convertChild(node.initializer) @@ -1305,7 +1305,7 @@ export class Converter { } if (node.modifiers) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSParameterProperty, accessibility: getTSNodeAccessibility(node) || undefined, readonly: @@ -1337,11 +1337,11 @@ export class Converter { ); const result = this.createNode< - es.ClassDeclaration | es.ClassExpression + TSESTree.ClassDeclaration | TSESTree.ClassExpression >(node, { type: classNodeType, id: this.convertChild(node.name), - body: this.createNode(node, { + body: this.createNode(node, { type: AST_NODE_TYPES.ClassBody, body: [], range: [node.members.pos - 1, node.end] @@ -1407,13 +1407,13 @@ export class Converter { // Modules case SyntaxKind.ModuleBlock: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSModuleBlock, body: this.convertBodyExpressions(node.statements, node) }); case SyntaxKind.ImportDeclaration: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.ImportDeclaration, source: this.convertChild(node.moduleSpecifier), specifiers: [] @@ -1445,20 +1445,20 @@ export class Converter { } case SyntaxKind.NamespaceImport: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ImportNamespaceSpecifier, local: this.convertChild(node.name) }); case SyntaxKind.ImportSpecifier: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ImportSpecifier, local: this.convertChild(node.name), imported: this.convertChild(node.propertyName || node.name) }); case SyntaxKind.ImportClause: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ImportDefaultSpecifier, local: this.convertChild(node.name), range: [node.getStart(this.ast), node.name!.end] @@ -1466,7 +1466,7 @@ export class Converter { case SyntaxKind.ExportDeclaration: if (node.exportClause) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ExportNamedDeclaration, source: this.convertChild(node.moduleSpecifier), specifiers: node.exportClause.elements.map(el => @@ -1475,14 +1475,14 @@ export class Converter { declaration: null }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ExportAllDeclaration, source: this.convertChild(node.moduleSpecifier) }); } case SyntaxKind.ExportSpecifier: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ExportSpecifier, local: this.convertChild(node.propertyName || node.name), exported: this.convertChild(node.name) @@ -1490,12 +1490,12 @@ export class Converter { case SyntaxKind.ExportAssignment: if (node.isExportEquals) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSExportAssignment, expression: this.convertChild(node.expression) }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ExportDefaultDeclaration, declaration: this.convertChild(node.expression) }); @@ -1510,14 +1510,14 @@ export class Converter { * ESTree uses UpdateExpression for ++/-- */ if (/^(?:\+\+|--)$/.test(operator)) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.UpdateExpression, operator, prefix: node.kind === SyntaxKind.PrefixUnaryExpression, argument: this.convertChild(node.operand) }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.UnaryExpression, operator, prefix: node.kind === SyntaxKind.PrefixUnaryExpression, @@ -1527,7 +1527,7 @@ export class Converter { } case SyntaxKind.DeleteExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.UnaryExpression, operator: 'delete', prefix: true, @@ -1535,7 +1535,7 @@ export class Converter { }); case SyntaxKind.VoidExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.UnaryExpression, operator: 'void', prefix: true, @@ -1543,7 +1543,7 @@ export class Converter { }); case SyntaxKind.TypeOfExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.UnaryExpression, operator: 'typeof', prefix: true, @@ -1551,7 +1551,7 @@ export class Converter { }); case SyntaxKind.TypeOperator: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTypeOperator, operator: getTextForTokenKind(node.operator) as any, typeAnnotation: this.convertChild(node.type) @@ -1562,7 +1562,7 @@ export class Converter { case SyntaxKind.BinaryExpression: { // TypeScript uses BinaryExpression for sequences as well if (isComma(node.operatorToken)) { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.SequenceExpression, expressions: [] }); @@ -1588,14 +1588,16 @@ export class Converter { this.allowPattern && type === AST_NODE_TYPES.AssignmentExpression ) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.AssignmentPattern, left: this.convertPattern(node.left, node), right: this.convertChild(node.right) }); } return this.createNode< - es.AssignmentExpression | es.LogicalExpression | es.BinaryExpression + | TSESTree.AssignmentExpression + | TSESTree.LogicalExpression + | TSESTree.BinaryExpression >(node, { type: type, operator: getTextForTokenKind(node.operatorToken.kind)!, @@ -1611,7 +1613,7 @@ export class Converter { } case SyntaxKind.PropertyAccessExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.MemberExpression, object: this.convertChild(node.expression), property: this.convertChild(node.name), @@ -1619,7 +1621,7 @@ export class Converter { }); case SyntaxKind.ElementAccessExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.MemberExpression, object: this.convertChild(node.expression), property: this.convertChild(node.argumentExpression), @@ -1627,7 +1629,7 @@ export class Converter { }); case SyntaxKind.ConditionalExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ConditionalExpression, test: this.convertChild(node.condition), consequent: this.convertChild(node.whenTrue), @@ -1635,7 +1637,7 @@ export class Converter { }); case SyntaxKind.CallExpression: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.CallExpression, callee: this.convertChild(node.expression), arguments: node.arguments.map(el => this.convertChild(el)) @@ -1649,7 +1651,7 @@ export class Converter { } case SyntaxKind.NewExpression: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.NewExpression, callee: this.convertChild(node.expression), arguments: node.arguments @@ -1665,9 +1667,9 @@ export class Converter { } case SyntaxKind.MetaProperty: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.MetaProperty, - meta: this.createNode(node.getFirstToken()!, { + meta: this.createNode(node.getFirstToken()!, { type: AST_NODE_TYPES.Identifier, name: getTextForTokenKind(node.keywordToken)! }), @@ -1676,7 +1678,7 @@ export class Converter { } case SyntaxKind.Decorator: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Decorator, expression: this.convertChild(node.expression) }); @@ -1685,7 +1687,7 @@ export class Converter { // Literals case SyntaxKind.StringLiteral: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.Literal, raw: '', value: '' @@ -1700,7 +1702,7 @@ export class Converter { } case SyntaxKind.NumericLiteral: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: Number(node.text), raw: node.getText() @@ -1708,7 +1710,7 @@ export class Converter { } case SyntaxKind.BigIntLiteral: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.BigIntLiteral, raw: '', value: '' @@ -1729,7 +1731,7 @@ export class Converter { regex = null; } - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: regex, raw: node.text, @@ -1741,14 +1743,14 @@ export class Converter { } case SyntaxKind.TrueKeyword: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: true, raw: 'true' }); case SyntaxKind.FalseKeyword: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: false, raw: 'false' @@ -1756,11 +1758,11 @@ export class Converter { case SyntaxKind.NullKeyword: { if (this.inTypeMode) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSNullKeyword }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: null, raw: 'null' @@ -1769,24 +1771,24 @@ export class Converter { } case SyntaxKind.ImportKeyword: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Import }); case SyntaxKind.EmptyStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.EmptyStatement }); case SyntaxKind.DebuggerStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.DebuggerStatement }); // JSX case SyntaxKind.JsxElement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXElement, openingElement: this.convertChild(node.openingElement), closingElement: this.convertChild(node.closingElement), @@ -1794,7 +1796,7 @@ export class Converter { }); case SyntaxKind.JsxFragment: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXFragment, openingFragment: this.convertChild(node.openingFragment), closingFragment: this.convertChild(node.closingFragment), @@ -1802,13 +1804,13 @@ export class Converter { }); case SyntaxKind.JsxSelfClosingElement: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXElement, /** * Convert SyntaxKind.JsxSelfClosingElement to SyntaxKind.JsxOpeningElement, * TypeScript does not seem to have the idea of openingElement when tag is self-closing */ - openingElement: this.createNode(node, { + openingElement: this.createNode(node, { type: AST_NODE_TYPES.JSXOpeningElement, typeParameters: node.typeArguments ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) @@ -1826,7 +1828,7 @@ export class Converter { } case SyntaxKind.JsxOpeningElement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXOpeningElement, typeParameters: node.typeArguments ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) @@ -1839,36 +1841,36 @@ export class Converter { }); case SyntaxKind.JsxClosingElement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXClosingElement, name: this.convertJSXTagName(node.tagName, node) }); case SyntaxKind.JsxOpeningFragment: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXOpeningFragment }); case SyntaxKind.JsxClosingFragment: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXClosingFragment }); case SyntaxKind.JsxExpression: { const expression = node.expression ? this.convertChild(node.expression) - : this.createNode(node, { + : this.createNode(node, { type: AST_NODE_TYPES.JSXEmptyExpression, range: [node.getStart(this.ast) + 1, node.getEnd() - 1] }); if (node.dotDotDotToken) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXSpreadChild, expression }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXExpressionContainer, expression }); @@ -1879,7 +1881,7 @@ export class Converter { const attributeName = this.convertChild(node.name); attributeName.type = AST_NODE_TYPES.JSXIdentifier; - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXAttribute, name: attributeName, value: this.convertChild(node.initializer) @@ -1897,14 +1899,14 @@ export class Converter { const end = node.getEnd(); if (this.options.useJSXTextNode) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXText, value: this.ast.text.slice(start, end), raw: this.ast.text.slice(start, end), range: [start, end] }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: this.ast.text.slice(start, end), raw: this.ast.text.slice(start, end), @@ -1914,13 +1916,13 @@ export class Converter { } case SyntaxKind.JsxSpreadAttribute: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXSpreadAttribute, argument: this.convertChild(node.expression) }); case SyntaxKind.QualifiedName: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSQualifiedName, left: this.convertChild(node.left), right: this.convertChild(node.right) @@ -1930,7 +1932,7 @@ export class Converter { // TypeScript specific case SyntaxKind.TypeReference: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTypeReference, typeName: this.convertType(node.typeName), typeParameters: node.typeArguments @@ -1940,7 +1942,7 @@ export class Converter { } case SyntaxKind.TypeParameter: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTypeParameter, name: this.convertType(node.name), constraint: node.constraint @@ -1968,28 +1970,28 @@ export class Converter { } case SyntaxKind.NonNullExpression: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSNonNullExpression, expression: this.convertChild(node.expression) }); } case SyntaxKind.TypeLiteral: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTypeLiteral, members: node.members.map(el => this.convertChild(el)) }); } case SyntaxKind.ArrayType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSArrayType, elementType: this.convertType(node.elementType) }); } case SyntaxKind.IndexedAccessType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSIndexedAccessType, objectType: this.convertType(node.objectType), indexType: this.convertType(node.indexType) @@ -1997,7 +1999,7 @@ export class Converter { } case SyntaxKind.ConditionalType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSConditionalType, checkType: this.convertType(node.checkType), extendsType: this.convertType(node.extendsType), @@ -2007,14 +2009,14 @@ export class Converter { } case SyntaxKind.TypeQuery: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTypeQuery, exprName: this.convertType(node.exprName) }); } case SyntaxKind.MappedType: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSMappedType, typeParameter: this.convertType(node.typeParameter) }); @@ -2049,7 +2051,7 @@ export class Converter { return this.convertChild(node.expression, parent); case SyntaxKind.TypeAliasDeclaration: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSTypeAliasDeclaration, id: this.convertChild(node.name), typeAnnotation: this.convertType(node.type) @@ -2071,7 +2073,7 @@ export class Converter { } case SyntaxKind.MethodSignature: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSMethodSignature, computed: isComputedProperty(node.name), key: this.convertChild(node.name), @@ -2112,7 +2114,7 @@ export class Converter { } case SyntaxKind.PropertySignature: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSPropertySignature, optional: isOptional(node) || undefined, computed: isComputedProperty(node.name), @@ -2135,7 +2137,7 @@ export class Converter { } case SyntaxKind.IndexSignature: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSIndexSignature, parameters: node.parameters.map(el => this.convertChild(el)) }); @@ -2183,10 +2185,10 @@ export class Converter { break; } const result = this.createNode< - | es.TSConstructSignatureDeclaration - | es.TSCallSignatureDeclaration - | es.TSFunctionType - | es.TSConstructorType + | TSESTree.TSConstructSignatureDeclaration + | TSESTree.TSCallSignatureDeclaration + | TSESTree.TSFunctionType + | TSESTree.TSConstructorType >(node, { type: type, params: this.convertParameters(node.parameters) @@ -2207,7 +2209,7 @@ export class Converter { case SyntaxKind.ExpressionWithTypeArguments: { const result = this.createNode< - es.TSInterfaceHeritage | es.TSClassImplements + TSESTree.TSInterfaceHeritage | TSESTree.TSClassImplements >(node, { type: parent && parent.kind === SyntaxKind.InterfaceDeclaration @@ -2226,9 +2228,9 @@ export class Converter { case SyntaxKind.InterfaceDeclaration: { const interfaceHeritageClauses = node.heritageClauses || []; - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSInterfaceDeclaration, - body: this.createNode(node, { + body: this.createNode(node, { type: AST_NODE_TYPES.TSInterfaceBody, body: node.members.map(member => this.convertChild(member)), range: [node.members.pos - 1, node.end] @@ -2286,7 +2288,7 @@ export class Converter { } case SyntaxKind.FirstTypeNode: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSTypePredicate, parameterName: this.convertChild(node.parameterName), typeAnnotation: this.convertTypeAnnotation(node.type, node) @@ -2301,7 +2303,7 @@ export class Converter { } case SyntaxKind.ImportType: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSImportType, isTypeOf: !!node.isTypeOf, parameter: this.convertChild(node.argument), @@ -2312,7 +2314,7 @@ export class Converter { }); case SyntaxKind.EnumDeclaration: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSEnumDeclaration, id: this.convertChild(node.name), members: node.members.map(el => this.convertChild(el)) @@ -2332,7 +2334,7 @@ export class Converter { } case SyntaxKind.EnumMember: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSEnumMember, id: this.convertChild(node.name) }); @@ -2343,7 +2345,7 @@ export class Converter { } case SyntaxKind.ModuleDeclaration: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSModuleDeclaration, id: this.convertChild(node.name) }); @@ -2361,69 +2363,69 @@ export class Converter { // TypeScript specific types case SyntaxKind.OptionalType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSOptionalType, typeAnnotation: this.convertType(node.type) }); } case SyntaxKind.ParenthesizedType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSParenthesizedType, typeAnnotation: this.convertType(node.type) }); } case SyntaxKind.TupleType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTupleType, elementTypes: node.elementTypes.map(el => this.convertType(el)) }); } case SyntaxKind.UnionType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSUnionType, types: node.types.map(el => this.convertType(el)) }); } case SyntaxKind.IntersectionType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSIntersectionType, types: node.types.map(el => this.convertType(el)) }); } case SyntaxKind.RestType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSRestType, typeAnnotation: this.convertType(node.type) }); } case SyntaxKind.AsExpression: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSAsExpression, expression: this.convertChild(node.expression), typeAnnotation: this.convertType(node.type) }); } case SyntaxKind.InferType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSInferType, typeParameter: this.convertType(node.typeParameter) }); } case SyntaxKind.LiteralType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSLiteralType, literal: this.convertType(node.literal) }); } case SyntaxKind.TypeAssertionExpression: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTypeAssertion, typeAnnotation: this.convertType(node.type), expression: this.convertChild(node.expression) }); } case SyntaxKind.ImportEqualsDeclaration: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSImportEqualsDeclaration, id: this.convertChild(node.name), moduleReference: this.convertChild(node.moduleReference), @@ -2431,13 +2433,13 @@ export class Converter { }); } case SyntaxKind.ExternalModuleReference: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSExternalModuleReference, expression: this.convertChild(node.expression) }); } case SyntaxKind.NamespaceExportDeclaration: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSNamespaceExportDeclaration, id: this.convertChild(node.name) }); diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index aa5a10418c76..4ab71cf5e9a4 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -6,7 +6,7 @@ */ import ts from 'typescript'; import unescape from 'lodash.unescape'; -import * as es from './typedefs'; +import { TSESTree } from './ts-estree'; import { AST_NODE_TYPES } from './ast-node-types'; const SyntaxKind = ts.SyntaxKind; @@ -224,7 +224,7 @@ export function getBinaryExpressionType( export function getLineAndCharacterFor( pos: number, ast: ts.SourceFile -): es.LineAndColumnData { +): TSESTree.LineAndColumnData { const loc = ast.getLineAndCharacterOfPosition(pos); return { line: loc.line + 1, @@ -244,7 +244,7 @@ export function getLocFor( start: number, end: number, ast: ts.SourceFile -): es.SourceLocation { +): TSESTree.SourceLocation { return { start: getLineAndCharacterFor(start, ast), end: getLineAndCharacterFor(end, ast) @@ -455,11 +455,11 @@ export function isOptional(node: { * @param ast the AST * @returns the ESTreeNode with fixed exports */ -export function fixExports( +export function fixExports( node: ts.Node, result: T, ast: ts.SourceFile -): es.ExportDefaultDeclaration | es.ExportNamedDeclaration | T { +): TSESTree.ExportDefaultDeclaration | TSESTree.ExportNamedDeclaration | T { // check for exports if (node.modifiers && node.modifiers[0].kind === SyntaxKind.ExportKeyword) { const exportKeyword = node.modifiers[0]; @@ -501,7 +501,7 @@ export function fixExports( * @param token the ts.Token * @returns the token type */ -export function getTokenType(token: any): es.TokenType { +export function getTokenType(token: any): TSESTree.TokenType { // Need two checks for keywords since some are also identifiers if (token.originalKeywordKind) { switch (token.originalKeywordKind) { @@ -607,16 +607,19 @@ export function getTokenType(token: any): es.TokenType { * Extends and formats a given ts.Token, for a given AST * @param token the ts.Token * @param ast the AST object - * @returns the converted es.Token + * @returns the converted Token */ -export function convertToken(token: ts.Node, ast: ts.SourceFile): es.Token { +export function convertToken( + token: ts.Node, + ast: ts.SourceFile +): TSESTree.Token { const start = token.kind === SyntaxKind.JsxText ? token.getFullStart() : token.getStart(ast), end = token.getEnd(), value = ast.text.slice(start, end), - newToken: es.Token = { + newToken: TSESTree.Token = { type: getTokenType(token), value, range: [start, end], @@ -638,8 +641,8 @@ export function convertToken(token: ts.Node, ast: ts.SourceFile): es.Token { * @param ast the AST object * @returns the converted Tokens */ -export function convertTokens(ast: ts.SourceFile): es.Token[] { - const result: es.Token[] = []; +export function convertTokens(ast: ts.SourceFile): TSESTree.Token[] { + const result: TSESTree.Token[] = []; /** * @param node the ts.Node */ diff --git a/packages/typescript-estree/src/parser-options.ts b/packages/typescript-estree/src/parser-options.ts index a838db4af139..6ec07b902cd1 100644 --- a/packages/typescript-estree/src/parser-options.ts +++ b/packages/typescript-estree/src/parser-options.ts @@ -1,4 +1,6 @@ -import { Token, Comment } from './typedefs'; +import { Program } from 'typescript'; +import { Token, Comment, Node } from './typedefs'; +import { TSNode } from './ts-nodes'; export interface Extra { errorOnUnknownASTType: boolean; @@ -33,3 +35,13 @@ export interface ParserOptions { tsconfigRootDir?: string; extraFileExtensions?: string[]; } + +export interface ParserWeakMap { + get(key: TKey): TValue; +} + +export interface ParserServices { + program: Program | undefined; + esTreeNodeToTSNodeMap: ParserWeakMap | undefined; + tsNodeToESTreeNodeMap: ParserWeakMap | undefined; +} diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index bad5cdd6fd50..bb77a186171a 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -14,8 +14,8 @@ import ts from 'typescript'; import convert from './ast-converter'; import { convertError } from './convert'; import { firstDefined } from './node-utils'; -import * as es from './typedefs'; -import { Extra, ParserOptions } from './parser-options'; +import { TSESTree } from './ts-estree'; +import { Extra, ParserOptions, ParserServices } from './parser-options'; import { getFirstSemanticOrSyntacticError } from './semantic-errors'; /** @@ -271,18 +271,14 @@ function warnAboutTSVersion(): void { // Parser //------------------------------------------------------------------------------ -type AST = es.Program & +type AST = TSESTree.Program & (T['range'] extends true ? { range: [number, number] } : {}) & - (T['tokens'] extends true ? { tokens: es.Token[] } : {}) & - (T['comment'] extends true ? { comments: es.Comment[] } : {}); + (T['tokens'] extends true ? { tokens: TSESTree.Token[] } : {}) & + (T['comment'] extends true ? { comments: TSESTree.Comment[] } : {}); interface ParseAndGenerateServicesResult { ast: AST; - services: { - program: ts.Program | undefined; - esTreeNodeToTSNodeMap: WeakMap | undefined; - tsNodeToESTreeNodeMap: WeakMap | undefined; - }; + services: ParserServices; } //------------------------------------------------------------------------------ @@ -419,3 +415,5 @@ export function parseAndGenerateServices< export { AST_NODE_TYPES } from './ast-node-types'; export { ParserOptions }; +export { ParserServices }; +export { TSESTree }; diff --git a/packages/typescript-estree/src/ts-estree.ts b/packages/typescript-estree/src/ts-estree.ts new file mode 100644 index 000000000000..846392c54430 --- /dev/null +++ b/packages/typescript-estree/src/ts-estree.ts @@ -0,0 +1,2 @@ +import * as TSESTree from './typedefs'; +export { TSESTree }; diff --git a/packages/typescript-estree/src/typedefs.ts b/packages/typescript-estree/src/typedefs.ts index a9a100e64623..af8d17e0157a 100644 --- a/packages/typescript-estree/src/typedefs.ts +++ b/packages/typescript-estree/src/typedefs.ts @@ -1185,7 +1185,7 @@ export interface TSModuleBlock extends BaseNode { export interface TSModuleDeclaration extends BaseNode { type: AST_NODE_TYPES.TSModuleDeclaration; id: Identifier | Literal; - body?: TSModuleBlock | Identifier; + body?: TSModuleBlock | TSModuleDeclaration; global?: boolean; declare?: boolean; modifiers?: Modifier[]; diff --git a/packages/typescript-estree/tests/lib/semanticInfo.ts b/packages/typescript-estree/tests/lib/semanticInfo.ts index a164288ceb0f..531ab1a34d54 100644 --- a/packages/typescript-estree/tests/lib/semanticInfo.ts +++ b/packages/typescript-estree/tests/lib/semanticInfo.ts @@ -123,10 +123,10 @@ describe('semanticInfo', () => { arrayBoundName ); expect(tsArrayBoundName).toBeDefined(); - checkNumberArrayType(checker, tsArrayBoundName); + checkNumberArrayType(checker, tsArrayBoundName!); expect( - parseResult.services.tsNodeToESTreeNodeMap!.get(tsArrayBoundName) + parseResult.services.tsNodeToESTreeNodeMap!.get(tsArrayBoundName!) ).toBe(arrayBoundName); }); @@ -149,9 +149,9 @@ describe('semanticInfo', () => { ); expect(tsBoundName).toBeDefined(); - checkNumberArrayType(checker, tsBoundName); + checkNumberArrayType(checker, tsBoundName!); - expect(parseResult.services.tsNodeToESTreeNodeMap!.get(tsBoundName)).toBe( + expect(parseResult.services.tsNodeToESTreeNodeMap!.get(tsBoundName!)).toBe( boundName ); }); diff --git a/yarn.lock b/yarn.lock index 00804abee1f8..95f575e0097c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -816,7 +816,7 @@ "@types/estree" "*" "@types/json-schema" "*" -"@types/estree@*", "@types/estree@^0.0.39": +"@types/estree@*": version "0.0.39" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== From 07e950eb877746ae34a7ce2f0afe4805178cbc43 Mon Sep 17 00:00:00 2001 From: Kanitkorn Sujautra Date: Thu, 7 Feb 2019 10:34:43 +0900 Subject: [PATCH 78/88] fix(eslint-plugin): fix false positive from adjacent-overload-signatures (#206) --- .../lib/rules/adjacent-overload-signatures.js | 35 +++++++++++++----- .../lib/rules/adjacent-overload-signatures.js | 37 +++++++++++++++++++ 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/packages/eslint-plugin/lib/rules/adjacent-overload-signatures.js b/packages/eslint-plugin/lib/rules/adjacent-overload-signatures.js index d8eb79509558..0c53769c0e8c 100644 --- a/packages/eslint-plugin/lib/rules/adjacent-overload-signatures.js +++ b/packages/eslint-plugin/lib/rules/adjacent-overload-signatures.js @@ -73,6 +73,17 @@ module.exports = { } } + /** + * Determine whether two methods are the same or not + * @param {{ name: string; static: boolean }} method1 a method to compare + * @param {{ name: string; static: boolean }} method2 another method to compare with + * @returns {boolean} true if two methods are the same + * @private + */ + function isSameMethod(method1, method2) { + return method1.name === method2.name && method1.static === method2.static; + } + /** * Check the body for overload methods. * @param {ASTNode} node the body to be inspected. @@ -83,28 +94,32 @@ module.exports = { const members = node.body || node.members; if (members) { - let name; - let index; - let lastName; - const seen = []; + let lastMethod; + const seenMethods = []; members.forEach(member => { - name = getMemberName(member); + const name = getMemberName(member); + const method = { + name, + static: member.static + }; - index = seen.indexOf(name); - if (index > -1 && lastName !== name) { + const index = seenMethods.findIndex(seenMethod => + isSameMethod(method, seenMethod) + ); + if (index > -1 && !isSameMethod(method, lastMethod)) { context.report({ node: member, messageId: 'adjacentSignature', data: { - name + name: (method.static ? 'static ' : '') + method.name } }); } else if (name && index === -1) { - seen.push(name); + seenMethods.push(method); } - lastName = name; + lastMethod = method; }); } } diff --git a/packages/eslint-plugin/tests/lib/rules/adjacent-overload-signatures.js b/packages/eslint-plugin/tests/lib/rules/adjacent-overload-signatures.js index 161ffd4035e6..fe42efd1015b 100644 --- a/packages/eslint-plugin/tests/lib/rules/adjacent-overload-signatures.js +++ b/packages/eslint-plugin/tests/lib/rules/adjacent-overload-signatures.js @@ -211,6 +211,23 @@ class Foo { foo(sn: string | number): void {} bar(): void {} baz(): void {} +} + `, + ` +class Foo { + name: string; + static foo(s: string): void; + static foo(n: number): void; + static foo(sn: string | number): void {} + bar(): void {} + baz(): void {} +} + `, + ` +class Test { + static test() {} + untest() {} + test() {} } `, // examples from https://github.com/nzakas/eslint-plugin-typescript/issues/138 @@ -789,6 +806,26 @@ class Foo { column: 5 } ] + }, + { + code: ` +class Foo { + static foo(s: string): void; + name: string; + static foo(n: number): void; + static foo(sn: string | number): void {} + bar(): void {} + baz(): void {} +} + `, + errors: [ + { + messageId: 'adjacentSignature', + data: { name: 'static foo' }, + line: 5, + column: 5 + } + ] } ] }); From 84162ba6167c21d57f0d5955b15b3135c9e3a438 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Wed, 6 Feb 2019 17:47:23 -0800 Subject: [PATCH 79/88] feat(eslint-plugin): add new rule no-for-in-array (#155) --- packages/eslint-plugin/README.md | 1 + packages/eslint-plugin/ROADMAP.md | 12 +++- .../docs/rules/no-for-in-array.md | 44 ++++++++++++ .../lib/rules/no-for-in-array.js | 56 +++++++++++++++ packages/eslint-plugin/lib/util.js | 2 +- .../tests/lib/rules/no-for-in-array.js | 69 +++++++++++++++++++ 6 files changed, 180 insertions(+), 4 deletions(-) create mode 100644 packages/eslint-plugin/docs/rules/no-for-in-array.md create mode 100644 packages/eslint-plugin/lib/rules/no-for-in-array.js create mode 100644 packages/eslint-plugin/tests/lib/rules/no-for-in-array.js diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index cacb6666fddf..3807877a073e 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -128,6 +128,7 @@ Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.e | [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type (`no-any` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) | | | +| [`@typescript-eslint/no-for-in-array`](./docs/rules/no-for-in-array.md) | Disallow iterating over an array with a for-in loop (`no-for-in-array` from TSLint) | | | | [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (`no-inferrable-types` from TSLint) | :heavy_check_mark: | :wrench: | | [`@typescript-eslint/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) | :heavy_check_mark: | | diff --git a/packages/eslint-plugin/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md index bd0480101cf1..5abf9e26d4ef 100644 --- a/packages/eslint-plugin/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -1,10 +1,15 @@ # Roadmap -✅ (29) = done
+ + +✅ (30) = done
🌟 (79) = in ESLint core
🔌 (33) = in another plugin
🌓 (16) = implementations differ or ESLint version is missing functionality
-🛑 (68) = unimplemented +🛑 (68) = unimplemented
## TSLint rules @@ -59,7 +64,7 @@ | [`no-empty`] | 🌟 | [`no-empty`][no-empty] | | [`no-eval`] | 🌟 | [`no-eval`][no-eval] | | [`no-floating-promises`] | 🛑 | N/A ([relevant plugin][plugin:promise]) | -| [`no-for-in-array`] | 🛑 | N/A | +| [`no-for-in-array`] | ✅ | [`@typescript-eslint/no-for-in-array`] | | [`no-implicit-dependencies`] | 🔌 | [`import/no-extraneous-dependencies`] | | [`no-inferred-empty-object-type`] | 🛑 | N/A | | [`no-invalid-template-strings`] | 🌟 | [`no-template-curly-in-string`][no-template-curly-in-string] | @@ -586,6 +591,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- [`@typescript-eslint/member-delimiter-style`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md [`@typescript-eslint/prefer-interface`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-interface.md [`@typescript-eslint/no-array-constructor`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-array-constructor.md +[`@typescript-eslint/no-for-in-array`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-for-in-array.md diff --git a/packages/eslint-plugin/docs/rules/no-for-in-array.md b/packages/eslint-plugin/docs/rules/no-for-in-array.md new file mode 100644 index 000000000000..3a1cf2bdd370 --- /dev/null +++ b/packages/eslint-plugin/docs/rules/no-for-in-array.md @@ -0,0 +1,44 @@ +# Disallow iterating over an array with a for-in loop (no-for-in-array) + +This rule prohibits iterating over an array with a for-in loop. + +## Rule Details + +Rationale from TSLint: + +A for-in loop (`for (var k in o)`) iterates over the properties of an Object. +While it is legal to use for-in loops with array types, it is not common. +for-in will iterate over the indices of the array as strings, omitting any "holes" in +the array. +More common is to use for-of, which iterates over the values of an array. +If you want to iterate over the indices, alternatives include: + +```js +array.forEach((value, index) => { ... }); +for (const [index, value] of array.entries()) { ... } +for (let i = 0; i < array.length; i++) { ... } +``` + +Examples of **incorrect** code for this rule: + +```js +for (const x in [3, 4, 5]) { + console.log(x); +} +``` + +Examples of **correct** code for this rule: + +```js +for (const x in { a: 3, b: 4, c: 5 }) { + console.log(x); +} +``` + +## When Not To Use It + +If you want to iterate through a loop using the indices in an array as strings, you can turn off this rule. + +## Related to + +- TSLint: ['no-for-in-array'](https://palantir.github.io/tslint/rules/no-for-in-array/) diff --git a/packages/eslint-plugin/lib/rules/no-for-in-array.js b/packages/eslint-plugin/lib/rules/no-for-in-array.js new file mode 100644 index 000000000000..23a19732ac45 --- /dev/null +++ b/packages/eslint-plugin/lib/rules/no-for-in-array.js @@ -0,0 +1,56 @@ +/** + * @fileoverview Disallow iterating over an array with a for-in loop + * @author Benjamin Lichtman + */ +'use strict'; +const ts = require('typescript'); +const util = require('../util'); + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +/** + * @type {import("eslint").Rule.RuleModule} + */ +module.exports = { + meta: { + docs: { + description: 'Disallow iterating over an array with a for-in loop', + category: 'Functionality', + recommended: false, + extraDescription: [util.tslintRule('no-for-in-array')], + url: util.metaDocsUrl('no-for-in-array') + }, + fixable: null, + messages: { + forInViolation: + 'For-in loops over arrays are forbidden. Use for-of or array.forEach instead.' + }, + schema: [], + type: 'problem' + }, + + create(context) { + return { + ForInStatement(node) { + const parserServices = util.getParserServices(context); + const checker = parserServices.program.getTypeChecker(); + const originalNode = parserServices.esTreeNodeToTSNodeMap.get(node); + + const type = checker.getTypeAtLocation(originalNode.expression); + + if ( + (typeof type.symbol !== 'undefined' && + type.symbol.name === 'Array') || + (type.flags & ts.TypeFlags.StringLike) !== 0 + ) { + context.report({ + node, + messageId: 'forInViolation' + }); + } + } + }; + } +}; diff --git a/packages/eslint-plugin/lib/util.js b/packages/eslint-plugin/lib/util.js index dac41fe21bb7..6714e600ee65 100644 --- a/packages/eslint-plugin/lib/util.js +++ b/packages/eslint-plugin/lib/util.js @@ -109,7 +109,7 @@ exports.upperCaseFirst = str => str[0].toUpperCase() + str.slice(1); /** * Try to retrieve typescript parser service from context * @param {RuleContext} context Rule context - * @returns {{esTreeNodeToTSNodeMap}|{program}|Object|*} parserServices + * @returns {{program: Program, esTreeNodeToTSNodeMap: NodeMap}} parserServices */ exports.getParserServices = context => { if ( diff --git a/packages/eslint-plugin/tests/lib/rules/no-for-in-array.js b/packages/eslint-plugin/tests/lib/rules/no-for-in-array.js new file mode 100644 index 000000000000..91984453000d --- /dev/null +++ b/packages/eslint-plugin/tests/lib/rules/no-for-in-array.js @@ -0,0 +1,69 @@ +/** + * @fileoverview Disallow iterating over an array with a for-in loop + * @author Benjamin Lichtman + */ +'use strict'; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const rule = require('../../../lib/rules/no-for-in-array'), + RuleTester = require('eslint').RuleTester, + path = require('path'); + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +const rootDir = path.join(process.cwd(), 'tests/fixtures/'); +const parserOptions = { + ecmaVersion: 2015, + tsconfigRootDir: rootDir, + project: './tsconfig.json' +}; +const ruleTester = new RuleTester({ + parserOptions, + parser: '@typescript-eslint/parser' +}); + +ruleTester.run('no-for-in-array', rule, { + valid: [ + ` +for (const x of [3, 4, 5]) { + console.log(x); +}`, + ` +for (const x in { a: 1, b: 2, c: 3 }) { + console.log(x); +}` + ], + + invalid: [ + { + code: ` +for (const x in [3, 4, 5]) { + console.log(x); +}`, + errors: [ + { + messageId: 'forInViolation', + type: 'ForInStatement' + } + ] + }, + { + code: ` +const z = [3, 4, 5]; +for (const x in z) { + console.log(x); +}`, + errors: [ + { + messageId: 'forInViolation', + type: 'ForInStatement' + } + ] + } + ] +}); From 0a1777fc900010f7fcd7fef725f57b02690b0535 Mon Sep 17 00:00:00 2001 From: James Henry Date: Wed, 6 Feb 2019 21:04:16 -0500 Subject: [PATCH 80/88] fix(ts-estree): convert decorators on var and fn decs (#211) --- .../lib/__snapshots__/typescript.ts.snap | 92 +++++++++++++++++++ packages/typescript-estree/src/convert.ts | 22 +++++ .../lib/__snapshots__/typescript.ts.snap | 92 +++++++++++++++++++ 3 files changed, 206 insertions(+) diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index ef757ac0453e..ac457ec0ca3d 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -91249,6 +91249,43 @@ Object { ], "type": "BlockStatement", }, + "decorators": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "name": "dec", + "range": Array [ + 1, + 4, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Decorator", + }, + ], "expression": false, "generator": false, "id": Object { @@ -91791,6 +91828,61 @@ Object { "type": "VariableDeclarator", }, ], + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [], + "callee": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "name": "deco", + "range": Array [ + 1, + 5, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 7, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 7, + ], + "type": "Decorator", + }, + ], "kind": "const", "loc": Object { "end": Object { diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 3686ba919150..bf121fa01bb0 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -696,6 +696,17 @@ export class Converter { ); } + /** + * Semantically, decorators are not allowed on function declarations, + * but the TypeScript compiler will parse them and produce a valid AST, + * so we handle them here too. + */ + if (node.decorators) { + (result as any).decorators = node.decorators.map(el => + this.convertChild(el) + ); + } + // check for exports return fixExports(node, result, this.ast); } @@ -730,6 +741,17 @@ export class Converter { kind: getDeclarationKind(node.declarationList) }); + /** + * Semantically, decorators are not allowed on variable declarations, + * but the TypeScript compiler will parse them and produce a valid AST, + * so we handle them here too. + */ + if (node.decorators) { + (result as any).decorators = node.decorators.map(el => + this.convertChild(el) + ); + } + if (hasModifier(SyntaxKind.DeclareKeyword, node)) { result.declare = true; } diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index 38bc1e93b184..9c0094cff37b 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -90557,6 +90557,43 @@ Object { ], "type": "BlockStatement", }, + "decorators": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "name": "dec", + "range": Array [ + 1, + 4, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Decorator", + }, + ], "expression": false, "generator": false, "id": Object { @@ -91097,6 +91134,61 @@ Object { "type": "VariableDeclarator", }, ], + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [], + "callee": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "name": "deco", + "range": Array [ + 1, + 5, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 7, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 7, + ], + "type": "Decorator", + }, + ], "kind": "const", "loc": Object { "end": Object { From a005541f0ba2f78e9f7b7000fb696db436e4c4d7 Mon Sep 17 00:00:00 2001 From: James Henry Date: Wed, 6 Feb 2019 21:13:16 -0500 Subject: [PATCH 81/88] docs(eslint-plugin): removed counts from ROADMAP (#225) --- packages/eslint-plugin/ROADMAP.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/eslint-plugin/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md index 5abf9e26d4ef..48ccaa900b63 100644 --- a/packages/eslint-plugin/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -1,15 +1,10 @@ # Roadmap - - -✅ (30) = done
-🌟 (79) = in ESLint core
-🔌 (33) = in another plugin
-🌓 (16) = implementations differ or ESLint version is missing functionality
-🛑 (68) = unimplemented
+✅ = done
+🌟 = in ESLint core
+🔌 = in another plugin
+🌓 = implementations differ or ESLint version is missing functionality
+🛑 = unimplemented
## TSLint rules From fc50167d2a1b38edeab05a472010a63e3fbd8ef2 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 7 Feb 2019 03:47:42 +0100 Subject: [PATCH 82/88] feat(ts-estree): enable errors 1098 and 1099 (#219) - add test cases for typed destruction - add test cases for anonymous function with returnType and typeParameters --- .../lib/__snapshots__/typescript.ts.snap | 11308 +++++++++------- ...ction-anonymus-with-type-parameters.src.ts | 3 + .../function-anynomus-with-return-type.src.ts | 2 + .../function-with-array-destruction.src.ts | 1 + .../function-with-object-destruction.src.ts | 1 + .../typescript-estree/src/semantic-errors.ts | 2 + .../tests/ast-alignment/fixtures-to-test.ts | 28 +- .../semantic-diagnostics-enabled.ts.snap | 89 +- .../lib/__snapshots__/typescript.ts.snap | 11304 ++++++++------- 9 files changed, 13199 insertions(+), 9539 deletions(-) create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/function-anonymus-with-type-parameters.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/function-anynomus-with-return-type.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/types/function-with-array-destruction.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/types/function-with-object-destruction.src.ts diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index ac457ec0ca3d..876c8b3b43b1 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -39253,139 +39253,269 @@ Object { } `; -exports[`typescript fixtures/basics/function-overloads.src 1`] = ` +exports[`typescript fixtures/basics/function-anonymus-with-type-parameters.src 1`] = ` Object { "body": Array [ Object { - "declaration": Object { - "async": false, - "expression": false, - "generator": false, - "id": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 16, - "line": 1, - }, - }, - "name": "f", - "range": Array [ - 16, - 17, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "params": Array [ - Object { + "declarations": Array [ + Object { + "id": Object { "loc": Object { "end": Object { - "column": 27, + "column": 7, "line": 1, }, "start": Object { - "column": 18, + "column": 4, "line": 1, }, }, - "name": "x", + "name": "obj", "range": Array [ - 18, - 27, + 4, + 7, ], "type": "Identifier", - "typeAnnotation": Object { + }, + "init": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "name": "a", + "range": Array [ + 45, + 46, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 38, + 47, + ], + "type": "ReturnStatement", + }, + ], "loc": Object { "end": Object { - "column": 27, - "line": 1, + "column": 1, + "line": 3, }, "start": Object { - "column": 19, + "column": 34, "line": 1, }, }, "range": Array [ - 19, - 27, + 34, + 49, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 27, + "column": 32, "line": 1, }, "start": Object { - "column": 21, + "column": 23, "line": 1, }, }, + "name": "a", "range": Array [ - 21, - 27, + 23, + 32, ], - "type": "TSNumberKeyword", + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 32, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 32, + ], + "type": "TSStringKeyword", + }, + }, + }, + ], + "range": Array [ + 10, + 49, + ], + "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + }, + "range": Array [ + 20, + 21, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 19, + 22, + ], + "type": "TSTypeParameterDeclaration", }, }, - ], - "range": Array [ - 7, - 37, - ], - "returnType": Object { "loc": Object { "end": Object { - "column": 36, - "line": 1, + "column": 1, + "line": 3, }, "start": Object { - "column": 28, + "column": 4, "line": 1, }, }, "range": Array [ - 28, - 36, + 4, + 49, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 30, - "line": 1, - }, - }, - "range": Array [ - 30, - 36, - ], - "type": "TSNumberKeyword", - }, + "type": "VariableDeclarator", + }, + ], + "kind": "var", + "loc": Object { + "end": Object { + "column": 2, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, }, - "type": "TSDeclareFunction", }, + "range": Array [ + 0, + 50, + ], + "type": "VariableDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 51, + ], + "sourceType": "module", + "tokens": Array [ + Object { "loc": Object { "end": Object { - "column": 37, + "column": 3, "line": 1, }, "start": Object { @@ -39395,514 +39525,133 @@ Object { }, "range": Array [ 0, - 37, + 3, ], - "source": null, - "specifiers": Array [], - "type": "ExportNamedDeclaration", + "type": "Keyword", + "value": "var", }, Object { - "declaration": Object { - "async": false, - "expression": false, - "generator": false, - "id": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "name": "f", - "range": Array [ - 54, - 55, - ], - "type": "Identifier", + "loc": Object { + "end": Object { + "column": 7, + "line": 1, }, - "loc": Object { - "end": Object { - "column": 37, - "line": 2, - }, - "start": Object { - "column": 7, - "line": 2, - }, + "start": Object { + "column": 4, + "line": 1, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 2, - }, - "start": Object { - "column": 18, - "line": 2, - }, - }, - "name": "x", - "range": Array [ - 56, - 65, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 2, - }, - "start": Object { - "column": 19, - "line": 2, - }, - }, - "range": Array [ - 57, - 65, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 2, - }, - "start": Object { - "column": 21, - "line": 2, - }, - }, - "range": Array [ - 59, - 65, - ], - "type": "TSStringKeyword", - }, - }, - }, - ], - "range": Array [ - 45, - 75, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 2, - }, - "start": Object { - "column": 28, - "line": 2, - }, - }, - "range": Array [ - 66, - 74, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 2, - }, - "start": Object { - "column": 30, - "line": 2, - }, - }, - "range": Array [ - 68, - 74, - ], - "type": "TSStringKeyword", - }, + }, + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + "value": "obj", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, }, - "type": "TSDeclareFunction", }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": "=", + }, + Object { "loc": Object { "end": Object { - "column": 37, - "line": 2, + "column": 18, + "line": 1, }, "start": Object { - "column": 0, - "line": 2, + "column": 10, + "line": 1, }, }, "range": Array [ - 38, - 75, + 10, + 18, ], - "source": null, - "specifiers": Array [], - "type": "ExportNamedDeclaration", + "type": "Keyword", + "value": "function", }, - Object { - "declaration": Object { - "async": false, - "body": Object { - "body": Array [ - Object { - "argument": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 4, - }, - "start": Object { - "column": 9, - "line": 4, - }, - }, - "name": "x", - "range": Array [ - 142, - 143, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 11, - "line": 4, - }, - "start": Object { - "column": 2, - "line": 4, - }, - }, - "range": Array [ - 135, - 144, - ], - "type": "ReturnStatement", - }, - ], - "loc": Object { - "end": Object { - "column": 1, - "line": 5, - }, - "start": Object { - "column": 55, - "line": 3, - }, - }, - "range": Array [ - 131, - 146, - ], - "type": "BlockStatement", - }, - "expression": false, - "generator": false, - "id": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 3, - }, - "start": Object { - "column": 16, - "line": 3, - }, - }, - "name": "f", - "range": Array [ - 92, - 93, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 1, - "line": 5, - }, - "start": Object { - "column": 7, - "line": 3, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 18, - "line": 3, - }, - }, - "name": "x", - "range": Array [ - 94, - 112, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 19, - "line": 3, - }, - }, - "range": Array [ - 95, - 112, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 21, - "line": 3, - }, - }, - "range": Array [ - 97, - 112, - ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 3, - }, - "start": Object { - "column": 21, - "line": 3, - }, - }, - "range": Array [ - 97, - 103, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 30, - "line": 3, - }, - }, - "range": Array [ - 106, - 112, - ], - "type": "TSNumberKeyword", - }, - ], - }, - }, - }, - ], - "range": Array [ - 83, - 146, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 3, - }, - "start": Object { - "column": 37, - "line": 3, - }, - }, - "range": Array [ - 113, - 130, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 3, - }, - "start": Object { - "column": 39, - "line": 3, - }, - }, - "range": Array [ - 115, - 130, - ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 45, - "line": 3, - }, - "start": Object { - "column": 39, - "line": 3, - }, - }, - "range": Array [ - 115, - 121, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 3, - }, - "start": Object { - "column": 48, - "line": 3, - }, - }, - "range": Array [ - 124, - 130, - ], - "type": "TSNumberKeyword", - }, - ], - }, - }, - "type": "FunctionDeclaration", - }, - "loc": Object { - "end": Object { - "column": 1, - "line": 5, - }, - "start": Object { - "column": 0, - "line": 3, - }, - }, - "range": Array [ - 76, - 146, - ], - "source": null, - "specifiers": Array [], - "type": "ExportNamedDeclaration", - }, - ], - "comments": Array [], - "loc": Object { - "end": Object { - "column": 0, - "line": 6, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 147, - ], - "sourceType": "module", - "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 6, + "column": 20, "line": 1, }, "start": Object { - "column": 0, + "column": 19, "line": 1, }, }, "range": Array [ - 0, - 6, + 19, + 20, ], - "type": "Keyword", - "value": "export", + "type": "Punctuator", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 21, "line": 1, }, "start": Object { - "column": 7, + "column": 20, "line": 1, }, }, "range": Array [ - 7, - 15, + 20, + 21, ], - "type": "Keyword", - "value": "function", + "type": "Identifier", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 22, "line": 1, }, "start": Object { - "column": 16, + "column": 21, "line": 1, }, }, "range": Array [ - 16, - 17, + 21, + 22, ], - "type": "Identifier", - "value": "f", + "type": "Punctuator", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 18, + "column": 23, "line": 1, }, "start": Object { - "column": 17, + "column": 22, "line": 1, }, }, "range": Array [ - 17, - 18, + 22, + 23, ], "type": "Punctuator", "value": "(", @@ -39910,35 +39659,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, + "column": 24, "line": 1, }, "start": Object { - "column": 18, + "column": 23, "line": 1, }, }, "range": Array [ - 18, - 19, + 23, + 24, ], "type": "Identifier", - "value": "x", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 25, "line": 1, }, "start": Object { - "column": 19, + "column": 24, "line": 1, }, }, "range": Array [ - 19, - 20, + 24, + 25, ], "type": "Punctuator", "value": ":", @@ -39946,35 +39695,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 27, + "column": 32, "line": 1, }, "start": Object { - "column": 21, + "column": 26, "line": 1, }, }, "range": Array [ - 21, - 27, + 26, + 32, ], "type": "Identifier", - "value": "number", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 33, "line": 1, }, "start": Object { - "column": 27, + "column": 32, "line": 1, }, }, "range": Array [ - 27, - 28, + 32, + 33, ], "type": "Punctuator", "value": ")", @@ -39982,65 +39731,29 @@ Object { Object { "loc": Object { "end": Object { - "column": 29, - "line": 1, - }, - "start": Object { - "column": 28, - "line": 1, - }, - }, - "range": Array [ - 28, - 29, - ], - "type": "Punctuator", - "value": ":", - }, - Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 30, - "line": 1, - }, - }, - "range": Array [ - 30, - 36, - ], - "type": "Identifier", - "value": "number", - }, - Object { - "loc": Object { - "end": Object { - "column": 37, + "column": 35, "line": 1, }, "start": Object { - "column": 36, + "column": 34, "line": 1, }, }, "range": Array [ - 36, - 37, + 34, + 35, ], "type": "Punctuator", - "value": ";", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 6, + "column": 8, "line": 2, }, "start": Object { - "column": 0, + "column": 2, "line": 2, }, }, @@ -40049,364 +39762,339 @@ Object { 44, ], "type": "Keyword", - "value": "export", + "value": "return", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 10, "line": 2, }, "start": Object { - "column": 7, + "column": 9, "line": 2, }, }, "range": Array [ 45, - 53, - ], - "type": "Keyword", - "value": "function", - }, - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "range": Array [ - 54, - 55, - ], - "type": "Identifier", - "value": "f", - }, - Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 2, - }, - "start": Object { - "column": 17, - "line": 2, - }, - }, - "range": Array [ - 55, - 56, - ], - "type": "Punctuator", - "value": "(", - }, - Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 2, - }, - "start": Object { - "column": 18, - "line": 2, - }, - }, - "range": Array [ - 56, - 57, + 46, ], "type": "Identifier", - "value": "x", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 11, "line": 2, }, "start": Object { - "column": 19, + "column": 10, "line": 2, }, }, "range": Array [ - 57, - 58, + 46, + 47, ], "type": "Punctuator", - "value": ":", - }, - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 2, - }, - "start": Object { - "column": 21, - "line": 2, - }, - }, - "range": Array [ - 59, - 65, - ], - "type": "Identifier", - "value": "string", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 28, - "line": 2, + "column": 1, + "line": 3, }, "start": Object { - "column": 27, - "line": 2, + "column": 0, + "line": 3, }, }, "range": Array [ - 65, - 66, + 48, + 49, ], "type": "Punctuator", - "value": ")", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 29, - "line": 2, + "column": 2, + "line": 3, }, "start": Object { - "column": 28, - "line": 2, + "column": 1, + "line": 3, }, }, "range": Array [ - 66, - 67, + 49, + 50, ], "type": "Punctuator", - "value": ":", + "value": ";", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/function-anynomus-with-return-type.src 1`] = ` +Object { + "body": Array [ Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 2, - }, - "start": Object { - "column": 30, - "line": 2, + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "obj", + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + }, + "init": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 1, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 31, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 1, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 10, + 31, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 27, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 27, + ], + "type": "TSVoidKeyword", + }, + }, + "type": "FunctionExpression", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 31, + ], + "type": "VariableDeclarator", }, - }, - "range": Array [ - 68, - 74, ], - "type": "Identifier", - "value": "string", - }, - Object { + "kind": "var", "loc": Object { "end": Object { - "column": 37, + "column": 2, "line": 2, }, "start": Object { - "column": 36, - "line": 2, + "column": 0, + "line": 1, }, }, "range": Array [ - 74, - 75, + 0, + 32, ], - "type": "Punctuator", - "value": ";", + "type": "VariableDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, }, + }, + "range": Array [ + 0, + 33, + ], + "sourceType": "module", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 6, - "line": 3, + "column": 3, + "line": 1, }, "start": Object { "column": 0, - "line": 3, + "line": 1, }, }, "range": Array [ - 76, - 82, + 0, + 3, ], "type": "Keyword", - "value": "export", + "value": "var", }, Object { "loc": Object { "end": Object { - "column": 15, - "line": 3, - }, - "start": Object { "column": 7, - "line": 3, - }, - }, - "range": Array [ - 83, - 91, - ], - "type": "Keyword", - "value": "function", - }, - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 3, + "line": 1, }, "start": Object { - "column": 16, - "line": 3, + "column": 4, + "line": 1, }, }, "range": Array [ - 92, - 93, + 4, + 7, ], "type": "Identifier", - "value": "f", + "value": "obj", }, Object { "loc": Object { "end": Object { - "column": 18, - "line": 3, + "column": 9, + "line": 1, }, "start": Object { - "column": 17, - "line": 3, + "column": 8, + "line": 1, }, }, "range": Array [ - 93, - 94, + 8, + 9, ], "type": "Punctuator", - "value": "(", + "value": "=", }, Object { "loc": Object { "end": Object { - "column": 19, - "line": 3, + "column": 18, + "line": 1, }, "start": Object { - "column": 18, - "line": 3, + "column": 10, + "line": 1, }, }, "range": Array [ - 94, - 95, + 10, + 18, ], - "type": "Identifier", - "value": "x", + "type": "Keyword", + "value": "function", }, Object { "loc": Object { "end": Object { "column": 20, - "line": 3, + "line": 1, }, "start": Object { "column": 19, - "line": 3, + "line": 1, }, }, "range": Array [ - 95, - 96, + 19, + 20, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 27, - "line": 3, - }, - "start": Object { "column": 21, - "line": 3, - }, - }, - "range": Array [ - 97, - 103, - ], - "type": "Identifier", - "value": "string", - }, - Object { - "loc": Object { - "end": Object { - "column": 29, - "line": 3, - }, - "start": Object { - "column": 28, - "line": 3, - }, - }, - "range": Array [ - 104, - 105, - ], - "type": "Punctuator", - "value": "|", - }, - Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 30, - "line": 3, - }, - }, - "range": Array [ - 106, - 112, - ], - "type": "Identifier", - "value": "number", - }, - Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 3, + "line": 1, }, "start": Object { - "column": 36, - "line": 3, + "column": 20, + "line": 1, }, }, "range": Array [ - 112, - 113, + 20, + 21, ], "type": "Punctuator", "value": ")", @@ -40414,17 +40102,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 38, - "line": 3, + "column": 22, + "line": 1, }, "start": Object { - "column": 37, - "line": 3, + "column": 21, + "line": 1, }, }, "range": Array [ - 113, - 114, + 21, + 22, ], "type": "Punctuator", "value": ":", @@ -40432,215 +40120,1468 @@ Object { Object { "loc": Object { "end": Object { - "column": 45, - "line": 3, + "column": 27, + "line": 1, }, "start": Object { - "column": 39, - "line": 3, + "column": 23, + "line": 1, }, }, "range": Array [ - 115, - 121, + 23, + 27, ], - "type": "Identifier", - "value": "string", + "type": "Keyword", + "value": "void", }, Object { "loc": Object { "end": Object { - "column": 47, - "line": 3, + "column": 29, + "line": 1, }, "start": Object { - "column": 46, - "line": 3, + "column": 28, + "line": 1, }, }, "range": Array [ - 122, - 123, + 28, + 29, ], "type": "Punctuator", - "value": "|", - }, - Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 3, - }, - "start": Object { - "column": 48, - "line": 3, - }, - }, - "range": Array [ - 124, - 130, - ], - "type": "Identifier", - "value": "number", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 56, - "line": 3, + "column": 1, + "line": 2, }, "start": Object { - "column": 55, - "line": 3, + "column": 0, + "line": 2, }, }, "range": Array [ - 131, - 132, + 30, + 31, ], "type": "Punctuator", - "value": "{", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 8, - "line": 4, - }, - "start": Object { "column": 2, - "line": 4, - }, - }, - "range": Array [ - 135, - 141, - ], - "type": "Keyword", - "value": "return", - }, - Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 4, - }, - "start": Object { - "column": 9, - "line": 4, - }, - }, - "range": Array [ - 142, - 143, - ], - "type": "Identifier", - "value": "x", - }, - Object { - "loc": Object { - "end": Object { - "column": 11, - "line": 4, + "line": 2, }, "start": Object { - "column": 10, - "line": 4, - }, - }, - "range": Array [ - 143, - 144, - ], - "type": "Punctuator", - "value": ";", - }, - Object { - "loc": Object { - "end": Object { "column": 1, - "line": 5, - }, - "start": Object { - "column": 0, - "line": 5, + "line": 2, }, }, "range": Array [ - 145, - 146, + 31, + 32, ], "type": "Punctuator", - "value": "}", + "value": ";", }, ], "type": "Program", } `; -exports[`typescript fixtures/basics/function-with-await.src 1`] = ` +exports[`typescript fixtures/basics/function-overloads.src 1`] = ` Object { "body": Array [ Object { - "async": true, - "body": Object { - "body": Array [ - Object { - "expression": Object { - "argument": Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 2, - }, - "start": Object { - "column": 10, - "line": 2, - }, - }, - "name": "future", - "range": Array [ - 40, - 46, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 16, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "range": Array [ - 34, - 46, - ], - "type": "AwaitExpression", + "declaration": Object { + "async": false, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, }, - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, + "start": Object { + "column": 16, + "line": 1, }, - "range": Array [ - 34, - 47, - ], - "type": "ExpressionStatement", }, - ], + "name": "f", + "range": Array [ + 16, + 17, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 1, + "column": 37, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 18, + 27, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 27, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 27, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 7, + 37, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 36, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 30, + "line": 1, + }, + }, + "range": Array [ + 30, + 36, + ], + "type": "TSNumberKeyword", + }, + }, + "type": "TSDeclareFunction", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 37, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + Object { + "declaration": Object { + "async": false, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": "f", + "range": Array [ + 54, + 55, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "name": "x", + "range": Array [ + 56, + 65, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 19, + "line": 2, + }, + }, + "range": Array [ + 57, + 65, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 21, + "line": 2, + }, + }, + "range": Array [ + 59, + 65, + ], + "type": "TSStringKeyword", + }, + }, + }, + ], + "range": Array [ + 45, + 75, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 66, + 74, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "range": Array [ + 68, + 74, + ], + "type": "TSStringKeyword", + }, + }, + "type": "TSDeclareFunction", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 38, + 75, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + Object { + "declaration": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 4, + }, + "start": Object { + "column": 9, + "line": 4, + }, + }, + "name": "x", + "range": Array [ + 142, + 143, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 135, + 144, + ], + "type": "ReturnStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 55, + "line": 3, + }, + }, + "range": Array [ + 131, + 146, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 3, + }, + }, + "name": "f", + "range": Array [ + 92, + 93, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 7, + "line": 3, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 18, + "line": 3, + }, + }, + "name": "x", + "range": Array [ + 94, + 112, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 19, + "line": 3, + }, + }, + "range": Array [ + 95, + 112, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "range": Array [ + 97, + 112, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "range": Array [ + 97, + 103, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 30, + "line": 3, + }, + }, + "range": Array [ + 106, + 112, + ], + "type": "TSNumberKeyword", + }, + ], + }, + }, + }, + ], + "range": Array [ + 83, + 146, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 3, + }, + "start": Object { + "column": 37, + "line": 3, + }, + }, + "range": Array [ + 113, + 130, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 3, + }, + "start": Object { + "column": 39, + "line": 3, + }, + }, + "range": Array [ + 115, + 130, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 3, + }, + "start": Object { + "column": 39, + "line": 3, + }, + }, + "range": Array [ + 115, + 121, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 3, + }, + "start": Object { + "column": 48, + "line": 3, + }, + }, + "range": Array [ + 124, + 130, + ], + "type": "TSNumberKeyword", + }, + ], + }, + }, + "type": "FunctionDeclaration", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 76, + 146, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 6, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 147, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 15, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Identifier", + "value": "f", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 27, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 30, + "line": 1, + }, + }, + "range": Array [ + 30, + 36, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 38, + 44, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 45, + 53, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 54, + 55, + ], + "type": "Identifier", + "value": "f", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 55, + 56, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 56, + 57, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 19, + "line": 2, + }, + }, + "range": Array [ + 57, + 58, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 21, + "line": 2, + }, + }, + "range": Array [ + 59, + 65, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 2, + }, + "start": Object { + "column": 27, + "line": 2, + }, + }, + "range": Array [ + 65, + 66, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 66, + 67, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "range": Array [ + 68, + 74, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 74, + 75, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 76, + 82, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 3, + }, + "start": Object { + "column": 7, + "line": 3, + }, + }, + "range": Array [ + 83, + 91, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 3, + }, + }, + "range": Array [ + 92, + 93, + ], + "type": "Identifier", + "value": "f", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 17, + "line": 3, + }, + }, + "range": Array [ + 93, + 94, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 3, + }, + "start": Object { + "column": 18, + "line": 3, + }, + }, + "range": Array [ + 94, + 95, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 3, + }, + "start": Object { + "column": 19, + "line": 3, + }, + }, + "range": Array [ + 95, + 96, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "range": Array [ + 97, + 103, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 3, + }, + "start": Object { + "column": 28, + "line": 3, + }, + }, + "range": Array [ + 104, + 105, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 30, + "line": 3, + }, + }, + "range": Array [ + 106, + 112, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 36, + "line": 3, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 3, + }, + "start": Object { + "column": 37, + "line": 3, + }, + }, + "range": Array [ + 113, + 114, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 3, + }, + "start": Object { + "column": 39, + "line": 3, + }, + }, + "range": Array [ + 115, + 121, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 3, + }, + "start": Object { + "column": 46, + "line": 3, + }, + }, + "range": Array [ + 122, + 123, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 3, + }, + "start": Object { + "column": 48, + "line": 3, + }, + }, + "range": Array [ + 124, + 130, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 3, + }, + "start": Object { + "column": 55, + "line": 3, + }, + }, + "range": Array [ + 131, + 132, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 135, + 141, + ], + "type": "Keyword", + "value": "return", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 4, + }, + "start": Object { + "column": 9, + "line": 4, + }, + }, + "range": Array [ + 142, + 143, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 4, + }, + "start": Object { + "column": 10, + "line": 4, + }, + }, + "range": Array [ + 143, + 144, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 145, + 146, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/function-with-await.src 1`] = ` +Object { + "body": Array [ + Object { + "async": true, + "body": Object { + "body": Array [ + Object { + "expression": Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "name": "future", + "range": Array [ + 40, + 46, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 34, + 46, + ], + "type": "AwaitExpression", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 34, + 47, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, "line": 3, }, "start": Object { @@ -107226,132 +108167,564 @@ Object { "line": 1, }, }, - "range": Array [ - 9, - 231, - ], - "type": "TSModuleBlock", + "range": Array [ + 9, + 231, + ], + "type": "TSModuleBlock", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "name": "A", + "range": Array [ + 7, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 12, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 231, + ], + "type": "TSModuleDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 1, + "line": 12, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 231, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Identifier", + "value": "module", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 16, + 22, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "range": Array [ + 23, + 26, + ], + "type": "Keyword", + "value": "var", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 17, + "line": 3, + }, + }, + "range": Array [ + 29, + 30, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 3, + }, + "start": Object { + "column": 19, + "line": 3, + }, + }, + "range": Array [ + 31, + 44, + ], + "type": "String", + "value": "'hello world'", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, }, - "id": Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, + "range": Array [ + 49, + 55, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 4, + }, + "start": Object { + "column": 11, + "line": 4, }, - "name": "A", - "range": Array [ - 7, - 8, - ], - "type": "Identifier", }, + "range": Array [ + 56, + 61, + ], + "type": "Keyword", + "value": "class", + }, + Object { "loc": Object { "end": Object { - "column": 1, - "line": 12, + "column": 22, + "line": 4, }, "start": Object { - "column": 0, - "line": 1, + "column": 17, + "line": 4, }, }, "range": Array [ - 0, - 231, + 62, + 67, ], - "type": "TSModuleDeclaration", + "type": "Identifier", + "value": "Point", }, - ], - "comments": Array [], - "loc": Object { - "end": Object { - "column": 1, - "line": 12, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 4, + }, + "start": Object { + "column": 23, + "line": 4, + }, + }, + "range": Array [ + 68, + 69, + ], + "type": "Punctuator", + "value": "{", }, - "start": Object { - "column": 0, - "line": 1, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 5, + }, + "start": Object { + "column": 8, + "line": 5, + }, + }, + "range": Array [ + 78, + 89, + ], + "type": "Identifier", + "value": "constructor", }, - }, - "range": Array [ - 0, - 231, - ], - "sourceType": "module", - "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 6, - "line": 1, + "column": 20, + "line": 5, }, "start": Object { - "column": 0, - "line": 1, + "column": 19, + "line": 5, }, }, "range": Array [ - 0, - 6, + 89, + 90, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 5, + }, + "start": Object { + "column": 20, + "line": 5, + }, + }, + "range": Array [ + 90, + 96, + ], + "type": "Keyword", + "value": "public", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 5, + }, + "start": Object { + "column": 27, + "line": 5, + }, + }, + "range": Array [ + 97, + 98, ], "type": "Identifier", - "value": "module", + "value": "x", }, Object { "loc": Object { "end": Object { - "column": 8, - "line": 1, + "column": 29, + "line": 5, }, "start": Object { - "column": 7, - "line": 1, + "column": 28, + "line": 5, }, }, "range": Array [ - 7, - 8, + 98, + 99, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 5, + }, + "start": Object { + "column": 30, + "line": 5, + }, + }, + "range": Array [ + 100, + 106, ], "type": "Identifier", - "value": "A", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 10, - "line": 1, + "column": 37, + "line": 5, }, "start": Object { - "column": 9, - "line": 1, + "column": 36, + "line": 5, }, }, "range": Array [ - 9, - 10, + 106, + 107, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 5, + }, + "start": Object { + "column": 38, + "line": 5, + }, + }, + "range": Array [ + 108, + 114, + ], + "type": "Keyword", + "value": "public", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 5, + }, + "start": Object { + "column": 45, + "line": 5, + }, + }, + "range": Array [ + 115, + 116, + ], + "type": "Identifier", + "value": "y", + }, + Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 5, + }, + "start": Object { + "column": 46, + "line": 5, + }, + }, + "range": Array [ + 116, + 117, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 5, + }, + "start": Object { + "column": 48, + "line": 5, + }, + }, + "range": Array [ + 118, + 124, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 55, + "line": 5, + }, + "start": Object { + "column": 54, + "line": 5, + }, + }, + "range": Array [ + 124, + 125, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 57, + "line": 5, + }, + "start": Object { + "column": 56, + "line": 5, + }, + }, + "range": Array [ + 126, + 127, ], "type": "Punctuator", "value": "{", }, + Object { + "loc": Object { + "end": Object { + "column": 59, + "line": 5, + }, + "start": Object { + "column": 58, + "line": 5, + }, + }, + "range": Array [ + 128, + 129, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 134, + 135, + ], + "type": "Punctuator", + "value": "}", + }, Object { "loc": Object { "end": Object { "column": 10, - "line": 3, + "line": 7, }, "start": Object { "column": 4, - "line": 3, + "line": 7, }, }, "range": Array [ - 16, - 22, + 140, + 146, ], "type": "Keyword", "value": "export", @@ -107359,593 +108732,935 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, - "line": 3, + "column": 17, + "line": 7, }, "start": Object { "column": 11, - "line": 3, + "line": 7, }, }, "range": Array [ - 23, - 26, + 147, + 153, + ], + "type": "Identifier", + "value": "module", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 7, + }, + "start": Object { + "column": 18, + "line": 7, + }, + }, + "range": Array [ + 154, + 155, + ], + "type": "Identifier", + "value": "B", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 7, + }, + "start": Object { + "column": 20, + "line": 7, + }, + }, + "range": Array [ + 156, + 157, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 8, + }, + "start": Object { + "column": 8, + "line": 8, + }, + }, + "range": Array [ + 166, + 172, ], "type": "Keyword", - "value": "var", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 8, + }, + "start": Object { + "column": 15, + "line": 8, + }, + }, + "range": Array [ + 173, + 182, + ], + "type": "Keyword", + "value": "interface", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 8, + }, + "start": Object { + "column": 25, + "line": 8, + }, + }, + "range": Array [ + 183, + 185, + ], + "type": "Identifier", + "value": "Id", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 8, + }, + "start": Object { + "column": 28, + "line": 8, + }, + }, + "range": Array [ + 186, + 187, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 9, + }, + "start": Object { + "column": 12, + "line": 9, + }, + }, + "range": Array [ + 200, + 204, + ], + "type": "Identifier", + "value": "name", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 9, + }, + "start": Object { + "column": 16, + "line": 9, + }, + }, + "range": Array [ + 204, + 205, + ], + "type": "Punctuator", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 16, - "line": 3, + "column": 24, + "line": 9, }, "start": Object { - "column": 15, - "line": 3, + "column": 18, + "line": 9, }, }, "range": Array [ - 27, - 28, + 206, + 212, ], "type": "Identifier", - "value": "x", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 18, - "line": 3, + "column": 25, + "line": 9, }, "start": Object { - "column": 17, - "line": 3, + "column": 24, + "line": 9, }, }, "range": Array [ - 29, - 30, + 212, + 213, ], "type": "Punctuator", - "value": "=", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 32, - "line": 3, + "column": 9, + "line": 10, }, "start": Object { - "column": 19, - "line": 3, + "column": 8, + "line": 10, }, }, "range": Array [ - 31, - 44, + 222, + 223, ], - "type": "String", - "value": "'hello world'", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 10, - "line": 4, + "column": 5, + "line": 11, }, "start": Object { "column": 4, - "line": 4, + "line": 11, }, }, "range": Array [ - 49, - 55, + 228, + 229, ], - "type": "Keyword", - "value": "export", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 16, - "line": 4, + "column": 1, + "line": 12, }, "start": Object { - "column": 11, - "line": 4, + "column": 0, + "line": 12, }, }, "range": Array [ - 56, - 61, + 230, + 231, ], - "type": "Keyword", - "value": "class", + "type": "Punctuator", + "value": "}", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/namespaces-and-modules/shorthand-ambient-module-declaration.src 1`] = ` +Object { + "body": Array [ Object { + "declare": true, + "id": Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 31, + ], + "raw": "\\"hot-new-module\\"", + "type": "Literal", + "value": "hot-new-module", + }, "loc": Object { "end": Object { - "column": 22, - "line": 4, + "column": 32, + "line": 1, }, "start": Object { - "column": 17, - "line": 4, + "column": 0, + "line": 1, }, }, "range": Array [ - 62, - 67, + 0, + 32, ], - "type": "Identifier", - "value": "Point", + "type": "TSModuleDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, }, + }, + "range": Array [ + 0, + 33, + ], + "sourceType": "module", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 24, - "line": 4, + "column": 7, + "line": 1, }, "start": Object { - "column": 23, - "line": 4, + "column": 0, + "line": 1, }, }, "range": Array [ - 68, - 69, + 0, + 7, ], - "type": "Punctuator", - "value": "{", + "type": "Identifier", + "value": "declare", }, Object { "loc": Object { "end": Object { - "column": 19, - "line": 5, + "column": 14, + "line": 1, }, "start": Object { "column": 8, - "line": 5, + "line": 1, }, }, "range": Array [ - 78, - 89, + 8, + 14, ], "type": "Identifier", - "value": "constructor", + "value": "module", }, Object { "loc": Object { "end": Object { - "column": 20, - "line": 5, + "column": 31, + "line": 1, }, "start": Object { - "column": 19, - "line": 5, + "column": 15, + "line": 1, }, }, "range": Array [ - 89, - 90, + 15, + 31, ], - "type": "Punctuator", - "value": "(", + "type": "String", + "value": "\\"hot-new-module\\"", }, Object { "loc": Object { "end": Object { - "column": 26, - "line": 5, + "column": 32, + "line": 1, }, "start": Object { - "column": 20, - "line": 5, + "column": 31, + "line": 1, }, }, "range": Array [ - 90, - 96, + 31, + 32, ], - "type": "Keyword", - "value": "public", + "type": "Punctuator", + "value": ";", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/array-type.src 1`] = ` +Object { + "body": Array [ Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 28, - "line": 5, + "column": 19, + "line": 1, }, "start": Object { - "column": 27, - "line": 5, + "column": 0, + "line": 1, }, }, "range": Array [ - 97, - 98, + 0, + 19, ], - "type": "Identifier", - "value": "x", + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "elementType": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSStringKeyword", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 19, + ], + "type": "TSArrayType", + }, + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 20, + ], + "sourceType": "module", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 29, - "line": 5, + "column": 4, + "line": 1, }, "start": Object { - "column": 28, - "line": 5, + "column": 0, + "line": 1, }, }, "range": Array [ - 98, - 99, + 0, + 4, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "type", }, Object { "loc": Object { "end": Object { - "column": 36, - "line": 5, + "column": 8, + "line": 1, }, "start": Object { - "column": 30, - "line": 5, + "column": 5, + "line": 1, }, }, "range": Array [ - 100, - 106, + 5, + 8, ], "type": "Identifier", - "value": "number", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 37, - "line": 5, + "column": 10, + "line": 1, }, "start": Object { - "column": 36, - "line": 5, + "column": 9, + "line": 1, }, }, "range": Array [ - 106, - 107, + 9, + 10, ], "type": "Punctuator", - "value": ",", + "value": "=", }, Object { "loc": Object { "end": Object { - "column": 44, - "line": 5, + "column": 17, + "line": 1, }, "start": Object { - "column": 38, - "line": 5, + "column": 11, + "line": 1, }, }, "range": Array [ - 108, - 114, + 11, + 17, ], - "type": "Keyword", - "value": "public", + "type": "Identifier", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 46, - "line": 5, + "column": 18, + "line": 1, }, "start": Object { - "column": 45, - "line": 5, + "column": 17, + "line": 1, }, }, "range": Array [ - 115, - 116, + 17, + 18, ], - "type": "Identifier", - "value": "y", + "type": "Punctuator", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 47, - "line": 5, + "column": 19, + "line": 1, }, "start": Object { - "column": 46, - "line": 5, + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": "]", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/conditional.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 47, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 47, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "checkType": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 13, + ], + "type": "TSNumberKeyword", + }, + "extendsType": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "TSStringKeyword", + }, + "falseType": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 47, + ], + "type": "TSStringKeyword", + }, + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 47, + ], + "trueType": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 38, + ], + "type": "TSBooleanKeyword", + }, + "type": "TSConditionalType", + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 47, + ], + "type": "VariableDeclarator", }, - }, - "range": Array [ - 116, - 117, ], - "type": "Punctuator", - "value": ":", - }, - Object { + "kind": "let", "loc": Object { "end": Object { - "column": 54, - "line": 5, - }, - "start": Object { "column": 48, - "line": 5, - }, - }, - "range": Array [ - 118, - 124, - ], - "type": "Identifier", - "value": "number", - }, - Object { - "loc": Object { - "end": Object { - "column": 55, - "line": 5, + "line": 1, }, "start": Object { - "column": 54, - "line": 5, + "column": 0, + "line": 1, }, }, "range": Array [ - 124, - 125, + 0, + 48, ], - "type": "Punctuator", - "value": ")", + "type": "VariableDeclaration", }, - Object { - "loc": Object { - "end": Object { - "column": 57, - "line": 5, - }, - "start": Object { - "column": 56, - "line": 5, - }, - }, - "range": Array [ - 126, - 127, - ], - "type": "Punctuator", - "value": "{", + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, }, - Object { - "loc": Object { - "end": Object { - "column": 59, - "line": 5, - }, - "start": Object { - "column": 58, - "line": 5, - }, - }, - "range": Array [ - 128, - 129, - ], - "type": "Punctuator", - "value": "}", + "start": Object { + "column": 0, + "line": 1, }, + }, + "range": Array [ + 0, + 49, + ], + "sourceType": "module", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 5, - "line": 6, + "column": 3, + "line": 1, }, "start": Object { - "column": 4, - "line": 6, + "column": 0, + "line": 1, }, }, "range": Array [ - 134, - 135, + 0, + 3, ], - "type": "Punctuator", - "value": "}", + "type": "Keyword", + "value": "let", }, Object { "loc": Object { "end": Object { - "column": 10, - "line": 7, + "column": 5, + "line": 1, }, "start": Object { "column": 4, - "line": 7, + "line": 1, }, }, "range": Array [ - 140, - 146, + 4, + 5, ], - "type": "Keyword", - "value": "export", + "type": "Identifier", + "value": "x", }, Object { "loc": Object { "end": Object { - "column": 17, - "line": 7, + "column": 6, + "line": 1, }, "start": Object { - "column": 11, - "line": 7, + "column": 5, + "line": 1, }, }, "range": Array [ - 147, - 153, + 5, + 6, ], - "type": "Identifier", - "value": "module", + "type": "Punctuator", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 19, - "line": 7, + "column": 13, + "line": 1, }, "start": Object { - "column": 18, - "line": 7, + "column": 7, + "line": 1, }, }, "range": Array [ - 154, - 155, + 7, + 13, ], "type": "Identifier", - "value": "B", + "value": "number", }, Object { "loc": Object { "end": Object { "column": 21, - "line": 7, + "line": 1, }, "start": Object { - "column": 20, - "line": 7, - }, - }, - "range": Array [ - 156, - 157, - ], - "type": "Punctuator", - "value": "{", - }, - Object { - "loc": Object { - "end": Object { "column": 14, - "line": 8, - }, - "start": Object { - "column": 8, - "line": 8, - }, - }, - "range": Array [ - 166, - 172, - ], - "type": "Keyword", - "value": "export", - }, - Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 8, - }, - "start": Object { - "column": 15, - "line": 8, + "line": 1, }, }, "range": Array [ - 173, - 182, + 14, + 21, ], "type": "Keyword", - "value": "interface", + "value": "extends", }, Object { "loc": Object { "end": Object { - "column": 27, - "line": 8, + "column": 28, + "line": 1, }, "start": Object { - "column": 25, - "line": 8, + "column": 22, + "line": 1, }, }, "range": Array [ - 183, - 185, + 22, + 28, ], "type": "Identifier", - "value": "Id", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 29, - "line": 8, + "column": 30, + "line": 1, }, "start": Object { - "column": 28, - "line": 8, + "column": 29, + "line": 1, }, }, "range": Array [ - 186, - 187, + 29, + 30, ], "type": "Punctuator", - "value": "{", + "value": "?", }, Object { "loc": Object { "end": Object { - "column": 16, - "line": 9, + "column": 38, + "line": 1, }, "start": Object { - "column": 12, - "line": 9, + "column": 31, + "line": 1, }, }, "range": Array [ - 200, - 204, + 31, + 38, ], "type": "Identifier", - "value": "name", + "value": "boolean", }, Object { "loc": Object { "end": Object { - "column": 17, - "line": 9, + "column": 40, + "line": 1, }, "start": Object { - "column": 16, - "line": 9, + "column": 39, + "line": 1, }, }, "range": Array [ - 204, - 205, + 39, + 40, ], "type": "Punctuator", "value": ":", @@ -107953,17 +109668,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 24, - "line": 9, + "column": 47, + "line": 1, }, "start": Object { - "column": 18, - "line": 9, + "column": 41, + "line": 1, }, }, "range": Array [ - 206, - 212, + 41, + 47, ], "type": "Identifier", "value": "string", @@ -107971,142 +109686,51 @@ Object { Object { "loc": Object { "end": Object { - "column": 25, - "line": 9, + "column": 48, + "line": 1, }, "start": Object { - "column": 24, - "line": 9, + "column": 47, + "line": 1, }, }, "range": Array [ - 212, - 213, + 47, + 48, ], "type": "Punctuator", "value": ";", }, - Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 10, - }, - "start": Object { - "column": 8, - "line": 10, - }, - }, - "range": Array [ - 222, - 223, - ], - "type": "Punctuator", - "value": "}", - }, - Object { - "loc": Object { - "end": Object { - "column": 5, - "line": 11, - }, - "start": Object { - "column": 4, - "line": 11, - }, - }, - "range": Array [ - 228, - 229, - ], - "type": "Punctuator", - "value": "}", - }, - Object { - "loc": Object { - "end": Object { - "column": 1, - "line": 12, - }, - "start": Object { - "column": 0, - "line": 12, - }, - }, - "range": Array [ - 230, - 231, - ], - "type": "Punctuator", - "value": "}", - }, ], "type": "Program", } `; -exports[`typescript fixtures/namespaces-and-modules/shorthand-ambient-module-declaration.src 1`] = ` +exports[`typescript fixtures/types/conditional-infer.src 1`] = ` Object { "body": Array [ Object { - "declare": true, "id": Object { "loc": Object { "end": Object { - "column": 31, + "column": 12, "line": 1, }, "start": Object { - "column": 15, + "column": 5, "line": 1, }, }, + "name": "Element", "range": Array [ - 15, - 31, + 5, + 12, ], - "raw": "\\"hot-new-module\\"", - "type": "Literal", - "value": "hot-new-module", - }, - "loc": Object { - "end": Object { - "column": 32, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, + "type": "Identifier", }, - "range": Array [ - 0, - 32, - ], - "type": "TSModuleDeclaration", - }, - ], - "comments": Array [], - "loc": Object { - "end": Object { - "column": 0, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 33, - ], - "sourceType": "module", - "tokens": Array [ - Object { "loc": Object { "end": Object { - "column": 7, + "column": 48, "line": 1, }, "start": Object { @@ -108116,140 +109740,270 @@ Object { }, "range": Array [ 0, - 7, - ], - "type": "Identifier", - "value": "declare", - }, - Object { - "loc": Object { - "end": Object { - "column": 14, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "range": Array [ - 8, - 14, + 48, ], - "type": "Identifier", - "value": "module", - }, - Object { - "loc": Object { - "end": Object { - "column": 31, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "checkType": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 18, + 19, + ], + "type": "Identifier", + }, }, - }, - "range": Array [ - 15, - 31, - ], - "type": "String", - "value": "\\"hot-new-module\\"", - }, - Object { - "loc": Object { - "end": Object { - "column": 32, - "line": 1, + "extendsType": Object { + "elementType": Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 37, + ], + "type": "TSParenthesizedType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 36, + ], + "type": "TSInferType", + "typeParameter": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "name": "U", + "range": Array [ + 35, + 36, + ], + "type": "Identifier", + }, + "range": Array [ + 35, + 36, + ], + "type": "TSTypeParameter", + }, + }, + }, + "loc": Object { + "end": Object { + "column": 39, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 39, + ], + "type": "TSArrayType", }, - "start": Object { - "column": 31, - "line": 1, + "falseType": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 46, + 47, + ], + "type": "Identifier", + }, }, - }, - "range": Array [ - 31, - 32, - ], - "type": "Punctuator", - "value": ";", - }, - ], - "type": "Program", -} -`; - -exports[`typescript fixtures/types/array-type.src 1`] = ` -Object { - "body": Array [ - Object { - "id": Object { "loc": Object { "end": Object { - "column": 8, + "column": 47, "line": 1, }, "start": Object { - "column": 5, + "column": 18, "line": 1, }, }, - "name": "Foo", "range": Array [ - 5, - 8, + 18, + 47, ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 19, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 19, - ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "elementType": Object { + "trueType": Object { "loc": Object { "end": Object { - "column": 17, + "column": 43, "line": 1, }, "start": Object { - "column": 11, + "column": 42, "line": 1, }, }, "range": Array [ - 11, - 17, + 42, + 43, ], - "type": "TSStringKeyword", + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 42, + "line": 1, + }, + }, + "name": "U", + "range": Array [ + 42, + 43, + ], + "type": "Identifier", + }, }, + "type": "TSConditionalType", + }, + "typeParameters": Object { "loc": Object { "end": Object { - "column": 19, + "column": 15, "line": 1, }, "start": Object { - "column": 11, + "column": 12, "line": 1, }, }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 13, + 14, + ], + "type": "Identifier", + }, + "range": Array [ + 13, + 14, + ], + "type": "TSTypeParameter", + }, + ], "range": Array [ - 11, - 19, + 12, + 15, ], - "type": "TSArrayType", + "type": "TSTypeParameterDeclaration", }, }, ], @@ -108266,7 +110020,7 @@ Object { }, "range": Array [ 0, - 20, + 49, ], "sourceType": "module", "tokens": Array [ @@ -108291,7 +110045,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 8, + "column": 12, "line": 1, }, "start": Object { @@ -108301,64 +110055,82 @@ Object { }, "range": Array [ 5, - 8, + 12, ], "type": "Identifier", - "value": "Foo", + "value": "Element", }, Object { "loc": Object { "end": Object { - "column": 10, + "column": 13, "line": 1, }, "start": Object { - "column": 9, + "column": 12, "line": 1, }, }, "range": Array [ - 9, - 10, + 12, + 13, ], "type": "Punctuator", - "value": "=", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 14, "line": 1, }, "start": Object { - "column": 11, + "column": 13, "line": 1, }, }, "range": Array [ - 11, - 17, + 13, + 14, ], "type": "Identifier", - "value": "string", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 18, + "column": 15, "line": 1, }, "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { "column": 17, "line": 1, }, + "start": Object { + "column": 16, + "line": 1, + }, }, "range": Array [ + 16, 17, - 18, ], "type": "Punctuator", - "value": "[", + "value": "=", }, Object { "loc": Object { @@ -108375,315 +110147,149 @@ Object { 18, 19, ], - "type": "Punctuator", - "value": "]", + "type": "Identifier", + "value": "T", }, - ], - "type": "Program", -} -`; - -exports[`typescript fixtures/types/conditional.src 1`] = ` -Object { - "body": Array [ Object { - "declarations": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 4, - "line": 1, - }, - }, - "name": "x", - "range": Array [ - 4, - 47, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "range": Array [ - 5, - 47, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "checkType": Object { - "loc": Object { - "end": Object { - "column": 13, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "range": Array [ - 7, - 13, - ], - "type": "TSNumberKeyword", - }, - "extendsType": Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, - "start": Object { - "column": 22, - "line": 1, - }, - }, - "range": Array [ - 22, - 28, - ], - "type": "TSStringKeyword", - }, - "falseType": Object { - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 41, - "line": 1, - }, - }, - "range": Array [ - 41, - 47, - ], - "type": "TSStringKeyword", - }, - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "range": Array [ - 7, - 47, - ], - "trueType": Object { - "loc": Object { - "end": Object { - "column": 38, - "line": 1, - }, - "start": Object { - "column": 31, - "line": 1, - }, - }, - "range": Array [ - 31, - 38, - ], - "type": "TSBooleanKeyword", - }, - "type": "TSConditionalType", - }, - }, - }, - "init": null, - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 4, - "line": 1, - }, - }, - "range": Array [ - 4, - 47, - ], - "type": "VariableDeclarator", - }, - ], - "kind": "let", "loc": Object { "end": Object { - "column": 48, + "column": 27, "line": 1, }, "start": Object { - "column": 0, + "column": 20, "line": 1, }, }, "range": Array [ - 0, - 48, + 20, + 27, ], - "type": "VariableDeclaration", - }, - ], - "comments": Array [], - "loc": Object { - "end": Object { - "column": 0, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 1, + "type": "Keyword", + "value": "extends", }, - }, - "range": Array [ - 0, - 49, - ], - "sourceType": "module", - "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 3, + "column": 29, "line": 1, }, "start": Object { - "column": 0, + "column": 28, "line": 1, }, }, "range": Array [ - 0, - 3, + 28, + 29, ], - "type": "Keyword", - "value": "let", + "type": "Punctuator", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 5, + "column": 34, "line": 1, }, "start": Object { - "column": 4, + "column": 29, "line": 1, }, }, "range": Array [ - 4, - 5, + 29, + 34, ], "type": "Identifier", - "value": "x", + "value": "infer", }, Object { "loc": Object { "end": Object { - "column": 6, + "column": 36, "line": 1, }, "start": Object { - "column": 5, + "column": 35, "line": 1, }, }, "range": Array [ - 5, - 6, + 35, + 36, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "U", }, Object { "loc": Object { "end": Object { - "column": 13, + "column": 37, "line": 1, }, "start": Object { - "column": 7, + "column": 36, "line": 1, }, }, "range": Array [ - 7, - 13, + 36, + 37, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 38, "line": 1, }, "start": Object { - "column": 14, + "column": 37, "line": 1, }, }, "range": Array [ - 14, - 21, + 37, + 38, ], - "type": "Keyword", - "value": "extends", + "type": "Punctuator", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 39, "line": 1, }, "start": Object { - "column": 22, + "column": 38, "line": 1, }, }, "range": Array [ - 22, - 28, + 38, + 39, ], - "type": "Identifier", - "value": "string", + "type": "Punctuator", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 30, + "column": 41, "line": 1, }, "start": Object { - "column": 29, + "column": 40, "line": 1, }, }, "range": Array [ - 29, - 30, + 40, + 41, ], "type": "Punctuator", "value": "?", @@ -108691,35 +110297,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 38, + "column": 43, "line": 1, }, "start": Object { - "column": 31, + "column": 42, "line": 1, }, }, "range": Array [ - 31, - 38, + 42, + 43, ], "type": "Identifier", - "value": "boolean", + "value": "U", }, Object { "loc": Object { "end": Object { - "column": 40, + "column": 45, "line": 1, }, "start": Object { - "column": 39, + "column": 44, "line": 1, }, }, "range": Array [ - 39, - 40, + 44, + 45, ], "type": "Punctuator", "value": ":", @@ -108731,16 +110337,16 @@ Object { "line": 1, }, "start": Object { - "column": 41, + "column": 46, "line": 1, }, }, "range": Array [ - 41, + 46, 47, ], "type": "Identifier", - "value": "string", + "value": "T", }, Object { "loc": Object { @@ -108765,14 +110371,14 @@ Object { } `; -exports[`typescript fixtures/types/conditional-infer.src 1`] = ` +exports[`typescript fixtures/types/conditional-infer-nested.src 1`] = ` Object { "body": Array [ Object { "id": Object { "loc": Object { "end": Object { - "column": 12, + "column": 13, "line": 1, }, "start": Object { @@ -108780,17 +110386,17 @@ Object { "line": 1, }, }, - "name": "Element", + "name": "Unpacked", "range": Array [ 5, - 12, + 13, ], "type": "Identifier", }, "loc": Object { "end": Object { - "column": 48, - "line": 1, + "column": 10, + "line": 5, }, "start": Object { "column": 0, @@ -108799,41 +110405,41 @@ Object { }, "range": Array [ 0, - 48, + 126, ], "type": "TSTypeAliasDeclaration", "typeAnnotation": Object { "checkType": Object { "loc": Object { "end": Object { - "column": 19, - "line": 1, + "column": 3, + "line": 2, }, "start": Object { - "column": 18, - "line": 1, + "column": 2, + "line": 2, }, }, "range": Array [ - 18, - 19, + 21, + 22, ], "type": "TSTypeReference", "typeName": Object { "loc": Object { "end": Object { - "column": 19, - "line": 1, + "column": 3, + "line": 2, }, "start": Object { - "column": 18, - "line": 1, + "column": 2, + "line": 2, }, }, "name": "T", "range": Array [ - 18, - 19, + 21, + 22, ], "type": "Identifier", }, @@ -108842,67 +110448,67 @@ Object { "elementType": Object { "loc": Object { "end": Object { - "column": 37, - "line": 1, + "column": 21, + "line": 2, }, "start": Object { - "column": 28, - "line": 1, + "column": 12, + "line": 2, }, }, "range": Array [ - 28, - 37, + 31, + 40, ], "type": "TSParenthesizedType", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 36, - "line": 1, + "column": 20, + "line": 2, }, "start": Object { - "column": 29, - "line": 1, + "column": 13, + "line": 2, }, }, "range": Array [ - 29, - 36, + 32, + 39, ], "type": "TSInferType", "typeParameter": Object { "loc": Object { "end": Object { - "column": 36, - "line": 1, + "column": 20, + "line": 2, }, "start": Object { - "column": 35, - "line": 1, + "column": 19, + "line": 2, }, }, "name": Object { "loc": Object { "end": Object { - "column": 36, - "line": 1, + "column": 20, + "line": 2, }, "start": Object { - "column": 35, - "line": 1, + "column": 19, + "line": 2, }, }, "name": "U", "range": Array [ - 35, - 36, + 38, + 39, ], "type": "Identifier", }, "range": Array [ - 35, - 36, + 38, + 39, ], "type": "TSTypeParameter", }, @@ -108910,100 +110516,432 @@ Object { }, "loc": Object { "end": Object { - "column": 39, - "line": 1, + "column": 23, + "line": 2, }, "start": Object { - "column": 28, - "line": 1, + "column": 12, + "line": 2, }, }, "range": Array [ - 28, - 39, + 31, + 42, ], "type": "TSArrayType", }, "falseType": Object { + "checkType": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 53, + 54, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "name": "T", + "range": Array [ + 53, + 54, + ], + "type": "Identifier", + }, + }, + "extendsType": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 3, + }, + "start": Object { + "column": 14, + "line": 3, + }, + }, + "range": Array [ + 63, + 70, + ], + "type": "TSInferType", + "typeParameter": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 3, + }, + "start": Object { + "column": 20, + "line": 3, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 3, + }, + "start": Object { + "column": 20, + "line": 3, + }, + }, + "name": "U", + "range": Array [ + 69, + 70, + ], + "type": "Identifier", + }, + "range": Array [ + 69, + 70, + ], + "type": "TSTypeParameter", + }, + }, + "falseType": Object { + "checkType": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 4, + }, + "start": Object { + "column": 6, + "line": 4, + }, + }, + "range": Array [ + 83, + 84, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 4, + }, + "start": Object { + "column": 6, + "line": 4, + }, + }, + "name": "T", + "range": Array [ + 83, + 84, + ], + "type": "Identifier", + }, + }, + "extendsType": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 4, + }, + "start": Object { + "column": 16, + "line": 4, + }, + }, + "range": Array [ + 93, + 109, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 4, + }, + "start": Object { + "column": 16, + "line": 4, + }, + }, + "name": "Promise", + "range": Array [ + 93, + 100, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 4, + }, + "start": Object { + "column": 23, + "line": 4, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 4, + }, + "start": Object { + "column": 24, + "line": 4, + }, + }, + "range": Array [ + 101, + 108, + ], + "type": "TSInferType", + "typeParameter": Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 4, + }, + "start": Object { + "column": 30, + "line": 4, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 4, + }, + "start": Object { + "column": 30, + "line": 4, + }, + }, + "name": "U", + "range": Array [ + 107, + 108, + ], + "type": "Identifier", + }, + "range": Array [ + 107, + 108, + ], + "type": "TSTypeParameter", + }, + }, + ], + "range": Array [ + 100, + 109, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + "falseType": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 5, + }, + "start": Object { + "column": 8, + "line": 5, + }, + }, + "range": Array [ + 124, + 125, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 5, + }, + "start": Object { + "column": 8, + "line": 5, + }, + }, + "name": "T", + "range": Array [ + 124, + 125, + ], + "type": "Identifier", + }, + }, + "loc": Object { + "end": Object { + "column": 9, + "line": 5, + }, + "start": Object { + "column": 6, + "line": 4, + }, + }, + "range": Array [ + 83, + 125, + ], + "trueType": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 4, + }, + "start": Object { + "column": 35, + "line": 4, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 4, + }, + "start": Object { + "column": 35, + "line": 4, + }, + }, + "name": "U", + "range": Array [ + 112, + 113, + ], + "type": "Identifier", + }, + }, + "type": "TSConditionalType", + }, "loc": Object { "end": Object { - "column": 47, - "line": 1, + "column": 9, + "line": 5, }, "start": Object { - "column": 46, - "line": 1, + "column": 4, + "line": 3, }, }, "range": Array [ - 46, - 47, + 53, + 125, ], - "type": "TSTypeReference", - "typeName": Object { + "trueType": Object { "loc": Object { "end": Object { - "column": 47, - "line": 1, + "column": 25, + "line": 3, }, "start": Object { - "column": 46, - "line": 1, + "column": 24, + "line": 3, }, }, - "name": "T", "range": Array [ - 46, - 47, + 73, + 74, ], - "type": "Identifier", + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 3, + }, + "start": Object { + "column": 24, + "line": 3, + }, + }, + "name": "U", + "range": Array [ + 73, + 74, + ], + "type": "Identifier", + }, }, + "type": "TSConditionalType", }, "loc": Object { "end": Object { - "column": 47, - "line": 1, + "column": 9, + "line": 5, }, "start": Object { - "column": 18, - "line": 1, + "column": 2, + "line": 2, }, }, "range": Array [ - 18, - 47, + 21, + 125, ], "trueType": Object { "loc": Object { "end": Object { - "column": 43, - "line": 1, + "column": 27, + "line": 2, }, "start": Object { - "column": 42, - "line": 1, + "column": 26, + "line": 2, }, }, "range": Array [ - 42, - 43, + 45, + 46, ], "type": "TSTypeReference", "typeName": Object { "loc": Object { "end": Object { - "column": 43, - "line": 1, + "column": 27, + "line": 2, }, "start": Object { - "column": 42, - "line": 1, + "column": 26, + "line": 2, }, }, "name": "U", "range": Array [ - 42, - 43, + 45, + 46, ], "type": "Identifier", }, @@ -109013,11 +110951,11 @@ Object { "typeParameters": Object { "loc": Object { "end": Object { - "column": 15, + "column": 16, "line": 1, }, "start": Object { - "column": 12, + "column": 13, "line": 1, }, }, @@ -109025,42 +110963,42 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, + "column": 15, "line": 1, }, "start": Object { - "column": 13, + "column": 14, "line": 1, }, }, "name": Object { "loc": Object { "end": Object { - "column": 14, + "column": 15, "line": 1, }, "start": Object { - "column": 13, + "column": 14, "line": 1, }, }, "name": "T", "range": Array [ - 13, 14, + 15, ], "type": "Identifier", }, "range": Array [ - 13, 14, + 15, ], "type": "TSTypeParameter", }, ], "range": Array [ - 12, - 15, + 13, + 16, ], "type": "TSTypeParameterDeclaration", }, @@ -109070,7 +111008,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 2, + "line": 6, }, "start": Object { "column": 0, @@ -109079,7 +111017,7 @@ Object { }, "range": Array [ 0, - 49, + 127, ], "sourceType": "module", "tokens": Array [ @@ -109104,7 +111042,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 12, + "column": 13, "line": 1, }, "start": Object { @@ -109114,25 +111052,25 @@ Object { }, "range": Array [ 5, - 12, + 13, ], "type": "Identifier", - "value": "Element", + "value": "Unpacked", }, Object { "loc": Object { "end": Object { - "column": 13, + "column": 14, "line": 1, }, "start": Object { - "column": 12, + "column": 13, "line": 1, }, }, "range": Array [ - 12, 13, + 14, ], "type": "Punctuator", "value": "<", @@ -109140,17 +111078,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, + "column": 15, "line": 1, }, "start": Object { - "column": 13, + "column": 14, "line": 1, }, }, "range": Array [ - 13, 14, + 15, ], "type": "Identifier", "value": "T", @@ -109158,17 +111096,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 16, "line": 1, }, "start": Object { - "column": 14, + "column": 15, "line": 1, }, }, "range": Array [ - 14, 15, + 16, ], "type": "Punctuator", "value": ">", @@ -109176,17 +111114,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 17, + "column": 18, "line": 1, }, "start": Object { - "column": 16, + "column": 17, "line": 1, }, }, "range": Array [ - 16, 17, + 18, ], "type": "Punctuator", "value": "=", @@ -109194,17 +111132,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, - "line": 1, + "column": 3, + "line": 2, }, "start": Object { - "column": 18, - "line": 1, + "column": 2, + "line": 2, }, }, "range": Array [ - 18, - 19, + 21, + 22, ], "type": "Identifier", "value": "T", @@ -109212,17 +111150,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 27, - "line": 1, + "column": 11, + "line": 2, }, "start": Object { - "column": 20, - "line": 1, + "column": 4, + "line": 2, }, }, "range": Array [ - 20, - 27, + 23, + 30, ], "type": "Keyword", "value": "extends", @@ -109230,17 +111168,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 29, - "line": 1, + "column": 13, + "line": 2, }, "start": Object { - "column": 28, - "line": 1, + "column": 12, + "line": 2, }, }, "range": Array [ - 28, - 29, + 31, + 32, ], "type": "Punctuator", "value": "(", @@ -109248,17 +111186,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 34, - "line": 1, + "column": 18, + "line": 2, }, "start": Object { - "column": 29, - "line": 1, + "column": 13, + "line": 2, }, }, "range": Array [ - 29, - 34, + 32, + 37, ], "type": "Identifier", "value": "infer", @@ -109266,17 +111204,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 36, - "line": 1, + "column": 20, + "line": 2, }, "start": Object { - "column": 35, - "line": 1, + "column": 19, + "line": 2, }, }, "range": Array [ - 35, - 36, + 38, + 39, ], "type": "Identifier", "value": "U", @@ -109284,17 +111222,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 37, - "line": 1, + "column": 21, + "line": 2, }, "start": Object { - "column": 36, - "line": 1, + "column": 20, + "line": 2, }, }, "range": Array [ - 36, - 37, + 39, + 40, ], "type": "Punctuator", "value": ")", @@ -109302,17 +111240,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 38, - "line": 1, + "column": 22, + "line": 2, }, "start": Object { - "column": 37, - "line": 1, + "column": 21, + "line": 2, }, }, "range": Array [ - 37, - 38, + 40, + 41, ], "type": "Punctuator", "value": "[", @@ -109320,17 +111258,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 39, - "line": 1, + "column": 23, + "line": 2, }, "start": Object { - "column": 38, - "line": 1, + "column": 22, + "line": 2, }, }, "range": Array [ - 38, - 39, + 41, + 42, ], "type": "Punctuator", "value": "]", @@ -109338,17 +111276,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 41, - "line": 1, + "column": 25, + "line": 2, }, "start": Object { - "column": 40, - "line": 1, + "column": 24, + "line": 2, }, }, "range": Array [ - 40, - 41, + 43, + 44, ], "type": "Punctuator", "value": "?", @@ -109356,17 +111294,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 43, - "line": 1, + "column": 27, + "line": 2, }, "start": Object { - "column": 42, - "line": 1, + "column": 26, + "line": 2, }, }, "range": Array [ - 42, - 43, + 45, + 46, ], "type": "Identifier", "value": "U", @@ -109374,17 +111312,323 @@ Object { Object { "loc": Object { "end": Object { - "column": 45, - "line": 1, + "column": 29, + "line": 2, }, "start": Object { - "column": 44, - "line": 1, + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 53, + 54, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 55, + 62, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 3, + }, + "start": Object { + "column": 14, + "line": 3, + }, + }, + "range": Array [ + 63, + 68, + ], + "type": "Identifier", + "value": "infer", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 3, + }, + "start": Object { + "column": 20, + "line": 3, + }, + }, + "range": Array [ + 69, + 70, + ], + "type": "Identifier", + "value": "U", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 22, + "line": 3, + }, + }, + "range": Array [ + 71, + 72, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 3, + }, + "start": Object { + "column": 24, + "line": 3, + }, + }, + "range": Array [ + 73, + 74, + ], + "type": "Identifier", + "value": "U", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "range": Array [ + 75, + 76, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 4, + }, + "start": Object { + "column": 6, + "line": 4, + }, + }, + "range": Array [ + 83, + 84, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 8, + "line": 4, + }, + }, + "range": Array [ + 85, + 92, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 4, + }, + "start": Object { + "column": 16, + "line": 4, + }, + }, + "range": Array [ + 93, + 100, + ], + "type": "Identifier", + "value": "Promise", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 4, + }, + "start": Object { + "column": 23, + "line": 4, + }, + }, + "range": Array [ + 100, + 101, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 4, + }, + "start": Object { + "column": 24, + "line": 4, + }, + }, + "range": Array [ + 101, + 106, + ], + "type": "Identifier", + "value": "infer", + }, + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 4, + }, + "start": Object { + "column": 30, + "line": 4, + }, + }, + "range": Array [ + 107, + 108, + ], + "type": "Identifier", + "value": "U", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 4, + }, + "start": Object { + "column": 31, + "line": 4, + }, + }, + "range": Array [ + 108, + 109, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 4, + }, + "start": Object { + "column": 33, + "line": 4, + }, + }, + "range": Array [ + 110, + 111, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 4, + }, + "start": Object { + "column": 35, + "line": 4, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "Identifier", + "value": "U", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 4, + }, + "start": Object { + "column": 37, + "line": 4, }, }, "range": Array [ - 44, - 45, + 114, + 115, ], "type": "Punctuator", "value": ":", @@ -109392,17 +111636,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 47, - "line": 1, + "column": 9, + "line": 5, }, "start": Object { - "column": 46, - "line": 1, + "column": 8, + "line": 5, }, }, "range": Array [ - 46, - 47, + 124, + 125, ], "type": "Identifier", "value": "T", @@ -109410,17 +111654,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 48, - "line": 1, + "column": 10, + "line": 5, }, "start": Object { - "column": 47, - "line": 1, + "column": 9, + "line": 5, }, }, "range": Array [ - 47, - 48, + 125, + 126, ], "type": "Punctuator", "value": ";", @@ -109430,14 +111674,14 @@ Object { } `; -exports[`typescript fixtures/types/conditional-infer-nested.src 1`] = ` +exports[`typescript fixtures/types/conditional-infer-simple.src 1`] = ` Object { "body": Array [ Object { "id": Object { "loc": Object { "end": Object { - "column": 13, + "column": 8, "line": 1, }, "start": Object { @@ -109445,17 +111689,17 @@ Object { "line": 1, }, }, - "name": "Unpacked", + "name": "Foo", "range": Array [ 5, - 13, + 8, ], "type": "Identifier", }, "loc": Object { "end": Object { - "column": 10, - "line": 5, + "column": 63, + "line": 1, }, "start": Object { "column": 0, @@ -109464,543 +111708,336 @@ Object { }, "range": Array [ 0, - 126, + 63, ], "type": "TSTypeAliasDeclaration", "typeAnnotation": Object { "checkType": Object { "loc": Object { "end": Object { - "column": 3, - "line": 2, + "column": 15, + "line": 1, }, "start": Object { - "column": 2, - "line": 2, + "column": 14, + "line": 1, }, }, "range": Array [ - 21, - 22, + 14, + 15, ], "type": "TSTypeReference", "typeName": Object { "loc": Object { "end": Object { - "column": 3, - "line": 2, + "column": 15, + "line": 1, }, "start": Object { - "column": 2, - "line": 2, + "column": 14, + "line": 1, }, }, "name": "T", "range": Array [ - 21, - 22, + 14, + 15, ], "type": "Identifier", }, }, "extendsType": Object { - "elementType": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 2, - }, - "start": Object { - "column": 12, - "line": 2, - }, - }, - "range": Array [ - 31, - 40, - ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 2, - }, - "start": Object { - "column": 13, - "line": 2, - }, - }, - "range": Array [ - 32, - 39, - ], - "type": "TSInferType", - "typeParameter": Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 2, - }, - "start": Object { - "column": 19, - "line": 2, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 2, - }, - "start": Object { - "column": 19, - "line": 2, - }, - }, - "name": "U", - "range": Array [ - 38, - 39, - ], - "type": "Identifier", - }, - "range": Array [ - 38, - 39, - ], - "type": "TSTypeParameter", - }, - }, - }, "loc": Object { "end": Object { - "column": 23, - "line": 2, + "column": 50, + "line": 1, }, "start": Object { - "column": 12, - "line": 2, - }, - }, - "range": Array [ - 31, - 42, - ], - "type": "TSArrayType", - }, - "falseType": Object { - "checkType": Object { - "loc": Object { - "end": Object { - "column": 5, - "line": 3, - }, - "start": Object { - "column": 4, - "line": 3, - }, - }, - "range": Array [ - 53, - 54, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 5, - "line": 3, - }, - "start": Object { - "column": 4, - "line": 3, - }, - }, - "name": "T", - "range": Array [ - 53, - 54, - ], - "type": "Identifier", - }, - }, - "extendsType": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 3, - }, - "start": Object { - "column": 14, - "line": 3, - }, - }, - "range": Array [ - 63, - 70, - ], - "type": "TSInferType", - "typeParameter": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 3, - }, - "start": Object { - "column": 20, - "line": 3, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 3, - }, - "start": Object { - "column": 20, - "line": 3, - }, - }, - "name": "U", - "range": Array [ - 69, - 70, - ], - "type": "Identifier", - }, - "range": Array [ - 69, - 70, - ], - "type": "TSTypeParameter", + "column": 24, + "line": 1, }, }, - "falseType": Object { - "checkType": Object { - "loc": Object { - "end": Object { - "column": 7, - "line": 4, - }, - "start": Object { - "column": 6, - "line": 4, - }, - }, - "range": Array [ - 83, - 84, - ], - "type": "TSTypeReference", - "typeName": Object { + "members": Array [ + Object { + "computed": false, + "key": Object { "loc": Object { "end": Object { - "column": 7, - "line": 4, + "column": 27, + "line": 1, }, "start": Object { - "column": 6, - "line": 4, + "column": 26, + "line": 1, }, }, - "name": "T", + "name": "a", "range": Array [ - 83, - 84, + 26, + 27, ], "type": "Identifier", }, - }, - "extendsType": Object { "loc": Object { "end": Object { - "column": 32, - "line": 4, + "column": 37, + "line": 1, }, "start": Object { - "column": 16, - "line": 4, + "column": 26, + "line": 1, }, }, "range": Array [ - 93, - 109, + 26, + 37, ], - "type": "TSTypeReference", - "typeName": Object { + "type": "TSPropertySignature", + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 23, - "line": 4, + "column": 36, + "line": 1, }, "start": Object { - "column": 16, - "line": 4, + "column": 27, + "line": 1, }, }, - "name": "Promise", "range": Array [ - 93, - 100, + 27, + 36, ], - "type": "Identifier", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 32, - "line": 4, - }, - "start": Object { - "column": 23, - "line": 4, + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, }, - }, - "params": Array [ - Object { + "range": Array [ + 29, + 36, + ], + "type": "TSInferType", + "typeParameter": Object { "loc": Object { "end": Object { - "column": 31, - "line": 4, + "column": 36, + "line": 1, }, "start": Object { - "column": 24, - "line": 4, + "column": 35, + "line": 1, }, }, - "range": Array [ - 101, - 108, - ], - "type": "TSInferType", - "typeParameter": Object { + "name": Object { "loc": Object { "end": Object { - "column": 31, - "line": 4, + "column": 36, + "line": 1, }, "start": Object { - "column": 30, - "line": 4, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 31, - "line": 4, - }, - "start": Object { - "column": 30, - "line": 4, - }, + "column": 35, + "line": 1, }, - "name": "U", - "range": Array [ - 107, - 108, - ], - "type": "Identifier", }, + "name": "U", "range": Array [ - 107, - 108, + 35, + 36, ], - "type": "TSTypeParameter", + "type": "Identifier", }, + "range": Array [ + 35, + 36, + ], + "type": "TSTypeParameter", }, - ], - "range": Array [ - 100, - 109, - ], - "type": "TSTypeParameterInstantiation", - }, - }, - "falseType": Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 5, - }, - "start": Object { - "column": 8, - "line": 5, }, }, - "range": Array [ - 124, - 125, - ], - "type": "TSTypeReference", - "typeName": Object { + }, + Object { + "computed": false, + "key": Object { "loc": Object { "end": Object { - "column": 9, - "line": 5, + "column": 39, + "line": 1, }, "start": Object { - "column": 8, - "line": 5, + "column": 38, + "line": 1, }, }, - "name": "T", + "name": "b", "range": Array [ - 124, - 125, + 38, + 39, ], "type": "Identifier", }, - }, - "loc": Object { - "end": Object { - "column": 9, - "line": 5, - }, - "start": Object { - "column": 6, - "line": 4, - }, - }, - "range": Array [ - 83, - 125, - ], - "trueType": Object { "loc": Object { "end": Object { - "column": 36, - "line": 4, + "column": 48, + "line": 1, }, "start": Object { - "column": 35, - "line": 4, + "column": 38, + "line": 1, }, }, "range": Array [ - 112, - 113, + 38, + 48, ], - "type": "TSTypeReference", - "typeName": Object { + "type": "TSPropertySignature", + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 36, - "line": 4, + "column": 48, + "line": 1, }, "start": Object { - "column": 35, - "line": 4, + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 48, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 48, + ], + "type": "TSInferType", + "typeParameter": Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "name": "U", + "range": Array [ + 47, + 48, + ], + "type": "Identifier", + }, + "range": Array [ + 47, + 48, + ], + "type": "TSTypeParameter", }, }, - "name": "U", - "range": Array [ - 112, - 113, - ], - "type": "Identifier", }, }, - "type": "TSConditionalType", - }, + ], + "range": Array [ + 24, + 50, + ], + "type": "TSTypeLiteral", + }, + "falseType": Object { "loc": Object { "end": Object { - "column": 9, - "line": 5, + "column": 62, + "line": 1, }, "start": Object { - "column": 4, - "line": 3, + "column": 57, + "line": 1, }, }, "range": Array [ - 53, - 125, + 57, + 62, ], - "trueType": Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 3, - }, - "start": Object { - "column": 24, - "line": 3, - }, - }, - "range": Array [ - 73, - 74, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 3, - }, - "start": Object { - "column": 24, - "line": 3, - }, - }, - "name": "U", - "range": Array [ - 73, - 74, - ], - "type": "Identifier", - }, - }, - "type": "TSConditionalType", + "type": "TSNeverKeyword", }, "loc": Object { "end": Object { - "column": 9, - "line": 5, + "column": 62, + "line": 1, }, "start": Object { - "column": 2, - "line": 2, + "column": 14, + "line": 1, }, }, "range": Array [ - 21, - 125, + 14, + 62, ], "trueType": Object { "loc": Object { "end": Object { - "column": 27, - "line": 2, + "column": 54, + "line": 1, }, "start": Object { - "column": 26, - "line": 2, + "column": 53, + "line": 1, }, }, "range": Array [ - 45, - 46, + 53, + 54, ], "type": "TSTypeReference", "typeName": Object { "loc": Object { "end": Object { - "column": 27, - "line": 2, + "column": 54, + "line": 1, }, "start": Object { - "column": 26, - "line": 2, + "column": 53, + "line": 1, }, }, "name": "U", "range": Array [ - 45, - 46, + 53, + 54, ], "type": "Identifier", }, @@ -110010,11 +112047,11 @@ Object { "typeParameters": Object { "loc": Object { "end": Object { - "column": 16, + "column": 11, "line": 1, }, "start": Object { - "column": 13, + "column": 8, "line": 1, }, }, @@ -110022,42 +112059,42 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 10, "line": 1, }, "start": Object { - "column": 14, + "column": 9, "line": 1, }, }, "name": Object { "loc": Object { "end": Object { - "column": 15, + "column": 10, "line": 1, }, "start": Object { - "column": 14, + "column": 9, "line": 1, }, }, "name": "T", "range": Array [ - 14, - 15, + 9, + 10, ], "type": "Identifier", }, "range": Array [ - 14, - 15, + 9, + 10, ], "type": "TSTypeParameter", }, ], "range": Array [ - 13, - 16, + 8, + 11, ], "type": "TSTypeParameterDeclaration", }, @@ -110067,7 +112104,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 2, }, "start": Object { "column": 0, @@ -110076,7 +112113,7 @@ Object { }, "range": Array [ 0, - 127, + 64, ], "sourceType": "module", "tokens": Array [ @@ -110101,7 +112138,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 8, "line": 1, }, "start": Object { @@ -110111,25 +112148,25 @@ Object { }, "range": Array [ 5, - 13, + 8, ], "type": "Identifier", - "value": "Unpacked", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 14, + "column": 9, "line": 1, }, "start": Object { - "column": 13, + "column": 8, "line": 1, }, }, "range": Array [ - 13, - 14, + 8, + 9, ], "type": "Punctuator", "value": "<", @@ -110137,17 +112174,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 10, "line": 1, }, "start": Object { - "column": 14, + "column": 9, "line": 1, }, }, "range": Array [ - 14, - 15, + 9, + 10, ], "type": "Identifier", "value": "T", @@ -110155,17 +112192,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 11, "line": 1, }, "start": Object { - "column": 15, + "column": 10, "line": 1, }, }, "range": Array [ - 15, - 16, + 10, + 11, ], "type": "Punctuator", "value": ">", @@ -110173,17 +112210,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 18, + "column": 13, "line": 1, }, "start": Object { - "column": 17, + "column": 12, "line": 1, }, }, "range": Array [ - 17, - 18, + 12, + 13, ], "type": "Punctuator", "value": "=", @@ -110191,17 +112228,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 3, - "line": 2, + "column": 15, + "line": 1, }, "start": Object { - "column": 2, - "line": 2, + "column": 14, + "line": 1, }, }, "range": Array [ - 21, - 22, + 14, + 15, ], "type": "Identifier", "value": "T", @@ -110209,179 +112246,71 @@ Object { Object { "loc": Object { "end": Object { - "column": 11, - "line": 2, + "column": 23, + "line": 1, }, "start": Object { - "column": 4, - "line": 2, + "column": 16, + "line": 1, }, }, "range": Array [ + 16, 23, - 30, ], "type": "Keyword", "value": "extends", }, - Object { - "loc": Object { - "end": Object { - "column": 13, - "line": 2, - }, - "start": Object { - "column": 12, - "line": 2, - }, - }, - "range": Array [ - 31, - 32, - ], - "type": "Punctuator", - "value": "(", - }, - Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 2, - }, - "start": Object { - "column": 13, - "line": 2, - }, - }, - "range": Array [ - 32, - 37, - ], - "type": "Identifier", - "value": "infer", - }, - Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 2, - }, - "start": Object { - "column": 19, - "line": 2, - }, - }, - "range": Array [ - 38, - 39, - ], - "type": "Identifier", - "value": "U", - }, - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 2, - }, - "start": Object { - "column": 20, - "line": 2, - }, - }, - "range": Array [ - 39, - 40, - ], - "type": "Punctuator", - "value": ")", - }, - Object { - "loc": Object { - "end": Object { - "column": 22, - "line": 2, - }, - "start": Object { - "column": 21, - "line": 2, - }, - }, - "range": Array [ - 40, - 41, - ], - "type": "Punctuator", - "value": "[", - }, - Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 2, - }, - "start": Object { - "column": 22, - "line": 2, - }, - }, - "range": Array [ - 41, - 42, - ], - "type": "Punctuator", - "value": "]", - }, Object { "loc": Object { "end": Object { "column": 25, - "line": 2, + "line": 1, }, "start": Object { "column": 24, - "line": 2, + "line": 1, }, }, "range": Array [ - 43, - 44, + 24, + 25, ], "type": "Punctuator", - "value": "?", + "value": "{", }, Object { "loc": Object { "end": Object { "column": 27, - "line": 2, + "line": 1, }, "start": Object { "column": 26, - "line": 2, + "line": 1, }, }, "range": Array [ - 45, - 46, + 26, + 27, ], "type": "Identifier", - "value": "U", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 29, - "line": 2, + "column": 28, + "line": 1, }, "start": Object { - "column": 28, - "line": 2, + "column": 27, + "line": 1, }, }, "range": Array [ - 47, - 48, + 27, + 28, ], "type": "Punctuator", "value": ":", @@ -110389,53 +112318,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 5, - "line": 3, - }, - "start": Object { - "column": 4, - "line": 3, - }, - }, - "range": Array [ - 53, - 54, - ], - "type": "Identifier", - "value": "T", - }, - Object { - "loc": Object { - "end": Object { - "column": 13, - "line": 3, - }, - "start": Object { - "column": 6, - "line": 3, - }, - }, - "range": Array [ - 55, - 62, - ], - "type": "Keyword", - "value": "extends", - }, - Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 3, + "column": 34, + "line": 1, }, "start": Object { - "column": 14, - "line": 3, + "column": 29, + "line": 1, }, }, "range": Array [ - 63, - 68, + 29, + 34, ], "type": "Identifier", "value": "infer", @@ -110443,53 +112336,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 21, - "line": 3, - }, - "start": Object { - "column": 20, - "line": 3, - }, - }, - "range": Array [ - 69, - 70, - ], - "type": "Identifier", - "value": "U", - }, - Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 3, - }, - "start": Object { - "column": 22, - "line": 3, - }, - }, - "range": Array [ - 71, - 72, - ], - "type": "Punctuator", - "value": "?", - }, - Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 3, + "column": 36, + "line": 1, }, "start": Object { - "column": 24, - "line": 3, + "column": 35, + "line": 1, }, }, "range": Array [ - 73, - 74, + 35, + 36, ], "type": "Identifier", "value": "U", @@ -110497,107 +112354,71 @@ Object { Object { "loc": Object { "end": Object { - "column": 27, - "line": 3, + "column": 37, + "line": 1, }, "start": Object { - "column": 26, - "line": 3, + "column": 36, + "line": 1, }, }, "range": Array [ - 75, - 76, + 36, + 37, ], "type": "Punctuator", - "value": ":", - }, - Object { - "loc": Object { - "end": Object { - "column": 7, - "line": 4, - }, - "start": Object { - "column": 6, - "line": 4, - }, - }, - "range": Array [ - 83, - 84, - ], - "type": "Identifier", - "value": "T", - }, - Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 4, - }, - "start": Object { - "column": 8, - "line": 4, - }, - }, - "range": Array [ - 85, - 92, - ], - "type": "Keyword", - "value": "extends", + "value": ",", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 4, + "column": 39, + "line": 1, }, "start": Object { - "column": 16, - "line": 4, + "column": 38, + "line": 1, }, }, "range": Array [ - 93, - 100, + 38, + 39, ], "type": "Identifier", - "value": "Promise", + "value": "b", }, Object { "loc": Object { "end": Object { - "column": 24, - "line": 4, + "column": 40, + "line": 1, }, - "start": Object { - "column": 23, - "line": 4, + "start": Object { + "column": 39, + "line": 1, }, }, "range": Array [ - 100, - 101, + 39, + 40, ], "type": "Punctuator", - "value": "<", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 29, - "line": 4, + "column": 46, + "line": 1, }, "start": Object { - "column": 24, - "line": 4, + "column": 41, + "line": 1, }, }, "range": Array [ - 101, - 106, + 41, + 46, ], "type": "Identifier", "value": "infer", @@ -110605,17 +112426,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 31, - "line": 4, + "column": 48, + "line": 1, }, "start": Object { - "column": 30, - "line": 4, + "column": 47, + "line": 1, }, }, "range": Array [ - 107, - 108, + 47, + 48, ], "type": "Identifier", "value": "U", @@ -110623,35 +112444,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 32, - "line": 4, + "column": 50, + "line": 1, }, "start": Object { - "column": 31, - "line": 4, + "column": 49, + "line": 1, }, }, "range": Array [ - 108, - 109, + 49, + 50, ], "type": "Punctuator", - "value": ">", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 34, - "line": 4, + "column": 52, + "line": 1, }, "start": Object { - "column": 33, - "line": 4, + "column": 51, + "line": 1, }, }, "range": Array [ - 110, - 111, + 51, + 52, ], "type": "Punctuator", "value": "?", @@ -110659,17 +112480,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 36, - "line": 4, + "column": 54, + "line": 1, }, "start": Object { - "column": 35, - "line": 4, + "column": 53, + "line": 1, }, }, "range": Array [ - 112, - 113, + 53, + 54, ], "type": "Identifier", "value": "U", @@ -110677,17 +112498,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 38, - "line": 4, + "column": 56, + "line": 1, }, "start": Object { - "column": 37, - "line": 4, + "column": 55, + "line": 1, }, }, "range": Array [ - 114, - 115, + 55, + 56, ], "type": "Punctuator", "value": ":", @@ -110695,35 +112516,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, - "line": 5, + "column": 62, + "line": 1, }, "start": Object { - "column": 8, - "line": 5, + "column": 57, + "line": 1, }, }, "range": Array [ - 124, - 125, + 57, + 62, ], "type": "Identifier", - "value": "T", + "value": "never", }, Object { "loc": Object { "end": Object { - "column": 10, - "line": 5, + "column": 63, + "line": 1, }, "start": Object { - "column": 9, - "line": 5, + "column": 62, + "line": 1, }, }, "range": Array [ - 125, - 126, + 62, + 63, ], "type": "Punctuator", "value": ";", @@ -110733,430 +112554,166 @@ Object { } `; -exports[`typescript fixtures/types/conditional-infer-simple.src 1`] = ` +exports[`typescript fixtures/types/conditional-with-null.src 1`] = ` Object { "body": Array [ Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "name": "Foo", - "range": Array [ - 5, - 8, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 63, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 63, - ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "checkType": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 14, - "line": 1, - }, - }, - "range": Array [ - 14, - 15, - ], - "type": "TSTypeReference", - "typeName": Object { + "declarations": Array [ + Object { + "id": Object { "loc": Object { "end": Object { - "column": 15, + "column": 45, "line": 1, }, "start": Object { - "column": 14, + "column": 4, "line": 1, }, }, - "name": "T", + "name": "x", "range": Array [ - 14, - 15, + 4, + 45, ], "type": "Identifier", - }, - }, - "extendsType": Object { - "loc": Object { - "end": Object { - "column": 50, - "line": 1, - }, - "start": Object { - "column": 24, - "line": 1, - }, - }, - "members": Array [ - Object { - "computed": false, - "key": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 26, - "line": 1, - }, - }, - "name": "a", - "range": Array [ - 26, - 27, - ], - "type": "Identifier", - }, + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 37, + "column": 45, "line": 1, }, "start": Object { - "column": 26, + "column": 5, "line": 1, }, }, "range": Array [ - 26, - 37, + 5, + 45, ], - "type": "TSPropertySignature", + "type": "TSTypeAnnotation", "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 27, - "line": 1, - }, - }, - "range": Array [ - 27, - 36, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "checkType": Object { "loc": Object { "end": Object { - "column": 36, + "column": 13, "line": 1, }, "start": Object { - "column": 29, + "column": 7, "line": 1, }, }, "range": Array [ - 29, - 36, + 7, + 13, ], - "type": "TSInferType", - "typeParameter": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 35, - "line": 1, - }, + "type": "TSNumberKeyword", + }, + "extendsType": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, }, - "name": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 35, - "line": 1, - }, - }, - "name": "U", - "range": Array [ - 35, - 36, - ], - "type": "Identifier", + "start": Object { + "column": 22, + "line": 1, }, - "range": Array [ - 35, - 36, - ], - "type": "TSTypeParameter", }, + "range": Array [ + 22, + 28, + ], + "type": "TSStringKeyword", }, - }, - }, - Object { - "computed": false, - "key": Object { - "loc": Object { - "end": Object { - "column": 39, - "line": 1, - }, - "start": Object { - "column": 38, - "line": 1, + "falseType": Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, }, + "range": Array [ + 41, + 45, + ], + "type": "TSNullKeyword", }, - "name": "b", - "range": Array [ - 38, - 39, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 38, - "line": 1, - }, - }, - "range": Array [ - 38, - 48, - ], - "type": "TSPropertySignature", - "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 48, + "column": 45, "line": 1, }, "start": Object { - "column": 39, + "column": 7, "line": 1, }, }, "range": Array [ - 39, - 48, + 7, + 45, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "trueType": Object { "loc": Object { "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 41, + "column": 38, "line": 1, }, - }, - "range": Array [ - 41, - 48, - ], - "type": "TSInferType", - "typeParameter": Object { - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 47, - "line": 1, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 47, - "line": 1, - }, - }, - "name": "U", - "range": Array [ - 47, - 48, - ], - "type": "Identifier", - }, - "range": Array [ - 47, - 48, - ], - "type": "TSTypeParameter", - }, - }, - }, - }, - ], - "range": Array [ - 24, - 50, - ], - "type": "TSTypeLiteral", - }, - "falseType": Object { - "loc": Object { - "end": Object { - "column": 62, - "line": 1, - }, - "start": Object { - "column": 57, - "line": 1, - }, - }, - "range": Array [ - 57, - 62, - ], - "type": "TSNeverKeyword", - }, - "loc": Object { - "end": Object { - "column": 62, - "line": 1, - }, - "start": Object { - "column": 14, - "line": 1, - }, - }, - "range": Array [ - 14, - 62, - ], - "trueType": Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 1, - }, - "start": Object { - "column": 53, - "line": 1, - }, - }, - "range": Array [ - 53, - 54, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 1, - }, - "start": Object { - "column": 53, - "line": 1, - }, - }, - "name": "U", - "range": Array [ - 53, - 54, - ], - "type": "Identifier", - }, - }, - "type": "TSConditionalType", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 11, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 38, + ], + "type": "TSBooleanKeyword", }, + "type": "TSConditionalType", }, - "name": "T", - "range": Array [ - 9, - 10, - ], - "type": "Identifier", }, - "range": Array [ - 9, - 10, - ], - "type": "TSTypeParameter", }, - ], - "range": Array [ - 8, - 11, - ], - "type": "TSTypeParameterDeclaration", + "init": null, + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 45, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, }, + "range": Array [ + 0, + 46, + ], + "type": "VariableDeclaration", }, ], "comments": Array [], @@ -111172,14 +112729,14 @@ Object { }, "range": Array [ 0, - 64, + 47, ], "sourceType": "module", "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 4, + "column": 3, "line": 1, }, "start": Object { @@ -111189,15 +112746,33 @@ Object { }, "range": Array [ 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ 4, + 5, ], "type": "Identifier", - "value": "type", + "value": "x", }, Object { "loc": Object { "end": Object { - "column": 8, + "column": 6, "line": 1, }, "start": Object { @@ -111207,169 +112782,462 @@ Object { }, "range": Array [ 5, - 8, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 13, ], "type": "Identifier", - "value": "Foo", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 9, + "column": 21, "line": 1, }, "start": Object { - "column": 8, + "column": 14, "line": 1, }, }, "range": Array [ - 8, - 9, + 14, + 21, ], - "type": "Punctuator", - "value": "<", + "type": "Keyword", + "value": "extends", }, Object { "loc": Object { "end": Object { - "column": 10, + "column": 28, "line": 1, }, "start": Object { - "column": 9, + "column": 22, "line": 1, }, }, "range": Array [ - 9, - 10, + 22, + 28, ], "type": "Identifier", - "value": "T", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 11, + "column": 30, "line": 1, }, "start": Object { - "column": 10, + "column": 29, "line": 1, }, }, "range": Array [ - 10, - 11, + 29, + 30, ], "type": "Punctuator", - "value": ">", + "value": "?", }, Object { "loc": Object { "end": Object { - "column": 13, + "column": 38, "line": 1, }, "start": Object { - "column": 12, + "column": 31, "line": 1, }, }, "range": Array [ - 12, - 13, + 31, + 38, ], - "type": "Punctuator", - "value": "=", + "type": "Identifier", + "value": "boolean", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 40, "line": 1, }, "start": Object { - "column": 14, + "column": 39, "line": 1, }, }, "range": Array [ - 14, - 15, + 39, + 40, ], - "type": "Identifier", - "value": "T", + "type": "Punctuator", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 23, + "column": 45, "line": 1, }, "start": Object { - "column": 16, + "column": 41, "line": 1, }, }, "range": Array [ - 16, - 23, + 41, + 45, ], "type": "Keyword", - "value": "extends", + "value": "null", }, Object { "loc": Object { "end": Object { - "column": 25, + "column": 46, "line": 1, }, "start": Object { - "column": 24, + "column": 45, "line": 1, }, }, "range": Array [ - 24, - 25, + 45, + 46, ], "type": "Punctuator", - "value": "{", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/constructor.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "f", + "range": Array [ + 4, + 42, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 42, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 12, + 21, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 21, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 21, + ], + "type": "TSNumberKeyword", + }, + }, + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "name": "b", + "optional": true, + "range": Array [ + 23, + 33, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 33, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 33, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 7, + 42, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 42, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 38, + "line": 1, + }, + }, + "range": Array [ + 38, + 42, + ], + "type": "TSVoidKeyword", + }, + }, + "type": "TSConstructorType", + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 42, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 43, + ], + "type": "VariableDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, }, + }, + "range": Array [ + 0, + 44, + ], + "sourceType": "module", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 27, + "column": 3, "line": 1, }, "start": Object { - "column": 26, + "column": 0, "line": 1, }, }, "range": Array [ - 26, - 27, + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, ], "type": "Identifier", - "value": "a", + "value": "f", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 6, "line": 1, }, "start": Object { - "column": 27, + "column": 5, "line": 1, }, }, "range": Array [ - 27, - 28, + 5, + 6, ], "type": "Punctuator", "value": ":", @@ -111377,233 +113245,251 @@ Object { Object { "loc": Object { "end": Object { - "column": 34, + "column": 10, "line": 1, }, "start": Object { - "column": 29, + "column": 7, "line": 1, }, }, "range": Array [ - 29, - 34, + 7, + 10, ], - "type": "Identifier", - "value": "infer", + "type": "Keyword", + "value": "new", }, Object { "loc": Object { "end": Object { - "column": 36, + "column": 12, "line": 1, }, "start": Object { - "column": 35, + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, "line": 1, }, }, "range": Array [ - 35, - 36, + 12, + 13, ], "type": "Identifier", - "value": "U", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 37, + "column": 14, "line": 1, }, "start": Object { - "column": 36, + "column": 13, "line": 1, }, }, "range": Array [ - 36, - 37, + 13, + 14, ], "type": "Punctuator", - "value": ",", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 39, + "column": 21, "line": 1, }, "start": Object { - "column": 38, + "column": 15, "line": 1, }, }, "range": Array [ - 38, - 39, + 15, + 21, ], "type": "Identifier", - "value": "b", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 40, + "column": 22, "line": 1, }, "start": Object { - "column": 39, + "column": 21, "line": 1, }, }, "range": Array [ - 39, - 40, + 21, + 22, ], "type": "Punctuator", - "value": ":", + "value": ",", }, Object { "loc": Object { "end": Object { - "column": 46, + "column": 24, "line": 1, }, "start": Object { - "column": 41, + "column": 23, "line": 1, }, }, "range": Array [ - 41, - 46, + 23, + 24, ], "type": "Identifier", - "value": "infer", + "value": "b", }, Object { "loc": Object { "end": Object { - "column": 48, + "column": 25, "line": 1, }, "start": Object { - "column": 47, + "column": 24, "line": 1, }, }, "range": Array [ - 47, - 48, + 24, + 25, ], - "type": "Identifier", - "value": "U", + "type": "Punctuator", + "value": "?", }, Object { "loc": Object { "end": Object { - "column": 50, + "column": 26, "line": 1, }, "start": Object { - "column": 49, + "column": 25, "line": 1, }, }, "range": Array [ - 49, - 50, + 25, + 26, ], "type": "Punctuator", - "value": "}", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 52, + "column": 33, "line": 1, }, "start": Object { - "column": 51, + "column": 27, "line": 1, }, }, "range": Array [ - 51, - 52, + 27, + 33, ], - "type": "Punctuator", - "value": "?", + "type": "Identifier", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 54, + "column": 34, "line": 1, }, "start": Object { - "column": 53, + "column": 33, "line": 1, }, }, "range": Array [ - 53, - 54, + 33, + 34, ], - "type": "Identifier", - "value": "U", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 56, + "column": 37, "line": 1, }, "start": Object { - "column": 55, + "column": 35, "line": 1, }, }, "range": Array [ - 55, - 56, + 35, + 37, ], "type": "Punctuator", - "value": ":", + "value": "=>", }, Object { "loc": Object { "end": Object { - "column": 62, + "column": 42, "line": 1, }, "start": Object { - "column": 57, + "column": 38, "line": 1, }, }, "range": Array [ - 57, - 62, + 38, + 42, ], - "type": "Identifier", - "value": "never", + "type": "Keyword", + "value": "void", }, Object { "loc": Object { "end": Object { - "column": 63, + "column": 43, "line": 1, }, "start": Object { - "column": 62, + "column": 42, "line": 1, }, }, "range": Array [ - 62, - 63, + 42, + 43, ], "type": "Punctuator", "value": ";", @@ -111613,7 +113499,7 @@ Object { } `; -exports[`typescript fixtures/types/conditional-with-null.src 1`] = ` +exports[`typescript fixtures/types/constructor-generic.src 1`] = ` Object { "body": Array [ Object { @@ -111622,7 +113508,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 45, + "column": 25, "line": 1, }, "start": Object { @@ -111630,16 +113516,16 @@ Object { "line": 1, }, }, - "name": "x", + "name": "f", "range": Array [ 4, - 45, + 25, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 45, + "column": 25, "line": 1, }, "start": Object { @@ -111649,100 +113535,210 @@ Object { }, "range": Array [ 5, - 45, + 25, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { - "checkType": Object { - "loc": Object { - "end": Object { - "column": 13, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, }, - "range": Array [ - 7, - 13, - ], - "type": "TSNumberKeyword", }, - "extendsType": Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 1, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, }, - "start": Object { - "column": 22, - "line": 1, + "name": "a", + "range": Array [ + 15, + 19, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 19, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 18, + 19, + ], + "type": "Identifier", + }, + }, }, }, - "range": Array [ - 22, - 28, - ], - "type": "TSStringKeyword", - }, - "falseType": Object { + ], + "range": Array [ + 7, + 25, + ], + "returnType": Object { "loc": Object { "end": Object { - "column": 45, + "column": 25, "line": 1, }, "start": Object { - "column": 41, + "column": 21, "line": 1, }, }, "range": Array [ - 41, - 45, + 21, + 25, ], - "type": "TSNullKeyword", - }, - "loc": Object { - "end": Object { - "column": 45, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 24, + 25, + ], + "type": "Identifier", + }, }, }, - "range": Array [ - 7, - 45, - ], - "trueType": Object { + "type": "TSConstructorType", + "typeParameters": Object { "loc": Object { "end": Object { - "column": 38, + "column": 14, "line": 1, }, "start": Object { - "column": 31, + "column": 11, "line": 1, }, }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 12, + 13, + ], + "type": "Identifier", + }, + "range": Array [ + 12, + 13, + ], + "type": "TSTypeParameter", + }, + ], "range": Array [ - 31, - 38, + 11, + 14, ], - "type": "TSBooleanKeyword", + "type": "TSTypeParameterDeclaration", }, - "type": "TSConditionalType", }, }, }, "init": null, "loc": Object { "end": Object { - "column": 45, + "column": 25, "line": 1, }, "start": Object { @@ -111752,7 +113748,7 @@ Object { }, "range": Array [ 4, - 45, + 25, ], "type": "VariableDeclarator", }, @@ -111760,7 +113756,7 @@ Object { "kind": "let", "loc": Object { "end": Object { - "column": 46, + "column": 26, "line": 1, }, "start": Object { @@ -111770,7 +113766,7 @@ Object { }, "range": Array [ 0, - 46, + 26, ], "type": "VariableDeclaration", }, @@ -111788,7 +113784,7 @@ Object { }, "range": Array [ 0, - 47, + 27, ], "sourceType": "module", "tokens": Array [ @@ -111826,7 +113822,7 @@ Object { 5, ], "type": "Identifier", - "value": "x", + "value": "f", }, Object { "loc": Object { @@ -111849,7 +113845,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 10, "line": 1, }, "start": Object { @@ -111859,15 +113855,69 @@ Object { }, "range": Array [ 7, + 10, + ], + "type": "Keyword", + "value": "new", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, 13, ], "type": "Identifier", - "value": "number", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, "line": 1, }, "start": Object { @@ -111877,115 +113927,133 @@ Object { }, "range": Array [ 14, - 21, + 15, ], - "type": "Keyword", - "value": "extends", + "type": "Punctuator", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 16, "line": 1, }, "start": Object { - "column": 22, + "column": 15, "line": 1, }, }, "range": Array [ - 22, - 28, + 15, + 16, ], "type": "Identifier", - "value": "string", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 30, + "column": 17, "line": 1, }, "start": Object { - "column": 29, + "column": 16, "line": 1, }, }, "range": Array [ - 29, - 30, + 16, + 17, ], "type": "Punctuator", - "value": "?", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 38, + "column": 19, "line": 1, }, "start": Object { - "column": 31, + "column": 18, "line": 1, }, }, "range": Array [ - 31, - 38, + 18, + 19, ], "type": "Identifier", - "value": "boolean", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 40, + "column": 20, "line": 1, }, "start": Object { - "column": 39, + "column": 19, "line": 1, }, }, "range": Array [ - 39, - 40, + 19, + 20, ], "type": "Punctuator", - "value": ":", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 45, + "column": 23, "line": 1, }, "start": Object { - "column": 41, + "column": 21, "line": 1, }, }, "range": Array [ - 41, - 45, + 21, + 23, ], - "type": "Keyword", - "value": "null", + "type": "Punctuator", + "value": "=>", }, Object { "loc": Object { "end": Object { - "column": 46, + "column": 25, "line": 1, }, "start": Object { - "column": 45, + "column": 24, "line": 1, }, }, "range": Array [ - 45, - 46, + 24, + 25, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, ], "type": "Punctuator", "value": ";", @@ -111995,7 +114063,7 @@ Object { } `; -exports[`typescript fixtures/types/constructor.src 1`] = ` +exports[`typescript fixtures/types/constructor-in-generic.src 1`] = ` Object { "body": Array [ Object { @@ -112004,7 +114072,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 42, + "column": 30, "line": 1, }, "start": Object { @@ -112012,16 +114080,16 @@ Object { "line": 1, }, }, - "name": "f", + "name": "x", "range": Array [ 4, - 42, + 30, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 42, + "column": 30, "line": 1, }, "start": Object { @@ -112031,13 +114099,13 @@ Object { }, "range": Array [ 5, - 42, + 30, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 42, + "column": 30, "line": 1, }, "start": Object { @@ -112045,28 +114113,45 @@ Object { "line": 1, }, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, + "range": Array [ + 7, + 30, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, }, - "name": "a", - "range": Array [ - 12, - 21, - ], - "type": "Identifier", - "typeAnnotation": Object { + "start": Object { + "column": 7, + "line": 1, + }, + }, + "name": "Array", + "range": Array [ + 7, + 12, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 21, + "column": 29, "line": 1, }, "start": Object { @@ -112074,130 +114159,61 @@ Object { "line": 1, }, }, + "params": Array [], "range": Array [ 13, - 21, + 29, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { - "column": 21, + "column": 29, "line": 1, }, "start": Object { - "column": 15, + "column": 20, "line": 1, }, }, "range": Array [ - 15, - 21, + 20, + 29, ], - "type": "TSNumberKeyword", - }, - }, - }, - Object { - "loc": Object { - "end": Object { - "column": 33, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "name": "b", - "optional": true, - "range": Array [ - 23, - 33, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 33, - "line": 1, - }, - "start": Object { - "column": 25, - "line": 1, - }, - }, - "range": Array [ - 25, - 33, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 33, - "line": 1, - }, - "start": Object { - "column": 27, - "line": 1, + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, }, + "range": Array [ + 23, + 29, + ], + "type": "TSStringKeyword", }, - "range": Array [ - 27, - 33, - ], - "type": "TSNumberKeyword", }, + "type": "TSConstructorType", }, - }, - ], - "range": Array [ - 7, - 42, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 42, - "line": 1, - }, - "start": Object { - "column": 35, - "line": 1, - }, - }, + ], "range": Array [ - 35, - 42, + 12, + 30, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 42, - "line": 1, - }, - "start": Object { - "column": 38, - "line": 1, - }, - }, - "range": Array [ - 38, - 42, - ], - "type": "TSVoidKeyword", - }, + "type": "TSTypeParameterInstantiation", }, - "type": "TSConstructorType", }, }, }, "init": null, "loc": Object { "end": Object { - "column": 42, + "column": 30, "line": 1, }, "start": Object { @@ -112207,7 +114223,7 @@ Object { }, "range": Array [ 4, - 42, + 30, ], "type": "VariableDeclarator", }, @@ -112215,7 +114231,7 @@ Object { "kind": "let", "loc": Object { "end": Object { - "column": 43, + "column": 31, "line": 1, }, "start": Object { @@ -112225,7 +114241,7 @@ Object { }, "range": Array [ 0, - 43, + 31, ], "type": "VariableDeclaration", }, @@ -112243,7 +114259,7 @@ Object { }, "range": Array [ 0, - 44, + 32, ], "sourceType": "module", "tokens": Array [ @@ -112281,7 +114297,7 @@ Object { 5, ], "type": "Identifier", - "value": "f", + "value": "x", }, Object { "loc": Object { @@ -112304,7 +114320,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 10, + "column": 12, "line": 1, }, "start": Object { @@ -112314,28 +114330,10 @@ Object { }, "range": Array [ 7, - 10, - ], - "type": "Keyword", - "value": "new", - }, - Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, 12, ], - "type": "Punctuator", - "value": "(", + "type": "Identifier", + "value": "Array", }, Object { "loc": Object { @@ -112352,13 +114350,13 @@ Object { 12, 13, ], - "type": "Identifier", - "value": "a", + "type": "Punctuator", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 14, + "column": 16, "line": 1, }, "start": Object { @@ -112368,187 +114366,115 @@ Object { }, "range": Array [ 13, - 14, - ], - "type": "Punctuator", - "value": ":", - }, - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, - }, - }, - "range": Array [ - 15, - 21, + 16, ], - "type": "Identifier", - "value": "number", + "type": "Keyword", + "value": "new", }, Object { "loc": Object { "end": Object { - "column": 22, + "column": 18, "line": 1, }, "start": Object { - "column": 21, + "column": 17, "line": 1, }, }, "range": Array [ - 21, - 22, + 17, + 18, ], "type": "Punctuator", - "value": ",", - }, - Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "range": Array [ - 23, - 24, - ], - "type": "Identifier", - "value": "b", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 25, + "column": 19, "line": 1, }, "start": Object { - "column": 24, + "column": 18, "line": 1, }, }, "range": Array [ - 24, - 25, + 18, + 19, ], "type": "Punctuator", - "value": "?", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 26, + "column": 22, "line": 1, }, "start": Object { - "column": 25, + "column": 20, "line": 1, }, }, "range": Array [ - 25, - 26, + 20, + 22, ], "type": "Punctuator", - "value": ":", + "value": "=>", }, Object { "loc": Object { "end": Object { - "column": 33, + "column": 29, "line": 1, }, "start": Object { - "column": 27, + "column": 23, "line": 1, }, }, "range": Array [ - 27, - 33, + 23, + 29, ], "type": "Identifier", - "value": "number", - }, - Object { - "loc": Object { - "end": Object { - "column": 34, - "line": 1, - }, - "start": Object { - "column": 33, - "line": 1, - }, - }, - "range": Array [ - 33, - 34, - ], - "type": "Punctuator", - "value": ")", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 37, + "column": 30, "line": 1, }, "start": Object { - "column": 35, + "column": 29, "line": 1, }, }, "range": Array [ - 35, - 37, + 29, + 30, ], "type": "Punctuator", - "value": "=>", - }, - Object { - "loc": Object { - "end": Object { - "column": 42, - "line": 1, - }, - "start": Object { - "column": 38, - "line": 1, - }, - }, - "range": Array [ - 38, - 42, - ], - "type": "Keyword", - "value": "void", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 43, + "column": 31, "line": 1, }, "start": Object { - "column": 42, + "column": 30, "line": 1, }, }, "range": Array [ - 42, - 43, + 30, + 31, ], "type": "Punctuator", "value": ";", @@ -112558,7 +114484,7 @@ Object { } `; -exports[`typescript fixtures/types/constructor-generic.src 1`] = ` +exports[`typescript fixtures/types/constructor-with-rest.src 1`] = ` Object { "body": Array [ Object { @@ -112567,7 +114493,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 25, + "column": 35, "line": 1, }, "start": Object { @@ -112578,13 +114504,13 @@ Object { "name": "f", "range": Array [ 4, - 25, + 35, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 25, + "column": 35, "line": 1, }, "start": Object { @@ -112594,13 +114520,13 @@ Object { }, "range": Array [ 5, - 25, + 35, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 25, + "column": 35, "line": 1, }, "start": Object { @@ -112610,194 +114536,138 @@ Object { }, "params": Array [ Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, - }, - }, - "name": "a", - "range": Array [ - 15, - 19, - ], - "type": "Identifier", - "typeAnnotation": Object { + "argument": Object { "loc": Object { "end": Object { - "column": 19, + "column": 16, "line": 1, }, "start": Object { - "column": 16, + "column": 15, "line": 1, }, }, + "name": "a", "range": Array [ + 15, 16, - 19, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 1, - }, - "start": Object { - "column": 18, - "line": 1, - }, - }, - "range": Array [ - 18, - 19, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 1, - }, - "start": Object { - "column": 18, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 18, - 19, - ], - "type": "Identifier", - }, - }, - }, - }, - ], - "range": Array [ - 7, - 25, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 1, - }, - "start": Object { - "column": 21, - "line": 1, + "type": "Identifier", }, - }, - "range": Array [ - 21, - 25, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 25, + "column": 26, "line": 1, }, "start": Object { - "column": 24, + "column": 12, "line": 1, }, }, "range": Array [ - 24, - 25, + 12, + 26, ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 1, - }, - "start": Object { - "column": 24, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 24, - 25, - ], - "type": "Identifier", - }, - }, - }, - "type": "TSConstructorType", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 14, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "params": Array [ - Object { + "type": "RestElement", + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 13, + "column": 26, "line": 1, }, "start": Object { - "column": 12, + "column": 16, "line": 1, }, }, - "name": Object { + "range": Array [ + 16, + 26, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "elementType": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 24, + ], + "type": "TSNumberKeyword", + }, "loc": Object { "end": Object { - "column": 13, + "column": 26, "line": 1, }, "start": Object { - "column": 12, + "column": 18, "line": 1, }, }, - "name": "T", "range": Array [ - 12, - 13, + 18, + 26, ], - "type": "Identifier", + "type": "TSArrayType", }, - "range": Array [ - 12, - 13, - ], - "type": "TSTypeParameter", }, - ], + }, + ], + "range": Array [ + 7, + 35, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, "range": Array [ - 11, - 14, + 28, + 35, ], - "type": "TSTypeParameterDeclaration", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 35, + ], + "type": "TSVoidKeyword", + }, }, + "type": "TSConstructorType", }, }, }, "init": null, "loc": Object { "end": Object { - "column": 25, + "column": 35, "line": 1, }, "start": Object { @@ -112807,7 +114677,7 @@ Object { }, "range": Array [ 4, - 25, + 35, ], "type": "VariableDeclarator", }, @@ -112815,7 +114685,7 @@ Object { "kind": "let", "loc": Object { "end": Object { - "column": 26, + "column": 36, "line": 1, }, "start": Object { @@ -112825,7 +114695,7 @@ Object { }, "range": Array [ 0, - 26, + 36, ], "type": "VariableDeclaration", }, @@ -112843,7 +114713,7 @@ Object { }, "range": Array [ 0, - 27, + 37, ], "sourceType": "module", "tokens": Array [ @@ -112935,12 +114805,12 @@ Object { 12, ], "type": "Punctuator", - "value": "<", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 13, + "column": 15, "line": 1, }, "start": Object { @@ -112950,115 +114820,115 @@ Object { }, "range": Array [ 12, - 13, + 15, ], - "type": "Identifier", - "value": "T", + "type": "Punctuator", + "value": "...", }, Object { "loc": Object { "end": Object { - "column": 14, + "column": 16, "line": 1, }, "start": Object { - "column": 13, + "column": 15, "line": 1, }, }, "range": Array [ - 13, - 14, + 15, + 16, ], - "type": "Punctuator", - "value": ">", + "type": "Identifier", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 17, "line": 1, }, "start": Object { - "column": 14, + "column": 16, "line": 1, }, }, "range": Array [ - 14, - 15, + 16, + 17, ], "type": "Punctuator", - "value": "(", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 24, "line": 1, }, "start": Object { - "column": 15, + "column": 18, "line": 1, }, }, "range": Array [ - 15, - 16, + 18, + 24, ], "type": "Identifier", - "value": "a", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 25, "line": 1, }, "start": Object { - "column": 16, + "column": 24, "line": 1, }, }, "range": Array [ - 16, - 17, + 24, + 25, ], "type": "Punctuator", - "value": ":", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 19, + "column": 26, "line": 1, }, "start": Object { - "column": 18, + "column": 25, "line": 1, }, }, "range": Array [ - 18, - 19, + 25, + 26, ], - "type": "Identifier", - "value": "T", + "type": "Punctuator", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 27, "line": 1, }, "start": Object { - "column": 19, + "column": 26, "line": 1, }, }, "range": Array [ - 19, - 20, + 26, + 27, ], "type": "Punctuator", "value": ")", @@ -113066,17 +114936,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 23, + "column": 30, "line": 1, }, "start": Object { - "column": 21, + "column": 28, "line": 1, }, }, "range": Array [ - 21, - 23, + 28, + 30, ], "type": "Punctuator", "value": "=>", @@ -113084,35 +114954,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 25, + "column": 35, "line": 1, }, "start": Object { - "column": 24, + "column": 31, "line": 1, }, }, "range": Array [ - 24, - 25, + 31, + 35, ], - "type": "Identifier", - "value": "T", + "type": "Keyword", + "value": "void", }, Object { "loc": Object { "end": Object { - "column": 26, + "column": 36, "line": 1, }, "start": Object { - "column": 25, + "column": 35, "line": 1, }, }, "range": Array [ - 25, - 26, + 35, + 36, ], "type": "Punctuator", "value": ";", @@ -113122,7 +114992,7 @@ Object { } `; -exports[`typescript fixtures/types/constructor-in-generic.src 1`] = ` +exports[`typescript fixtures/types/function.src 1`] = ` Object { "body": Array [ Object { @@ -113131,7 +115001,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 30, + "column": 38, "line": 1, }, "start": Object { @@ -113139,16 +115009,16 @@ Object { "line": 1, }, }, - "name": "x", + "name": "f", "range": Array [ 4, - 30, + 38, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 30, + "column": 38, "line": 1, }, "start": Object { @@ -113158,13 +115028,13 @@ Object { }, "range": Array [ 5, - 30, + 38, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 30, + "column": 38, "line": 1, }, "start": Object { @@ -113172,107 +115042,159 @@ Object { "line": 1, }, }, - "range": Array [ - 7, - 30, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 1, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, }, - "start": Object { - "column": 7, - "line": 1, + "name": "a", + "range": Array [ + 8, + 17, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 17, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSNumberKeyword", + }, }, }, - "name": "Array", - "range": Array [ - 7, - 12, - ], - "type": "Identifier", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, }, - }, - "params": Array [ - Object { + "name": "b", + "optional": true, + "range": Array [ + 19, + 29, + ], + "type": "Identifier", + "typeAnnotation": Object { "loc": Object { "end": Object { "column": 29, "line": 1, }, "start": Object { - "column": 13, + "column": 21, "line": 1, }, }, - "params": Array [], "range": Array [ - 13, + 21, 29, ], - "returnType": Object { + "type": "TSTypeAnnotation", + "typeAnnotation": Object { "loc": Object { "end": Object { "column": 29, "line": 1, }, "start": Object { - "column": 20, + "column": 23, "line": 1, }, }, "range": Array [ - 20, + 23, 29, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 29, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "range": Array [ - 23, - 29, - ], - "type": "TSStringKeyword", - }, + "type": "TSNumberKeyword", }, - "type": "TSConstructorType", }, - ], + }, + ], + "range": Array [ + 7, + 38, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, "range": Array [ - 12, - 30, + 31, + 38, ], - "type": "TSTypeParameterInstantiation", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "range": Array [ + 34, + 38, + ], + "type": "TSVoidKeyword", + }, }, + "type": "TSFunctionType", }, }, }, "init": null, "loc": Object { "end": Object { - "column": 30, + "column": 38, "line": 1, }, "start": Object { @@ -113282,7 +115204,7 @@ Object { }, "range": Array [ 4, - 30, + 38, ], "type": "VariableDeclarator", }, @@ -113290,7 +115212,7 @@ Object { "kind": "let", "loc": Object { "end": Object { - "column": 31, + "column": 39, "line": 1, }, "start": Object { @@ -113300,7 +115222,7 @@ Object { }, "range": Array [ 0, - 31, + 39, ], "type": "VariableDeclaration", }, @@ -113318,7 +115240,7 @@ Object { }, "range": Array [ 0, - 32, + 40, ], "sourceType": "module", "tokens": Array [ @@ -113356,7 +115278,7 @@ Object { 5, ], "type": "Identifier", - "value": "x", + "value": "f", }, Object { "loc": Object { @@ -113379,7 +115301,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 12, + "column": 8, "line": 1, }, "start": Object { @@ -113389,46 +115311,64 @@ Object { }, "range": Array [ 7, - 12, + 8, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, ], "type": "Identifier", - "value": "Array", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 13, + "column": 10, "line": 1, }, "start": Object { - "column": 12, + "column": 9, "line": 1, }, }, "range": Array [ - 12, - 13, + 9, + 10, ], "type": "Punctuator", - "value": "<", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 17, "line": 1, }, "start": Object { - "column": 13, + "column": 11, "line": 1, }, }, "range": Array [ - 13, - 16, + 11, + 17, ], - "type": "Keyword", - "value": "new", + "type": "Identifier", + "value": "number", }, Object { "loc": Object { @@ -113446,30 +115386,30 @@ Object { 18, ], "type": "Punctuator", - "value": "(", + "value": ",", }, Object { "loc": Object { "end": Object { - "column": 19, + "column": 20, "line": 1, }, "start": Object { - "column": 18, + "column": 19, "line": 1, }, }, "range": Array [ - 18, 19, + 20, ], - "type": "Punctuator", - "value": ")", + "type": "Identifier", + "value": "b", }, Object { "loc": Object { "end": Object { - "column": 22, + "column": 21, "line": 1, }, "start": Object { @@ -113479,10 +115419,28 @@ Object { }, "range": Array [ 20, + 21, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, 22, ], "type": "Punctuator", - "value": "=>", + "value": ":", }, Object { "loc": Object { @@ -113500,7 +115458,7 @@ Object { 29, ], "type": "Identifier", - "value": "string", + "value": "number", }, Object { "loc": Object { @@ -113517,23 +115475,59 @@ Object { 29, 30, ], - "type": "Punctuator", - "value": ">", + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 33, + ], + "type": "Punctuator", + "value": "=>", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "range": Array [ + 34, + 38, + ], + "type": "Keyword", + "value": "void", }, Object { "loc": Object { "end": Object { - "column": 31, + "column": 39, "line": 1, }, "start": Object { - "column": 30, + "column": 38, "line": 1, }, }, "range": Array [ - 30, - 31, + 38, + 39, ], "type": "Punctuator", "value": ";", @@ -113543,7 +115537,7 @@ Object { } `; -exports[`typescript fixtures/types/constructor-with-rest.src 1`] = ` +exports[`typescript fixtures/types/function-generic.src 1`] = ` Object { "body": Array [ Object { @@ -113552,7 +115546,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { @@ -113563,13 +115557,13 @@ Object { "name": "f", "range": Array [ 4, - 35, + 21, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { @@ -113579,13 +115573,13 @@ Object { }, "range": Array [ 5, - 35, + 21, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { @@ -113595,138 +115589,194 @@ Object { }, "params": Array [ Object { - "argument": Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, - }, - }, - "name": "a", - "range": Array [ - 15, - 16, - ], - "type": "Identifier", - }, "loc": Object { "end": Object { - "column": 26, + "column": 15, "line": 1, }, "start": Object { - "column": 12, + "column": 11, "line": 1, }, }, + "name": "a", "range": Array [ - 12, - 26, + 11, + 15, ], - "type": "RestElement", + "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 26, + "column": 15, "line": 1, }, "start": Object { - "column": 16, + "column": 12, "line": 1, }, }, "range": Array [ - 16, - 26, + 12, + 15, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { - "elementType": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "TSTypeReference", + "typeName": Object { "loc": Object { "end": Object { - "column": 24, + "column": 15, "line": 1, }, "start": Object { - "column": 18, + "column": 14, "line": 1, }, }, + "name": "T", "range": Array [ - 18, - 24, + 14, + 15, ], - "type": "TSNumberKeyword", - }, - "loc": Object { - "end": Object { - "column": 26, - "line": 1, - }, - "start": Object { - "column": 18, - "line": 1, - }, + "type": "Identifier", }, - "range": Array [ - 18, - 26, - ], - "type": "TSArrayType", }, }, }, ], "range": Array [ 7, - 35, + 21, ], "returnType": Object { "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { - "column": 28, + "column": 17, "line": 1, }, }, "range": Array [ - 28, - 35, + 17, + 21, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { - "column": 31, + "column": 20, "line": 1, }, }, "range": Array [ - 31, - 35, + 20, + 21, ], - "type": "TSVoidKeyword", + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + }, }, }, - "type": "TSConstructorType", + "type": "TSFunctionType", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 8, + 9, + ], + "type": "Identifier", + }, + "range": Array [ + 8, + 9, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 7, + 10, + ], + "type": "TSTypeParameterDeclaration", + }, }, }, }, "init": null, "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { @@ -113736,7 +115786,7 @@ Object { }, "range": Array [ 4, - 35, + 21, ], "type": "VariableDeclarator", }, @@ -113744,7 +115794,7 @@ Object { "kind": "let", "loc": Object { "end": Object { - "column": 36, + "column": 22, "line": 1, }, "start": Object { @@ -113754,7 +115804,7 @@ Object { }, "range": Array [ 0, - 36, + 22, ], "type": "VariableDeclaration", }, @@ -113772,7 +115822,7 @@ Object { }, "range": Array [ 0, - 37, + 23, ], "sourceType": "module", "tokens": Array [ @@ -113833,7 +115883,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 10, + "column": 8, "line": 1, }, "start": Object { @@ -113843,151 +115893,133 @@ Object { }, "range": Array [ 7, - 10, - ], - "type": "Keyword", - "value": "new", - }, - Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, - 12, + 8, ], "type": "Punctuator", - "value": "(", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 9, "line": 1, }, "start": Object { - "column": 12, + "column": 8, "line": 1, }, }, "range": Array [ - 12, - 15, + 8, + 9, ], - "type": "Punctuator", - "value": "...", + "type": "Identifier", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 10, "line": 1, }, "start": Object { - "column": 15, + "column": 9, "line": 1, }, }, "range": Array [ - 15, - 16, + 9, + 10, ], - "type": "Identifier", - "value": "a", + "type": "Punctuator", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 11, "line": 1, }, "start": Object { - "column": 16, + "column": 10, "line": 1, }, }, "range": Array [ - 16, - 17, + 10, + 11, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 24, + "column": 12, "line": 1, }, "start": Object { - "column": 18, + "column": 11, "line": 1, }, }, "range": Array [ - 18, - 24, + 11, + 12, ], "type": "Identifier", - "value": "number", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 25, + "column": 13, "line": 1, }, "start": Object { - "column": 24, + "column": 12, "line": 1, }, }, "range": Array [ - 24, - 25, + 12, + 13, ], "type": "Punctuator", - "value": "[", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 26, + "column": 15, "line": 1, }, "start": Object { - "column": 25, + "column": 14, "line": 1, }, }, "range": Array [ - 25, - 26, + 14, + 15, ], - "type": "Punctuator", - "value": "]", + "type": "Identifier", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 27, + "column": 16, "line": 1, }, "start": Object { - "column": 26, + "column": 15, "line": 1, }, }, "range": Array [ - 26, - 27, + 15, + 16, ], "type": "Punctuator", "value": ")", @@ -113995,17 +116027,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 30, + "column": 19, "line": 1, }, "start": Object { - "column": 28, + "column": 17, "line": 1, }, }, "range": Array [ - 28, - 30, + 17, + 19, ], "type": "Punctuator", "value": "=>", @@ -114013,35 +116045,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { - "column": 31, + "column": 20, "line": 1, }, }, "range": Array [ - 31, - 35, + 20, + 21, ], - "type": "Keyword", - "value": "void", + "type": "Identifier", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 36, + "column": 22, "line": 1, }, "start": Object { - "column": 35, + "column": 21, "line": 1, }, }, "range": Array [ - 35, - 36, + 21, + 22, ], "type": "Punctuator", "value": ";", @@ -114051,7 +116083,7 @@ Object { } `; -exports[`typescript fixtures/types/function.src 1`] = ` +exports[`typescript fixtures/types/function-in-generic.src 1`] = ` Object { "body": Array [ Object { @@ -114060,7 +116092,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 38, + "column": 24, "line": 1, }, "start": Object { @@ -114068,16 +116100,16 @@ Object { "line": 1, }, }, - "name": "f", + "name": "x", "range": Array [ 4, - 38, + 24, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 38, + "column": 24, "line": 1, }, "start": Object { @@ -114087,13 +116119,13 @@ Object { }, "range": Array [ 5, - 38, + 24, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 38, + "column": 24, "line": 1, }, "start": Object { @@ -114101,159 +116133,107 @@ Object { "line": 1, }, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, + "range": Array [ + 7, + 24, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, }, - "name": "a", - "range": Array [ - 8, - 17, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, - }, - }, - "range": Array [ - 9, - 17, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, - 17, - ], - "type": "TSNumberKeyword", - }, + "start": Object { + "column": 7, + "line": 1, }, }, - Object { - "loc": Object { - "end": Object { - "column": 29, - "line": 1, - }, - "start": Object { - "column": 19, - "line": 1, - }, + "name": "Array", + "range": Array [ + 7, + 12, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, }, - "name": "b", - "optional": true, - "range": Array [ - 19, - 29, - ], - "type": "Identifier", - "typeAnnotation": Object { + "start": Object { + "column": 12, + "line": 1, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 29, + "column": 23, "line": 1, }, "start": Object { - "column": 21, + "column": 13, "line": 1, }, }, + "params": Array [], "range": Array [ - 21, - 29, + 13, + 23, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { - "column": 29, + "column": 23, "line": 1, }, "start": Object { - "column": 23, + "column": 16, "line": 1, }, }, "range": Array [ + 16, 23, - 29, ], - "type": "TSNumberKeyword", - }, - }, - }, - ], - "range": Array [ - 7, - 38, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 38, - "line": 1, - }, - "start": Object { - "column": 31, - "line": 1, - }, - }, - "range": Array [ - 31, - 38, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 38, - "line": 1, - }, - "start": Object { - "column": 34, - "line": 1, + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 23, + ], + "type": "TSVoidKeyword", + }, }, + "type": "TSFunctionType", }, - "range": Array [ - 34, - 38, - ], - "type": "TSVoidKeyword", - }, + ], + "range": Array [ + 12, + 24, + ], + "type": "TSTypeParameterInstantiation", }, - "type": "TSFunctionType", }, }, }, "init": null, "loc": Object { "end": Object { - "column": 38, + "column": 24, "line": 1, }, "start": Object { @@ -114263,7 +116243,7 @@ Object { }, "range": Array [ 4, - 38, + 24, ], "type": "VariableDeclarator", }, @@ -114271,7 +116251,7 @@ Object { "kind": "let", "loc": Object { "end": Object { - "column": 39, + "column": 25, "line": 1, }, "start": Object { @@ -114281,7 +116261,7 @@ Object { }, "range": Array [ 0, - 39, + 25, ], "type": "VariableDeclaration", }, @@ -114299,7 +116279,7 @@ Object { }, "range": Array [ 0, - 40, + 26, ], "sourceType": "module", "tokens": Array [ @@ -114337,7 +116317,7 @@ Object { 5, ], "type": "Identifier", - "value": "f", + "value": "x", }, Object { "loc": Object { @@ -114360,7 +116340,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 8, + "column": 12, "line": 1, }, "start": Object { @@ -114370,64 +116350,64 @@ Object { }, "range": Array [ 7, - 8, + 12, ], - "type": "Punctuator", - "value": "(", + "type": "Identifier", + "value": "Array", }, Object { "loc": Object { "end": Object { - "column": 9, + "column": 13, "line": 1, }, "start": Object { - "column": 8, + "column": 12, "line": 1, }, }, "range": Array [ - 8, - 9, + 12, + 13, ], - "type": "Identifier", - "value": "a", + "type": "Punctuator", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 10, + "column": 14, "line": 1, }, "start": Object { - "column": 9, + "column": 13, "line": 1, }, }, "range": Array [ - 9, - 10, + 13, + 14, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 15, "line": 1, }, "start": Object { - "column": 11, + "column": 14, "line": 1, }, }, "range": Array [ - 11, - 17, + 14, + 15, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { @@ -114436,21 +116416,21 @@ Object { "line": 1, }, "start": Object { - "column": 17, + "column": 16, "line": 1, }, }, "range": Array [ - 17, + 16, 18, ], "type": "Punctuator", - "value": ",", + "value": "=>", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 23, "line": 1, }, "start": Object { @@ -114460,51 +116440,15 @@ Object { }, "range": Array [ 19, - 20, - ], - "type": "Identifier", - "value": "b", - }, - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, - }, - }, - "range": Array [ - 20, - 21, - ], - "type": "Punctuator", - "value": "?", - }, - Object { - "loc": Object { - "end": Object { - "column": 22, - "line": 1, - }, - "start": Object { - "column": 21, - "line": 1, - }, - }, - "range": Array [ - 21, - 22, + 23, ], - "type": "Punctuator", - "value": ":", + "type": "Keyword", + "value": "void", }, Object { "loc": Object { "end": Object { - "column": 29, + "column": 24, "line": 1, }, "start": Object { @@ -114514,358 +116458,195 @@ Object { }, "range": Array [ 23, - 29, - ], - "type": "Identifier", - "value": "number", - }, - Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 1, - }, - "start": Object { - "column": 29, - "line": 1, - }, - }, - "range": Array [ - 29, - 30, + 24, ], "type": "Punctuator", - "value": ")", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 33, + "column": 25, "line": 1, }, "start": Object { - "column": 31, + "column": 24, "line": 1, }, }, "range": Array [ - 31, - 33, + 24, + 25, ], "type": "Punctuator", - "value": "=>", + "value": ";", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/function-with-array-destruction.src 1`] = ` +Object { + "body": Array [ Object { - "loc": Object { - "end": Object { - "column": 38, - "line": 1, - }, - "start": Object { - "column": 34, - "line": 1, + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, }, + "name": "foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", }, - "range": Array [ - 34, - 38, - ], - "type": "Keyword", - "value": "void", - }, - Object { "loc": Object { "end": Object { - "column": 39, + "column": 28, "line": 1, }, "start": Object { - "column": 38, + "column": 0, "line": 1, }, }, "range": Array [ - 38, - 39, + 0, + 28, ], - "type": "Punctuator", - "value": ";", - }, - ], - "type": "Program", -} -`; - -exports[`typescript fixtures/types/function-generic.src 1`] = ` -Object { - "body": Array [ - Object { - "declarations": Array [ - Object { - "id": Object { + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "params": Array [ + Object { + "elements": Array [ + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 13, + 14, + ], + "type": "Identifier", + }, + ], "loc": Object { "end": Object { - "column": 21, + "column": 20, "line": 1, }, "start": Object { - "column": 4, + "column": 12, "line": 1, }, }, - "name": "f", "range": Array [ - 4, - 21, + 12, + 20, ], - "type": "Identifier", + "type": "ArrayPattern", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 21, + "column": 20, "line": 1, }, "start": Object { - "column": 5, + "column": 15, "line": 1, }, }, "range": Array [ - 5, - 21, + 15, + 20, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 21, + "column": 20, "line": 1, }, "start": Object { - "column": 7, + "column": 17, "line": 1, }, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "name": "a", - "range": Array [ - 11, - 15, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, - }, - "range": Array [ - 12, - 15, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 14, - "line": 1, - }, - }, - "range": Array [ - 14, - 15, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 14, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 14, - 15, - ], - "type": "Identifier", - }, - }, - }, - }, - ], "range": Array [ - 7, - 21, + 17, + 20, ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 17, - "line": 1, - }, - }, - "range": Array [ - 17, - 21, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, - }, - }, - "range": Array [ - 20, - 21, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 20, - 21, - ], - "type": "Identifier", - }, - }, - }, - "type": "TSFunctionType", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 8, - 9, - ], - "type": "Identifier", - }, - "range": Array [ - 8, - 9, - ], - "type": "TSTypeParameter", - }, - ], - "range": Array [ - 7, - 10, - ], - "type": "TSTypeParameterDeclaration", - }, + "type": "TSAnyKeyword", }, }, }, - "init": null, + ], + "range": Array [ + 11, + 28, + ], + "returnType": Object { "loc": Object { "end": Object { - "column": 21, + "column": 28, "line": 1, }, "start": Object { - "column": 4, + "column": 22, "line": 1, }, }, "range": Array [ - 4, - 21, + 22, + 28, ], - "type": "VariableDeclarator", - }, - ], - "kind": "let", - "loc": Object { - "end": Object { - "column": 22, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 22, - ], - "type": "VariableDeclaration", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 28, + ], + "type": "TSAnyKeyword", + }, + }, + "type": "TSFunctionType", + }, }, ], "comments": Array [], @@ -114881,14 +116662,14 @@ Object { }, "range": Array [ 0, - 23, + 29, ], "sourceType": "module", "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 3, + "column": 4, "line": 1, }, "start": Object { @@ -114898,33 +116679,15 @@ Object { }, "range": Array [ 0, - 3, - ], - "type": "Keyword", - "value": "let", - }, - Object { - "loc": Object { - "end": Object { - "column": 5, - "line": 1, - }, - "start": Object { - "column": 4, - "line": 1, - }, - }, - "range": Array [ 4, - 5, ], "type": "Identifier", - "value": "f", + "value": "type", }, Object { "loc": Object { "end": Object { - "column": 6, + "column": 8, "line": 1, }, "start": Object { @@ -114934,46 +116697,10 @@ Object { }, "range": Array [ 5, - 6, - ], - "type": "Punctuator", - "value": ":", - }, - Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "range": Array [ - 7, - 8, - ], - "type": "Punctuator", - "value": "<", - }, - Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "range": Array [ 8, - 9, ], "type": "Identifier", - "value": "T", + "value": "foo", }, Object { "loc": Object { @@ -114991,22 +116718,22 @@ Object { 10, ], "type": "Punctuator", - "value": ">", + "value": "=", }, Object { "loc": Object { "end": Object { - "column": 11, + "column": 12, "line": 1, }, "start": Object { - "column": 10, + "column": 11, "line": 1, }, }, "range": Array [ - 10, 11, + 12, ], "type": "Punctuator", "value": "(", @@ -115014,38 +116741,38 @@ Object { Object { "loc": Object { "end": Object { - "column": 12, + "column": 13, "line": 1, }, "start": Object { - "column": 11, + "column": 12, "line": 1, }, }, "range": Array [ - 11, 12, + 13, ], - "type": "Identifier", - "value": "a", + "type": "Punctuator", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 13, + "column": 14, "line": 1, }, "start": Object { - "column": 12, + "column": 13, "line": 1, }, }, "range": Array [ - 12, 13, + 14, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "a", }, Object { "loc": Object { @@ -115062,8 +116789,8 @@ Object { 14, 15, ], - "type": "Identifier", - "value": "T", + "type": "Punctuator", + "value": "]", }, Object { "loc": Object { @@ -115081,12 +116808,12 @@ Object { 16, ], "type": "Punctuator", - "value": ")", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 19, + "column": 20, "line": 1, }, "start": Object { @@ -115096,10 +116823,10 @@ Object { }, "range": Array [ 17, - 19, + 20, ], - "type": "Punctuator", - "value": "=>", + "type": "Identifier", + "value": "any", }, Object { "loc": Object { @@ -115116,213 +116843,250 @@ Object { 20, 21, ], - "type": "Identifier", - "value": "T", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 22, + "column": 24, "line": 1, }, "start": Object { - "column": 21, + "column": 22, "line": 1, }, }, "range": Array [ - 21, 22, + 24, ], "type": "Punctuator", - "value": ";", + "value": "=>", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 28, + ], + "type": "Identifier", + "value": "any", }, ], "type": "Program", } `; -exports[`typescript fixtures/types/function-in-generic.src 1`] = ` +exports[`typescript fixtures/types/function-with-object-destruction.src 1`] = ` Object { "body": Array [ Object { - "declarations": Array [ - Object { - "id": Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 24, + "column": 20, "line": 1, }, "start": Object { - "column": 4, + "column": 12, "line": 1, }, }, - "name": "x", - "range": Array [ - 4, - 24, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 13, + 14, + ], + "type": "Identifier", }, - }, - "range": Array [ - 5, - 24, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "kind": "init", "loc": Object { "end": Object { - "column": 24, + "column": 14, "line": 1, }, "start": Object { - "column": 7, + "column": 13, "line": 1, }, }, + "method": false, "range": Array [ - 7, - 24, + 13, + 14, ], - "type": "TSTypeReference", - "typeName": Object { + "shorthand": true, + "type": "Property", + "value": Object { "loc": Object { "end": Object { - "column": 12, + "column": 14, "line": 1, }, "start": Object { - "column": 7, + "column": 13, "line": 1, }, }, - "name": "Array", + "name": "a", "range": Array [ - 7, - 12, + 13, + 14, ], "type": "Identifier", }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, + }, + ], + "range": Array [ + 12, + 20, + ], + "type": "ObjectPattern", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 20, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 13, - "line": 1, - }, - }, - "params": Array [], - "range": Array [ - 13, - 23, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 16, - "line": 1, - }, - }, - "range": Array [ - 16, - 23, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 19, - "line": 1, - }, - }, - "range": Array [ - 19, - 23, - ], - "type": "TSVoidKeyword", - }, - }, - "type": "TSFunctionType", - }, - ], - "range": Array [ - 12, - 24, - ], - "type": "TSTypeParameterInstantiation", }, + "range": Array [ + 17, + 20, + ], + "type": "TSAnyKeyword", }, }, }, - "init": null, + ], + "range": Array [ + 11, + 28, + ], + "returnType": Object { "loc": Object { "end": Object { - "column": 24, + "column": 28, "line": 1, }, "start": Object { - "column": 4, + "column": 22, "line": 1, }, }, "range": Array [ - 4, - 24, + 22, + 28, ], - "type": "VariableDeclarator", - }, - ], - "kind": "let", - "loc": Object { - "end": Object { - "column": 25, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 28, + ], + "type": "TSAnyKeyword", + }, }, + "type": "TSFunctionType", }, - "range": Array [ - 0, - 25, - ], - "type": "VariableDeclaration", }, ], "comments": Array [], @@ -115338,14 +117102,14 @@ Object { }, "range": Array [ 0, - 26, + 29, ], "sourceType": "module", "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 3, + "column": 4, "line": 1, }, "start": Object { @@ -115355,46 +117119,46 @@ Object { }, "range": Array [ 0, - 3, + 4, ], - "type": "Keyword", - "value": "let", + "type": "Identifier", + "value": "type", }, Object { "loc": Object { "end": Object { - "column": 5, + "column": 8, "line": 1, }, "start": Object { - "column": 4, + "column": 5, "line": 1, }, }, "range": Array [ - 4, 5, + 8, ], "type": "Identifier", - "value": "x", + "value": "foo", }, Object { "loc": Object { "end": Object { - "column": 6, + "column": 10, "line": 1, }, "start": Object { - "column": 5, + "column": 9, "line": 1, }, }, "range": Array [ - 5, - 6, + 9, + 10, ], "type": "Punctuator", - "value": ":", + "value": "=", }, Object { "loc": Object { @@ -115403,16 +117167,16 @@ Object { "line": 1, }, "start": Object { - "column": 7, + "column": 11, "line": 1, }, }, "range": Array [ - 7, + 11, 12, ], - "type": "Identifier", - "value": "Array", + "type": "Punctuator", + "value": "(", }, Object { "loc": Object { @@ -115430,7 +117194,7 @@ Object { 13, ], "type": "Punctuator", - "value": "<", + "value": "{", }, Object { "loc": Object { @@ -115447,8 +117211,8 @@ Object { 13, 14, ], - "type": "Punctuator", - "value": "(", + "type": "Identifier", + "value": "a", }, Object { "loc": Object { @@ -115466,43 +117230,61 @@ Object { 15, ], "type": "Punctuator", - "value": ")", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 18, + "column": 16, "line": 1, }, "start": Object { - "column": 16, + "column": 15, "line": 1, }, }, "range": Array [ + 15, 16, - 18, ], "type": "Punctuator", - "value": "=>", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 23, + "column": 20, "line": 1, }, "start": Object { - "column": 19, + "column": 17, "line": 1, }, }, "range": Array [ - 19, - 23, + 17, + 20, ], - "type": "Keyword", - "value": "void", + "type": "Identifier", + "value": "any", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { @@ -115511,34 +117293,34 @@ Object { "line": 1, }, "start": Object { - "column": 23, + "column": 22, "line": 1, }, }, "range": Array [ - 23, + 22, 24, ], "type": "Punctuator", - "value": ">", + "value": "=>", }, Object { "loc": Object { "end": Object { - "column": 25, + "column": 28, "line": 1, }, "start": Object { - "column": 24, + "column": 25, "line": 1, }, }, "range": Array [ - 24, 25, + 28, ], - "type": "Punctuator", - "value": ";", + "type": "Identifier", + "value": "any", }, ], "type": "Program", diff --git a/packages/shared-fixtures/fixtures/typescript/basics/function-anonymus-with-type-parameters.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/function-anonymus-with-type-parameters.src.ts new file mode 100644 index 000000000000..44c7468b366d --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/function-anonymus-with-type-parameters.src.ts @@ -0,0 +1,3 @@ +var obj = function (a: string) { + return a; +}; diff --git a/packages/shared-fixtures/fixtures/typescript/basics/function-anynomus-with-return-type.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/function-anynomus-with-return-type.src.ts new file mode 100644 index 000000000000..a5d4544e0b12 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/function-anynomus-with-return-type.src.ts @@ -0,0 +1,2 @@ +var obj = function (): void { +}; diff --git a/packages/shared-fixtures/fixtures/typescript/types/function-with-array-destruction.src.ts b/packages/shared-fixtures/fixtures/typescript/types/function-with-array-destruction.src.ts new file mode 100644 index 000000000000..2517be450da2 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/types/function-with-array-destruction.src.ts @@ -0,0 +1 @@ +type foo = ([a]: any) => any diff --git a/packages/shared-fixtures/fixtures/typescript/types/function-with-object-destruction.src.ts b/packages/shared-fixtures/fixtures/typescript/types/function-with-object-destruction.src.ts new file mode 100644 index 000000000000..fdb44b90178c --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/types/function-with-object-destruction.src.ts @@ -0,0 +1 @@ +type foo = ({a}: any) => any diff --git a/packages/typescript-estree/src/semantic-errors.ts b/packages/typescript-estree/src/semantic-errors.ts index 169031947d3f..f563e404464d 100644 --- a/packages/typescript-estree/src/semantic-errors.ts +++ b/packages/typescript-estree/src/semantic-errors.ts @@ -66,6 +66,8 @@ function whitelistSupportedDiagnostics( case 1090: // ts 3.2 "'{0}' modifier cannot appear on a parameter." case 1096: // ts 3.2 "An index signature must have exactly one parameter." case 1097: // ts 3.2 "'{0}' list cannot be empty." + case 1098: // ts 3.3 "Type parameter list cannot be empty." + case 1099: // ts 3.3 "Type argument list cannot be empty." case 1117: // ts 3.2 "An object literal cannot have multiple properties with the same name in strict mode." case 1121: // ts 3.2 "Octal literals are not allowed in strict mode." case 1123: // ts 3.2: "Variable declaration list cannot be empty." 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 564a5ab6a1ab..8fc5d6acd68c 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -383,8 +383,8 @@ tester.addFixturePatternConfig('typescript/basics', { */ 'type-assertion-arrow-function', /** - * Babel does not include optional keyword into range parameter in arrow function - * https://github.com/babel/babel/issues/9461 + * PR for optional parameters in arrow function has been merged into Babel: https://github.com/babel/babel/pull/9463 + * TODO: remove me in next babel > 7.3.2 */ 'arrow-function-with-optional-parameter' ], @@ -434,7 +434,23 @@ tester.addFixturePatternConfig('typescript/expressions', { }); tester.addFixturePatternConfig('typescript/errorRecovery', { - fileType: 'ts' + fileType: 'ts', + ignore: [ + /** + * Expected error on empty type arguments and type parameters + * TypeScript report diagnostics correctly but babel not + * https://github.com/babel/babel/issues/9462 + */ + 'empty-type-arguments', + 'empty-type-arguments-in-call-expression', + 'empty-type-arguments-in-new-expression', + 'empty-type-parameters', + 'empty-type-parameters-in-arrow-function', + 'empty-type-parameters-in-constructor', + 'empty-type-parameters-in-function-expression', + 'empty-type-parameters-in-method', + 'empty-type-parameters-in-method-signature' + ] }); tester.addFixturePatternConfig('typescript/types', { @@ -443,7 +459,11 @@ tester.addFixturePatternConfig('typescript/types', { /** * AST difference */ - 'literal-number-negative' + 'literal-number-negative', + /** + * Babel parse error: https://github.com/babel/babel/pull/9431 + */ + 'function-with-array-destruction' ] }); diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index 45c5544625ef..bfbda1148412 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -1798,6 +1798,10 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type-function-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/function-anonymus-with-type-parameters.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/function-anynomus-with-return-type.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/function-overloads.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/function-with-await.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -2073,23 +2077,86 @@ Object { } `; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments.src 1`] = ` +Object { + "column": 14, + "index": 14, + "lineNumber": 1, + "message": "Type argument list cannot be empty.", +} +`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments-in-call-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments-in-call-expression.src 1`] = ` +Object { + "column": 3, + "index": 3, + "lineNumber": 1, + "message": "Type argument list cannot be empty.", +} +`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments-in-new-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-arguments-in-new-expression.src 1`] = ` +Object { + "column": 7, + "index": 7, + "lineNumber": 1, + "message": "Type argument list cannot be empty.", +} +`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters.src 1`] = ` +Object { + "column": 11, + "index": 11, + "lineNumber": 1, + "message": "Type parameter list cannot be empty.", +} +`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-arrow-function.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-arrow-function.src 1`] = ` +Object { + "column": 11, + "index": 11, + "lineNumber": 1, + "message": "Type parameter list cannot be empty.", +} +`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-constructor.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-constructor.src 1`] = ` +Object { + "column": 13, + "index": 25, + "lineNumber": 2, + "message": "Type parameter list cannot be empty.", +} +`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-function-expression.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-function-expression.src 1`] = ` +Object { + "column": 20, + "index": 20, + "lineNumber": 1, + "message": "Type parameter list cannot be empty.", +} +`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-method.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-method.src 1`] = ` +Object { + "column": 6, + "index": 18, + "lineNumber": 2, + "message": "Type parameter list cannot be empty.", +} +`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-method-signature.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/empty-type-parameters-in-method-signature.src 1`] = ` +Object { + "column": 6, + "index": 22, + "lineNumber": 2, + "message": "Type parameter list cannot be empty.", +} +`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/errorRecovery/enum-with-keywords.src 1`] = ` Object { @@ -2360,6 +2427,10 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/function-in-generic.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/function-with-array-destruction.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/function-with-object-destruction.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/function-with-rest.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/function-with-this.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index 9c0094cff37b..b9e876c45955 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -39177,139 +39177,268 @@ Object { } `; -exports[`typescript fixtures/basics/function-overloads.src 1`] = ` +exports[`typescript fixtures/basics/function-anonymus-with-type-parameters.src 1`] = ` Object { "body": Array [ Object { - "declaration": Object { - "async": false, - "expression": false, - "generator": false, - "id": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 16, - "line": 1, - }, - }, - "name": "f", - "range": Array [ - 16, - 17, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "params": Array [ - Object { + "declarations": Array [ + Object { + "id": Object { "loc": Object { "end": Object { - "column": 27, + "column": 7, "line": 1, }, "start": Object { - "column": 18, + "column": 4, "line": 1, }, }, - "name": "x", + "name": "obj", "range": Array [ - 18, - 27, + 4, + 7, ], "type": "Identifier", - "typeAnnotation": Object { + }, + "init": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "name": "a", + "range": Array [ + 45, + 46, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 38, + 47, + ], + "type": "ReturnStatement", + }, + ], "loc": Object { "end": Object { - "column": 27, - "line": 1, + "column": 1, + "line": 3, }, "start": Object { - "column": 19, + "column": 34, "line": 1, }, }, "range": Array [ - 19, - 27, + 34, + 49, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 27, + "column": 32, "line": 1, }, "start": Object { - "column": 21, + "column": 23, "line": 1, }, }, + "name": "a", "range": Array [ - 21, - 27, + 23, + 32, ], - "type": "TSNumberKeyword", + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 32, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 32, + ], + "type": "TSStringKeyword", + }, + }, + }, + ], + "range": Array [ + 10, + 49, + ], + "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + }, + "range": Array [ + 20, + 21, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 19, + 22, + ], + "type": "TSTypeParameterDeclaration", }, }, - ], - "range": Array [ - 7, - 37, - ], - "returnType": Object { "loc": Object { "end": Object { - "column": 36, - "line": 1, + "column": 1, + "line": 3, }, "start": Object { - "column": 28, + "column": 4, "line": 1, }, }, "range": Array [ - 28, - 36, + 4, + 49, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 30, - "line": 1, - }, - }, - "range": Array [ - 30, - 36, - ], - "type": "TSNumberKeyword", - }, + "type": "VariableDeclarator", + }, + ], + "kind": "var", + "loc": Object { + "end": Object { + "column": 2, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, }, - "type": "TSDeclareFunction", }, + "range": Array [ + 0, + 50, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 51, + ], + "sourceType": "script", + "tokens": Array [ + Object { "loc": Object { "end": Object { - "column": 37, + "column": 3, "line": 1, }, "start": Object { @@ -39319,513 +39448,133 @@ Object { }, "range": Array [ 0, - 37, + 3, ], - "source": null, - "specifiers": Array [], - "type": "ExportNamedDeclaration", + "type": "Keyword", + "value": "var", }, Object { - "declaration": Object { - "async": false, - "expression": false, - "generator": false, - "id": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "name": "f", - "range": Array [ - 54, - 55, - ], - "type": "Identifier", + "loc": Object { + "end": Object { + "column": 7, + "line": 1, }, - "loc": Object { - "end": Object { - "column": 37, - "line": 2, - }, - "start": Object { - "column": 7, - "line": 2, - }, + "start": Object { + "column": 4, + "line": 1, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 2, - }, - "start": Object { - "column": 18, - "line": 2, - }, - }, - "name": "x", - "range": Array [ - 56, - 65, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 2, - }, - "start": Object { - "column": 19, - "line": 2, - }, - }, - "range": Array [ - 57, - 65, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 2, - }, - "start": Object { - "column": 21, - "line": 2, - }, - }, - "range": Array [ - 59, - 65, - ], - "type": "TSStringKeyword", - }, - }, - }, - ], - "range": Array [ - 45, - 75, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 2, - }, - "start": Object { - "column": 28, - "line": 2, - }, - }, - "range": Array [ - 66, - 74, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 2, - }, - "start": Object { - "column": 30, - "line": 2, - }, - }, - "range": Array [ - 68, - 74, - ], - "type": "TSStringKeyword", - }, + }, + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + "value": "obj", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, }, - "type": "TSDeclareFunction", }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": "=", + }, + Object { "loc": Object { "end": Object { - "column": 37, - "line": 2, + "column": 18, + "line": 1, }, "start": Object { - "column": 0, - "line": 2, + "column": 10, + "line": 1, }, }, "range": Array [ - 38, - 75, + 10, + 18, ], - "source": null, - "specifiers": Array [], - "type": "ExportNamedDeclaration", + "type": "Keyword", + "value": "function", }, - Object { - "declaration": Object { - "async": false, - "body": Object { - "body": Array [ - Object { - "argument": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 4, - }, - "start": Object { - "column": 9, - "line": 4, - }, - }, - "name": "x", - "range": Array [ - 142, - 143, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 11, - "line": 4, - }, - "start": Object { - "column": 2, - "line": 4, - }, - }, - "range": Array [ - 135, - 144, - ], - "type": "ReturnStatement", - }, - ], - "loc": Object { - "end": Object { - "column": 1, - "line": 5, - }, - "start": Object { - "column": 55, - "line": 3, - }, - }, - "range": Array [ - 131, - 146, - ], - "type": "BlockStatement", - }, - "expression": false, - "generator": false, - "id": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 3, - }, - "start": Object { - "column": 16, - "line": 3, - }, - }, - "name": "f", - "range": Array [ - 92, - 93, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 1, - "line": 5, - }, - "start": Object { - "column": 7, - "line": 3, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 18, - "line": 3, - }, - }, - "name": "x", - "range": Array [ - 94, - 112, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 19, - "line": 3, - }, - }, - "range": Array [ - 95, - 112, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 21, - "line": 3, - }, - }, - "range": Array [ - 97, - 112, - ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 3, - }, - "start": Object { - "column": 21, - "line": 3, - }, - }, - "range": Array [ - 97, - 103, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 30, - "line": 3, - }, - }, - "range": Array [ - 106, - 112, - ], - "type": "TSNumberKeyword", - }, - ], - }, - }, - }, - ], - "range": Array [ - 83, - 146, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 3, - }, - "start": Object { - "column": 37, - "line": 3, - }, - }, - "range": Array [ - 113, - 130, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 3, - }, - "start": Object { - "column": 39, - "line": 3, - }, - }, - "range": Array [ - 115, - 130, - ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 45, - "line": 3, - }, - "start": Object { - "column": 39, - "line": 3, - }, - }, - "range": Array [ - 115, - 121, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 3, - }, - "start": Object { - "column": 48, - "line": 3, - }, - }, - "range": Array [ - 124, - 130, - ], - "type": "TSNumberKeyword", - }, - ], - }, - }, - "type": "FunctionDeclaration", - }, - "loc": Object { - "end": Object { - "column": 1, - "line": 5, - }, - "start": Object { - "column": 0, - "line": 3, - }, - }, - "range": Array [ - 76, - 146, - ], - "source": null, - "specifiers": Array [], - "type": "ExportNamedDeclaration", - }, - ], - "loc": Object { - "end": Object { - "column": 0, - "line": 6, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 147, - ], - "sourceType": "module", - "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 6, + "column": 20, "line": 1, }, "start": Object { - "column": 0, + "column": 19, "line": 1, }, }, "range": Array [ - 0, - 6, + 19, + 20, ], - "type": "Keyword", - "value": "export", + "type": "Punctuator", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 21, "line": 1, }, "start": Object { - "column": 7, + "column": 20, "line": 1, }, }, "range": Array [ - 7, - 15, + 20, + 21, ], - "type": "Keyword", - "value": "function", + "type": "Identifier", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 22, "line": 1, }, "start": Object { - "column": 16, + "column": 21, "line": 1, }, }, "range": Array [ - 16, - 17, + 21, + 22, ], - "type": "Identifier", - "value": "f", + "type": "Punctuator", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 18, + "column": 23, "line": 1, }, "start": Object { - "column": 17, + "column": 22, "line": 1, }, }, "range": Array [ - 17, - 18, + 22, + 23, ], "type": "Punctuator", "value": "(", @@ -39833,35 +39582,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, + "column": 24, "line": 1, }, "start": Object { - "column": 18, + "column": 23, "line": 1, }, }, "range": Array [ - 18, - 19, + 23, + 24, ], "type": "Identifier", - "value": "x", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 25, "line": 1, }, "start": Object { - "column": 19, + "column": 24, "line": 1, }, }, "range": Array [ - 19, - 20, + 24, + 25, ], "type": "Punctuator", "value": ":", @@ -39869,35 +39618,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 27, + "column": 32, "line": 1, }, "start": Object { - "column": 21, + "column": 26, "line": 1, }, }, "range": Array [ - 21, - 27, + 26, + 32, ], "type": "Identifier", - "value": "number", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 33, "line": 1, }, "start": Object { - "column": 27, + "column": 32, "line": 1, }, }, "range": Array [ - 27, - 28, + 32, + 33, ], "type": "Punctuator", "value": ")", @@ -39905,65 +39654,29 @@ Object { Object { "loc": Object { "end": Object { - "column": 29, - "line": 1, - }, - "start": Object { - "column": 28, - "line": 1, - }, - }, - "range": Array [ - 28, - 29, - ], - "type": "Punctuator", - "value": ":", - }, - Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 30, - "line": 1, - }, - }, - "range": Array [ - 30, - 36, - ], - "type": "Identifier", - "value": "number", - }, - Object { - "loc": Object { - "end": Object { - "column": 37, + "column": 35, "line": 1, }, "start": Object { - "column": 36, + "column": 34, "line": 1, }, }, "range": Array [ - 36, - 37, + 34, + 35, ], "type": "Punctuator", - "value": ";", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 6, + "column": 8, "line": 2, }, "start": Object { - "column": 0, + "column": 2, "line": 2, }, }, @@ -39972,364 +39685,338 @@ Object { 44, ], "type": "Keyword", - "value": "export", + "value": "return", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 10, "line": 2, }, "start": Object { - "column": 7, + "column": 9, "line": 2, }, }, "range": Array [ 45, - 53, - ], - "type": "Keyword", - "value": "function", - }, - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "range": Array [ - 54, - 55, - ], - "type": "Identifier", - "value": "f", - }, - Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 2, - }, - "start": Object { - "column": 17, - "line": 2, - }, - }, - "range": Array [ - 55, - 56, - ], - "type": "Punctuator", - "value": "(", - }, - Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 2, - }, - "start": Object { - "column": 18, - "line": 2, - }, - }, - "range": Array [ - 56, - 57, + 46, ], "type": "Identifier", - "value": "x", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 11, "line": 2, }, "start": Object { - "column": 19, + "column": 10, "line": 2, }, }, "range": Array [ - 57, - 58, + 46, + 47, ], "type": "Punctuator", - "value": ":", - }, - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 2, - }, - "start": Object { - "column": 21, - "line": 2, - }, - }, - "range": Array [ - 59, - 65, - ], - "type": "Identifier", - "value": "string", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 28, - "line": 2, + "column": 1, + "line": 3, }, "start": Object { - "column": 27, - "line": 2, + "column": 0, + "line": 3, }, }, "range": Array [ - 65, - 66, + 48, + 49, ], "type": "Punctuator", - "value": ")", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 29, - "line": 2, + "column": 2, + "line": 3, }, "start": Object { - "column": 28, - "line": 2, + "column": 1, + "line": 3, }, }, "range": Array [ - 66, - 67, + 49, + 50, ], "type": "Punctuator", - "value": ":", + "value": ";", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/function-anynomus-with-return-type.src 1`] = ` +Object { + "body": Array [ Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 2, - }, - "start": Object { - "column": 30, - "line": 2, + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "obj", + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + }, + "init": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 1, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 31, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 1, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 10, + 31, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 27, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 27, + ], + "type": "TSVoidKeyword", + }, + }, + "type": "FunctionExpression", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 31, + ], + "type": "VariableDeclarator", }, - }, - "range": Array [ - 68, - 74, ], - "type": "Identifier", - "value": "string", - }, - Object { + "kind": "var", "loc": Object { "end": Object { - "column": 37, + "column": 2, "line": 2, }, "start": Object { - "column": 36, - "line": 2, + "column": 0, + "line": 1, }, }, "range": Array [ - 74, - 75, + 0, + 32, ], - "type": "Punctuator", - "value": ";", + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, }, + }, + "range": Array [ + 0, + 33, + ], + "sourceType": "script", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 6, - "line": 3, + "column": 3, + "line": 1, }, "start": Object { "column": 0, - "line": 3, + "line": 1, }, }, "range": Array [ - 76, - 82, + 0, + 3, ], "type": "Keyword", - "value": "export", + "value": "var", }, Object { "loc": Object { "end": Object { - "column": 15, - "line": 3, - }, - "start": Object { "column": 7, - "line": 3, - }, - }, - "range": Array [ - 83, - 91, - ], - "type": "Keyword", - "value": "function", - }, - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 3, + "line": 1, }, "start": Object { - "column": 16, - "line": 3, + "column": 4, + "line": 1, }, }, "range": Array [ - 92, - 93, + 4, + 7, ], "type": "Identifier", - "value": "f", + "value": "obj", }, Object { "loc": Object { "end": Object { - "column": 18, - "line": 3, + "column": 9, + "line": 1, }, "start": Object { - "column": 17, - "line": 3, + "column": 8, + "line": 1, }, }, "range": Array [ - 93, - 94, + 8, + 9, ], "type": "Punctuator", - "value": "(", + "value": "=", }, Object { "loc": Object { "end": Object { - "column": 19, - "line": 3, + "column": 18, + "line": 1, }, "start": Object { - "column": 18, - "line": 3, + "column": 10, + "line": 1, }, }, "range": Array [ - 94, - 95, + 10, + 18, ], - "type": "Identifier", - "value": "x", + "type": "Keyword", + "value": "function", }, Object { "loc": Object { "end": Object { "column": 20, - "line": 3, + "line": 1, }, "start": Object { "column": 19, - "line": 3, + "line": 1, }, }, "range": Array [ - 95, - 96, + 19, + 20, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 27, - "line": 3, - }, - "start": Object { "column": 21, - "line": 3, - }, - }, - "range": Array [ - 97, - 103, - ], - "type": "Identifier", - "value": "string", - }, - Object { - "loc": Object { - "end": Object { - "column": 29, - "line": 3, - }, - "start": Object { - "column": 28, - "line": 3, - }, - }, - "range": Array [ - 104, - 105, - ], - "type": "Punctuator", - "value": "|", - }, - Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 30, - "line": 3, - }, - }, - "range": Array [ - 106, - 112, - ], - "type": "Identifier", - "value": "number", - }, - Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 3, + "line": 1, }, "start": Object { - "column": 36, - "line": 3, + "column": 20, + "line": 1, }, }, "range": Array [ - 112, - 113, + 20, + 21, ], "type": "Punctuator", "value": ")", @@ -40337,17 +40024,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 38, - "line": 3, + "column": 22, + "line": 1, }, "start": Object { - "column": 37, - "line": 3, + "column": 21, + "line": 1, }, }, "range": Array [ - 113, - 114, + 21, + 22, ], "type": "Punctuator", "value": ":", @@ -40355,216 +40042,1468 @@ Object { Object { "loc": Object { "end": Object { - "column": 45, - "line": 3, + "column": 27, + "line": 1, }, "start": Object { - "column": 39, - "line": 3, + "column": 23, + "line": 1, }, }, "range": Array [ - 115, - 121, + 23, + 27, ], - "type": "Identifier", - "value": "string", + "type": "Keyword", + "value": "void", }, Object { "loc": Object { "end": Object { - "column": 47, - "line": 3, + "column": 29, + "line": 1, }, "start": Object { - "column": 46, - "line": 3, + "column": 28, + "line": 1, }, }, "range": Array [ - 122, - 123, + 28, + 29, ], "type": "Punctuator", - "value": "|", - }, - Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 3, - }, - "start": Object { - "column": 48, - "line": 3, - }, - }, - "range": Array [ - 124, - 130, - ], - "type": "Identifier", - "value": "number", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 56, - "line": 3, + "column": 1, + "line": 2, }, "start": Object { - "column": 55, - "line": 3, + "column": 0, + "line": 2, }, }, "range": Array [ - 131, - 132, + 30, + 31, ], "type": "Punctuator", - "value": "{", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 8, - "line": 4, - }, - "start": Object { "column": 2, - "line": 4, - }, - }, - "range": Array [ - 135, - 141, - ], - "type": "Keyword", - "value": "return", - }, - Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 4, - }, - "start": Object { - "column": 9, - "line": 4, - }, - }, - "range": Array [ - 142, - 143, - ], - "type": "Identifier", - "value": "x", - }, - Object { - "loc": Object { - "end": Object { - "column": 11, - "line": 4, + "line": 2, }, "start": Object { - "column": 10, - "line": 4, - }, - }, - "range": Array [ - 143, - 144, - ], - "type": "Punctuator", - "value": ";", - }, - Object { - "loc": Object { - "end": Object { "column": 1, - "line": 5, - }, - "start": Object { - "column": 0, - "line": 5, + "line": 2, }, }, "range": Array [ - 145, - 146, + 31, + 32, ], "type": "Punctuator", - "value": "}", + "value": ";", }, ], "type": "Program", } `; -exports[`typescript fixtures/basics/function-with-await.src 1`] = ` +exports[`typescript fixtures/basics/function-overloads.src 1`] = ` Object { "body": Array [ Object { - "async": true, - "body": Object { - "body": Array [ - Object { - "expression": Object { - "argument": Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 2, - }, - "start": Object { - "column": 10, - "line": 2, - }, - }, - "name": "future", - "range": Array [ - 40, - 46, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 16, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "range": Array [ - 34, - 46, - ], - "type": "AwaitExpression", + "declaration": Object { + "async": false, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, }, - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, + "start": Object { + "column": 16, + "line": 1, }, - "range": Array [ - 34, - 47, - ], - "type": "ExpressionStatement", }, - ], + "name": "f", + "range": Array [ + 16, + 17, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 1, - "line": 3, + "column": 37, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 18, + 27, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 27, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 27, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 7, + 37, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 36, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 30, + "line": 1, + }, + }, + "range": Array [ + 30, + 36, + ], + "type": "TSNumberKeyword", + }, + }, + "type": "TSDeclareFunction", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 37, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + Object { + "declaration": Object { + "async": false, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": "f", + "range": Array [ + 54, + 55, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "name": "x", + "range": Array [ + 56, + 65, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 19, + "line": 2, + }, + }, + "range": Array [ + 57, + 65, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 21, + "line": 2, + }, + }, + "range": Array [ + 59, + 65, + ], + "type": "TSStringKeyword", + }, + }, + }, + ], + "range": Array [ + 45, + 75, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 66, + 74, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "range": Array [ + 68, + 74, + ], + "type": "TSStringKeyword", + }, + }, + "type": "TSDeclareFunction", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 38, + 75, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + Object { + "declaration": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 4, + }, + "start": Object { + "column": 9, + "line": 4, + }, + }, + "name": "x", + "range": Array [ + 142, + 143, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 135, + 144, + ], + "type": "ReturnStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 55, + "line": 3, + }, + }, + "range": Array [ + 131, + 146, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 3, + }, + }, + "name": "f", + "range": Array [ + 92, + 93, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 7, + "line": 3, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 18, + "line": 3, + }, + }, + "name": "x", + "range": Array [ + 94, + 112, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 19, + "line": 3, + }, + }, + "range": Array [ + 95, + 112, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "range": Array [ + 97, + 112, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "range": Array [ + 97, + 103, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 30, + "line": 3, + }, + }, + "range": Array [ + 106, + 112, + ], + "type": "TSNumberKeyword", + }, + ], + }, + }, + }, + ], + "range": Array [ + 83, + 146, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 3, + }, + "start": Object { + "column": 37, + "line": 3, + }, + }, + "range": Array [ + 113, + 130, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 3, + }, + "start": Object { + "column": 39, + "line": 3, + }, + }, + "range": Array [ + 115, + 130, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 3, + }, + "start": Object { + "column": 39, + "line": 3, + }, + }, + "range": Array [ + 115, + 121, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 3, + }, + "start": Object { + "column": 48, + "line": 3, + }, + }, + "range": Array [ + 124, + 130, + ], + "type": "TSNumberKeyword", + }, + ], + }, + }, + "type": "FunctionDeclaration", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 76, + 146, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 6, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 147, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 15, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Identifier", + "value": "f", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 27, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 30, + "line": 1, + }, + }, + "range": Array [ + 30, + 36, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 38, + 44, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 45, + 53, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 54, + 55, + ], + "type": "Identifier", + "value": "f", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 55, + 56, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 56, + 57, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 19, + "line": 2, + }, + }, + "range": Array [ + 57, + 58, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 21, + "line": 2, + }, + }, + "range": Array [ + 59, + 65, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 2, + }, + "start": Object { + "column": 27, + "line": 2, + }, + }, + "range": Array [ + 65, + 66, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 66, + 67, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "range": Array [ + 68, + 74, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 74, + 75, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 76, + 82, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 3, + }, + "start": Object { + "column": 7, + "line": 3, + }, + }, + "range": Array [ + 83, + 91, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 3, + }, + }, + "range": Array [ + 92, + 93, + ], + "type": "Identifier", + "value": "f", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 17, + "line": 3, + }, + }, + "range": Array [ + 93, + 94, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 3, + }, + "start": Object { + "column": 18, + "line": 3, + }, + }, + "range": Array [ + 94, + 95, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 3, + }, + "start": Object { + "column": 19, + "line": 3, + }, + }, + "range": Array [ + 95, + 96, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "range": Array [ + 97, + 103, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 3, + }, + "start": Object { + "column": 28, + "line": 3, + }, + }, + "range": Array [ + 104, + 105, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 30, + "line": 3, + }, + }, + "range": Array [ + 106, + 112, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 36, + "line": 3, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 3, + }, + "start": Object { + "column": 37, + "line": 3, + }, + }, + "range": Array [ + 113, + 114, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 3, + }, + "start": Object { + "column": 39, + "line": 3, + }, + }, + "range": Array [ + 115, + 121, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 3, + }, + "start": Object { + "column": 46, + "line": 3, + }, + }, + "range": Array [ + 122, + 123, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 3, + }, + "start": Object { + "column": 48, + "line": 3, + }, + }, + "range": Array [ + 124, + 130, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 3, + }, + "start": Object { + "column": 55, + "line": 3, + }, + }, + "range": Array [ + 131, + 132, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 135, + 141, + ], + "type": "Keyword", + "value": "return", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 4, + }, + "start": Object { + "column": 9, + "line": 4, + }, + }, + "range": Array [ + 142, + 143, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 4, + }, + "start": Object { + "column": 10, + "line": 4, + }, + }, + "range": Array [ + 143, + 144, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 145, + 146, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/function-with-await.src 1`] = ` +Object { + "body": Array [ + Object { + "async": true, + "body": Object { + "body": Array [ + Object { + "expression": Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "name": "future", + "range": Array [ + 40, + 46, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 34, + 46, + ], + "type": "AwaitExpression", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 34, + 47, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, }, "start": Object { "column": 28, @@ -106491,131 +107430,563 @@ Object { "line": 1, }, }, - "range": Array [ - 9, - 231, - ], - "type": "TSModuleBlock", + "range": Array [ + 9, + 231, + ], + "type": "TSModuleBlock", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "name": "A", + "range": Array [ + 7, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 12, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 231, + ], + "type": "TSModuleDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 12, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 231, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Identifier", + "value": "module", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 16, + 22, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "range": Array [ + 23, + 26, + ], + "type": "Keyword", + "value": "var", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 17, + "line": 3, + }, + }, + "range": Array [ + 29, + 30, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 3, + }, + "start": Object { + "column": 19, + "line": 3, + }, + }, + "range": Array [ + 31, + 44, + ], + "type": "String", + "value": "'hello world'", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, }, - "id": Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, + "range": Array [ + 49, + 55, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 4, + }, + "start": Object { + "column": 11, + "line": 4, }, - "name": "A", - "range": Array [ - 7, - 8, - ], - "type": "Identifier", }, + "range": Array [ + 56, + 61, + ], + "type": "Keyword", + "value": "class", + }, + Object { "loc": Object { "end": Object { - "column": 1, - "line": 12, + "column": 22, + "line": 4, }, "start": Object { - "column": 0, - "line": 1, + "column": 17, + "line": 4, }, }, "range": Array [ - 0, - 231, + 62, + 67, ], - "type": "TSModuleDeclaration", + "type": "Identifier", + "value": "Point", }, - ], - "loc": Object { - "end": Object { - "column": 1, - "line": 12, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 4, + }, + "start": Object { + "column": 23, + "line": 4, + }, + }, + "range": Array [ + 68, + 69, + ], + "type": "Punctuator", + "value": "{", }, - "start": Object { - "column": 0, - "line": 1, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 5, + }, + "start": Object { + "column": 8, + "line": 5, + }, + }, + "range": Array [ + 78, + 89, + ], + "type": "Identifier", + "value": "constructor", }, - }, - "range": Array [ - 0, - 231, - ], - "sourceType": "script", - "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 6, - "line": 1, + "column": 20, + "line": 5, }, "start": Object { - "column": 0, - "line": 1, + "column": 19, + "line": 5, }, }, "range": Array [ - 0, - 6, + 89, + 90, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 5, + }, + "start": Object { + "column": 20, + "line": 5, + }, + }, + "range": Array [ + 90, + 96, + ], + "type": "Keyword", + "value": "public", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 5, + }, + "start": Object { + "column": 27, + "line": 5, + }, + }, + "range": Array [ + 97, + 98, ], "type": "Identifier", - "value": "module", + "value": "x", }, Object { "loc": Object { "end": Object { - "column": 8, - "line": 1, + "column": 29, + "line": 5, }, "start": Object { - "column": 7, - "line": 1, + "column": 28, + "line": 5, }, }, "range": Array [ - 7, - 8, + 98, + 99, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 5, + }, + "start": Object { + "column": 30, + "line": 5, + }, + }, + "range": Array [ + 100, + 106, ], "type": "Identifier", - "value": "A", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 10, - "line": 1, + "column": 37, + "line": 5, }, "start": Object { - "column": 9, - "line": 1, + "column": 36, + "line": 5, }, }, "range": Array [ - 9, - 10, + 106, + 107, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 5, + }, + "start": Object { + "column": 38, + "line": 5, + }, + }, + "range": Array [ + 108, + 114, + ], + "type": "Keyword", + "value": "public", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 5, + }, + "start": Object { + "column": 45, + "line": 5, + }, + }, + "range": Array [ + 115, + 116, + ], + "type": "Identifier", + "value": "y", + }, + Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 5, + }, + "start": Object { + "column": 46, + "line": 5, + }, + }, + "range": Array [ + 116, + 117, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 5, + }, + "start": Object { + "column": 48, + "line": 5, + }, + }, + "range": Array [ + 118, + 124, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 55, + "line": 5, + }, + "start": Object { + "column": 54, + "line": 5, + }, + }, + "range": Array [ + 124, + 125, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 57, + "line": 5, + }, + "start": Object { + "column": 56, + "line": 5, + }, + }, + "range": Array [ + 126, + 127, ], "type": "Punctuator", "value": "{", }, + Object { + "loc": Object { + "end": Object { + "column": 59, + "line": 5, + }, + "start": Object { + "column": 58, + "line": 5, + }, + }, + "range": Array [ + 128, + 129, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 134, + 135, + ], + "type": "Punctuator", + "value": "}", + }, Object { "loc": Object { "end": Object { "column": 10, - "line": 3, + "line": 7, }, "start": Object { "column": 4, - "line": 3, + "line": 7, }, }, "range": Array [ - 16, - 22, + 140, + 146, ], "type": "Keyword", "value": "export", @@ -106623,593 +107994,932 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, - "line": 3, + "column": 17, + "line": 7, }, "start": Object { "column": 11, - "line": 3, + "line": 7, }, }, "range": Array [ - 23, - 26, + 147, + 153, + ], + "type": "Identifier", + "value": "module", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 7, + }, + "start": Object { + "column": 18, + "line": 7, + }, + }, + "range": Array [ + 154, + 155, + ], + "type": "Identifier", + "value": "B", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 7, + }, + "start": Object { + "column": 20, + "line": 7, + }, + }, + "range": Array [ + 156, + 157, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 8, + }, + "start": Object { + "column": 8, + "line": 8, + }, + }, + "range": Array [ + 166, + 172, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 8, + }, + "start": Object { + "column": 15, + "line": 8, + }, + }, + "range": Array [ + 173, + 182, + ], + "type": "Keyword", + "value": "interface", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 8, + }, + "start": Object { + "column": 25, + "line": 8, + }, + }, + "range": Array [ + 183, + 185, + ], + "type": "Identifier", + "value": "Id", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 8, + }, + "start": Object { + "column": 28, + "line": 8, + }, + }, + "range": Array [ + 186, + 187, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 9, + }, + "start": Object { + "column": 12, + "line": 9, + }, + }, + "range": Array [ + 200, + 204, + ], + "type": "Identifier", + "value": "name", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 9, + }, + "start": Object { + "column": 16, + "line": 9, + }, + }, + "range": Array [ + 204, + 205, ], - "type": "Keyword", - "value": "var", + "type": "Punctuator", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 16, - "line": 3, + "column": 24, + "line": 9, }, "start": Object { - "column": 15, - "line": 3, + "column": 18, + "line": 9, }, }, "range": Array [ - 27, - 28, + 206, + 212, ], "type": "Identifier", - "value": "x", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 18, - "line": 3, + "column": 25, + "line": 9, }, "start": Object { - "column": 17, - "line": 3, + "column": 24, + "line": 9, }, }, "range": Array [ - 29, - 30, + 212, + 213, ], "type": "Punctuator", - "value": "=", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 32, - "line": 3, + "column": 9, + "line": 10, }, "start": Object { - "column": 19, - "line": 3, + "column": 8, + "line": 10, }, }, "range": Array [ - 31, - 44, + 222, + 223, ], - "type": "String", - "value": "'hello world'", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 10, - "line": 4, + "column": 5, + "line": 11, }, "start": Object { "column": 4, - "line": 4, + "line": 11, }, }, "range": Array [ - 49, - 55, + 228, + 229, ], - "type": "Keyword", - "value": "export", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 16, - "line": 4, + "column": 1, + "line": 12, }, "start": Object { - "column": 11, - "line": 4, + "column": 0, + "line": 12, }, }, "range": Array [ - 56, - 61, + 230, + 231, ], - "type": "Keyword", - "value": "class", + "type": "Punctuator", + "value": "}", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/namespaces-and-modules/shorthand-ambient-module-declaration.src 1`] = ` +Object { + "body": Array [ Object { + "declare": true, + "id": Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 31, + ], + "raw": "\\"hot-new-module\\"", + "type": "Literal", + "value": "hot-new-module", + }, "loc": Object { "end": Object { - "column": 22, - "line": 4, + "column": 32, + "line": 1, }, "start": Object { - "column": 17, - "line": 4, + "column": 0, + "line": 1, }, }, "range": Array [ - 62, - 67, + 0, + 32, ], - "type": "Identifier", - "value": "Point", + "type": "TSModuleDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 33, + ], + "sourceType": "script", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 24, - "line": 4, + "column": 7, + "line": 1, }, "start": Object { - "column": 23, - "line": 4, + "column": 0, + "line": 1, }, }, "range": Array [ - 68, - 69, + 0, + 7, ], - "type": "Punctuator", - "value": "{", + "type": "Identifier", + "value": "declare", }, Object { "loc": Object { "end": Object { - "column": 19, - "line": 5, + "column": 14, + "line": 1, }, "start": Object { "column": 8, - "line": 5, + "line": 1, }, }, "range": Array [ - 78, - 89, + 8, + 14, ], "type": "Identifier", - "value": "constructor", + "value": "module", }, Object { "loc": Object { "end": Object { - "column": 20, - "line": 5, + "column": 31, + "line": 1, }, "start": Object { - "column": 19, - "line": 5, + "column": 15, + "line": 1, }, }, "range": Array [ - 89, - 90, + 15, + 31, ], - "type": "Punctuator", - "value": "(", + "type": "String", + "value": "\\"hot-new-module\\"", }, Object { "loc": Object { "end": Object { - "column": 26, - "line": 5, + "column": 32, + "line": 1, }, "start": Object { - "column": 20, - "line": 5, + "column": 31, + "line": 1, }, }, "range": Array [ - 90, - 96, + 31, + 32, ], - "type": "Keyword", - "value": "public", + "type": "Punctuator", + "value": ";", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/array-type.src 1`] = ` +Object { + "body": Array [ Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 28, - "line": 5, + "column": 19, + "line": 1, }, "start": Object { - "column": 27, - "line": 5, + "column": 0, + "line": 1, }, }, "range": Array [ - 97, - 98, + 0, + 19, ], - "type": "Identifier", - "value": "x", + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "elementType": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSStringKeyword", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 19, + ], + "type": "TSArrayType", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 20, + ], + "sourceType": "script", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 29, - "line": 5, + "column": 4, + "line": 1, }, "start": Object { - "column": 28, - "line": 5, + "column": 0, + "line": 1, }, }, "range": Array [ - 98, - 99, + 0, + 4, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "type", }, Object { "loc": Object { "end": Object { - "column": 36, - "line": 5, + "column": 8, + "line": 1, }, "start": Object { - "column": 30, - "line": 5, + "column": 5, + "line": 1, }, }, "range": Array [ - 100, - 106, + 5, + 8, ], "type": "Identifier", - "value": "number", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 37, - "line": 5, + "column": 10, + "line": 1, }, "start": Object { - "column": 36, - "line": 5, + "column": 9, + "line": 1, }, }, "range": Array [ - 106, - 107, + 9, + 10, ], "type": "Punctuator", - "value": ",", + "value": "=", }, Object { "loc": Object { "end": Object { - "column": 44, - "line": 5, + "column": 17, + "line": 1, }, "start": Object { - "column": 38, - "line": 5, + "column": 11, + "line": 1, }, }, "range": Array [ - 108, - 114, + 11, + 17, ], - "type": "Keyword", - "value": "public", + "type": "Identifier", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 46, - "line": 5, + "column": 18, + "line": 1, }, "start": Object { - "column": 45, - "line": 5, + "column": 17, + "line": 1, }, }, "range": Array [ - 115, - 116, + 17, + 18, ], - "type": "Identifier", - "value": "y", + "type": "Punctuator", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 47, - "line": 5, + "column": 19, + "line": 1, }, "start": Object { - "column": 46, - "line": 5, + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": "]", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/conditional.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 47, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 47, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "checkType": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 13, + ], + "type": "TSNumberKeyword", + }, + "extendsType": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "TSStringKeyword", + }, + "falseType": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 47, + ], + "type": "TSStringKeyword", + }, + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 47, + ], + "trueType": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 38, + ], + "type": "TSBooleanKeyword", + }, + "type": "TSConditionalType", + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 47, + ], + "type": "VariableDeclarator", }, - }, - "range": Array [ - 116, - 117, ], - "type": "Punctuator", - "value": ":", - }, - Object { + "kind": "let", "loc": Object { "end": Object { - "column": 54, - "line": 5, - }, - "start": Object { "column": 48, - "line": 5, - }, - }, - "range": Array [ - 118, - 124, - ], - "type": "Identifier", - "value": "number", - }, - Object { - "loc": Object { - "end": Object { - "column": 55, - "line": 5, + "line": 1, }, "start": Object { - "column": 54, - "line": 5, + "column": 0, + "line": 1, }, }, "range": Array [ - 124, - 125, + 0, + 48, ], - "type": "Punctuator", - "value": ")", + "type": "VariableDeclaration", }, - Object { - "loc": Object { - "end": Object { - "column": 57, - "line": 5, - }, - "start": Object { - "column": 56, - "line": 5, - }, - }, - "range": Array [ - 126, - 127, - ], - "type": "Punctuator", - "value": "{", + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, }, - Object { - "loc": Object { - "end": Object { - "column": 59, - "line": 5, - }, - "start": Object { - "column": 58, - "line": 5, - }, - }, - "range": Array [ - 128, - 129, - ], - "type": "Punctuator", - "value": "}", + "start": Object { + "column": 0, + "line": 1, }, + }, + "range": Array [ + 0, + 49, + ], + "sourceType": "script", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 5, - "line": 6, + "column": 3, + "line": 1, }, "start": Object { - "column": 4, - "line": 6, + "column": 0, + "line": 1, }, }, "range": Array [ - 134, - 135, + 0, + 3, ], - "type": "Punctuator", - "value": "}", + "type": "Keyword", + "value": "let", }, Object { "loc": Object { "end": Object { - "column": 10, - "line": 7, + "column": 5, + "line": 1, }, "start": Object { "column": 4, - "line": 7, + "line": 1, }, }, "range": Array [ - 140, - 146, + 4, + 5, ], - "type": "Keyword", - "value": "export", + "type": "Identifier", + "value": "x", }, Object { "loc": Object { "end": Object { - "column": 17, - "line": 7, + "column": 6, + "line": 1, }, "start": Object { - "column": 11, - "line": 7, + "column": 5, + "line": 1, }, }, "range": Array [ - 147, - 153, + 5, + 6, ], - "type": "Identifier", - "value": "module", + "type": "Punctuator", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 19, - "line": 7, + "column": 13, + "line": 1, }, "start": Object { - "column": 18, - "line": 7, + "column": 7, + "line": 1, }, }, "range": Array [ - 154, - 155, + 7, + 13, ], "type": "Identifier", - "value": "B", + "value": "number", }, Object { "loc": Object { "end": Object { "column": 21, - "line": 7, + "line": 1, }, "start": Object { - "column": 20, - "line": 7, - }, - }, - "range": Array [ - 156, - 157, - ], - "type": "Punctuator", - "value": "{", - }, - Object { - "loc": Object { - "end": Object { "column": 14, - "line": 8, - }, - "start": Object { - "column": 8, - "line": 8, - }, - }, - "range": Array [ - 166, - 172, - ], - "type": "Keyword", - "value": "export", - }, - Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 8, - }, - "start": Object { - "column": 15, - "line": 8, + "line": 1, }, }, "range": Array [ - 173, - 182, + 14, + 21, ], "type": "Keyword", - "value": "interface", + "value": "extends", }, Object { "loc": Object { "end": Object { - "column": 27, - "line": 8, + "column": 28, + "line": 1, }, "start": Object { - "column": 25, - "line": 8, + "column": 22, + "line": 1, }, }, "range": Array [ - 183, - 185, + 22, + 28, ], "type": "Identifier", - "value": "Id", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 29, - "line": 8, + "column": 30, + "line": 1, }, "start": Object { - "column": 28, - "line": 8, + "column": 29, + "line": 1, }, }, "range": Array [ - 186, - 187, + 29, + 30, ], "type": "Punctuator", - "value": "{", + "value": "?", }, Object { "loc": Object { "end": Object { - "column": 16, - "line": 9, + "column": 38, + "line": 1, }, "start": Object { - "column": 12, - "line": 9, + "column": 31, + "line": 1, }, }, "range": Array [ - 200, - 204, + 31, + 38, ], "type": "Identifier", - "value": "name", + "value": "boolean", }, Object { "loc": Object { "end": Object { - "column": 17, - "line": 9, + "column": 40, + "line": 1, }, "start": Object { - "column": 16, - "line": 9, + "column": 39, + "line": 1, }, }, "range": Array [ - 204, - 205, + 39, + 40, ], "type": "Punctuator", "value": ":", @@ -107217,17 +108927,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 24, - "line": 9, + "column": 47, + "line": 1, }, "start": Object { - "column": 18, - "line": 9, + "column": 41, + "line": 1, }, }, "range": Array [ - 206, - 212, + 41, + 47, ], "type": "Identifier", "value": "string", @@ -107235,141 +108945,51 @@ Object { Object { "loc": Object { "end": Object { - "column": 25, - "line": 9, + "column": 48, + "line": 1, }, "start": Object { - "column": 24, - "line": 9, + "column": 47, + "line": 1, }, }, "range": Array [ - 212, - 213, + 47, + 48, ], "type": "Punctuator", "value": ";", }, - Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 10, - }, - "start": Object { - "column": 8, - "line": 10, - }, - }, - "range": Array [ - 222, - 223, - ], - "type": "Punctuator", - "value": "}", - }, - Object { - "loc": Object { - "end": Object { - "column": 5, - "line": 11, - }, - "start": Object { - "column": 4, - "line": 11, - }, - }, - "range": Array [ - 228, - 229, - ], - "type": "Punctuator", - "value": "}", - }, - Object { - "loc": Object { - "end": Object { - "column": 1, - "line": 12, - }, - "start": Object { - "column": 0, - "line": 12, - }, - }, - "range": Array [ - 230, - 231, - ], - "type": "Punctuator", - "value": "}", - }, ], "type": "Program", } `; -exports[`typescript fixtures/namespaces-and-modules/shorthand-ambient-module-declaration.src 1`] = ` +exports[`typescript fixtures/types/conditional-infer.src 1`] = ` Object { "body": Array [ Object { - "declare": true, "id": Object { "loc": Object { "end": Object { - "column": 31, + "column": 12, "line": 1, }, "start": Object { - "column": 15, + "column": 5, "line": 1, }, }, + "name": "Element", "range": Array [ - 15, - 31, + 5, + 12, ], - "raw": "\\"hot-new-module\\"", - "type": "Literal", - "value": "hot-new-module", - }, - "loc": Object { - "end": Object { - "column": 32, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, + "type": "Identifier", }, - "range": Array [ - 0, - 32, - ], - "type": "TSModuleDeclaration", - }, - ], - "loc": Object { - "end": Object { - "column": 0, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 33, - ], - "sourceType": "script", - "tokens": Array [ - Object { "loc": Object { "end": Object { - "column": 7, + "column": 48, "line": 1, }, "start": Object { @@ -107379,140 +108999,270 @@ Object { }, "range": Array [ 0, - 7, - ], - "type": "Identifier", - "value": "declare", - }, - Object { - "loc": Object { - "end": Object { - "column": 14, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "range": Array [ - 8, - 14, + 48, ], - "type": "Identifier", - "value": "module", - }, - Object { - "loc": Object { - "end": Object { - "column": 31, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "checkType": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 18, + 19, + ], + "type": "Identifier", + }, }, - }, - "range": Array [ - 15, - 31, - ], - "type": "String", - "value": "\\"hot-new-module\\"", - }, - Object { - "loc": Object { - "end": Object { - "column": 32, - "line": 1, + "extendsType": Object { + "elementType": Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 37, + ], + "type": "TSParenthesizedType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 36, + ], + "type": "TSInferType", + "typeParameter": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "name": "U", + "range": Array [ + 35, + 36, + ], + "type": "Identifier", + }, + "range": Array [ + 35, + 36, + ], + "type": "TSTypeParameter", + }, + }, + }, + "loc": Object { + "end": Object { + "column": 39, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 39, + ], + "type": "TSArrayType", }, - "start": Object { - "column": 31, - "line": 1, + "falseType": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 46, + 47, + ], + "type": "Identifier", + }, }, - }, - "range": Array [ - 31, - 32, - ], - "type": "Punctuator", - "value": ";", - }, - ], - "type": "Program", -} -`; - -exports[`typescript fixtures/types/array-type.src 1`] = ` -Object { - "body": Array [ - Object { - "id": Object { "loc": Object { "end": Object { - "column": 8, + "column": 47, "line": 1, }, "start": Object { - "column": 5, + "column": 18, "line": 1, }, }, - "name": "Foo", "range": Array [ - 5, - 8, + 18, + 47, ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 19, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 19, - ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "elementType": Object { + "trueType": Object { "loc": Object { "end": Object { - "column": 17, + "column": 43, "line": 1, }, "start": Object { - "column": 11, + "column": 42, "line": 1, }, }, "range": Array [ - 11, - 17, + 42, + 43, ], - "type": "TSStringKeyword", + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 42, + "line": 1, + }, + }, + "name": "U", + "range": Array [ + 42, + 43, + ], + "type": "Identifier", + }, }, + "type": "TSConditionalType", + }, + "typeParameters": Object { "loc": Object { "end": Object { - "column": 19, + "column": 15, "line": 1, }, "start": Object { - "column": 11, + "column": 12, "line": 1, }, }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 13, + 14, + ], + "type": "Identifier", + }, + "range": Array [ + 13, + 14, + ], + "type": "TSTypeParameter", + }, + ], "range": Array [ - 11, - 19, + 12, + 15, ], - "type": "TSArrayType", + "type": "TSTypeParameterDeclaration", }, }, ], @@ -107528,7 +109278,7 @@ Object { }, "range": Array [ 0, - 20, + 49, ], "sourceType": "script", "tokens": Array [ @@ -107553,7 +109303,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 8, + "column": 12, "line": 1, }, "start": Object { @@ -107563,64 +109313,82 @@ Object { }, "range": Array [ 5, - 8, + 12, ], "type": "Identifier", - "value": "Foo", + "value": "Element", }, Object { "loc": Object { "end": Object { - "column": 10, + "column": 13, "line": 1, }, "start": Object { - "column": 9, + "column": 12, "line": 1, }, }, "range": Array [ - 9, - 10, + 12, + 13, ], "type": "Punctuator", - "value": "=", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 14, "line": 1, }, "start": Object { - "column": 11, + "column": 13, "line": 1, }, }, "range": Array [ - 11, - 17, + 13, + 14, ], "type": "Identifier", - "value": "string", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 18, + "column": 15, "line": 1, }, "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { "column": 17, "line": 1, }, + "start": Object { + "column": 16, + "line": 1, + }, }, "range": Array [ + 16, 17, - 18, ], "type": "Punctuator", - "value": "[", + "value": "=", }, Object { "loc": Object { @@ -107637,314 +109405,149 @@ Object { 18, 19, ], - "type": "Punctuator", - "value": "]", + "type": "Identifier", + "value": "T", }, - ], - "type": "Program", -} -`; - -exports[`typescript fixtures/types/conditional.src 1`] = ` -Object { - "body": Array [ Object { - "declarations": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 4, - "line": 1, - }, - }, - "name": "x", - "range": Array [ - 4, - 47, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "range": Array [ - 5, - 47, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "checkType": Object { - "loc": Object { - "end": Object { - "column": 13, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "range": Array [ - 7, - 13, - ], - "type": "TSNumberKeyword", - }, - "extendsType": Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, - "start": Object { - "column": 22, - "line": 1, - }, - }, - "range": Array [ - 22, - 28, - ], - "type": "TSStringKeyword", - }, - "falseType": Object { - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 41, - "line": 1, - }, - }, - "range": Array [ - 41, - 47, - ], - "type": "TSStringKeyword", - }, - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "range": Array [ - 7, - 47, - ], - "trueType": Object { - "loc": Object { - "end": Object { - "column": 38, - "line": 1, - }, - "start": Object { - "column": 31, - "line": 1, - }, - }, - "range": Array [ - 31, - 38, - ], - "type": "TSBooleanKeyword", - }, - "type": "TSConditionalType", - }, - }, - }, - "init": null, - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 4, - "line": 1, - }, - }, - "range": Array [ - 4, - 47, - ], - "type": "VariableDeclarator", - }, - ], - "kind": "let", "loc": Object { "end": Object { - "column": 48, + "column": 27, "line": 1, }, "start": Object { - "column": 0, + "column": 20, "line": 1, }, }, "range": Array [ - 0, - 48, + 20, + 27, ], - "type": "VariableDeclaration", - }, - ], - "loc": Object { - "end": Object { - "column": 0, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 1, + "type": "Keyword", + "value": "extends", }, - }, - "range": Array [ - 0, - 49, - ], - "sourceType": "script", - "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 3, + "column": 29, "line": 1, }, "start": Object { - "column": 0, + "column": 28, "line": 1, }, }, "range": Array [ - 0, - 3, + 28, + 29, ], - "type": "Keyword", - "value": "let", + "type": "Punctuator", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 5, + "column": 34, "line": 1, }, "start": Object { - "column": 4, + "column": 29, "line": 1, }, }, "range": Array [ - 4, - 5, + 29, + 34, ], "type": "Identifier", - "value": "x", + "value": "infer", }, Object { "loc": Object { "end": Object { - "column": 6, + "column": 36, "line": 1, }, "start": Object { - "column": 5, + "column": 35, "line": 1, }, }, "range": Array [ - 5, - 6, + 35, + 36, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "U", }, Object { "loc": Object { "end": Object { - "column": 13, + "column": 37, "line": 1, }, "start": Object { - "column": 7, + "column": 36, "line": 1, }, }, "range": Array [ - 7, - 13, + 36, + 37, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 38, "line": 1, }, "start": Object { - "column": 14, + "column": 37, "line": 1, }, }, "range": Array [ - 14, - 21, + 37, + 38, ], - "type": "Keyword", - "value": "extends", + "type": "Punctuator", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 39, "line": 1, }, "start": Object { - "column": 22, + "column": 38, "line": 1, }, }, - "range": Array [ - 22, - 28, + "range": Array [ + 38, + 39, ], - "type": "Identifier", - "value": "string", + "type": "Punctuator", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 30, + "column": 41, "line": 1, }, "start": Object { - "column": 29, + "column": 40, "line": 1, }, }, "range": Array [ - 29, - 30, + 40, + 41, ], "type": "Punctuator", "value": "?", @@ -107952,35 +109555,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 38, + "column": 43, "line": 1, }, "start": Object { - "column": 31, + "column": 42, "line": 1, }, }, "range": Array [ - 31, - 38, + 42, + 43, ], "type": "Identifier", - "value": "boolean", + "value": "U", }, Object { "loc": Object { "end": Object { - "column": 40, + "column": 45, "line": 1, }, "start": Object { - "column": 39, + "column": 44, "line": 1, }, }, "range": Array [ - 39, - 40, + 44, + 45, ], "type": "Punctuator", "value": ":", @@ -107992,16 +109595,16 @@ Object { "line": 1, }, "start": Object { - "column": 41, + "column": 46, "line": 1, }, }, "range": Array [ - 41, + 46, 47, ], "type": "Identifier", - "value": "string", + "value": "T", }, Object { "loc": Object { @@ -108026,14 +109629,14 @@ Object { } `; -exports[`typescript fixtures/types/conditional-infer.src 1`] = ` +exports[`typescript fixtures/types/conditional-infer-nested.src 1`] = ` Object { "body": Array [ Object { "id": Object { "loc": Object { "end": Object { - "column": 12, + "column": 13, "line": 1, }, "start": Object { @@ -108041,17 +109644,17 @@ Object { "line": 1, }, }, - "name": "Element", + "name": "Unpacked", "range": Array [ 5, - 12, + 13, ], "type": "Identifier", }, "loc": Object { "end": Object { - "column": 48, - "line": 1, + "column": 10, + "line": 5, }, "start": Object { "column": 0, @@ -108060,41 +109663,41 @@ Object { }, "range": Array [ 0, - 48, + 126, ], "type": "TSTypeAliasDeclaration", "typeAnnotation": Object { "checkType": Object { "loc": Object { "end": Object { - "column": 19, - "line": 1, + "column": 3, + "line": 2, }, "start": Object { - "column": 18, - "line": 1, + "column": 2, + "line": 2, }, }, "range": Array [ - 18, - 19, + 21, + 22, ], "type": "TSTypeReference", "typeName": Object { "loc": Object { "end": Object { - "column": 19, - "line": 1, + "column": 3, + "line": 2, }, "start": Object { - "column": 18, - "line": 1, + "column": 2, + "line": 2, }, }, "name": "T", "range": Array [ - 18, - 19, + 21, + 22, ], "type": "Identifier", }, @@ -108103,67 +109706,67 @@ Object { "elementType": Object { "loc": Object { "end": Object { - "column": 37, - "line": 1, + "column": 21, + "line": 2, }, "start": Object { - "column": 28, - "line": 1, + "column": 12, + "line": 2, }, }, "range": Array [ - 28, - 37, + 31, + 40, ], "type": "TSParenthesizedType", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 36, - "line": 1, + "column": 20, + "line": 2, }, "start": Object { - "column": 29, - "line": 1, + "column": 13, + "line": 2, }, }, "range": Array [ - 29, - 36, + 32, + 39, ], "type": "TSInferType", "typeParameter": Object { "loc": Object { "end": Object { - "column": 36, - "line": 1, + "column": 20, + "line": 2, }, "start": Object { - "column": 35, - "line": 1, + "column": 19, + "line": 2, }, }, "name": Object { "loc": Object { "end": Object { - "column": 36, - "line": 1, + "column": 20, + "line": 2, }, "start": Object { - "column": 35, - "line": 1, + "column": 19, + "line": 2, }, }, "name": "U", "range": Array [ - 35, - 36, + 38, + 39, ], "type": "Identifier", }, "range": Array [ - 35, - 36, + 38, + 39, ], "type": "TSTypeParameter", }, @@ -108171,100 +109774,432 @@ Object { }, "loc": Object { "end": Object { - "column": 39, - "line": 1, + "column": 23, + "line": 2, }, "start": Object { - "column": 28, - "line": 1, + "column": 12, + "line": 2, }, }, "range": Array [ - 28, - 39, + 31, + 42, ], "type": "TSArrayType", }, "falseType": Object { + "checkType": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 53, + 54, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "name": "T", + "range": Array [ + 53, + 54, + ], + "type": "Identifier", + }, + }, + "extendsType": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 3, + }, + "start": Object { + "column": 14, + "line": 3, + }, + }, + "range": Array [ + 63, + 70, + ], + "type": "TSInferType", + "typeParameter": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 3, + }, + "start": Object { + "column": 20, + "line": 3, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 3, + }, + "start": Object { + "column": 20, + "line": 3, + }, + }, + "name": "U", + "range": Array [ + 69, + 70, + ], + "type": "Identifier", + }, + "range": Array [ + 69, + 70, + ], + "type": "TSTypeParameter", + }, + }, + "falseType": Object { + "checkType": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 4, + }, + "start": Object { + "column": 6, + "line": 4, + }, + }, + "range": Array [ + 83, + 84, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 4, + }, + "start": Object { + "column": 6, + "line": 4, + }, + }, + "name": "T", + "range": Array [ + 83, + 84, + ], + "type": "Identifier", + }, + }, + "extendsType": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 4, + }, + "start": Object { + "column": 16, + "line": 4, + }, + }, + "range": Array [ + 93, + 109, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 4, + }, + "start": Object { + "column": 16, + "line": 4, + }, + }, + "name": "Promise", + "range": Array [ + 93, + 100, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 4, + }, + "start": Object { + "column": 23, + "line": 4, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 4, + }, + "start": Object { + "column": 24, + "line": 4, + }, + }, + "range": Array [ + 101, + 108, + ], + "type": "TSInferType", + "typeParameter": Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 4, + }, + "start": Object { + "column": 30, + "line": 4, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 4, + }, + "start": Object { + "column": 30, + "line": 4, + }, + }, + "name": "U", + "range": Array [ + 107, + 108, + ], + "type": "Identifier", + }, + "range": Array [ + 107, + 108, + ], + "type": "TSTypeParameter", + }, + }, + ], + "range": Array [ + 100, + 109, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + "falseType": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 5, + }, + "start": Object { + "column": 8, + "line": 5, + }, + }, + "range": Array [ + 124, + 125, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 5, + }, + "start": Object { + "column": 8, + "line": 5, + }, + }, + "name": "T", + "range": Array [ + 124, + 125, + ], + "type": "Identifier", + }, + }, + "loc": Object { + "end": Object { + "column": 9, + "line": 5, + }, + "start": Object { + "column": 6, + "line": 4, + }, + }, + "range": Array [ + 83, + 125, + ], + "trueType": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 4, + }, + "start": Object { + "column": 35, + "line": 4, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 4, + }, + "start": Object { + "column": 35, + "line": 4, + }, + }, + "name": "U", + "range": Array [ + 112, + 113, + ], + "type": "Identifier", + }, + }, + "type": "TSConditionalType", + }, "loc": Object { "end": Object { - "column": 47, - "line": 1, + "column": 9, + "line": 5, }, "start": Object { - "column": 46, - "line": 1, + "column": 4, + "line": 3, }, }, "range": Array [ - 46, - 47, + 53, + 125, ], - "type": "TSTypeReference", - "typeName": Object { + "trueType": Object { "loc": Object { "end": Object { - "column": 47, - "line": 1, + "column": 25, + "line": 3, }, "start": Object { - "column": 46, - "line": 1, + "column": 24, + "line": 3, }, }, - "name": "T", "range": Array [ - 46, - 47, + 73, + 74, ], - "type": "Identifier", + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 3, + }, + "start": Object { + "column": 24, + "line": 3, + }, + }, + "name": "U", + "range": Array [ + 73, + 74, + ], + "type": "Identifier", + }, }, + "type": "TSConditionalType", }, "loc": Object { "end": Object { - "column": 47, - "line": 1, + "column": 9, + "line": 5, }, "start": Object { - "column": 18, - "line": 1, + "column": 2, + "line": 2, }, }, - "range": Array [ - 18, - 47, + "range": Array [ + 21, + 125, ], "trueType": Object { "loc": Object { "end": Object { - "column": 43, - "line": 1, + "column": 27, + "line": 2, }, "start": Object { - "column": 42, - "line": 1, + "column": 26, + "line": 2, }, }, "range": Array [ - 42, - 43, + 45, + 46, ], "type": "TSTypeReference", "typeName": Object { "loc": Object { "end": Object { - "column": 43, - "line": 1, + "column": 27, + "line": 2, }, "start": Object { - "column": 42, - "line": 1, + "column": 26, + "line": 2, }, }, "name": "U", "range": Array [ - 42, - 43, + 45, + 46, ], "type": "Identifier", }, @@ -108274,11 +110209,11 @@ Object { "typeParameters": Object { "loc": Object { "end": Object { - "column": 15, + "column": 16, "line": 1, }, "start": Object { - "column": 12, + "column": 13, "line": 1, }, }, @@ -108286,42 +110221,42 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, + "column": 15, "line": 1, }, "start": Object { - "column": 13, + "column": 14, "line": 1, }, }, "name": Object { "loc": Object { "end": Object { - "column": 14, + "column": 15, "line": 1, }, "start": Object { - "column": 13, + "column": 14, "line": 1, }, }, "name": "T", "range": Array [ - 13, 14, + 15, ], "type": "Identifier", }, "range": Array [ - 13, 14, + 15, ], "type": "TSTypeParameter", }, ], "range": Array [ - 12, - 15, + 13, + 16, ], "type": "TSTypeParameterDeclaration", }, @@ -108330,7 +110265,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 2, + "line": 6, }, "start": Object { "column": 0, @@ -108339,7 +110274,7 @@ Object { }, "range": Array [ 0, - 49, + 127, ], "sourceType": "script", "tokens": Array [ @@ -108364,7 +110299,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 12, + "column": 13, "line": 1, }, "start": Object { @@ -108374,25 +110309,25 @@ Object { }, "range": Array [ 5, - 12, + 13, ], "type": "Identifier", - "value": "Element", + "value": "Unpacked", }, Object { "loc": Object { "end": Object { - "column": 13, + "column": 14, "line": 1, }, "start": Object { - "column": 12, + "column": 13, "line": 1, }, }, "range": Array [ - 12, 13, + 14, ], "type": "Punctuator", "value": "<", @@ -108400,17 +110335,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, + "column": 15, "line": 1, }, "start": Object { - "column": 13, + "column": 14, "line": 1, }, }, "range": Array [ - 13, 14, + 15, ], "type": "Identifier", "value": "T", @@ -108418,17 +110353,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 16, "line": 1, }, "start": Object { - "column": 14, + "column": 15, "line": 1, }, }, "range": Array [ - 14, 15, + 16, ], "type": "Punctuator", "value": ">", @@ -108436,17 +110371,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 17, + "column": 18, "line": 1, }, "start": Object { - "column": 16, + "column": 17, "line": 1, }, }, "range": Array [ - 16, 17, + 18, ], "type": "Punctuator", "value": "=", @@ -108454,17 +110389,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, - "line": 1, + "column": 3, + "line": 2, }, "start": Object { - "column": 18, - "line": 1, + "column": 2, + "line": 2, }, }, "range": Array [ - 18, - 19, + 21, + 22, ], "type": "Identifier", "value": "T", @@ -108472,17 +110407,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 27, - "line": 1, + "column": 11, + "line": 2, }, "start": Object { - "column": 20, - "line": 1, + "column": 4, + "line": 2, }, }, "range": Array [ - 20, - 27, + 23, + 30, ], "type": "Keyword", "value": "extends", @@ -108490,17 +110425,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 29, - "line": 1, + "column": 13, + "line": 2, }, "start": Object { - "column": 28, - "line": 1, + "column": 12, + "line": 2, }, }, "range": Array [ - 28, - 29, + 31, + 32, ], "type": "Punctuator", "value": "(", @@ -108508,17 +110443,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 34, - "line": 1, + "column": 18, + "line": 2, }, "start": Object { - "column": 29, - "line": 1, + "column": 13, + "line": 2, }, }, "range": Array [ - 29, - 34, + 32, + 37, ], "type": "Identifier", "value": "infer", @@ -108526,17 +110461,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 36, - "line": 1, + "column": 20, + "line": 2, }, "start": Object { - "column": 35, - "line": 1, + "column": 19, + "line": 2, }, }, "range": Array [ - 35, - 36, + 38, + 39, ], "type": "Identifier", "value": "U", @@ -108544,17 +110479,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 37, - "line": 1, + "column": 21, + "line": 2, }, "start": Object { - "column": 36, - "line": 1, + "column": 20, + "line": 2, }, }, "range": Array [ - 36, - 37, + 39, + 40, ], "type": "Punctuator", "value": ")", @@ -108562,17 +110497,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 38, - "line": 1, + "column": 22, + "line": 2, }, "start": Object { - "column": 37, - "line": 1, + "column": 21, + "line": 2, }, }, "range": Array [ - 37, - 38, + 40, + 41, ], "type": "Punctuator", "value": "[", @@ -108580,17 +110515,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 39, - "line": 1, + "column": 23, + "line": 2, }, "start": Object { - "column": 38, - "line": 1, + "column": 22, + "line": 2, }, }, "range": Array [ - 38, - 39, + 41, + 42, ], "type": "Punctuator", "value": "]", @@ -108598,17 +110533,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 41, - "line": 1, + "column": 25, + "line": 2, }, "start": Object { - "column": 40, - "line": 1, + "column": 24, + "line": 2, }, }, "range": Array [ - 40, - 41, + 43, + 44, ], "type": "Punctuator", "value": "?", @@ -108616,17 +110551,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 43, - "line": 1, + "column": 27, + "line": 2, }, "start": Object { - "column": 42, - "line": 1, + "column": 26, + "line": 2, }, }, "range": Array [ - 42, - 43, + 45, + 46, ], "type": "Identifier", "value": "U", @@ -108634,17 +110569,323 @@ Object { Object { "loc": Object { "end": Object { - "column": 45, - "line": 1, + "column": 29, + "line": 2, }, "start": Object { - "column": 44, - "line": 1, + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 53, + 54, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 55, + 62, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 3, + }, + "start": Object { + "column": 14, + "line": 3, + }, + }, + "range": Array [ + 63, + 68, + ], + "type": "Identifier", + "value": "infer", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 3, + }, + "start": Object { + "column": 20, + "line": 3, + }, + }, + "range": Array [ + 69, + 70, + ], + "type": "Identifier", + "value": "U", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 22, + "line": 3, + }, + }, + "range": Array [ + 71, + 72, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 3, + }, + "start": Object { + "column": 24, + "line": 3, + }, + }, + "range": Array [ + 73, + 74, + ], + "type": "Identifier", + "value": "U", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "range": Array [ + 75, + 76, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 4, + }, + "start": Object { + "column": 6, + "line": 4, + }, + }, + "range": Array [ + 83, + 84, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 8, + "line": 4, + }, + }, + "range": Array [ + 85, + 92, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 4, + }, + "start": Object { + "column": 16, + "line": 4, + }, + }, + "range": Array [ + 93, + 100, + ], + "type": "Identifier", + "value": "Promise", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 4, + }, + "start": Object { + "column": 23, + "line": 4, + }, + }, + "range": Array [ + 100, + 101, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 4, + }, + "start": Object { + "column": 24, + "line": 4, + }, + }, + "range": Array [ + 101, + 106, + ], + "type": "Identifier", + "value": "infer", + }, + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 4, + }, + "start": Object { + "column": 30, + "line": 4, + }, + }, + "range": Array [ + 107, + 108, + ], + "type": "Identifier", + "value": "U", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 4, + }, + "start": Object { + "column": 31, + "line": 4, + }, + }, + "range": Array [ + 108, + 109, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 4, + }, + "start": Object { + "column": 33, + "line": 4, + }, + }, + "range": Array [ + 110, + 111, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 4, + }, + "start": Object { + "column": 35, + "line": 4, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "Identifier", + "value": "U", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 4, + }, + "start": Object { + "column": 37, + "line": 4, }, }, "range": Array [ - 44, - 45, + 114, + 115, ], "type": "Punctuator", "value": ":", @@ -108652,17 +110893,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 47, - "line": 1, + "column": 9, + "line": 5, }, "start": Object { - "column": 46, - "line": 1, + "column": 8, + "line": 5, }, }, "range": Array [ - 46, - 47, + 124, + 125, ], "type": "Identifier", "value": "T", @@ -108670,17 +110911,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 48, - "line": 1, + "column": 10, + "line": 5, }, "start": Object { - "column": 47, - "line": 1, + "column": 9, + "line": 5, }, }, "range": Array [ - 47, - 48, + 125, + 126, ], "type": "Punctuator", "value": ";", @@ -108690,14 +110931,14 @@ Object { } `; -exports[`typescript fixtures/types/conditional-infer-nested.src 1`] = ` +exports[`typescript fixtures/types/conditional-infer-simple.src 1`] = ` Object { "body": Array [ Object { "id": Object { "loc": Object { "end": Object { - "column": 13, + "column": 8, "line": 1, }, "start": Object { @@ -108705,17 +110946,17 @@ Object { "line": 1, }, }, - "name": "Unpacked", + "name": "Foo", "range": Array [ 5, - 13, + 8, ], "type": "Identifier", }, "loc": Object { "end": Object { - "column": 10, - "line": 5, + "column": 63, + "line": 1, }, "start": Object { "column": 0, @@ -108724,543 +110965,336 @@ Object { }, "range": Array [ 0, - 126, + 63, ], "type": "TSTypeAliasDeclaration", "typeAnnotation": Object { "checkType": Object { "loc": Object { "end": Object { - "column": 3, - "line": 2, + "column": 15, + "line": 1, }, "start": Object { - "column": 2, - "line": 2, + "column": 14, + "line": 1, }, }, "range": Array [ - 21, - 22, + 14, + 15, ], "type": "TSTypeReference", "typeName": Object { "loc": Object { "end": Object { - "column": 3, - "line": 2, + "column": 15, + "line": 1, }, "start": Object { - "column": 2, - "line": 2, + "column": 14, + "line": 1, }, }, "name": "T", "range": Array [ - 21, - 22, + 14, + 15, ], "type": "Identifier", }, }, "extendsType": Object { - "elementType": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 2, - }, - "start": Object { - "column": 12, - "line": 2, - }, - }, - "range": Array [ - 31, - 40, - ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 2, - }, - "start": Object { - "column": 13, - "line": 2, - }, - }, - "range": Array [ - 32, - 39, - ], - "type": "TSInferType", - "typeParameter": Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 2, - }, - "start": Object { - "column": 19, - "line": 2, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 2, - }, - "start": Object { - "column": 19, - "line": 2, - }, - }, - "name": "U", - "range": Array [ - 38, - 39, - ], - "type": "Identifier", - }, - "range": Array [ - 38, - 39, - ], - "type": "TSTypeParameter", - }, - }, - }, "loc": Object { "end": Object { - "column": 23, - "line": 2, + "column": 50, + "line": 1, }, "start": Object { - "column": 12, - "line": 2, - }, - }, - "range": Array [ - 31, - 42, - ], - "type": "TSArrayType", - }, - "falseType": Object { - "checkType": Object { - "loc": Object { - "end": Object { - "column": 5, - "line": 3, - }, - "start": Object { - "column": 4, - "line": 3, - }, - }, - "range": Array [ - 53, - 54, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 5, - "line": 3, - }, - "start": Object { - "column": 4, - "line": 3, - }, - }, - "name": "T", - "range": Array [ - 53, - 54, - ], - "type": "Identifier", - }, - }, - "extendsType": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 3, - }, - "start": Object { - "column": 14, - "line": 3, - }, - }, - "range": Array [ - 63, - 70, - ], - "type": "TSInferType", - "typeParameter": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 3, - }, - "start": Object { - "column": 20, - "line": 3, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 3, - }, - "start": Object { - "column": 20, - "line": 3, - }, - }, - "name": "U", - "range": Array [ - 69, - 70, - ], - "type": "Identifier", - }, - "range": Array [ - 69, - 70, - ], - "type": "TSTypeParameter", + "column": 24, + "line": 1, }, }, - "falseType": Object { - "checkType": Object { - "loc": Object { - "end": Object { - "column": 7, - "line": 4, - }, - "start": Object { - "column": 6, - "line": 4, - }, - }, - "range": Array [ - 83, - 84, - ], - "type": "TSTypeReference", - "typeName": Object { + "members": Array [ + Object { + "computed": false, + "key": Object { "loc": Object { "end": Object { - "column": 7, - "line": 4, + "column": 27, + "line": 1, }, "start": Object { - "column": 6, - "line": 4, + "column": 26, + "line": 1, }, }, - "name": "T", + "name": "a", "range": Array [ - 83, - 84, + 26, + 27, ], "type": "Identifier", }, - }, - "extendsType": Object { "loc": Object { "end": Object { - "column": 32, - "line": 4, + "column": 37, + "line": 1, }, "start": Object { - "column": 16, - "line": 4, + "column": 26, + "line": 1, }, }, "range": Array [ - 93, - 109, + 26, + 37, ], - "type": "TSTypeReference", - "typeName": Object { + "type": "TSPropertySignature", + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 23, - "line": 4, + "column": 36, + "line": 1, }, "start": Object { - "column": 16, - "line": 4, + "column": 27, + "line": 1, }, }, - "name": "Promise", "range": Array [ - 93, - 100, + 27, + 36, ], - "type": "Identifier", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 32, - "line": 4, - }, - "start": Object { - "column": 23, - "line": 4, + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, }, - }, - "params": Array [ - Object { + "range": Array [ + 29, + 36, + ], + "type": "TSInferType", + "typeParameter": Object { "loc": Object { "end": Object { - "column": 31, - "line": 4, + "column": 36, + "line": 1, }, "start": Object { - "column": 24, - "line": 4, + "column": 35, + "line": 1, }, }, - "range": Array [ - 101, - 108, - ], - "type": "TSInferType", - "typeParameter": Object { + "name": Object { "loc": Object { "end": Object { - "column": 31, - "line": 4, + "column": 36, + "line": 1, }, "start": Object { - "column": 30, - "line": 4, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 31, - "line": 4, - }, - "start": Object { - "column": 30, - "line": 4, - }, + "column": 35, + "line": 1, }, - "name": "U", - "range": Array [ - 107, - 108, - ], - "type": "Identifier", }, + "name": "U", "range": Array [ - 107, - 108, + 35, + 36, ], - "type": "TSTypeParameter", + "type": "Identifier", }, + "range": Array [ + 35, + 36, + ], + "type": "TSTypeParameter", }, - ], - "range": Array [ - 100, - 109, - ], - "type": "TSTypeParameterInstantiation", - }, - }, - "falseType": Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 5, - }, - "start": Object { - "column": 8, - "line": 5, }, }, - "range": Array [ - 124, - 125, - ], - "type": "TSTypeReference", - "typeName": Object { + }, + Object { + "computed": false, + "key": Object { "loc": Object { "end": Object { - "column": 9, - "line": 5, + "column": 39, + "line": 1, }, "start": Object { - "column": 8, - "line": 5, + "column": 38, + "line": 1, }, }, - "name": "T", + "name": "b", "range": Array [ - 124, - 125, + 38, + 39, ], "type": "Identifier", }, - }, - "loc": Object { - "end": Object { - "column": 9, - "line": 5, - }, - "start": Object { - "column": 6, - "line": 4, - }, - }, - "range": Array [ - 83, - 125, - ], - "trueType": Object { "loc": Object { "end": Object { - "column": 36, - "line": 4, + "column": 48, + "line": 1, }, "start": Object { - "column": 35, - "line": 4, + "column": 38, + "line": 1, }, }, "range": Array [ - 112, - 113, + 38, + 48, ], - "type": "TSTypeReference", - "typeName": Object { + "type": "TSPropertySignature", + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 36, - "line": 4, + "column": 48, + "line": 1, }, "start": Object { - "column": 35, - "line": 4, + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 48, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 48, + ], + "type": "TSInferType", + "typeParameter": Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "name": "U", + "range": Array [ + 47, + 48, + ], + "type": "Identifier", + }, + "range": Array [ + 47, + 48, + ], + "type": "TSTypeParameter", }, }, - "name": "U", - "range": Array [ - 112, - 113, - ], - "type": "Identifier", }, }, - "type": "TSConditionalType", - }, + ], + "range": Array [ + 24, + 50, + ], + "type": "TSTypeLiteral", + }, + "falseType": Object { "loc": Object { "end": Object { - "column": 9, - "line": 5, + "column": 62, + "line": 1, }, "start": Object { - "column": 4, - "line": 3, + "column": 57, + "line": 1, }, }, "range": Array [ - 53, - 125, + 57, + 62, ], - "trueType": Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 3, - }, - "start": Object { - "column": 24, - "line": 3, - }, - }, - "range": Array [ - 73, - 74, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 3, - }, - "start": Object { - "column": 24, - "line": 3, - }, - }, - "name": "U", - "range": Array [ - 73, - 74, - ], - "type": "Identifier", - }, - }, - "type": "TSConditionalType", + "type": "TSNeverKeyword", }, "loc": Object { "end": Object { - "column": 9, - "line": 5, + "column": 62, + "line": 1, }, "start": Object { - "column": 2, - "line": 2, + "column": 14, + "line": 1, }, }, "range": Array [ - 21, - 125, + 14, + 62, ], "trueType": Object { "loc": Object { "end": Object { - "column": 27, - "line": 2, + "column": 54, + "line": 1, }, "start": Object { - "column": 26, - "line": 2, + "column": 53, + "line": 1, }, }, "range": Array [ - 45, - 46, + 53, + 54, ], "type": "TSTypeReference", "typeName": Object { "loc": Object { "end": Object { - "column": 27, - "line": 2, + "column": 54, + "line": 1, }, "start": Object { - "column": 26, - "line": 2, + "column": 53, + "line": 1, }, }, "name": "U", "range": Array [ - 45, - 46, + 53, + 54, ], "type": "Identifier", }, @@ -109270,11 +111304,11 @@ Object { "typeParameters": Object { "loc": Object { "end": Object { - "column": 16, + "column": 11, "line": 1, }, "start": Object { - "column": 13, + "column": 8, "line": 1, }, }, @@ -109282,42 +111316,42 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 10, "line": 1, }, "start": Object { - "column": 14, + "column": 9, "line": 1, }, }, "name": Object { "loc": Object { "end": Object { - "column": 15, + "column": 10, "line": 1, }, "start": Object { - "column": 14, + "column": 9, "line": 1, }, }, "name": "T", "range": Array [ - 14, - 15, + 9, + 10, ], "type": "Identifier", }, "range": Array [ - 14, - 15, + 9, + 10, ], "type": "TSTypeParameter", }, ], "range": Array [ - 13, - 16, + 8, + 11, ], "type": "TSTypeParameterDeclaration", }, @@ -109326,7 +111360,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 2, }, "start": Object { "column": 0, @@ -109335,7 +111369,7 @@ Object { }, "range": Array [ 0, - 127, + 64, ], "sourceType": "script", "tokens": Array [ @@ -109360,7 +111394,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 8, "line": 1, }, "start": Object { @@ -109370,25 +111404,25 @@ Object { }, "range": Array [ 5, - 13, + 8, ], "type": "Identifier", - "value": "Unpacked", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 14, + "column": 9, "line": 1, }, "start": Object { - "column": 13, + "column": 8, "line": 1, }, }, "range": Array [ - 13, - 14, + 8, + 9, ], "type": "Punctuator", "value": "<", @@ -109396,17 +111430,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 10, "line": 1, }, "start": Object { - "column": 14, + "column": 9, "line": 1, }, }, "range": Array [ - 14, - 15, + 9, + 10, ], "type": "Identifier", "value": "T", @@ -109414,17 +111448,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 11, "line": 1, }, "start": Object { - "column": 15, + "column": 10, "line": 1, }, }, "range": Array [ - 15, - 16, + 10, + 11, ], "type": "Punctuator", "value": ">", @@ -109432,17 +111466,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 18, + "column": 13, "line": 1, }, "start": Object { - "column": 17, + "column": 12, "line": 1, }, }, "range": Array [ - 17, - 18, + 12, + 13, ], "type": "Punctuator", "value": "=", @@ -109450,17 +111484,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 3, - "line": 2, + "column": 15, + "line": 1, }, "start": Object { - "column": 2, - "line": 2, + "column": 14, + "line": 1, }, }, "range": Array [ - 21, - 22, + 14, + 15, ], "type": "Identifier", "value": "T", @@ -109468,179 +111502,71 @@ Object { Object { "loc": Object { "end": Object { - "column": 11, - "line": 2, + "column": 23, + "line": 1, }, "start": Object { - "column": 4, - "line": 2, + "column": 16, + "line": 1, }, }, "range": Array [ + 16, 23, - 30, ], "type": "Keyword", "value": "extends", }, - Object { - "loc": Object { - "end": Object { - "column": 13, - "line": 2, - }, - "start": Object { - "column": 12, - "line": 2, - }, - }, - "range": Array [ - 31, - 32, - ], - "type": "Punctuator", - "value": "(", - }, - Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 2, - }, - "start": Object { - "column": 13, - "line": 2, - }, - }, - "range": Array [ - 32, - 37, - ], - "type": "Identifier", - "value": "infer", - }, - Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 2, - }, - "start": Object { - "column": 19, - "line": 2, - }, - }, - "range": Array [ - 38, - 39, - ], - "type": "Identifier", - "value": "U", - }, - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 2, - }, - "start": Object { - "column": 20, - "line": 2, - }, - }, - "range": Array [ - 39, - 40, - ], - "type": "Punctuator", - "value": ")", - }, - Object { - "loc": Object { - "end": Object { - "column": 22, - "line": 2, - }, - "start": Object { - "column": 21, - "line": 2, - }, - }, - "range": Array [ - 40, - 41, - ], - "type": "Punctuator", - "value": "[", - }, - Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 2, - }, - "start": Object { - "column": 22, - "line": 2, - }, - }, - "range": Array [ - 41, - 42, - ], - "type": "Punctuator", - "value": "]", - }, Object { "loc": Object { "end": Object { "column": 25, - "line": 2, + "line": 1, }, "start": Object { "column": 24, - "line": 2, + "line": 1, }, }, "range": Array [ - 43, - 44, + 24, + 25, ], "type": "Punctuator", - "value": "?", + "value": "{", }, Object { "loc": Object { "end": Object { "column": 27, - "line": 2, + "line": 1, }, "start": Object { "column": 26, - "line": 2, + "line": 1, }, }, "range": Array [ - 45, - 46, + 26, + 27, ], "type": "Identifier", - "value": "U", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 29, - "line": 2, + "column": 28, + "line": 1, }, "start": Object { - "column": 28, - "line": 2, + "column": 27, + "line": 1, }, }, "range": Array [ - 47, - 48, + 27, + 28, ], "type": "Punctuator", "value": ":", @@ -109648,53 +111574,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 5, - "line": 3, - }, - "start": Object { - "column": 4, - "line": 3, - }, - }, - "range": Array [ - 53, - 54, - ], - "type": "Identifier", - "value": "T", - }, - Object { - "loc": Object { - "end": Object { - "column": 13, - "line": 3, - }, - "start": Object { - "column": 6, - "line": 3, - }, - }, - "range": Array [ - 55, - 62, - ], - "type": "Keyword", - "value": "extends", - }, - Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 3, + "column": 34, + "line": 1, }, "start": Object { - "column": 14, - "line": 3, + "column": 29, + "line": 1, }, }, "range": Array [ - 63, - 68, + 29, + 34, ], "type": "Identifier", "value": "infer", @@ -109702,53 +111592,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 21, - "line": 3, - }, - "start": Object { - "column": 20, - "line": 3, - }, - }, - "range": Array [ - 69, - 70, - ], - "type": "Identifier", - "value": "U", - }, - Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 3, - }, - "start": Object { - "column": 22, - "line": 3, - }, - }, - "range": Array [ - 71, - 72, - ], - "type": "Punctuator", - "value": "?", - }, - Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 3, + "column": 36, + "line": 1, }, "start": Object { - "column": 24, - "line": 3, + "column": 35, + "line": 1, }, }, "range": Array [ - 73, - 74, + 35, + 36, ], "type": "Identifier", "value": "U", @@ -109756,107 +111610,71 @@ Object { Object { "loc": Object { "end": Object { - "column": 27, - "line": 3, + "column": 37, + "line": 1, }, "start": Object { - "column": 26, - "line": 3, + "column": 36, + "line": 1, }, }, "range": Array [ - 75, - 76, + 36, + 37, ], "type": "Punctuator", - "value": ":", - }, - Object { - "loc": Object { - "end": Object { - "column": 7, - "line": 4, - }, - "start": Object { - "column": 6, - "line": 4, - }, - }, - "range": Array [ - 83, - 84, - ], - "type": "Identifier", - "value": "T", - }, - Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 4, - }, - "start": Object { - "column": 8, - "line": 4, - }, - }, - "range": Array [ - 85, - 92, - ], - "type": "Keyword", - "value": "extends", + "value": ",", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 4, + "column": 39, + "line": 1, }, "start": Object { - "column": 16, - "line": 4, + "column": 38, + "line": 1, }, }, "range": Array [ - 93, - 100, + 38, + 39, ], "type": "Identifier", - "value": "Promise", + "value": "b", }, Object { "loc": Object { "end": Object { - "column": 24, - "line": 4, + "column": 40, + "line": 1, }, "start": Object { - "column": 23, - "line": 4, + "column": 39, + "line": 1, }, }, "range": Array [ - 100, - 101, + 39, + 40, ], "type": "Punctuator", - "value": "<", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 29, - "line": 4, + "column": 46, + "line": 1, }, "start": Object { - "column": 24, - "line": 4, + "column": 41, + "line": 1, }, }, "range": Array [ - 101, - 106, + 41, + 46, ], "type": "Identifier", "value": "infer", @@ -109864,17 +111682,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 31, - "line": 4, + "column": 48, + "line": 1, }, "start": Object { - "column": 30, - "line": 4, + "column": 47, + "line": 1, }, }, "range": Array [ - 107, - 108, + 47, + 48, ], "type": "Identifier", "value": "U", @@ -109882,35 +111700,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 32, - "line": 4, + "column": 50, + "line": 1, }, "start": Object { - "column": 31, - "line": 4, + "column": 49, + "line": 1, }, }, "range": Array [ - 108, - 109, + 49, + 50, ], "type": "Punctuator", - "value": ">", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 34, - "line": 4, + "column": 52, + "line": 1, }, "start": Object { - "column": 33, - "line": 4, + "column": 51, + "line": 1, }, }, "range": Array [ - 110, - 111, + 51, + 52, ], "type": "Punctuator", "value": "?", @@ -109918,17 +111736,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 36, - "line": 4, + "column": 54, + "line": 1, }, "start": Object { - "column": 35, - "line": 4, + "column": 53, + "line": 1, }, }, "range": Array [ - 112, - 113, + 53, + 54, ], "type": "Identifier", "value": "U", @@ -109936,17 +111754,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 38, - "line": 4, + "column": 56, + "line": 1, }, "start": Object { - "column": 37, - "line": 4, + "column": 55, + "line": 1, }, }, "range": Array [ - 114, - 115, + 55, + 56, ], "type": "Punctuator", "value": ":", @@ -109954,35 +111772,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, - "line": 5, + "column": 62, + "line": 1, }, "start": Object { - "column": 8, - "line": 5, + "column": 57, + "line": 1, }, }, "range": Array [ - 124, - 125, + 57, + 62, ], "type": "Identifier", - "value": "T", + "value": "never", }, Object { "loc": Object { "end": Object { - "column": 10, - "line": 5, + "column": 63, + "line": 1, }, "start": Object { - "column": 9, - "line": 5, + "column": 62, + "line": 1, }, }, "range": Array [ - 125, - 126, + 62, + 63, ], "type": "Punctuator", "value": ";", @@ -109992,430 +111810,166 @@ Object { } `; -exports[`typescript fixtures/types/conditional-infer-simple.src 1`] = ` +exports[`typescript fixtures/types/conditional-with-null.src 1`] = ` Object { "body": Array [ Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "name": "Foo", - "range": Array [ - 5, - 8, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 63, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 63, - ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "checkType": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 14, - "line": 1, - }, - }, - "range": Array [ - 14, - 15, - ], - "type": "TSTypeReference", - "typeName": Object { + "declarations": Array [ + Object { + "id": Object { "loc": Object { "end": Object { - "column": 15, + "column": 45, "line": 1, }, "start": Object { - "column": 14, + "column": 4, "line": 1, }, }, - "name": "T", + "name": "x", "range": Array [ - 14, - 15, + 4, + 45, ], "type": "Identifier", - }, - }, - "extendsType": Object { - "loc": Object { - "end": Object { - "column": 50, - "line": 1, - }, - "start": Object { - "column": 24, - "line": 1, - }, - }, - "members": Array [ - Object { - "computed": false, - "key": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 26, - "line": 1, - }, - }, - "name": "a", - "range": Array [ - 26, - 27, - ], - "type": "Identifier", - }, + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 37, + "column": 45, "line": 1, }, "start": Object { - "column": 26, + "column": 5, "line": 1, }, }, "range": Array [ - 26, - 37, + 5, + 45, ], - "type": "TSPropertySignature", + "type": "TSTypeAnnotation", "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 27, - "line": 1, - }, - }, - "range": Array [ - 27, - 36, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "checkType": Object { "loc": Object { "end": Object { - "column": 36, + "column": 13, "line": 1, }, "start": Object { - "column": 29, + "column": 7, "line": 1, }, }, "range": Array [ - 29, - 36, + 7, + 13, ], - "type": "TSInferType", - "typeParameter": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 35, - "line": 1, - }, + "type": "TSNumberKeyword", + }, + "extendsType": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, }, - "name": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 35, - "line": 1, - }, - }, - "name": "U", - "range": Array [ - 35, - 36, - ], - "type": "Identifier", + "start": Object { + "column": 22, + "line": 1, }, - "range": Array [ - 35, - 36, - ], - "type": "TSTypeParameter", }, + "range": Array [ + 22, + 28, + ], + "type": "TSStringKeyword", }, - }, - }, - Object { - "computed": false, - "key": Object { - "loc": Object { - "end": Object { - "column": 39, - "line": 1, - }, - "start": Object { - "column": 38, - "line": 1, + "falseType": Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, }, + "range": Array [ + 41, + 45, + ], + "type": "TSNullKeyword", }, - "name": "b", - "range": Array [ - 38, - 39, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 38, - "line": 1, - }, - }, - "range": Array [ - 38, - 48, - ], - "type": "TSPropertySignature", - "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 48, + "column": 45, "line": 1, }, "start": Object { - "column": 39, + "column": 7, "line": 1, }, }, "range": Array [ - 39, - 48, + 7, + 45, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "trueType": Object { "loc": Object { "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 41, + "column": 38, "line": 1, - }, - }, - "range": Array [ - 41, - 48, - ], - "type": "TSInferType", - "typeParameter": Object { - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 47, - "line": 1, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 47, - "line": 1, - }, - }, - "name": "U", - "range": Array [ - 47, - 48, - ], - "type": "Identifier", - }, - "range": Array [ - 47, - 48, - ], - "type": "TSTypeParameter", - }, - }, - }, - }, - ], - "range": Array [ - 24, - 50, - ], - "type": "TSTypeLiteral", - }, - "falseType": Object { - "loc": Object { - "end": Object { - "column": 62, - "line": 1, - }, - "start": Object { - "column": 57, - "line": 1, - }, - }, - "range": Array [ - 57, - 62, - ], - "type": "TSNeverKeyword", - }, - "loc": Object { - "end": Object { - "column": 62, - "line": 1, - }, - "start": Object { - "column": 14, - "line": 1, - }, - }, - "range": Array [ - 14, - 62, - ], - "trueType": Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 1, - }, - "start": Object { - "column": 53, - "line": 1, - }, - }, - "range": Array [ - 53, - 54, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 1, - }, - "start": Object { - "column": 53, - "line": 1, - }, - }, - "name": "U", - "range": Array [ - 53, - 54, - ], - "type": "Identifier", - }, - }, - "type": "TSConditionalType", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 11, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 38, + ], + "type": "TSBooleanKeyword", }, + "type": "TSConditionalType", }, - "name": "T", - "range": Array [ - 9, - 10, - ], - "type": "Identifier", }, - "range": Array [ - 9, - 10, - ], - "type": "TSTypeParameter", }, - ], - "range": Array [ - 8, - 11, - ], - "type": "TSTypeParameterDeclaration", + "init": null, + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 45, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, }, + "range": Array [ + 0, + 46, + ], + "type": "VariableDeclaration", }, ], "loc": Object { @@ -110430,14 +111984,14 @@ Object { }, "range": Array [ 0, - 64, + 47, ], "sourceType": "script", "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 4, + "column": 3, "line": 1, }, "start": Object { @@ -110447,15 +112001,33 @@ Object { }, "range": Array [ 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ 4, + 5, ], "type": "Identifier", - "value": "type", + "value": "x", }, Object { "loc": Object { "end": Object { - "column": 8, + "column": 6, "line": 1, }, "start": Object { @@ -110465,169 +112037,461 @@ Object { }, "range": Array [ 5, - 8, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 13, ], "type": "Identifier", - "value": "Foo", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 9, + "column": 21, "line": 1, }, "start": Object { - "column": 8, + "column": 14, "line": 1, }, }, "range": Array [ - 8, - 9, + 14, + 21, ], - "type": "Punctuator", - "value": "<", + "type": "Keyword", + "value": "extends", }, Object { "loc": Object { "end": Object { - "column": 10, + "column": 28, "line": 1, }, "start": Object { - "column": 9, + "column": 22, "line": 1, }, }, "range": Array [ - 9, - 10, + 22, + 28, ], "type": "Identifier", - "value": "T", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 11, + "column": 30, "line": 1, }, "start": Object { - "column": 10, + "column": 29, "line": 1, }, }, "range": Array [ - 10, - 11, + 29, + 30, ], "type": "Punctuator", - "value": ">", + "value": "?", }, Object { "loc": Object { "end": Object { - "column": 13, + "column": 38, "line": 1, }, "start": Object { - "column": 12, + "column": 31, "line": 1, }, }, "range": Array [ - 12, - 13, + 31, + 38, ], - "type": "Punctuator", - "value": "=", + "type": "Identifier", + "value": "boolean", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 40, "line": 1, }, "start": Object { - "column": 14, + "column": 39, "line": 1, }, }, "range": Array [ - 14, - 15, + 39, + 40, ], - "type": "Identifier", - "value": "T", + "type": "Punctuator", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 23, + "column": 45, "line": 1, }, "start": Object { - "column": 16, + "column": 41, "line": 1, }, }, "range": Array [ - 16, - 23, + 41, + 45, ], "type": "Keyword", - "value": "extends", + "value": "null", }, Object { "loc": Object { "end": Object { - "column": 25, + "column": 46, "line": 1, }, "start": Object { - "column": 24, + "column": 45, "line": 1, }, }, "range": Array [ - 24, - 25, + 45, + 46, ], "type": "Punctuator", - "value": "{", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/constructor.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "f", + "range": Array [ + 4, + 42, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 42, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 12, + 21, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 21, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 21, + ], + "type": "TSNumberKeyword", + }, + }, + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "name": "b", + "optional": true, + "range": Array [ + 23, + 33, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 33, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 33, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 7, + 42, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 42, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 38, + "line": 1, + }, + }, + "range": Array [ + 38, + 42, + ], + "type": "TSVoidKeyword", + }, + }, + "type": "TSConstructorType", + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 42, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 43, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, }, + }, + "range": Array [ + 0, + 44, + ], + "sourceType": "script", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 27, + "column": 3, "line": 1, }, "start": Object { - "column": 26, + "column": 0, "line": 1, }, }, "range": Array [ - 26, - 27, + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, ], "type": "Identifier", - "value": "a", + "value": "f", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 6, "line": 1, }, "start": Object { - "column": 27, + "column": 5, "line": 1, }, }, "range": Array [ - 27, - 28, + 5, + 6, ], "type": "Punctuator", "value": ":", @@ -110635,233 +112499,251 @@ Object { Object { "loc": Object { "end": Object { - "column": 34, + "column": 10, "line": 1, }, "start": Object { - "column": 29, + "column": 7, "line": 1, }, }, "range": Array [ - 29, - 34, + 7, + 10, ], - "type": "Identifier", - "value": "infer", + "type": "Keyword", + "value": "new", }, Object { "loc": Object { "end": Object { - "column": 36, + "column": 12, "line": 1, }, "start": Object { - "column": 35, + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, "line": 1, }, }, "range": Array [ - 35, - 36, + 12, + 13, ], "type": "Identifier", - "value": "U", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 37, + "column": 14, "line": 1, }, "start": Object { - "column": 36, + "column": 13, "line": 1, }, }, "range": Array [ - 36, - 37, + 13, + 14, ], "type": "Punctuator", - "value": ",", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 39, + "column": 21, "line": 1, }, "start": Object { - "column": 38, + "column": 15, "line": 1, }, }, "range": Array [ - 38, - 39, + 15, + 21, ], "type": "Identifier", - "value": "b", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 40, + "column": 22, "line": 1, }, "start": Object { - "column": 39, + "column": 21, "line": 1, }, }, "range": Array [ - 39, - 40, + 21, + 22, ], "type": "Punctuator", - "value": ":", + "value": ",", }, Object { "loc": Object { "end": Object { - "column": 46, + "column": 24, "line": 1, }, "start": Object { - "column": 41, + "column": 23, "line": 1, }, }, "range": Array [ - 41, - 46, + 23, + 24, ], "type": "Identifier", - "value": "infer", + "value": "b", }, Object { "loc": Object { "end": Object { - "column": 48, + "column": 25, "line": 1, }, "start": Object { - "column": 47, + "column": 24, "line": 1, }, }, "range": Array [ - 47, - 48, + 24, + 25, ], - "type": "Identifier", - "value": "U", + "type": "Punctuator", + "value": "?", }, Object { "loc": Object { "end": Object { - "column": 50, + "column": 26, "line": 1, }, "start": Object { - "column": 49, + "column": 25, "line": 1, }, }, "range": Array [ - 49, - 50, + 25, + 26, ], "type": "Punctuator", - "value": "}", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 52, + "column": 33, "line": 1, }, "start": Object { - "column": 51, + "column": 27, "line": 1, }, }, "range": Array [ - 51, - 52, + 27, + 33, ], - "type": "Punctuator", - "value": "?", + "type": "Identifier", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 54, + "column": 34, "line": 1, }, "start": Object { - "column": 53, + "column": 33, "line": 1, }, }, "range": Array [ - 53, - 54, + 33, + 34, ], - "type": "Identifier", - "value": "U", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 56, + "column": 37, "line": 1, }, "start": Object { - "column": 55, + "column": 35, "line": 1, }, }, "range": Array [ - 55, - 56, + 35, + 37, ], "type": "Punctuator", - "value": ":", + "value": "=>", }, Object { "loc": Object { "end": Object { - "column": 62, + "column": 42, "line": 1, }, "start": Object { - "column": 57, + "column": 38, "line": 1, }, }, "range": Array [ - 57, - 62, + 38, + 42, ], - "type": "Identifier", - "value": "never", + "type": "Keyword", + "value": "void", }, Object { "loc": Object { "end": Object { - "column": 63, + "column": 43, "line": 1, }, "start": Object { - "column": 62, + "column": 42, "line": 1, }, }, "range": Array [ - 62, - 63, + 42, + 43, ], "type": "Punctuator", "value": ";", @@ -110871,7 +112753,7 @@ Object { } `; -exports[`typescript fixtures/types/conditional-with-null.src 1`] = ` +exports[`typescript fixtures/types/constructor-generic.src 1`] = ` Object { "body": Array [ Object { @@ -110880,7 +112762,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 45, + "column": 25, "line": 1, }, "start": Object { @@ -110888,16 +112770,16 @@ Object { "line": 1, }, }, - "name": "x", + "name": "f", "range": Array [ 4, - 45, + 25, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 45, + "column": 25, "line": 1, }, "start": Object { @@ -110907,100 +112789,210 @@ Object { }, "range": Array [ 5, - 45, + 25, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { - "checkType": Object { - "loc": Object { - "end": Object { - "column": 13, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, }, - "range": Array [ - 7, - 13, - ], - "type": "TSNumberKeyword", }, - "extendsType": Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 1, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, }, - "start": Object { - "column": 22, - "line": 1, + "name": "a", + "range": Array [ + 15, + 19, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 19, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 18, + 19, + ], + "type": "Identifier", + }, + }, }, }, - "range": Array [ - 22, - 28, - ], - "type": "TSStringKeyword", - }, - "falseType": Object { + ], + "range": Array [ + 7, + 25, + ], + "returnType": Object { "loc": Object { "end": Object { - "column": 45, + "column": 25, "line": 1, }, "start": Object { - "column": 41, + "column": 21, "line": 1, }, }, "range": Array [ - 41, - 45, + 21, + 25, ], - "type": "TSNullKeyword", - }, - "loc": Object { - "end": Object { - "column": 45, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 24, + 25, + ], + "type": "Identifier", + }, }, }, - "range": Array [ - 7, - 45, - ], - "trueType": Object { + "type": "TSConstructorType", + "typeParameters": Object { "loc": Object { "end": Object { - "column": 38, + "column": 14, "line": 1, }, "start": Object { - "column": 31, + "column": 11, "line": 1, }, }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 12, + 13, + ], + "type": "Identifier", + }, + "range": Array [ + 12, + 13, + ], + "type": "TSTypeParameter", + }, + ], "range": Array [ - 31, - 38, + 11, + 14, ], - "type": "TSBooleanKeyword", + "type": "TSTypeParameterDeclaration", }, - "type": "TSConditionalType", }, }, }, "init": null, "loc": Object { "end": Object { - "column": 45, + "column": 25, "line": 1, }, "start": Object { @@ -111010,7 +113002,7 @@ Object { }, "range": Array [ 4, - 45, + 25, ], "type": "VariableDeclarator", }, @@ -111018,7 +113010,7 @@ Object { "kind": "let", "loc": Object { "end": Object { - "column": 46, + "column": 26, "line": 1, }, "start": Object { @@ -111028,7 +113020,7 @@ Object { }, "range": Array [ 0, - 46, + 26, ], "type": "VariableDeclaration", }, @@ -111045,7 +113037,7 @@ Object { }, "range": Array [ 0, - 47, + 27, ], "sourceType": "script", "tokens": Array [ @@ -111083,7 +113075,7 @@ Object { 5, ], "type": "Identifier", - "value": "x", + "value": "f", }, Object { "loc": Object { @@ -111106,7 +113098,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 10, "line": 1, }, "start": Object { @@ -111116,15 +113108,69 @@ Object { }, "range": Array [ 7, + 10, + ], + "type": "Keyword", + "value": "new", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, 13, ], "type": "Identifier", - "value": "number", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, "line": 1, }, "start": Object { @@ -111134,115 +113180,133 @@ Object { }, "range": Array [ 14, - 21, + 15, ], - "type": "Keyword", - "value": "extends", + "type": "Punctuator", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 16, "line": 1, }, "start": Object { - "column": 22, + "column": 15, "line": 1, }, }, "range": Array [ - 22, - 28, + 15, + 16, ], "type": "Identifier", - "value": "string", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 30, + "column": 17, "line": 1, }, "start": Object { - "column": 29, + "column": 16, "line": 1, }, }, "range": Array [ - 29, - 30, + 16, + 17, ], "type": "Punctuator", - "value": "?", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 38, + "column": 19, "line": 1, }, "start": Object { - "column": 31, + "column": 18, "line": 1, }, }, "range": Array [ - 31, - 38, + 18, + 19, ], "type": "Identifier", - "value": "boolean", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 40, + "column": 20, "line": 1, }, "start": Object { - "column": 39, + "column": 19, "line": 1, }, }, "range": Array [ - 39, - 40, + 19, + 20, ], "type": "Punctuator", - "value": ":", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 45, + "column": 23, "line": 1, }, "start": Object { - "column": 41, + "column": 21, "line": 1, }, }, "range": Array [ - 41, - 45, + 21, + 23, ], - "type": "Keyword", - "value": "null", + "type": "Punctuator", + "value": "=>", }, Object { "loc": Object { "end": Object { - "column": 46, + "column": 25, "line": 1, }, "start": Object { - "column": 45, + "column": 24, "line": 1, }, }, "range": Array [ - 45, - 46, + 24, + 25, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, ], "type": "Punctuator", "value": ";", @@ -111252,7 +113316,7 @@ Object { } `; -exports[`typescript fixtures/types/constructor.src 1`] = ` +exports[`typescript fixtures/types/constructor-in-generic.src 1`] = ` Object { "body": Array [ Object { @@ -111261,7 +113325,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 42, + "column": 30, "line": 1, }, "start": Object { @@ -111269,16 +113333,16 @@ Object { "line": 1, }, }, - "name": "f", + "name": "x", "range": Array [ 4, - 42, + 30, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 42, + "column": 30, "line": 1, }, "start": Object { @@ -111288,13 +113352,13 @@ Object { }, "range": Array [ 5, - 42, + 30, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 42, + "column": 30, "line": 1, }, "start": Object { @@ -111302,28 +113366,45 @@ Object { "line": 1, }, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, + "range": Array [ + 7, + 30, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, }, - "name": "a", - "range": Array [ - 12, - 21, - ], - "type": "Identifier", - "typeAnnotation": Object { + "start": Object { + "column": 7, + "line": 1, + }, + }, + "name": "Array", + "range": Array [ + 7, + 12, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 21, + "column": 29, "line": 1, }, "start": Object { @@ -111331,130 +113412,61 @@ Object { "line": 1, }, }, + "params": Array [], "range": Array [ 13, - 21, + 29, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { - "column": 21, + "column": 29, "line": 1, }, "start": Object { - "column": 15, + "column": 20, "line": 1, }, }, "range": Array [ - 15, - 21, + 20, + 29, ], - "type": "TSNumberKeyword", - }, - }, - }, - Object { - "loc": Object { - "end": Object { - "column": 33, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "name": "b", - "optional": true, - "range": Array [ - 23, - 33, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 33, - "line": 1, - }, - "start": Object { - "column": 25, - "line": 1, - }, - }, - "range": Array [ - 25, - 33, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 33, - "line": 1, - }, - "start": Object { - "column": 27, - "line": 1, + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, }, + "range": Array [ + 23, + 29, + ], + "type": "TSStringKeyword", }, - "range": Array [ - 27, - 33, - ], - "type": "TSNumberKeyword", }, + "type": "TSConstructorType", }, - }, - ], - "range": Array [ - 7, - 42, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 42, - "line": 1, - }, - "start": Object { - "column": 35, - "line": 1, - }, - }, + ], "range": Array [ - 35, - 42, + 12, + 30, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 42, - "line": 1, - }, - "start": Object { - "column": 38, - "line": 1, - }, - }, - "range": Array [ - 38, - 42, - ], - "type": "TSVoidKeyword", - }, + "type": "TSTypeParameterInstantiation", }, - "type": "TSConstructorType", }, }, }, "init": null, "loc": Object { "end": Object { - "column": 42, + "column": 30, "line": 1, }, "start": Object { @@ -111464,7 +113476,7 @@ Object { }, "range": Array [ 4, - 42, + 30, ], "type": "VariableDeclarator", }, @@ -111472,7 +113484,7 @@ Object { "kind": "let", "loc": Object { "end": Object { - "column": 43, + "column": 31, "line": 1, }, "start": Object { @@ -111482,7 +113494,7 @@ Object { }, "range": Array [ 0, - 43, + 31, ], "type": "VariableDeclaration", }, @@ -111499,7 +113511,7 @@ Object { }, "range": Array [ 0, - 44, + 32, ], "sourceType": "script", "tokens": Array [ @@ -111537,7 +113549,7 @@ Object { 5, ], "type": "Identifier", - "value": "f", + "value": "x", }, Object { "loc": Object { @@ -111560,7 +113572,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 10, + "column": 12, "line": 1, }, "start": Object { @@ -111570,28 +113582,10 @@ Object { }, "range": Array [ 7, - 10, - ], - "type": "Keyword", - "value": "new", - }, - Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, 12, ], - "type": "Punctuator", - "value": "(", + "type": "Identifier", + "value": "Array", }, Object { "loc": Object { @@ -111608,13 +113602,13 @@ Object { 12, 13, ], - "type": "Identifier", - "value": "a", + "type": "Punctuator", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 14, + "column": 16, "line": 1, }, "start": Object { @@ -111624,187 +113618,115 @@ Object { }, "range": Array [ 13, - 14, - ], - "type": "Punctuator", - "value": ":", - }, - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, - }, - }, - "range": Array [ - 15, - 21, + 16, ], - "type": "Identifier", - "value": "number", + "type": "Keyword", + "value": "new", }, Object { "loc": Object { "end": Object { - "column": 22, + "column": 18, "line": 1, }, "start": Object { - "column": 21, + "column": 17, "line": 1, }, }, "range": Array [ - 21, - 22, + 17, + 18, ], "type": "Punctuator", - "value": ",", - }, - Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "range": Array [ - 23, - 24, - ], - "type": "Identifier", - "value": "b", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 25, + "column": 19, "line": 1, }, "start": Object { - "column": 24, + "column": 18, "line": 1, }, }, "range": Array [ - 24, - 25, + 18, + 19, ], "type": "Punctuator", - "value": "?", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 26, + "column": 22, "line": 1, }, "start": Object { - "column": 25, + "column": 20, "line": 1, }, }, "range": Array [ - 25, - 26, + 20, + 22, ], "type": "Punctuator", - "value": ":", + "value": "=>", }, Object { "loc": Object { "end": Object { - "column": 33, + "column": 29, "line": 1, }, "start": Object { - "column": 27, + "column": 23, "line": 1, }, }, "range": Array [ - 27, - 33, + 23, + 29, ], "type": "Identifier", - "value": "number", - }, - Object { - "loc": Object { - "end": Object { - "column": 34, - "line": 1, - }, - "start": Object { - "column": 33, - "line": 1, - }, - }, - "range": Array [ - 33, - 34, - ], - "type": "Punctuator", - "value": ")", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 37, + "column": 30, "line": 1, }, "start": Object { - "column": 35, + "column": 29, "line": 1, }, }, "range": Array [ - 35, - 37, + 29, + 30, ], "type": "Punctuator", - "value": "=>", - }, - Object { - "loc": Object { - "end": Object { - "column": 42, - "line": 1, - }, - "start": Object { - "column": 38, - "line": 1, - }, - }, - "range": Array [ - 38, - 42, - ], - "type": "Keyword", - "value": "void", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 43, + "column": 31, "line": 1, }, "start": Object { - "column": 42, + "column": 30, "line": 1, }, }, "range": Array [ - 42, - 43, + 30, + 31, ], "type": "Punctuator", "value": ";", @@ -111814,7 +113736,7 @@ Object { } `; -exports[`typescript fixtures/types/constructor-generic.src 1`] = ` +exports[`typescript fixtures/types/constructor-with-rest.src 1`] = ` Object { "body": Array [ Object { @@ -111823,7 +113745,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 25, + "column": 35, "line": 1, }, "start": Object { @@ -111834,13 +113756,13 @@ Object { "name": "f", "range": Array [ 4, - 25, + 35, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 25, + "column": 35, "line": 1, }, "start": Object { @@ -111850,13 +113772,13 @@ Object { }, "range": Array [ 5, - 25, + 35, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 25, + "column": 35, "line": 1, }, "start": Object { @@ -111866,194 +113788,138 @@ Object { }, "params": Array [ Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, - }, - }, - "name": "a", - "range": Array [ - 15, - 19, - ], - "type": "Identifier", - "typeAnnotation": Object { + "argument": Object { "loc": Object { "end": Object { - "column": 19, + "column": 16, "line": 1, }, "start": Object { - "column": 16, + "column": 15, "line": 1, }, }, + "name": "a", "range": Array [ + 15, 16, - 19, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 1, - }, - "start": Object { - "column": 18, - "line": 1, - }, - }, - "range": Array [ - 18, - 19, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 1, - }, - "start": Object { - "column": 18, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 18, - 19, - ], - "type": "Identifier", - }, - }, - }, - }, - ], - "range": Array [ - 7, - 25, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 1, - }, - "start": Object { - "column": 21, - "line": 1, + "type": "Identifier", }, - }, - "range": Array [ - 21, - 25, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 25, + "column": 26, "line": 1, }, "start": Object { - "column": 24, + "column": 12, "line": 1, }, }, "range": Array [ - 24, - 25, + 12, + 26, ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 1, - }, - "start": Object { - "column": 24, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 24, - 25, - ], - "type": "Identifier", - }, - }, - }, - "type": "TSConstructorType", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 14, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "params": Array [ - Object { + "type": "RestElement", + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 13, + "column": 26, "line": 1, }, "start": Object { - "column": 12, + "column": 16, "line": 1, }, }, - "name": Object { + "range": Array [ + 16, + 26, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "elementType": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 24, + ], + "type": "TSNumberKeyword", + }, "loc": Object { "end": Object { - "column": 13, + "column": 26, "line": 1, }, "start": Object { - "column": 12, + "column": 18, "line": 1, }, }, - "name": "T", "range": Array [ - 12, - 13, + 18, + 26, ], - "type": "Identifier", + "type": "TSArrayType", }, - "range": Array [ - 12, - 13, - ], - "type": "TSTypeParameter", }, - ], + }, + ], + "range": Array [ + 7, + 35, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, "range": Array [ - 11, - 14, + 28, + 35, ], - "type": "TSTypeParameterDeclaration", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 35, + ], + "type": "TSVoidKeyword", + }, }, + "type": "TSConstructorType", }, }, }, "init": null, "loc": Object { "end": Object { - "column": 25, + "column": 35, "line": 1, }, "start": Object { @@ -112063,7 +113929,7 @@ Object { }, "range": Array [ 4, - 25, + 35, ], "type": "VariableDeclarator", }, @@ -112071,7 +113937,7 @@ Object { "kind": "let", "loc": Object { "end": Object { - "column": 26, + "column": 36, "line": 1, }, "start": Object { @@ -112081,7 +113947,7 @@ Object { }, "range": Array [ 0, - 26, + 36, ], "type": "VariableDeclaration", }, @@ -112098,7 +113964,7 @@ Object { }, "range": Array [ 0, - 27, + 37, ], "sourceType": "script", "tokens": Array [ @@ -112190,12 +114056,12 @@ Object { 12, ], "type": "Punctuator", - "value": "<", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 13, + "column": 15, "line": 1, }, "start": Object { @@ -112205,115 +114071,115 @@ Object { }, "range": Array [ 12, - 13, + 15, ], - "type": "Identifier", - "value": "T", + "type": "Punctuator", + "value": "...", }, Object { "loc": Object { "end": Object { - "column": 14, + "column": 16, "line": 1, }, "start": Object { - "column": 13, + "column": 15, "line": 1, }, }, "range": Array [ - 13, - 14, + 15, + 16, ], - "type": "Punctuator", - "value": ">", + "type": "Identifier", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 17, "line": 1, }, "start": Object { - "column": 14, + "column": 16, "line": 1, }, }, "range": Array [ - 14, - 15, + 16, + 17, ], "type": "Punctuator", - "value": "(", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 24, "line": 1, }, "start": Object { - "column": 15, + "column": 18, "line": 1, }, }, "range": Array [ - 15, - 16, + 18, + 24, ], "type": "Identifier", - "value": "a", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 25, "line": 1, }, "start": Object { - "column": 16, + "column": 24, "line": 1, }, }, "range": Array [ - 16, - 17, + 24, + 25, ], "type": "Punctuator", - "value": ":", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 19, + "column": 26, "line": 1, }, "start": Object { - "column": 18, + "column": 25, "line": 1, }, }, "range": Array [ - 18, - 19, + 25, + 26, ], - "type": "Identifier", - "value": "T", + "type": "Punctuator", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 27, "line": 1, }, "start": Object { - "column": 19, + "column": 26, "line": 1, }, }, "range": Array [ - 19, - 20, + 26, + 27, ], "type": "Punctuator", "value": ")", @@ -112321,17 +114187,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 23, + "column": 30, "line": 1, }, "start": Object { - "column": 21, + "column": 28, "line": 1, }, }, "range": Array [ - 21, - 23, + 28, + 30, ], "type": "Punctuator", "value": "=>", @@ -112339,35 +114205,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 25, + "column": 35, "line": 1, }, "start": Object { - "column": 24, + "column": 31, "line": 1, }, }, "range": Array [ - 24, - 25, + 31, + 35, ], - "type": "Identifier", - "value": "T", + "type": "Keyword", + "value": "void", }, Object { "loc": Object { "end": Object { - "column": 26, + "column": 36, "line": 1, }, "start": Object { - "column": 25, + "column": 35, "line": 1, }, }, "range": Array [ - 25, - 26, + 35, + 36, ], "type": "Punctuator", "value": ";", @@ -112377,7 +114243,7 @@ Object { } `; -exports[`typescript fixtures/types/constructor-in-generic.src 1`] = ` +exports[`typescript fixtures/types/function.src 1`] = ` Object { "body": Array [ Object { @@ -112386,7 +114252,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 30, + "column": 38, "line": 1, }, "start": Object { @@ -112394,16 +114260,16 @@ Object { "line": 1, }, }, - "name": "x", + "name": "f", "range": Array [ 4, - 30, + 38, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 30, + "column": 38, "line": 1, }, "start": Object { @@ -112413,13 +114279,13 @@ Object { }, "range": Array [ 5, - 30, + 38, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 30, + "column": 38, "line": 1, }, "start": Object { @@ -112427,107 +114293,159 @@ Object { "line": 1, }, }, - "range": Array [ - 7, - 30, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 1, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, }, - "start": Object { - "column": 7, - "line": 1, + "name": "a", + "range": Array [ + 8, + 17, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 17, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSNumberKeyword", + }, }, }, - "name": "Array", - "range": Array [ - 7, - 12, - ], - "type": "Identifier", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, }, - }, - "params": Array [ - Object { + "name": "b", + "optional": true, + "range": Array [ + 19, + 29, + ], + "type": "Identifier", + "typeAnnotation": Object { "loc": Object { "end": Object { "column": 29, "line": 1, }, "start": Object { - "column": 13, + "column": 21, "line": 1, }, }, - "params": Array [], "range": Array [ - 13, + 21, 29, ], - "returnType": Object { + "type": "TSTypeAnnotation", + "typeAnnotation": Object { "loc": Object { "end": Object { "column": 29, "line": 1, }, "start": Object { - "column": 20, + "column": 23, "line": 1, }, }, "range": Array [ - 20, + 23, 29, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 29, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "range": Array [ - 23, - 29, - ], - "type": "TSStringKeyword", - }, + "type": "TSNumberKeyword", }, - "type": "TSConstructorType", }, - ], + }, + ], + "range": Array [ + 7, + 38, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, "range": Array [ - 12, - 30, + 31, + 38, ], - "type": "TSTypeParameterInstantiation", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "range": Array [ + 34, + 38, + ], + "type": "TSVoidKeyword", + }, }, + "type": "TSFunctionType", }, }, }, "init": null, "loc": Object { "end": Object { - "column": 30, + "column": 38, "line": 1, }, "start": Object { @@ -112537,7 +114455,7 @@ Object { }, "range": Array [ 4, - 30, + 38, ], "type": "VariableDeclarator", }, @@ -112545,7 +114463,7 @@ Object { "kind": "let", "loc": Object { "end": Object { - "column": 31, + "column": 39, "line": 1, }, "start": Object { @@ -112555,7 +114473,7 @@ Object { }, "range": Array [ 0, - 31, + 39, ], "type": "VariableDeclaration", }, @@ -112572,7 +114490,7 @@ Object { }, "range": Array [ 0, - 32, + 40, ], "sourceType": "script", "tokens": Array [ @@ -112610,7 +114528,7 @@ Object { 5, ], "type": "Identifier", - "value": "x", + "value": "f", }, Object { "loc": Object { @@ -112633,7 +114551,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 12, + "column": 8, "line": 1, }, "start": Object { @@ -112643,46 +114561,64 @@ Object { }, "range": Array [ 7, - 12, + 8, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, ], "type": "Identifier", - "value": "Array", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 13, + "column": 10, "line": 1, }, "start": Object { - "column": 12, + "column": 9, "line": 1, }, }, "range": Array [ - 12, - 13, + 9, + 10, ], "type": "Punctuator", - "value": "<", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 17, "line": 1, }, "start": Object { - "column": 13, + "column": 11, "line": 1, }, }, "range": Array [ - 13, - 16, + 11, + 17, ], - "type": "Keyword", - "value": "new", + "type": "Identifier", + "value": "number", }, Object { "loc": Object { @@ -112700,30 +114636,30 @@ Object { 18, ], "type": "Punctuator", - "value": "(", + "value": ",", }, Object { "loc": Object { "end": Object { - "column": 19, + "column": 20, "line": 1, }, "start": Object { - "column": 18, + "column": 19, "line": 1, }, }, "range": Array [ - 18, 19, + 20, ], - "type": "Punctuator", - "value": ")", + "type": "Identifier", + "value": "b", }, Object { "loc": Object { "end": Object { - "column": 22, + "column": 21, "line": 1, }, "start": Object { @@ -112733,10 +114669,28 @@ Object { }, "range": Array [ 20, + 21, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, 22, ], "type": "Punctuator", - "value": "=>", + "value": ":", }, Object { "loc": Object { @@ -112754,7 +114708,7 @@ Object { 29, ], "type": "Identifier", - "value": "string", + "value": "number", }, Object { "loc": Object { @@ -112771,23 +114725,59 @@ Object { 29, 30, ], - "type": "Punctuator", - "value": ">", + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 33, + ], + "type": "Punctuator", + "value": "=>", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "range": Array [ + 34, + 38, + ], + "type": "Keyword", + "value": "void", }, Object { "loc": Object { "end": Object { - "column": 31, + "column": 39, "line": 1, }, "start": Object { - "column": 30, + "column": 38, "line": 1, }, }, "range": Array [ - 30, - 31, + 38, + 39, ], "type": "Punctuator", "value": ";", @@ -112797,7 +114787,7 @@ Object { } `; -exports[`typescript fixtures/types/constructor-with-rest.src 1`] = ` +exports[`typescript fixtures/types/function-generic.src 1`] = ` Object { "body": Array [ Object { @@ -112806,7 +114796,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { @@ -112817,13 +114807,13 @@ Object { "name": "f", "range": Array [ 4, - 35, + 21, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { @@ -112833,13 +114823,13 @@ Object { }, "range": Array [ 5, - 35, + 21, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { @@ -112849,138 +114839,194 @@ Object { }, "params": Array [ Object { - "argument": Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, - }, - }, - "name": "a", - "range": Array [ - 15, - 16, - ], - "type": "Identifier", - }, "loc": Object { "end": Object { - "column": 26, + "column": 15, "line": 1, }, "start": Object { - "column": 12, + "column": 11, "line": 1, }, }, + "name": "a", "range": Array [ - 12, - 26, + 11, + 15, ], - "type": "RestElement", + "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 26, + "column": 15, "line": 1, }, "start": Object { - "column": 16, + "column": 12, "line": 1, }, }, "range": Array [ - 16, - 26, + 12, + 15, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { - "elementType": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "TSTypeReference", + "typeName": Object { "loc": Object { "end": Object { - "column": 24, + "column": 15, "line": 1, }, "start": Object { - "column": 18, + "column": 14, "line": 1, }, }, + "name": "T", "range": Array [ - 18, - 24, + 14, + 15, ], - "type": "TSNumberKeyword", - }, - "loc": Object { - "end": Object { - "column": 26, - "line": 1, - }, - "start": Object { - "column": 18, - "line": 1, - }, + "type": "Identifier", }, - "range": Array [ - 18, - 26, - ], - "type": "TSArrayType", }, }, }, ], "range": Array [ 7, - 35, + 21, ], "returnType": Object { "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { - "column": 28, + "column": 17, "line": 1, }, }, "range": Array [ - 28, - 35, + 17, + 21, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { - "column": 31, + "column": 20, "line": 1, }, }, "range": Array [ - 31, - 35, + 20, + 21, ], - "type": "TSVoidKeyword", + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + }, }, }, - "type": "TSConstructorType", + "type": "TSFunctionType", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 8, + 9, + ], + "type": "Identifier", + }, + "range": Array [ + 8, + 9, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 7, + 10, + ], + "type": "TSTypeParameterDeclaration", + }, }, }, }, "init": null, "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { @@ -112990,7 +115036,7 @@ Object { }, "range": Array [ 4, - 35, + 21, ], "type": "VariableDeclarator", }, @@ -112998,7 +115044,7 @@ Object { "kind": "let", "loc": Object { "end": Object { - "column": 36, + "column": 22, "line": 1, }, "start": Object { @@ -113008,7 +115054,7 @@ Object { }, "range": Array [ 0, - 36, + 22, ], "type": "VariableDeclaration", }, @@ -113025,7 +115071,7 @@ Object { }, "range": Array [ 0, - 37, + 23, ], "sourceType": "script", "tokens": Array [ @@ -113086,7 +115132,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 10, + "column": 8, "line": 1, }, "start": Object { @@ -113096,151 +115142,133 @@ Object { }, "range": Array [ 7, - 10, - ], - "type": "Keyword", - "value": "new", - }, - Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, - 12, + 8, ], "type": "Punctuator", - "value": "(", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 9, "line": 1, }, "start": Object { - "column": 12, + "column": 8, "line": 1, }, }, "range": Array [ - 12, - 15, + 8, + 9, ], - "type": "Punctuator", - "value": "...", + "type": "Identifier", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 10, "line": 1, }, "start": Object { - "column": 15, + "column": 9, "line": 1, }, }, "range": Array [ - 15, - 16, + 9, + 10, ], - "type": "Identifier", - "value": "a", + "type": "Punctuator", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 11, "line": 1, }, "start": Object { - "column": 16, + "column": 10, "line": 1, }, }, "range": Array [ - 16, - 17, + 10, + 11, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 24, + "column": 12, "line": 1, }, "start": Object { - "column": 18, + "column": 11, "line": 1, }, }, "range": Array [ - 18, - 24, + 11, + 12, ], "type": "Identifier", - "value": "number", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 25, + "column": 13, "line": 1, }, "start": Object { - "column": 24, + "column": 12, "line": 1, }, }, "range": Array [ - 24, - 25, + 12, + 13, ], "type": "Punctuator", - "value": "[", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 26, + "column": 15, "line": 1, }, "start": Object { - "column": 25, + "column": 14, "line": 1, }, }, "range": Array [ - 25, - 26, + 14, + 15, ], - "type": "Punctuator", - "value": "]", + "type": "Identifier", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 27, + "column": 16, "line": 1, }, "start": Object { - "column": 26, + "column": 15, "line": 1, }, }, "range": Array [ - 26, - 27, + 15, + 16, ], "type": "Punctuator", "value": ")", @@ -113248,17 +115276,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 30, + "column": 19, "line": 1, }, "start": Object { - "column": 28, + "column": 17, "line": 1, }, }, "range": Array [ - 28, - 30, + 17, + 19, ], "type": "Punctuator", "value": "=>", @@ -113266,35 +115294,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 35, + "column": 21, "line": 1, }, "start": Object { - "column": 31, + "column": 20, "line": 1, }, }, "range": Array [ - 31, - 35, + 20, + 21, ], - "type": "Keyword", - "value": "void", + "type": "Identifier", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 36, + "column": 22, "line": 1, }, "start": Object { - "column": 35, + "column": 21, "line": 1, }, }, "range": Array [ - 35, - 36, + 21, + 22, ], "type": "Punctuator", "value": ";", @@ -113304,7 +115332,7 @@ Object { } `; -exports[`typescript fixtures/types/function.src 1`] = ` +exports[`typescript fixtures/types/function-in-generic.src 1`] = ` Object { "body": Array [ Object { @@ -113313,7 +115341,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 38, + "column": 24, "line": 1, }, "start": Object { @@ -113321,16 +115349,16 @@ Object { "line": 1, }, }, - "name": "f", + "name": "x", "range": Array [ 4, - 38, + 24, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 38, + "column": 24, "line": 1, }, "start": Object { @@ -113340,13 +115368,13 @@ Object { }, "range": Array [ 5, - 38, + 24, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 38, + "column": 24, "line": 1, }, "start": Object { @@ -113354,159 +115382,107 @@ Object { "line": 1, }, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, + "range": Array [ + 7, + 24, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, }, - "name": "a", - "range": Array [ - 8, - 17, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, - }, - }, - "range": Array [ - 9, - 17, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, - 17, - ], - "type": "TSNumberKeyword", - }, + "start": Object { + "column": 7, + "line": 1, }, }, - Object { - "loc": Object { - "end": Object { - "column": 29, - "line": 1, - }, - "start": Object { - "column": 19, - "line": 1, - }, + "name": "Array", + "range": Array [ + 7, + 12, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, }, - "name": "b", - "optional": true, - "range": Array [ - 19, - 29, - ], - "type": "Identifier", - "typeAnnotation": Object { + "start": Object { + "column": 12, + "line": 1, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 29, + "column": 23, "line": 1, }, "start": Object { - "column": 21, + "column": 13, "line": 1, }, }, + "params": Array [], "range": Array [ - 21, - 29, + 13, + 23, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { - "column": 29, + "column": 23, "line": 1, }, "start": Object { - "column": 23, + "column": 16, "line": 1, }, }, "range": Array [ + 16, 23, - 29, ], - "type": "TSNumberKeyword", - }, - }, - }, - ], - "range": Array [ - 7, - 38, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 38, - "line": 1, - }, - "start": Object { - "column": 31, - "line": 1, - }, - }, - "range": Array [ - 31, - 38, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 38, - "line": 1, - }, - "start": Object { - "column": 34, - "line": 1, + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 23, + ], + "type": "TSVoidKeyword", + }, }, + "type": "TSFunctionType", }, - "range": Array [ - 34, - 38, - ], - "type": "TSVoidKeyword", - }, + ], + "range": Array [ + 12, + 24, + ], + "type": "TSTypeParameterInstantiation", }, - "type": "TSFunctionType", }, }, }, "init": null, "loc": Object { "end": Object { - "column": 38, + "column": 24, "line": 1, }, "start": Object { @@ -113516,7 +115492,7 @@ Object { }, "range": Array [ 4, - 38, + 24, ], "type": "VariableDeclarator", }, @@ -113524,7 +115500,7 @@ Object { "kind": "let", "loc": Object { "end": Object { - "column": 39, + "column": 25, "line": 1, }, "start": Object { @@ -113534,7 +115510,7 @@ Object { }, "range": Array [ 0, - 39, + 25, ], "type": "VariableDeclaration", }, @@ -113551,7 +115527,7 @@ Object { }, "range": Array [ 0, - 40, + 26, ], "sourceType": "script", "tokens": Array [ @@ -113589,7 +115565,7 @@ Object { 5, ], "type": "Identifier", - "value": "f", + "value": "x", }, Object { "loc": Object { @@ -113612,7 +115588,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 8, + "column": 12, "line": 1, }, "start": Object { @@ -113622,64 +115598,64 @@ Object { }, "range": Array [ 7, - 8, + 12, ], - "type": "Punctuator", - "value": "(", + "type": "Identifier", + "value": "Array", }, Object { "loc": Object { "end": Object { - "column": 9, + "column": 13, "line": 1, }, "start": Object { - "column": 8, + "column": 12, "line": 1, }, }, "range": Array [ - 8, - 9, + 12, + 13, ], - "type": "Identifier", - "value": "a", + "type": "Punctuator", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 10, + "column": 14, "line": 1, }, "start": Object { - "column": 9, + "column": 13, "line": 1, }, }, "range": Array [ - 9, - 10, + 13, + 14, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 15, "line": 1, }, "start": Object { - "column": 11, + "column": 14, "line": 1, }, }, "range": Array [ - 11, - 17, + 14, + 15, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { @@ -113688,21 +115664,21 @@ Object { "line": 1, }, "start": Object { - "column": 17, + "column": 16, "line": 1, }, }, "range": Array [ - 17, + 16, 18, ], "type": "Punctuator", - "value": ",", + "value": "=>", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 23, "line": 1, }, "start": Object { @@ -113712,51 +115688,15 @@ Object { }, "range": Array [ 19, - 20, - ], - "type": "Identifier", - "value": "b", - }, - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, - }, - }, - "range": Array [ - 20, - 21, - ], - "type": "Punctuator", - "value": "?", - }, - Object { - "loc": Object { - "end": Object { - "column": 22, - "line": 1, - }, - "start": Object { - "column": 21, - "line": 1, - }, - }, - "range": Array [ - 21, - 22, + 23, ], - "type": "Punctuator", - "value": ":", + "type": "Keyword", + "value": "void", }, Object { "loc": Object { "end": Object { - "column": 29, + "column": 24, "line": 1, }, "start": Object { @@ -113766,358 +115706,195 @@ Object { }, "range": Array [ 23, - 29, - ], - "type": "Identifier", - "value": "number", - }, - Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 1, - }, - "start": Object { - "column": 29, - "line": 1, - }, - }, - "range": Array [ - 29, - 30, + 24, ], "type": "Punctuator", - "value": ")", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 33, + "column": 25, "line": 1, }, "start": Object { - "column": 31, + "column": 24, "line": 1, }, }, "range": Array [ - 31, - 33, + 24, + 25, ], "type": "Punctuator", - "value": "=>", + "value": ";", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/function-with-array-destruction.src 1`] = ` +Object { + "body": Array [ Object { - "loc": Object { - "end": Object { - "column": 38, - "line": 1, - }, - "start": Object { - "column": 34, - "line": 1, + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, }, + "name": "foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", }, - "range": Array [ - 34, - 38, - ], - "type": "Keyword", - "value": "void", - }, - Object { "loc": Object { "end": Object { - "column": 39, + "column": 28, "line": 1, }, "start": Object { - "column": 38, + "column": 0, "line": 1, }, }, "range": Array [ - 38, - 39, + 0, + 28, ], - "type": "Punctuator", - "value": ";", - }, - ], - "type": "Program", -} -`; - -exports[`typescript fixtures/types/function-generic.src 1`] = ` -Object { - "body": Array [ - Object { - "declarations": Array [ - Object { - "id": Object { + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "params": Array [ + Object { + "elements": Array [ + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 13, + 14, + ], + "type": "Identifier", + }, + ], "loc": Object { "end": Object { - "column": 21, + "column": 20, "line": 1, }, "start": Object { - "column": 4, + "column": 12, "line": 1, }, }, - "name": "f", "range": Array [ - 4, - 21, + 12, + 20, ], - "type": "Identifier", + "type": "ArrayPattern", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 21, + "column": 20, "line": 1, }, "start": Object { - "column": 5, + "column": 15, "line": 1, }, }, "range": Array [ - 5, - 21, + 15, + 20, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 21, + "column": 20, "line": 1, }, "start": Object { - "column": 7, + "column": 17, "line": 1, }, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "name": "a", - "range": Array [ - 11, - 15, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, - }, - "range": Array [ - 12, - 15, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 14, - "line": 1, - }, - }, - "range": Array [ - 14, - 15, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 14, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 14, - 15, - ], - "type": "Identifier", - }, - }, - }, - }, - ], "range": Array [ - 7, - 21, + 17, + 20, ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 17, - "line": 1, - }, - }, - "range": Array [ - 17, - 21, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, - }, - }, - "range": Array [ - 20, - 21, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 20, - 21, - ], - "type": "Identifier", - }, - }, - }, - "type": "TSFunctionType", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 8, - 9, - ], - "type": "Identifier", - }, - "range": Array [ - 8, - 9, - ], - "type": "TSTypeParameter", - }, - ], - "range": Array [ - 7, - 10, - ], - "type": "TSTypeParameterDeclaration", - }, + "type": "TSAnyKeyword", }, }, }, - "init": null, + ], + "range": Array [ + 11, + 28, + ], + "returnType": Object { "loc": Object { "end": Object { - "column": 21, + "column": 28, "line": 1, }, "start": Object { - "column": 4, + "column": 22, "line": 1, }, }, "range": Array [ - 4, - 21, + 22, + 28, ], - "type": "VariableDeclarator", - }, - ], - "kind": "let", - "loc": Object { - "end": Object { - "column": 22, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 22, - ], - "type": "VariableDeclaration", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 28, + ], + "type": "TSAnyKeyword", + }, + }, + "type": "TSFunctionType", + }, }, ], "loc": Object { @@ -114132,14 +115909,14 @@ Object { }, "range": Array [ 0, - 23, + 29, ], "sourceType": "script", "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 3, + "column": 4, "line": 1, }, "start": Object { @@ -114149,33 +115926,15 @@ Object { }, "range": Array [ 0, - 3, - ], - "type": "Keyword", - "value": "let", - }, - Object { - "loc": Object { - "end": Object { - "column": 5, - "line": 1, - }, - "start": Object { - "column": 4, - "line": 1, - }, - }, - "range": Array [ 4, - 5, ], "type": "Identifier", - "value": "f", + "value": "type", }, Object { "loc": Object { "end": Object { - "column": 6, + "column": 8, "line": 1, }, "start": Object { @@ -114185,46 +115944,10 @@ Object { }, "range": Array [ 5, - 6, - ], - "type": "Punctuator", - "value": ":", - }, - Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "range": Array [ - 7, - 8, - ], - "type": "Punctuator", - "value": "<", - }, - Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "range": Array [ 8, - 9, ], "type": "Identifier", - "value": "T", + "value": "foo", }, Object { "loc": Object { @@ -114242,22 +115965,22 @@ Object { 10, ], "type": "Punctuator", - "value": ">", + "value": "=", }, Object { "loc": Object { "end": Object { - "column": 11, + "column": 12, "line": 1, }, "start": Object { - "column": 10, + "column": 11, "line": 1, }, }, "range": Array [ - 10, 11, + 12, ], "type": "Punctuator", "value": "(", @@ -114265,38 +115988,38 @@ Object { Object { "loc": Object { "end": Object { - "column": 12, + "column": 13, "line": 1, }, "start": Object { - "column": 11, + "column": 12, "line": 1, }, }, "range": Array [ - 11, 12, + 13, ], - "type": "Identifier", - "value": "a", + "type": "Punctuator", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 13, + "column": 14, "line": 1, }, "start": Object { - "column": 12, + "column": 13, "line": 1, }, }, "range": Array [ - 12, 13, + 14, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "a", }, Object { "loc": Object { @@ -114313,8 +116036,8 @@ Object { 14, 15, ], - "type": "Identifier", - "value": "T", + "type": "Punctuator", + "value": "]", }, Object { "loc": Object { @@ -114332,12 +116055,12 @@ Object { 16, ], "type": "Punctuator", - "value": ")", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 19, + "column": 20, "line": 1, }, "start": Object { @@ -114347,10 +116070,10 @@ Object { }, "range": Array [ 17, - 19, + 20, ], - "type": "Punctuator", - "value": "=>", + "type": "Identifier", + "value": "any", }, Object { "loc": Object { @@ -114367,213 +116090,250 @@ Object { 20, 21, ], - "type": "Identifier", - "value": "T", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 22, + "column": 24, "line": 1, }, "start": Object { - "column": 21, + "column": 22, "line": 1, }, }, "range": Array [ - 21, 22, + 24, ], "type": "Punctuator", - "value": ";", + "value": "=>", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 28, + ], + "type": "Identifier", + "value": "any", }, ], "type": "Program", } `; -exports[`typescript fixtures/types/function-in-generic.src 1`] = ` +exports[`typescript fixtures/types/function-with-object-destruction.src 1`] = ` Object { "body": Array [ Object { - "declarations": Array [ - Object { - "id": Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 24, + "column": 20, "line": 1, }, "start": Object { - "column": 4, + "column": 12, "line": 1, }, }, - "name": "x", - "range": Array [ - 4, - 24, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 13, + 14, + ], + "type": "Identifier", }, - }, - "range": Array [ - 5, - 24, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "kind": "init", "loc": Object { "end": Object { - "column": 24, + "column": 14, "line": 1, }, "start": Object { - "column": 7, + "column": 13, "line": 1, }, }, + "method": false, "range": Array [ - 7, - 24, + 13, + 14, ], - "type": "TSTypeReference", - "typeName": Object { + "shorthand": true, + "type": "Property", + "value": Object { "loc": Object { "end": Object { - "column": 12, + "column": 14, "line": 1, }, "start": Object { - "column": 7, + "column": 13, "line": 1, }, }, - "name": "Array", + "name": "a", "range": Array [ - 7, - 12, + 13, + 14, ], "type": "Identifier", }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, + }, + ], + "range": Array [ + 12, + 20, + ], + "type": "ObjectPattern", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 20, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 13, - "line": 1, - }, - }, - "params": Array [], - "range": Array [ - 13, - 23, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 16, - "line": 1, - }, - }, - "range": Array [ - 16, - 23, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 19, - "line": 1, - }, - }, - "range": Array [ - 19, - 23, - ], - "type": "TSVoidKeyword", - }, - }, - "type": "TSFunctionType", - }, - ], - "range": Array [ - 12, - 24, - ], - "type": "TSTypeParameterInstantiation", }, + "range": Array [ + 17, + 20, + ], + "type": "TSAnyKeyword", }, }, }, - "init": null, + ], + "range": Array [ + 11, + 28, + ], + "returnType": Object { "loc": Object { "end": Object { - "column": 24, + "column": 28, "line": 1, }, "start": Object { - "column": 4, + "column": 22, "line": 1, }, }, "range": Array [ - 4, - 24, + 22, + 28, ], - "type": "VariableDeclarator", - }, - ], - "kind": "let", - "loc": Object { - "end": Object { - "column": 25, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 28, + ], + "type": "TSAnyKeyword", + }, }, + "type": "TSFunctionType", }, - "range": Array [ - 0, - 25, - ], - "type": "VariableDeclaration", }, ], "loc": Object { @@ -114588,14 +116348,14 @@ Object { }, "range": Array [ 0, - 26, + 29, ], "sourceType": "script", "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 3, + "column": 4, "line": 1, }, "start": Object { @@ -114605,46 +116365,46 @@ Object { }, "range": Array [ 0, - 3, + 4, ], - "type": "Keyword", - "value": "let", + "type": "Identifier", + "value": "type", }, Object { "loc": Object { "end": Object { - "column": 5, + "column": 8, "line": 1, }, "start": Object { - "column": 4, + "column": 5, "line": 1, }, }, "range": Array [ - 4, 5, + 8, ], "type": "Identifier", - "value": "x", + "value": "foo", }, Object { "loc": Object { "end": Object { - "column": 6, + "column": 10, "line": 1, }, "start": Object { - "column": 5, + "column": 9, "line": 1, }, }, "range": Array [ - 5, - 6, + 9, + 10, ], "type": "Punctuator", - "value": ":", + "value": "=", }, Object { "loc": Object { @@ -114653,16 +116413,16 @@ Object { "line": 1, }, "start": Object { - "column": 7, + "column": 11, "line": 1, }, }, "range": Array [ - 7, + 11, 12, ], - "type": "Identifier", - "value": "Array", + "type": "Punctuator", + "value": "(", }, Object { "loc": Object { @@ -114680,7 +116440,7 @@ Object { 13, ], "type": "Punctuator", - "value": "<", + "value": "{", }, Object { "loc": Object { @@ -114697,8 +116457,8 @@ Object { 13, 14, ], - "type": "Punctuator", - "value": "(", + "type": "Identifier", + "value": "a", }, Object { "loc": Object { @@ -114716,43 +116476,61 @@ Object { 15, ], "type": "Punctuator", - "value": ")", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 18, + "column": 16, "line": 1, }, "start": Object { - "column": 16, + "column": 15, "line": 1, }, }, "range": Array [ + 15, 16, - 18, ], "type": "Punctuator", - "value": "=>", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 23, + "column": 20, "line": 1, }, "start": Object { - "column": 19, + "column": 17, "line": 1, }, }, "range": Array [ - 19, - 23, + 17, + 20, ], - "type": "Keyword", - "value": "void", + "type": "Identifier", + "value": "any", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { @@ -114761,34 +116539,34 @@ Object { "line": 1, }, "start": Object { - "column": 23, + "column": 22, "line": 1, }, }, "range": Array [ - 23, + 22, 24, ], "type": "Punctuator", - "value": ">", + "value": "=>", }, Object { "loc": Object { "end": Object { - "column": 25, + "column": 28, "line": 1, }, "start": Object { - "column": 24, + "column": 25, "line": 1, }, }, "range": Array [ - 24, 25, + 28, ], - "type": "Punctuator", - "value": ";", + "type": "Identifier", + "value": "any", }, ], "type": "Program", From 5f3aec9f3397825dd8f61be111798964f864a343 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 7 Feb 2019 08:04:03 -0500 Subject: [PATCH 83/88] feat(eslint-plugin): added new rule promise-function-async (#194) --- packages/eslint-plugin/README.md | 1 + packages/eslint-plugin/ROADMAP.md | 2 +- .../docs/rules/promise-function-async.md | 65 +++++ .../lib/rules/promise-function-async.js | 125 ++++++++ packages/eslint-plugin/lib/utils/types.js | 38 +++ .../tests/lib/rules/promise-function-async.js | 275 ++++++++++++++++++ 6 files changed, 505 insertions(+), 1 deletion(-) create mode 100644 packages/eslint-plugin/docs/rules/promise-function-async.md create mode 100644 packages/eslint-plugin/lib/rules/promise-function-async.js create mode 100644 packages/eslint-plugin/lib/utils/types.js create mode 100644 packages/eslint-plugin/tests/lib/rules/promise-function-async.js diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 3807877a073e..90da943b887c 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -145,6 +145,7 @@ Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.e | [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: | | [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async. (`promise-function-async` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string. (`restrict-plus-operands` from TSLint) | | | | [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: | diff --git a/packages/eslint-plugin/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md index 48ccaa900b63..444700439669 100644 --- a/packages/eslint-plugin/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -30,7 +30,7 @@ | [`no-var-requires`] | ✅ | [`@typescript-eslint/no-var-requires`] | | [`only-arrow-functions`] | 🔌 | [`prefer-arrow/prefer-arrow-functions`] | | [`prefer-for-of`] | 🛑 | N/A | -| [`promise-function-async`] | 🛑 | N/A ([relevant plugin][plugin:promise]) | +| [`promise-function-async`] | ✅ | [`@typescript-eslint/promise-function-async`] | | [`typedef`] | 🛑 | N/A | | [`typedef-whitespace`] | ✅ | [`@typescript-eslint/type-annotation-spacing`] | | [`unified-signatures`] | 🛑 | N/A | diff --git a/packages/eslint-plugin/docs/rules/promise-function-async.md b/packages/eslint-plugin/docs/rules/promise-function-async.md new file mode 100644 index 000000000000..c64c25c11b5a --- /dev/null +++ b/packages/eslint-plugin/docs/rules/promise-function-async.md @@ -0,0 +1,65 @@ +# Functions that return promises must be async (promise-function-async) + +Requires any function or method that returns a Promise to be marked async. +Ensures that each function is only capable of: + +- returning a rejected promise, or +- throwing an Error object. + +In contrast, non-`async` `Promise`-returning functions are technically capable of either. +Code that handles the results of those functions will often need to handle both cases, which can get complex. +This rule's practice removes a requirement for creating code to handle both cases. + +## Rule Details + +Examples of **incorrect** code for this rule + +```ts +const arrowFunctionReturnsPromise = () => Promise.resolve('value'); + +function functionDeturnsPromise() { + return Math.random() > 0.5 ? Promise.resolve('value') : false; +} +``` + +Examples of **correct** code for this rule + +```ts +const arrowFunctionReturnsPromise = async () => 'value'; + +async function functionDeturnsPromise() { + return Math.random() > 0.5 ? 'value' : false; +} +``` + +## Options + +Options may be provided as an object with: + +- `allowedPromiseNames` to indicate any extra names of classes or interfaces to be considered Promises when returned. + +In addition, each of the following properties may be provided, and default to `true`: + +- `checkArrowFunctions` +- `checkFunctionDeclarations` +- `checkFunctionExpressions` +- `checkMethodDeclarations` + +```json +{ + "@typescript-eslint/promise-function-async": [ + "error", + { + "allowedPromiseNames": ["Thenable"], + "checkArrowFunctions": true, + "checkFunctionDeclarations": true, + "checkFunctionExpressions": true, + "checkMethodDeclarations": true + } + ] +} +``` + +## Related To + +- TSLint: [promise-function-async](https://palantir.github.io/tslint/rules/promise-function-async) diff --git a/packages/eslint-plugin/lib/rules/promise-function-async.js b/packages/eslint-plugin/lib/rules/promise-function-async.js new file mode 100644 index 000000000000..febbbc2a012b --- /dev/null +++ b/packages/eslint-plugin/lib/rules/promise-function-async.js @@ -0,0 +1,125 @@ +/** + * @fileoverview Requires any function or method that returns a Promise to be marked async + * @author Josh Goldberg + */ +'use strict'; + +const util = require('../util'); +const types = require('../utils/types'); + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +const defaultOptions = [ + { + allowedPromiseNames: [], + checkArrowFunctions: true, + checkFunctionDeclarations: true, + checkFunctionExpressions: true, + checkMethodDeclarations: true + } +]; + +/** + * @type {import("eslint").Rule.RuleModule} + */ +module.exports = { + meta: { + type: 'suggestion', + docs: { + description: + 'Requires any function or method that returns a Promise to be marked async.', + extraDescription: [util.tslintRule('promise-function-async')], + category: 'TypeScript', + url: util.metaDocsUrl('promise-function-async'), + recommended: 'error' + }, + fixable: null, + messages: { + missingAsync: 'Functions that return promises must be async.' + }, + schema: [ + { + type: 'object', + properties: { + allowedPromiseNames: { + type: 'array', + items: { + type: 'string' + } + }, + checkArrowFunctions: { + type: 'boolean' + }, + checkFunctionDeclarations: { + type: 'boolean' + }, + checkFunctionExpressions: { + type: 'boolean' + }, + checkMethodDeclarations: { + type: 'boolean' + } + }, + additionalProperties: false + } + ] + }, + + create(context) { + const { + allowedPromiseNames, + checkArrowFunctions, + checkFunctionDeclarations, + checkFunctionExpressions, + checkMethodDeclarations + } = util.applyDefault(defaultOptions, context.options)[0]; + + const allAllowedPromiseNames = new Set(['Promise', ...allowedPromiseNames]); + const parserServices = util.getParserServices(context); + const checker = parserServices.program.getTypeChecker(); + + /** + * @param {import("estree").Function} node + */ + function validateNode(node) { + const originalNode = parserServices.esTreeNodeToTSNodeMap.get(node); + const [callSignature] = checker + .getTypeAtLocation(originalNode) + .getCallSignatures(); + const returnType = checker.getReturnTypeOfSignature(callSignature); + + if (!types.containsTypeByName(returnType, allAllowedPromiseNames)) { + return; + } + + context.report({ + messageId: 'missingAsync', + node + }); + } + + return { + ArrowFunctionExpression(node) { + if (checkArrowFunctions && !node.async) { + validateNode(node); + } + }, + FunctionDeclaration(node) { + if (checkFunctionDeclarations && !node.async) { + validateNode(node); + } + }, + FunctionExpression(node) { + if (!!node.parent && node.parent.kind === 'method') { + if (checkMethodDeclarations && !node.async) { + validateNode(node.parent); + } + } else if (checkFunctionExpressions && !node.async) { + validateNode(node); + } + } + }; + } +}; diff --git a/packages/eslint-plugin/lib/utils/types.js b/packages/eslint-plugin/lib/utils/types.js new file mode 100644 index 000000000000..adfb402b72ae --- /dev/null +++ b/packages/eslint-plugin/lib/utils/types.js @@ -0,0 +1,38 @@ +'use strict'; + +const tsutils = require('tsutils'); +const ts = require('typescript'); + +/** + * @param {string} type Type being checked by name. + * @param {Set} allowedNames Symbol names checking on the type. + * @returns {boolean} Whether the type is, extends, or contains any of the allowed names. + */ +function containsTypeByName(type, allowedNames) { + if (tsutils.isTypeFlagSet(type, ts.TypeFlags.Any | ts.TypeFlags.Unknown)) { + return true; + } + + if (tsutils.isTypeReference(type)) { + type = type.target; + } + + if ( + typeof type.symbol !== 'undefined' && + allowedNames.has(type.symbol.name) + ) { + return true; + } + + if (tsutils.isUnionOrIntersectionType(type)) { + return type.types.some(t => containsTypeByName(t, allowedNames)); + } + + const bases = type.getBaseTypes(); + return ( + typeof bases !== 'undefined' && + bases.some(t => containsTypeByName(t, allowedNames)) + ); +} + +exports.containsTypeByName = containsTypeByName; diff --git a/packages/eslint-plugin/tests/lib/rules/promise-function-async.js b/packages/eslint-plugin/tests/lib/rules/promise-function-async.js new file mode 100644 index 000000000000..dddb26046435 --- /dev/null +++ b/packages/eslint-plugin/tests/lib/rules/promise-function-async.js @@ -0,0 +1,275 @@ +/** + * @fileoverview Requires any function or method that returns a Promise to be marked async + * @author Josh Goldberg + */ +'use strict'; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const rule = require('../../../lib/rules/promise-function-async'), + RuleTester = require('eslint').RuleTester, + path = require('path'); + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +const rootDir = path.join(process.cwd(), 'tests/fixtures/'); +const parserOptions = { + ecmaVersion: 2018, + tsconfigRootDir: rootDir, + project: './tsconfig.json' +}; + +const messageId = 'missingAsync'; + +const ruleTester = new RuleTester({ + parserOptions, + parser: '@typescript-eslint/parser' +}); + +ruleTester.run('promise-function-async', rule, { + valid: [ + ` +const nonAsyncNonPromiseArrowFunction = (n: number) => n; + +function nonAsyncNonPromiseFunctionDeclaration(n: number) { return n; } + +const asyncPromiseFunctionExpressionA = async function(p: Promise) { return p; }; +const asyncPromiseFunctionExpressionB = async function() { return new Promise(); }; + +class Test { + public nonAsyncNonPromiseArrowFunction = (n: number) => n; + + public nonAsyncNonPromiseMethod() { + return 0; + } + + public async asyncPromiseMethodA(p: Promise) { + return p; + } + + public async asyncPromiseMethodB() { + return new Promise(); + } +} +` + ], + invalid: [ + { + code: ` +const nonAsyncPromiseFunctionExpressionA = function(p: Promise) { return p; }; + +const nonAsyncPromiseFunctionExpressionB = function() { return new Promise(); }; + +function nonAsyncPromiseFunctionDeclarationA(p: Promise) { return p; } + +function nonAsyncPromiseFunctionDeclarationB() { return new Promise(); } + +const nonAsyncPromiseArrowFunctionA = (p: Promise) => p; + +const nonAsyncPromiseArrowFunctionB = () => new Promise(); + +class Test { + public nonAsyncPromiseMethodA(p: Promise) { + return p; + } + + public nonAsyncPromiseMethodB() { + return new Promise(); + } +} +`, + errors: [ + { + line: 2, + messageId + }, + { + line: 4, + messageId + }, + { + line: 6, + messageId + }, + { + line: 8, + messageId + }, + { + line: 10, + messageId + }, + { + line: 12, + messageId + }, + { + line: 15, + messageId + }, + { + line: 19, + messageId + } + ] + }, + { + code: ` +const nonAsyncPromiseFunctionExpression = function(p: Promise) { return p; }; + +function nonAsyncPromiseFunctionDeclaration(p: Promise) { return p; } + +const nonAsyncPromiseArrowFunction = (p: Promise) => p; + +class Test { + public nonAsyncPromiseMethod(p: Promise) { + return p; + } +} +`, + options: [ + { + checkArrowFunctions: false + } + ], + errors: [ + { + line: 2, + messageId + }, + { + line: 4, + messageId + }, + { + line: 9, + messageId + } + ] + }, + { + code: ` +const nonAsyncPromiseFunctionExpression = function(p: Promise) { return p; }; + +function nonAsyncPromiseFunctionDeclaration(p: Promise) { return p; } + +const nonAsyncPromiseArrowFunction = (p: Promise) => p; + +class Test { + public nonAsyncPromiseMethod(p: Promise) { + return p; + } +} +`, + options: [ + { + checkFunctionDeclarations: false + } + ], + errors: [ + { + line: 2, + messageId + }, + { + line: 6, + messageId + }, + { + line: 9, + messageId + } + ] + }, + { + code: ` +const nonAsyncPromiseFunctionExpression = function(p: Promise) { return p; }; + +function nonAsyncPromiseFunctionDeclaration(p: Promise) { return p; } + +const nonAsyncPromiseArrowFunction = (p: Promise) => p; + +class Test { + public nonAsyncPromiseMethod(p: Promise) { + return p; + } +} +`, + options: [ + { + checkFunctionExpressions: false + } + ], + errors: [ + { + line: 4, + messageId + }, + { + line: 6, + messageId + }, + { + line: 9, + messageId + } + ] + }, + { + code: ` +const nonAsyncPromiseFunctionExpression = function(p: Promise) { return p; }; + +function nonAsyncPromiseFunctionDeclaration(p: Promise) { return p; } + +const nonAsyncPromiseArrowFunction = (p: Promise) => p; + +class Test { + public nonAsyncPromiseMethod(p: Promise) { + return p; + } +} +`, + options: [ + { + checkMethodDeclarations: false + } + ], + errors: [ + { + line: 2, + messageId + }, + { + line: 4, + messageId + }, + { + line: 6, + messageId + } + ] + }, + { + code: ` +class PromiseType { } + +const returnAllowedType = () => new PromiseType(); +`, + options: [ + { + allowedPromiseNames: ['PromiseType'] + } + ], + errors: [ + { + line: 4, + messageId + } + ] + } + ] +}); From 683e5bcf38682cf66c52ba41980f52fa2d0c3bc6 Mon Sep 17 00:00:00 2001 From: Kanitkorn Sujautra Date: Thu, 7 Feb 2019 22:11:15 +0900 Subject: [PATCH 84/88] feat(eslint-plugin): add new rule no-require-imports (#199) --- packages/eslint-plugin/README.md | 1 + packages/eslint-plugin/ROADMAP.md | 3 +- .../docs/rules/no-require-imports.md | 34 ++++++++ .../lib/rules/no-require-imports.js | 50 ++++++++++++ .../tests/lib/rules/no-require-imports.js | 81 +++++++++++++++++++ 5 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 packages/eslint-plugin/docs/rules/no-require-imports.md create mode 100644 packages/eslint-plugin/lib/rules/no-require-imports.js create mode 100644 packages/eslint-plugin/tests/lib/rules/no-require-imports.js diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 90da943b887c..5030ca291751 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -135,6 +135,7 @@ Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.e | [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md) | Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-parameter-properties`](./docs/rules/no-parameter-properties.md) | Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-require-imports`](./docs/rules/no-require-imports.md) | Disallows invocation of `require()` (`no-require-imports` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | | | [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// ` comments (`no-reference` from TSLint) | :heavy_check_mark: | | | [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | | diff --git a/packages/eslint-plugin/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md index 444700439669..86f0224f0af5 100644 --- a/packages/eslint-plugin/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -114,7 +114,7 @@ | [`no-default-export`] | 🔌 | [`import/no-default-export`] | | [`no-duplicate-imports`] | 🔌 | [`import/no-duplicates`] | | [`no-mergeable-namespace`] | 🛑 | N/A | -| [`no-require-imports`] | 🛑 | N/A | +| [`no-require-imports`] | ✅ | [`@typescript-eslint/no-require-imports`] | | [`object-literal-sort-keys`] | 🌓 | [`sort-keys`][sort-keys] [2] | | [`prefer-const`] | 🌟 | [`prefer-const`][prefer-const] | | [`prefer-readonly`] | 🛑 | N/A | @@ -578,6 +578,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- [`@typescript-eslint/no-use-before-define`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md [`@typescript-eslint/restrict-plus-operands`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/restrict-plus-operands.md [`@typescript-eslint/indent`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/indent.md +[`@typescript-eslint/no-require-imports`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-require-imports.md [`@typescript-eslint/array-type`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md [`@typescript-eslint/class-name-casing`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/class-name-casing.md [`@typescript-eslint/interface-name-prefix`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/interface-name-prefix.md diff --git a/packages/eslint-plugin/docs/rules/no-require-imports.md b/packages/eslint-plugin/docs/rules/no-require-imports.md new file mode 100644 index 000000000000..0d2b831a1acd --- /dev/null +++ b/packages/eslint-plugin/docs/rules/no-require-imports.md @@ -0,0 +1,34 @@ +# Disallows invocation of `require()` (no-require-imports) + +Prefer the newer ES6-style imports over `require()`. + +## Rule Details + +Examples of **incorrect** code for this rule: + +```ts +var lib = require('lib'); +let lib2 = require('lib2'); +var lib5 = require('lib5'), + lib6 = require('lib6'); +import lib8 = require('lib8'); +``` + +Examples of **correct** code for this rule: + +```ts +import { l } from 'lib'; +var lib3 = load('not_an_import'); +var lib4 = lib2.subImport; +var lib7 = 700; +import lib9 = lib2.anotherSubImport; +import lib10 from 'lib10'; +``` + +## When Not To Use It + +If you don't care about TypeScript module syntax, then you will not need this rule. + +## Compatibility + +- TSLint: [no-require-imports](https://palantir.github.io/tslint/rules/no-require-imports/) diff --git a/packages/eslint-plugin/lib/rules/no-require-imports.js b/packages/eslint-plugin/lib/rules/no-require-imports.js new file mode 100644 index 000000000000..82537a4dcdaa --- /dev/null +++ b/packages/eslint-plugin/lib/rules/no-require-imports.js @@ -0,0 +1,50 @@ +/** + * @fileoverview Disallows invocation of `require()`. + * @author Kanitkorn Sujautra + */ +'use strict'; + +const util = require('../util'); + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + type: 'problem', + docs: { + description: 'Disallows invocation of `require()`.', + extraDescription: [util.tslintRule('no-require-imports')], + category: 'TypeScript', + url: util.metaDocsUrl('no-require-imports'), + recommended: 'error' + }, + schema: [], + messages: { + noRequireImports: 'A `require()` style import is forbidden.' + } + }, + create(context) { + //---------------------------------------------------------------------- + // Public + //---------------------------------------------------------------------- + + return { + CallExpression(node) { + if (node.callee.name === 'require') { + context.report({ + node, + messageId: 'noRequireImports' + }); + } + }, + TSExternalModuleReference(node) { + context.report({ + node, + messageId: 'noRequireImports' + }); + } + }; + } +}; diff --git a/packages/eslint-plugin/tests/lib/rules/no-require-imports.js b/packages/eslint-plugin/tests/lib/rules/no-require-imports.js new file mode 100644 index 000000000000..1eb40a59c34e --- /dev/null +++ b/packages/eslint-plugin/tests/lib/rules/no-require-imports.js @@ -0,0 +1,81 @@ +/** + * @fileoverview Disallows invocation of `require()`. + * @author Kanitkorn Sujautra + */ +'use strict'; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const rule = require('../../../lib/rules/no-require-imports'), + RuleTester = require('eslint').RuleTester; + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +const ruleTester = new RuleTester({ + parserOptions: { + sourceType: 'module' + }, + parser: '@typescript-eslint/parser' +}); + +ruleTester.run('no-require-imports', rule, { + valid: [ + "import {l} from 'lib'", + "var lib3 = load('not_an_import')", + 'var lib4 = lib2.subImport', + 'var lib7 = 700', + 'import lib9 = lib2.anotherSubImport', + "import lib10 from 'lib10'" + ], + invalid: [ + { + code: "var lib = require('lib')", + errors: [ + { + message: 'A `require()` style import is forbidden.', + line: 1, + column: 11 + } + ] + }, + { + code: "let lib2 = require('lib2')", + errors: [ + { + message: 'A `require()` style import is forbidden.', + line: 1, + column: 12 + } + ] + }, + { + code: "var lib5 = require('lib5'), lib6 = require('lib6')", + errors: [ + { + message: 'A `require()` style import is forbidden.', + line: 1, + column: 12 + }, + { + message: 'A `require()` style import is forbidden.', + line: 1, + column: 36 + } + ] + }, + { + code: "import lib8 = require('lib8')", + errors: [ + { + message: 'A `require()` style import is forbidden.', + line: 1, + column: 15 + } + ] + } + ] +}); From d1784992902a41ffc76e917c6b2227e487c76671 Mon Sep 17 00:00:00 2001 From: James Henry Date: Thu, 7 Feb 2019 08:11:57 -0500 Subject: [PATCH 85/88] chore: publish v1.3.0 --- CHANGELOG.md | 17 +++++++++++++++++ lerna.json | 2 +- packages/eslint-plugin-tslint/CHANGELOG.md | 4 ++++ packages/eslint-plugin-tslint/package.json | 4 ++-- packages/eslint-plugin/CHANGELOG.md | 13 +++++++++++++ packages/eslint-plugin/package.json | 4 ++-- packages/parser/CHANGELOG.md | 13 +++++++++++++ packages/parser/package.json | 6 +++--- packages/shared-fixtures/CHANGELOG.md | 16 ++++++++++++++++ packages/shared-fixtures/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 13 +++++++++++++ packages/typescript-estree/package.json | 4 ++-- 12 files changed, 87 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbde088c3966..ee67cc587fb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,23 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.2.0...v1.3.0) (2019-02-07) + +### Bug Fixes + +- **eslint-plugin:** fix false positive from adjacent-overload-signatures ([#206](https://github.com/typescript-eslint/typescript-eslint/issues/206)) ([07e950e](https://github.com/typescript-eslint/typescript-eslint/commit/07e950e)) +- **ts-estree:** align typeArguments and typeParameters across nodes ([#223](https://github.com/typescript-eslint/typescript-eslint/issues/223)) ([3306198](https://github.com/typescript-eslint/typescript-eslint/commit/3306198)) +- **ts-estree:** convert decorators on var and fn decs ([#211](https://github.com/typescript-eslint/typescript-eslint/issues/211)) ([0a1777f](https://github.com/typescript-eslint/typescript-eslint/commit/0a1777f)) +- **ts-estree:** fix issues with typeParams in FunctionExpression ([#208](https://github.com/typescript-eslint/typescript-eslint/issues/208)) ([d4dfa3b](https://github.com/typescript-eslint/typescript-eslint/commit/d4dfa3b)) + +### Features + +- change TypeScript version range to >=3.2.1 <3.4.0 ([#184](https://github.com/typescript-eslint/typescript-eslint/issues/184)) ([f513a14](https://github.com/typescript-eslint/typescript-eslint/commit/f513a14)) +- **eslint-plugin:** add new rule no-for-in-array ([#155](https://github.com/typescript-eslint/typescript-eslint/issues/155)) ([84162ba](https://github.com/typescript-eslint/typescript-eslint/commit/84162ba)) +- **eslint-plugin:** add new rule no-require-imports ([#199](https://github.com/typescript-eslint/typescript-eslint/issues/199)) ([683e5bc](https://github.com/typescript-eslint/typescript-eslint/commit/683e5bc)) +- **eslint-plugin:** added new rule promise-function-async ([#194](https://github.com/typescript-eslint/typescript-eslint/issues/194)) ([5f3aec9](https://github.com/typescript-eslint/typescript-eslint/commit/5f3aec9)) +- **ts-estree:** enable errors 1098 and 1099 ([#219](https://github.com/typescript-eslint/typescript-eslint/issues/219)) ([fc50167](https://github.com/typescript-eslint/typescript-eslint/commit/fc50167)) + # [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01) ### Bug Fixes diff --git a/lerna.json b/lerna.json index 77a95bb3fb2c..ba8df5d99378 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.2.0", + "version": "1.3.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index ca4b53781cd3..20c017da22b5 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.2.0...v1.3.0) (2019-02-07) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + # [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 59b66dd7b153..c69652e9c659 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "1.2.0", + "version": "1.3.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -34,6 +34,6 @@ "devDependencies": { "@types/eslint": "^4.16.3", "@types/lodash.memoize": "^4.1.4", - "@typescript-eslint/parser": "1.2.0" + "@typescript-eslint/parser": "1.3.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 6f10e09e6f08..1cecaf46e024 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.2.0...v1.3.0) (2019-02-07) + +### Bug Fixes + +- **eslint-plugin:** fix false positive from adjacent-overload-signatures ([#206](https://github.com/typescript-eslint/typescript-eslint/issues/206)) ([07e950e](https://github.com/typescript-eslint/typescript-eslint/commit/07e950e)) + +### Features + +- change TypeScript version range to >=3.2.1 <3.4.0 ([#184](https://github.com/typescript-eslint/typescript-eslint/issues/184)) ([f513a14](https://github.com/typescript-eslint/typescript-eslint/commit/f513a14)) +- **eslint-plugin:** add new rule no-for-in-array ([#155](https://github.com/typescript-eslint/typescript-eslint/issues/155)) ([84162ba](https://github.com/typescript-eslint/typescript-eslint/commit/84162ba)) +- **eslint-plugin:** add new rule no-require-imports ([#199](https://github.com/typescript-eslint/typescript-eslint/issues/199)) ([683e5bc](https://github.com/typescript-eslint/typescript-eslint/commit/683e5bc)) +- **eslint-plugin:** added new rule promise-function-async ([#194](https://github.com/typescript-eslint/typescript-eslint/issues/194)) ([5f3aec9](https://github.com/typescript-eslint/typescript-eslint/commit/5f3aec9)) + # [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01) ### Bug Fixes diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index e710176c4250..7b1c3d4bc204 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "1.2.0", + "version": "1.3.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -24,7 +24,7 @@ "recommended:update": "node tools/update-recommended.js" }, "dependencies": { - "@typescript-eslint/parser": "1.2.0", + "@typescript-eslint/parser": "1.3.0", "requireindex": "^1.2.0", "tsutils": "^3.7.0" }, diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index 5e618787d914..7df65d7a587a 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.2.0...v1.3.0) (2019-02-07) + +### Bug Fixes + +- **ts-estree:** align typeArguments and typeParameters across nodes ([#223](https://github.com/typescript-eslint/typescript-eslint/issues/223)) ([3306198](https://github.com/typescript-eslint/typescript-eslint/commit/3306198)) +- **ts-estree:** convert decorators on var and fn decs ([#211](https://github.com/typescript-eslint/typescript-eslint/issues/211)) ([0a1777f](https://github.com/typescript-eslint/typescript-eslint/commit/0a1777f)) +- **ts-estree:** fix issues with typeParams in FunctionExpression ([#208](https://github.com/typescript-eslint/typescript-eslint/issues/208)) ([d4dfa3b](https://github.com/typescript-eslint/typescript-eslint/commit/d4dfa3b)) + +### Features + +- change TypeScript version range to >=3.2.1 <3.4.0 ([#184](https://github.com/typescript-eslint/typescript-eslint/issues/184)) ([f513a14](https://github.com/typescript-eslint/typescript-eslint/commit/f513a14)) +- **ts-estree:** enable errors 1098 and 1099 ([#219](https://github.com/typescript-eslint/typescript-eslint/issues/219)) ([fc50167](https://github.com/typescript-eslint/typescript-eslint/commit/fc50167)) + # [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01) ### Bug Fixes diff --git a/packages/parser/package.json b/packages/parser/package.json index 8cadc1c74159..5b89a50f1eff 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "1.2.0", + "version": "1.3.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/parser.js", "files": [ @@ -36,13 +36,13 @@ "typescript": "*" }, "dependencies": { - "@typescript-eslint/typescript-estree": "1.2.0", + "@typescript-eslint/typescript-estree": "1.3.0", "eslint-scope": "^4.0.0", "eslint-visitor-keys": "^1.0.0" }, "devDependencies": { "@types/eslint": "^4.16.5", "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/shared-fixtures": "1.2.0" + "@typescript-eslint/shared-fixtures": "1.3.0" } } diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index 6ac765de90a1..d6a58a75e6c3 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.2.0...v1.3.0) (2019-02-07) + + +### Bug Fixes + +* **ts-estree:** align typeArguments and typeParameters across nodes ([#223](https://github.com/typescript-eslint/typescript-eslint/issues/223)) ([3306198](https://github.com/typescript-eslint/typescript-eslint/commit/3306198)) + + +### Features + +* **ts-estree:** enable errors 1098 and 1099 ([#219](https://github.com/typescript-eslint/typescript-eslint/issues/219)) ([fc50167](https://github.com/typescript-eslint/typescript-eslint/commit/fc50167)) + + + + + # [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01) **Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index 99e0091de873..30339b84cab3 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "1.2.0", + "version": "1.3.0", "private": true } diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index a1fc5f4167ef..53d7a048eabe 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.2.0...v1.3.0) (2019-02-07) + +### Bug Fixes + +- **ts-estree:** align typeArguments and typeParameters across nodes ([#223](https://github.com/typescript-eslint/typescript-eslint/issues/223)) ([3306198](https://github.com/typescript-eslint/typescript-eslint/commit/3306198)) +- **ts-estree:** convert decorators on var and fn decs ([#211](https://github.com/typescript-eslint/typescript-eslint/issues/211)) ([0a1777f](https://github.com/typescript-eslint/typescript-eslint/commit/0a1777f)) +- **ts-estree:** fix issues with typeParams in FunctionExpression ([#208](https://github.com/typescript-eslint/typescript-eslint/issues/208)) ([d4dfa3b](https://github.com/typescript-eslint/typescript-eslint/commit/d4dfa3b)) + +### Features + +- change TypeScript version range to >=3.2.1 <3.4.0 ([#184](https://github.com/typescript-eslint/typescript-eslint/issues/184)) ([f513a14](https://github.com/typescript-eslint/typescript-eslint/commit/f513a14)) +- **ts-estree:** enable errors 1098 and 1099 ([#219](https://github.com/typescript-eslint/typescript-eslint/issues/219)) ([fc50167](https://github.com/typescript-eslint/typescript-eslint/commit/fc50167)) + # [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01) **Note:** Version bump only for package @typescript-eslint/typescript-estree diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 50432ba4d214..18b452e4be5d 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "1.2.0", + "version": "1.3.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/parser.js", "types": "dist/parser.d.ts", @@ -42,6 +42,6 @@ "typescript": "*" }, "devDependencies": { - "@typescript-eslint/shared-fixtures": "1.2.0" + "@typescript-eslint/shared-fixtures": "1.3.0" } } From 317405ad78298c44812ed570fc8d27674df002ed Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Fri, 8 Feb 2019 08:38:35 -0800 Subject: [PATCH 86/88] fix(typescript-estree, eslint-plugin): stop adding ParenthesizedExpressions to node maps (#226) * fix(typescript-estree, eslint-plugin): stop adding PEs to node maps * refactor(eslint-plugin): move only verifyCast into create * fix(typescript-estree): don't add computedpropertyname to map * fix: fix line endings in new fixture * fix: move all functions into closure --- .../rules/no-unnecessary-type-assertion.js | 240 +++---- .../rules/no-unnecessary-type-assertion.js | 12 + packages/typescript-estree/src/convert.ts | 10 +- .../non-existent-estree-nodes.src.ts | 5 + .../lib/__snapshots__/semanticInfo.ts.snap | 607 ++++++++++++++++++ .../tests/lib/semanticInfo.ts | 28 + 6 files changed, 784 insertions(+), 118 deletions(-) create mode 100644 packages/typescript-estree/tests/fixtures/semanticInfo/non-existent-estree-nodes.src.ts diff --git a/packages/eslint-plugin/lib/rules/no-unnecessary-type-assertion.js b/packages/eslint-plugin/lib/rules/no-unnecessary-type-assertion.js index ed1747c0d95e..bcbe300a01b0 100644 --- a/packages/eslint-plugin/lib/rules/no-unnecessary-type-assertion.js +++ b/packages/eslint-plugin/lib/rules/no-unnecessary-type-assertion.js @@ -15,120 +15,6 @@ const util = require('../util'); // Rule Definition //------------------------------------------------------------------------------ -/** - * Sometimes tuple types don't have ObjectFlags.Tuple set, like when they're being matched against an inferred type. - * So, in addition, check if there are integer properties 0..n and no other numeric keys - * @param {ts.ObjectType} type type - * @returns {boolean} true if type could be a tuple type - */ -function couldBeTupleType(type) { - const properties = type.getProperties(); - - if (properties.length === 0) { - return false; - } - let i = 0; - - for (; i < properties.length; ++i) { - const name = properties[i].name; - - if (String(i) !== name) { - if (i === 0) { - // if there are no integer properties, this is not a tuple - return false; - } - break; - } - } - for (; i < properties.length; ++i) { - if (String(+properties[i].name) === properties[i].name) { - return false; // if there are any other numeric properties, this is not a tuple - } - } - return true; -} - -/** - * - * @param {Node} node node being linted - * @param {Context} context linting context - * @param {ts.TypeChecker} checker TypeScript typechecker - * @returns {void} - */ -function checkNonNullAssertion(node, context, checker) { - /** - * Corresponding TSNode is guaranteed to be in map - * @type {ts.NonNullExpression} - */ - const originalNode = context.parserServices.esTreeNodeToTSNodeMap.get(node); - const type = checker.getTypeAtLocation(originalNode.expression); - - if (type === checker.getNonNullableType(type)) { - context.report({ - node, - messageId: 'unnecessaryAssertion', - fix(fixer) { - return fixer.removeRange([ - originalNode.expression.end, - originalNode.end - ]); - } - }); - } -} - -/** - * @param {Node} node node being linted - * @param {Context} context linting context - * @param {ts.TypeChecker} checker TypeScript typechecker - * @returns {void} - */ -function verifyCast(node, context, checker) { - /** - * * Corresponding TSNode is guaranteed to be in map - * @type {ts.AssertionExpression} - */ - const originalNode = context.parserServices.esTreeNodeToTSNodeMap.get(node); - const options = context.options[0]; - - if ( - options && - options.typesToIgnore && - options.typesToIgnore.indexOf(originalNode.type.getText()) !== -1 - ) { - return; - } - const castType = checker.getTypeAtLocation(originalNode); - - if ( - tsutils.isTypeFlagSet(castType, ts.TypeFlags.Literal) || - (tsutils.isObjectType(castType) && - (tsutils.isObjectFlagSet(castType, ts.ObjectFlags.Tuple) || - couldBeTupleType(castType))) - ) { - // It's not always safe to remove a cast to a literal type or tuple - // type, as those types are sometimes widened without the cast. - return; - } - - const uncastType = checker.getTypeAtLocation(originalNode.expression); - - if (uncastType === castType) { - context.report({ - node, - messageId: 'unnecessaryAssertion', - fix(fixer) { - return originalNode.kind === ts.SyntaxKind.TypeAssertionExpression - ? fixer.removeRange([ - originalNode.getStart(), - originalNode.expression.getStart() - ]) - : fixer.removeRange([originalNode.expression.end, originalNode.end]); - } - }); - } -} - /** @type {import("eslint").Rule.RuleModule} */ module.exports = { meta: { @@ -162,17 +48,137 @@ module.exports = { }, create(context) { + const sourceCode = context.getSourceCode(); const checker = util.getParserServices(context).program.getTypeChecker(); + /** + * Sometimes tuple types don't have ObjectFlags.Tuple set, like when they're being matched against an inferred type. + * So, in addition, check if there are integer properties 0..n and no other numeric keys + * @param {ts.ObjectType} type type + * @returns {boolean} true if type could be a tuple type + */ + function couldBeTupleType(type) { + const properties = type.getProperties(); + + if (properties.length === 0) { + return false; + } + let i = 0; + + for (; i < properties.length; ++i) { + const name = properties[i].name; + + if (String(i) !== name) { + if (i === 0) { + // if there are no integer properties, this is not a tuple + return false; + } + break; + } + } + for (; i < properties.length; ++i) { + if (String(+properties[i].name) === properties[i].name) { + return false; // if there are any other numeric properties, this is not a tuple + } + } + return true; + } + + /** + * @param {Node} node node being linted + * @returns {void} + */ + function checkNonNullAssertion(node) { + /** + * Corresponding TSNode is guaranteed to be in map + * @type {ts.NonNullExpression} + */ + const originalNode = context.parserServices.esTreeNodeToTSNodeMap.get( + node + ); + const type = checker.getTypeAtLocation(originalNode.expression); + + if (type === checker.getNonNullableType(type)) { + context.report({ + node, + messageId: 'unnecessaryAssertion', + fix(fixer) { + return fixer.removeRange([ + originalNode.expression.end, + originalNode.end + ]); + } + }); + } + } + + /** + * @param {Node} node node being linted + * @returns {void} + */ + function verifyCast(node) { + const options = context.options[0]; + + if ( + options && + options.typesToIgnore && + options.typesToIgnore.indexOf( + sourceCode.getText(node.typeAnnotation) + ) !== -1 + ) { + return; + } + + /** + * Corresponding TSNode is guaranteed to be in map + * @type {ts.AssertionExpression} + */ + const originalNode = context.parserServices.esTreeNodeToTSNodeMap.get( + node + ); + const castType = checker.getTypeAtLocation(originalNode); + + if ( + tsutils.isTypeFlagSet(castType, ts.TypeFlags.Literal) || + (tsutils.isObjectType(castType) && + (tsutils.isObjectFlagSet(castType, ts.ObjectFlags.Tuple) || + couldBeTupleType(castType))) + ) { + // It's not always safe to remove a cast to a literal type or tuple + // type, as those types are sometimes widened without the cast. + return; + } + + const uncastType = checker.getTypeAtLocation(originalNode.expression); + + if (uncastType === castType) { + context.report({ + node, + messageId: 'unnecessaryAssertion', + fix(fixer) { + return originalNode.kind === ts.SyntaxKind.TypeAssertionExpression + ? fixer.removeRange([ + originalNode.getStart(), + originalNode.expression.getStart() + ]) + : fixer.removeRange([ + originalNode.expression.end, + originalNode.end + ]); + } + }); + } + } + return { TSNonNullExpression(node) { - checkNonNullAssertion(node, context, checker); + checkNonNullAssertion(node); }, TSTypeAssertion(node) { - verifyCast(node, context, checker); + verifyCast(node); }, TSAsExpression(node) { - verifyCast(node, context, checker); + verifyCast(node); } }; } diff --git a/packages/eslint-plugin/tests/lib/rules/no-unnecessary-type-assertion.js b/packages/eslint-plugin/tests/lib/rules/no-unnecessary-type-assertion.js index 633f1a334330..8795cff89c51 100644 --- a/packages/eslint-plugin/tests/lib/rules/no-unnecessary-type-assertion.js +++ b/packages/eslint-plugin/tests/lib/rules/no-unnecessary-type-assertion.js @@ -51,6 +51,18 @@ type Foo = number; const foo = (3 + 5) as Foo;`, options: [{ typesToIgnore: ['Foo'] }] }, + { + code: `const foo = (3 + 5) as any;`, + options: [{ typesToIgnore: ['any'] }] + }, + { + code: `((Syntax as any).ArrayExpression = 'foo')`, + options: [{ typesToIgnore: ['any'] }] + }, + { + code: `const foo = (3 + 5) as string;`, + options: [{ typesToIgnore: ['string'] }] + }, { code: ` type Foo = number; diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index bf121fa01bb0..9f14bbcc2489 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -119,7 +119,15 @@ export class Converter { if (result && this.options.shouldProvideParserServices) { this.tsNodeToESTreeNodeMap.set(node, result); - this.esTreeNodeToTSNodeMap.set(result, node); + if ( + node.kind !== SyntaxKind.ParenthesizedExpression && + node.kind !== SyntaxKind.ComputedPropertyName + ) { + // Parenthesized expressions and computed property names do not have individual nodes in ESTree. + // Therefore, result.type will never "match" node.kind if it is a ParenthesizedExpression + // or a ComputedPropertyName and, furthermore, will overwrite the "matching" node + this.esTreeNodeToTSNodeMap.set(result, node); + } } this.inTypeMode = typeMode; diff --git a/packages/typescript-estree/tests/fixtures/semanticInfo/non-existent-estree-nodes.src.ts b/packages/typescript-estree/tests/fixtures/semanticInfo/non-existent-estree-nodes.src.ts new file mode 100644 index 000000000000..4eb9dba432b4 --- /dev/null +++ b/packages/typescript-estree/tests/fixtures/semanticInfo/non-existent-estree-nodes.src.ts @@ -0,0 +1,5 @@ +const binExp = (3 + 5); + +class Bar { + ['test']: string; +} diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.ts.snap index 5af1b41ba261..f5722861dd24 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.ts.snap @@ -1133,4 +1133,611 @@ Object { } `; +exports[`semanticInfo fixtures/non-existent-estree-nodes.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "binExp", + "range": Array [ + 6, + 12, + ], + "type": "Identifier", + }, + "init": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "raw": "3", + "type": "Literal", + "value": 3, + }, + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "operator": "+", + "range": Array [ + 16, + 21, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "raw": "5", + "type": "Literal", + "value": 5, + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 22, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 23, + ], + "type": "VariableDeclaration", + }, + Object { + "body": Object { + "body": Array [ + Object { + "computed": true, + "key": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 4, + }, + "start": Object { + "column": 3, + "line": 4, + }, + }, + "range": Array [ + 40, + 46, + ], + "raw": "'test'", + "type": "Literal", + "value": "test", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 39, + 56, + ], + "static": false, + "type": "ClassProperty", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 4, + }, + "start": Object { + "column": 10, + "line": 4, + }, + }, + "range": Array [ + 47, + 55, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 4, + }, + "start": Object { + "column": 12, + "line": 4, + }, + }, + "range": Array [ + 49, + 55, + ], + "type": "TSStringKeyword", + }, + }, + "value": null, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 35, + 58, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "name": "Bar", + "range": Array [ + 31, + 34, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 25, + 58, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 6, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 59, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 12, + ], + "type": "Identifier", + "value": "binExp", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Numeric", + "value": "3", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": "+", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Numeric", + "value": "5", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 25, + 30, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 31, + 34, + ], + "type": "Identifier", + "value": "Bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 4, + }, + "start": Object { + "column": 3, + "line": 4, + }, + }, + "range": Array [ + 40, + 46, + ], + "type": "String", + "value": "'test'", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 4, + }, + "start": Object { + "column": 9, + "line": 4, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 4, + }, + "start": Object { + "column": 10, + "line": 4, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 4, + }, + "start": Object { + "column": 12, + "line": 4, + }, + }, + "range": Array [ + 49, + 55, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 4, + }, + "start": Object { + "column": 18, + "line": 4, + }, + }, + "range": Array [ + 55, + 56, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 57, + 58, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + exports[`semanticInfo malformed project file 1`] = `"Compiler option 'compileOnSave' requires a value of type boolean."`; diff --git a/packages/typescript-estree/tests/lib/semanticInfo.ts b/packages/typescript-estree/tests/lib/semanticInfo.ts index 531ab1a34d54..126ad35879b6 100644 --- a/packages/typescript-estree/tests/lib/semanticInfo.ts +++ b/packages/typescript-estree/tests/lib/semanticInfo.ts @@ -18,6 +18,11 @@ import { parseCodeAndGenerateServices } from '../../tools/test-utils'; import { parseAndGenerateServices } from '../../src/parser'; +import { + VariableDeclaration, + ClassDeclaration, + ClassProperty +} from '../../src/typedefs'; //------------------------------------------------------------------------------ // Setup @@ -101,6 +106,29 @@ describe('semanticInfo', () => { testIsolatedFile(parseResult); }); + it('non-existent-estree-nodes tests', () => { + const fileName = resolve(FIXTURES_DIR, 'non-existent-estree-nodes.src.ts'); + const parseResult = parseCodeAndGenerateServices( + readFileSync(fileName, 'utf8'), + createOptions(fileName) + ); + + expect(parseResult).toHaveProperty('services.esTreeNodeToTSNodeMap'); + const binaryExpression = (parseResult.ast.body[0] as VariableDeclaration) + .declarations[0].init!; + const tsBinaryExpression = parseResult.services.esTreeNodeToTSNodeMap!.get( + binaryExpression + ); + expect(tsBinaryExpression.kind).toEqual(ts.SyntaxKind.BinaryExpression); + + const computedPropertyString = ((parseResult.ast + .body[1] as ClassDeclaration).body.body[0] as ClassProperty).key; + const tsComputedPropertyString = parseResult.services.esTreeNodeToTSNodeMap!.get( + computedPropertyString + ); + expect(tsComputedPropertyString.kind).toEqual(ts.SyntaxKind.StringLiteral); + }); + it('imported-file tests', () => { const fileName = resolve(FIXTURES_DIR, 'import-file.src.ts'); const parseResult = parseCodeAndGenerateServices( From b95c4cf803f42352976389494f604d0b94bbf644 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Fri, 8 Feb 2019 08:49:40 -0800 Subject: [PATCH 87/88] feat(eslint-plugin): add prefer-function-type rule (#222) feat(eslint-plugin): add prefer-function-type rule --- packages/eslint-plugin/README.md | 1 + packages/eslint-plugin/ROADMAP.md | 3 +- .../docs/rules/prefer-function-type.md | 57 ++++++ .../lib/rules/prefer-function-type.js | 171 ++++++++++++++++++ .../tests/lib/rules/prefer-function-type.js | 147 +++++++++++++++ 5 files changed, 378 insertions(+), 1 deletion(-) create mode 100644 packages/eslint-plugin/docs/rules/prefer-function-type.md create mode 100644 packages/eslint-plugin/lib/rules/prefer-function-type.js create mode 100644 packages/eslint-plugin/tests/lib/rules/prefer-function-type.js diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 5030ca291751..daacab20afdb 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -144,6 +144,7 @@ Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.e | [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | | | [`@typescript-eslint/no-useless-constructor`](./docs/rules/no-useless-constructor.md) | Disallow unnecessary constructors | | | | [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/prefer-function-type`](./docs/rules/prefer-function-type.md) | Use function types instead of interfaces with call signatures (`callable-types` from TSLint) | | :wrench: | | [`@typescript-eslint/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: | | [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: | | [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async. (`promise-function-async` from TSLint) | :heavy_check_mark: | | diff --git a/packages/eslint-plugin/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md index 86f0224f0af5..9d4c2ef5a9f1 100644 --- a/packages/eslint-plugin/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -132,7 +132,7 @@ | [`arrow-parens`] | 🌟 | [`arrow-parens`][arrow-parens] | | [`arrow-return-shorthand`] | 🌟 | [`arrow-body-style`][arrow-body-style] | | [`binary-expression-operand-order`] | 🌟 | [`yoda`][yoda] | -| [`callable-types`] | 🛑 | N/A | +| [`callable-types`] | ✅ | [`@typescript-eslint/prefer-function-type`] | | [`class-name`] | ✅ | [`@typescript-eslint/class-name-casing`] | | [`comment-format`] | 🌟 | [`capitalized-comments`][capitalized-comments] & [`spaced-comment`][spaced-comment] | | [`completed-docs`] | 🔌 | [`eslint-plugin-jsdoc`][plugin:jsdoc] | @@ -587,6 +587,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- [`@typescript-eslint/member-delimiter-style`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md [`@typescript-eslint/prefer-interface`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-interface.md [`@typescript-eslint/no-array-constructor`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-array-constructor.md +[`@typescript-eslint/prefer-function-type`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-function-type.md [`@typescript-eslint/no-for-in-array`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-for-in-array.md diff --git a/packages/eslint-plugin/docs/rules/prefer-function-type.md b/packages/eslint-plugin/docs/rules/prefer-function-type.md new file mode 100644 index 000000000000..7cbf2be0480d --- /dev/null +++ b/packages/eslint-plugin/docs/rules/prefer-function-type.md @@ -0,0 +1,57 @@ +# Use function types instead of interfaces with call signatures (prefer-function-type) + +## Rule Details + +This rule suggests using a function type instead of an interface or object type literal with a single call signature. + +Examples of **incorrect** code for this rule: + +```ts +interface Foo { + (): string; +} +``` + +```ts +function foo(bar: { (): number }): number { + return bar(); +} +``` + +```ts +interface Foo extends Function { + (): void; +} +``` + +Examples of **correct** code for this rule: + +```ts +interface Foo { + (): void; + bar: number; +} +``` + +```ts +function foo(bar: { (): string; baz: number }): string { + return bar(); +} +``` + +```ts +interface Foo { + bar: string; +} +interface Bar extends Foo { + (): void; +} +``` + +## When Not To Use It + +If you specifically want to use an interface or type literal with a single call signature for stylistic reasons, you can disable this rule. + +## Further Reading + +- TSLint: [`callable-types`](https://palantir.github.io/tslint/rules/callable-types/) diff --git a/packages/eslint-plugin/lib/rules/prefer-function-type.js b/packages/eslint-plugin/lib/rules/prefer-function-type.js new file mode 100644 index 000000000000..f591179932fb --- /dev/null +++ b/packages/eslint-plugin/lib/rules/prefer-function-type.js @@ -0,0 +1,171 @@ +/** + * @fileoverview Use function types instead of interfaces with call signatures + * @author Benjamin Lichtman + */ +'use strict'; +const util = require('../util'); + +/** + * @typedef {import("eslint").Rule.RuleModule} RuleModule + * @typedef {import("estree").Node} ESTreeNode + */ + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +/** + * @type {RuleModule} + */ +module.exports = { + meta: { + docs: { + description: + 'Use function types instead of interfaces with call signatures', + category: 'TypeScript', + recommended: false, + extraDescription: [util.tslintRule('prefer-function-type')], + url: util.metaDocsUrl('prefer-function-type') + }, + fixable: 'code', + messages: { + functionTypeOverCallableType: + "{{ type }} has only a call signature - use '{{ sigSuggestion }}' instead." + }, + schema: [], + type: 'suggestion' + }, + + create(context) { + const sourceCode = context.getSourceCode(); + + //---------------------------------------------------------------------- + // Helpers + //---------------------------------------------------------------------- + + /** + * Checks if there is no supertype or if the supertype is 'Function' + * @param {ESTreeNode} node The node being checked + * @returns {boolean} Returns true iff there is no supertype or if the supertype is 'Function' + */ + function noSupertype(node) { + if (!node.extends || node.extends.length === 0) { + return true; + } + if (node.extends.length !== 1) { + return false; + } + const expr = node.extends[0].expression; + + return expr.type === 'Identifier' && expr.name === 'Function'; + } + + /** + * @param {ESTreeNode} parent The parent of the call signature causing the diagnostic + * @returns {boolean} true iff the parent node needs to be wrapped for readability + */ + function shouldWrapSuggestion(parent) { + switch (parent.type) { + case 'TSUnionType': + case 'TSIntersectionType': + case 'TSArrayType': + return true; + default: + return false; + } + } + + /** + * @param {ESTreeNode} call The call signature causing the diagnostic + * @param {ESTreeNode} parent The parent of the call + * @returns {string} The suggestion to report + */ + function renderSuggestion(call, parent) { + const start = call.range[0]; + const colonPos = call.returnType.range[0] - start; + const text = sourceCode.getText().slice(start, call.range[1]); + + let suggestion = `${text.slice(0, colonPos)} =>${text.slice( + colonPos + 1 + )}`; + + if (shouldWrapSuggestion(parent.parent)) { + suggestion = `(${suggestion})`; + } + if (parent.type === 'TSInterfaceDeclaration') { + if (typeof parent.typeParameters !== 'undefined') { + return `type ${sourceCode + .getText() + .slice( + parent.id.range[0], + parent.typeParameters.range[1] + )} = ${suggestion}`; + } + return `type ${parent.id.name} = ${suggestion}`; + } + return suggestion.endsWith(';') ? suggestion.slice(0, -1) : suggestion; + } + + /** + * @param {ESTreeNode} member The TypeElement being checked + * @param {ESTreeNode} node The parent of member being checked + * @returns {void} + */ + function checkMember(member, node) { + if ( + (member.type === 'TSCallSignatureDeclaration' || + member.type === 'TSConstructSignatureDeclaration') && + typeof member.returnType !== 'undefined' + ) { + const suggestion = renderSuggestion(member, node); + const fixStart = + node.type === 'TSTypeLiteral' + ? node.range[0] + : sourceCode + .getTokens(node) + .filter( + token => + token.type === 'Keyword' && token.value === 'interface' + )[0].range[0]; + + context.report({ + node: member, + messageId: 'functionTypeOverCallableType', + data: { + type: node.type === 'TSTypeLiteral' ? 'Type literal' : 'Interface', + sigSuggestion: suggestion + }, + fix(fixer) { + return fixer.replaceTextRange( + [fixStart, node.range[1]], + suggestion + ); + } + }); + } + } + + //---------------------------------------------------------------------- + // Public + //---------------------------------------------------------------------- + + return { + /** + * @param {TSInterfaceDeclaration} node The node being checked + * @returns {void} + */ + TSInterfaceDeclaration(node) { + if (noSupertype(node) && node.body.body.length === 1) { + checkMember(node.body.body[0], node); + } + }, + /** + * @param {TSTypeLiteral} node The node being checked + * @returns {void} + */ + 'TSTypeLiteral[members.length = 1]'(node) { + checkMember(node.members[0], node); + } + }; + } +}; diff --git a/packages/eslint-plugin/tests/lib/rules/prefer-function-type.js b/packages/eslint-plugin/tests/lib/rules/prefer-function-type.js new file mode 100644 index 000000000000..d0587afcaf7c --- /dev/null +++ b/packages/eslint-plugin/tests/lib/rules/prefer-function-type.js @@ -0,0 +1,147 @@ +/** + * @fileoverview Use function types instead of interfaces with call signatures + * @author Benjamin Lichtman + */ +'use strict'; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +var rule = require('../../../lib/rules/prefer-function-type'), + RuleTester = require('eslint').RuleTester; + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +const parserOptions = { + ecmaVersion: 2015 +}; +var ruleTester = new RuleTester({ + parserOptions, + parser: '@typescript-eslint/parser' +}); +ruleTester.run('prefer-function-type', rule, { + valid: [ + ` +interface Foo { + (): void; + bar: number; +}`, + ` +type Foo = { + (): void; + bar: number; +}`, + ` +function foo(bar: { (): string, baz: number }): string { + return bar(); +}`, + ` +interface Foo { + bar: string; +} +interface Bar extends Foo { + (): void; +}`, + ` +interface Foo { + bar: string; +} +interface Bar extends Function, Foo { + (): void; +}` + ], + + invalid: [ + { + code: ` +interface Foo { + (): string; +}`, + errors: [ + { + messageId: 'functionTypeOverCallableType', + type: 'TSCallSignatureDeclaration' + } + ], + output: ` +type Foo = () => string;` + }, + { + code: ` +type Foo = { + (): string; +}`, + errors: [ + { + messageId: 'functionTypeOverCallableType', + type: 'TSCallSignatureDeclaration' + } + ], + output: ` +type Foo = () => string` + }, + { + code: ` +function foo(bar: { (s: string): number }): number { + return bar("hello"); +}`, + errors: [ + { + messageId: 'functionTypeOverCallableType', + type: 'TSCallSignatureDeclaration' + } + ], + output: ` +function foo(bar: (s: string) => number): number { + return bar("hello"); +}` + }, + { + code: ` +function foo(bar: { (s: string): number } | undefined): number { + return bar("hello"); +}`, + errors: [ + { + messageId: 'functionTypeOverCallableType', + type: 'TSCallSignatureDeclaration' + } + ], + output: ` +function foo(bar: ((s: string) => number) | undefined): number { + return bar("hello"); +}` + }, + { + code: ` +interface Foo extends Function { + (): void; +}`, + errors: [ + { + messageId: 'functionTypeOverCallableType', + type: 'TSCallSignatureDeclaration' + } + ], + output: ` +type Foo = () => void;` + }, + { + code: ` +interface Foo { + (bar: T): string; +}`, + errors: [ + { + messageId: 'functionTypeOverCallableType', + type: 'TSCallSignatureDeclaration' + } + ], + output: ` +type Foo = (bar: T) => string;` + } + ] +}); From 5e3e285eb937ebdfaada23d8687e3e9dbcce4d18 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Fri, 8 Feb 2019 15:27:49 -0800 Subject: [PATCH 88/88] docs(eslint-plugin): fix metadata for prefer-function-type (#232) --- packages/eslint-plugin/lib/rules/prefer-function-type.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/lib/rules/prefer-function-type.js b/packages/eslint-plugin/lib/rules/prefer-function-type.js index f591179932fb..a34b7ba4c1a3 100644 --- a/packages/eslint-plugin/lib/rules/prefer-function-type.js +++ b/packages/eslint-plugin/lib/rules/prefer-function-type.js @@ -24,7 +24,7 @@ module.exports = { 'Use function types instead of interfaces with call signatures', category: 'TypeScript', recommended: false, - extraDescription: [util.tslintRule('prefer-function-type')], + extraDescription: [util.tslintRule('callable-types')], url: util.metaDocsUrl('prefer-function-type') }, fixable: 'code',