From 09f67ffac728cb90242833b6ac96a22a996ec286 Mon Sep 17 00:00:00 2001 From: "azure-pipelines[bot]" Date: Sun, 20 Jan 2019 20:05:01 -0500 Subject: [PATCH 01/16] 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 02/16] 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 03/16] 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 04/16] 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 05/16] 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 06/16] 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 07/16] 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 08/16] 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 09/16] 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 10/16] =?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 11/16] 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 12/16] 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 13/16] 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 14/16] 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 15/16] 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 16/16] 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" } }