From e6383fd3a862c7db3f919073967aeee9938b1d9b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Mar 2021 13:06:07 -0700 Subject: [PATCH 01/11] chore: bump eslint-plugin-jest from 24.2.1 to 24.3.1 (#3185) Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 24.2.1 to 24.3.1. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v24.2.1...v24.3.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4d15d230e256..84441403778d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3759,9 +3759,9 @@ eslint-plugin-import@^2.22.0: tsconfig-paths "^3.9.0" eslint-plugin-jest@^24.1.3: - version "24.2.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.2.1.tgz#7e84f16a3ca6589b86be9732a93d71367a4ed627" - integrity sha512-s24ve8WUu3DLVidvlSzaqlOpTZre9lTkZTAO+a7X0WMtj8HraWTiTEkW3pbDT1xVxqEHMWSv+Kx7MyqR50nhBw== + version "24.3.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.3.1.tgz#c8df037847b83397940bef7fbc2cc168ab466bcc" + integrity sha512-RQt59rfMSHyvedImT72iaf8JcvCcR4P7Uq499dALtjY8mrCjbwWrFi1UceG4sid2wVIeDi+0tjxXZ8CZEVO7Zw== dependencies: "@typescript-eslint/experimental-utils" "^4.0.1" From 7b6f2ab4c0206619b493f6e7f82d280313fec9e9 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 16 Mar 2021 04:13:31 +0800 Subject: [PATCH 02/11] docs: update babel-eslint to @babel/eslint-parser (#3186) --- README.md | 8 ++++---- packages/typescript-estree/tests/ast-alignment/utils.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e44cd7102461..d8abbe324a96 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ - [How does `typescript-eslint` work and why do you have multiple packages?](#how-does-typescript-eslint-work-and-why-do-you-have-multiple-packages) - [Can I use all of the existing ESLint plugins and rules without any changes?](#can-i-use-all-of-the-existing-eslint-plugins-and-rules-without-any-changes) - [Can we write rules which leverage type information?](#can-we-write-rules-which-leverage-type-information) -- [What about Babel and `babel-eslint`?](#what-about-babel-and-babel-eslint) +- [What about Babel and `@babel/eslint-parser`?](#what-about-babel-and-babeleslint-parser) - [How can I help?](#how-can-i-help) - [Packages included in this project?](#packages-included-in-this-project) - [Package Versions](#package-versions) @@ -161,15 +161,15 @@ We already do this in numerous rules within [`@typescript-eslint/eslint-plugin`]
-## What about Babel and `babel-eslint`? +## What about Babel and `@babel/eslint-parser`? Babel does now support parsing (but not type-checking) TypeScript source code. This is as an alternative to using the TypeScript Compiler. It also supports many other syntaxes, via plugins, which are not supported by the TypeScript Compiler. As mentioned above, `typescript-eslint` is powered by the TypeScript Compiler, so we support whatever it does. -The key trade-off can be summarized as `babel-eslint` supports additional syntax which TypeScript itself does not, but `typescript-eslint` supports creating rules based on type information, which is not available to babel because there is no type-checker. +The key trade-off can be summarized as `@babel/eslint-parser` supports additional syntax which TypeScript itself does not, but `typescript-eslint` supports creating rules based on type information, which is not available to babel because there is no type-checker. Because they are separate projects powered by different underlying tooling, they are currently not intended to be used together. -Some of the people involved in `typescript-eslint` are also involved in Babel and `babel-eslint`, and in this project, we are working hard to align on the AST format for non-standard JavaScript syntax. This is an ongoing effort. +Some of the people involved in `typescript-eslint` are also involved in Babel and `@babel/eslint-parser`, and in this project, we are working hard to align on the AST format for non-standard JavaScript syntax. This is an ongoing effort.
diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index a2c1d6f87f93..81f4ae71c4d2 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -225,7 +225,7 @@ export function preprocessBabylonAST(ast: BabelTypes.File): any { /** * Template strings seem to also be affected by the difference in opinion between different parsers in * @see https://github.com/babel/babel/issues/6681 - * @see https://github.com/babel/babel-eslint/blob/master/lib/babylon-to-espree/convertAST.js#L81-L96 + * @see https://github.com/babel/babel/blob/main/eslint/babel-eslint-parser/src/convert/convertAST.js#L64-L80 */ TemplateLiteral(node: any) { for (let j = 0; j < node.quasis.length; j++) { From 9ed3c5020cf390f7f26cdb24638c222fc0383647 Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 17 Mar 2021 11:25:49 +0100 Subject: [PATCH 03/11] refactor(eslint-plugin): use direct ts type guards instead of tsutils (#3193) --- .../eslint-plugin/src/rules/no-floating-promises.ts | 6 +++--- .../src/rules/no-unnecessary-type-arguments.ts | 2 +- packages/eslint-plugin/src/rules/return-await.ts | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-floating-promises.ts b/packages/eslint-plugin/src/rules/no-floating-promises.ts index deb4ee5c00f9..afaa61cd4722 100644 --- a/packages/eslint-plugin/src/rules/no-floating-promises.ts +++ b/packages/eslint-plugin/src/rules/no-floating-promises.ts @@ -227,7 +227,7 @@ function isFunctionParam( function isPromiseCatchCallWithHandler(expression: ts.CallExpression): boolean { return ( - tsutils.isPropertyAccessExpression(expression.expression) && + ts.isPropertyAccessExpression(expression.expression) && expression.expression.name.text === 'catch' && expression.arguments.length >= 1 ); @@ -237,7 +237,7 @@ function isPromiseThenCallWithRejectionHandler( expression: ts.CallExpression, ): boolean { return ( - tsutils.isPropertyAccessExpression(expression.expression) && + ts.isPropertyAccessExpression(expression.expression) && expression.expression.name.text === 'then' && expression.arguments.length >= 2 ); @@ -247,7 +247,7 @@ function isPromiseFinallyCallWithHandler( expression: ts.CallExpression, ): boolean { return ( - tsutils.isPropertyAccessExpression(expression.expression) && + ts.isPropertyAccessExpression(expression.expression) && expression.expression.name.text === 'finally' && expression.arguments.length >= 1 ); diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts b/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts index 2ff89c5931b4..2df933084dcf 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts @@ -118,7 +118,7 @@ function getTypeParametersFromType( } return findFirstResult(declarations, decl => - tsutils.isClassLikeDeclaration(decl) || + ts.isClassLike(decl) || ts.isTypeAliasDeclaration(decl) || ts.isInterfaceDeclaration(decl) ? decl.typeParameters diff --git a/packages/eslint-plugin/src/rules/return-await.ts b/packages/eslint-plugin/src/rules/return-await.ts index c8e7f102b095..85a2eebe1f58 100644 --- a/packages/eslint-plugin/src/rules/return-await.ts +++ b/packages/eslint-plugin/src/rules/return-await.ts @@ -61,7 +61,7 @@ export default util.createRule({ let ancestor = node.parent; while (ancestor && !ts.isFunctionLike(ancestor)) { - if (tsutils.isTryStatement(ancestor)) { + if (ts.isTryStatement(ancestor)) { return true; } @@ -75,7 +75,7 @@ export default util.createRule({ let ancestor = node.parent; while (ancestor && !ts.isFunctionLike(ancestor)) { - if (tsutils.isCatchClause(ancestor)) { + if (ts.isCatchClause(ancestor)) { return true; } @@ -90,8 +90,8 @@ export default util.createRule({ while (ancestor && !ts.isFunctionLike(ancestor)) { if ( - tsutils.isTryStatement(ancestor.parent) && - tsutils.isBlock(ancestor) && + ts.isTryStatement(ancestor.parent) && + ts.isBlock(ancestor) && ancestor.parent.end === ancestor.end ) { return true; @@ -106,7 +106,7 @@ export default util.createRule({ let ancestor = node.parent; while (ancestor && !ts.isFunctionLike(ancestor)) { - if (tsutils.isTryStatement(ancestor)) { + if (ts.isTryStatement(ancestor)) { return !!ancestor.finallyBlock; } ancestor = ancestor.parent; @@ -154,7 +154,7 @@ export default util.createRule({ function test(node: TSESTree.Expression, expression: ts.Node): void { let child: ts.Node; - const isAwait = tsutils.isAwaitExpression(expression); + const isAwait = ts.isAwaitExpression(expression); if (isAwait) { child = expression.getChildAt(1); From 6703df194203d9fa233bb5a3cb96560b5d51e345 Mon Sep 17 00:00:00 2001 From: James Craster Date: Thu, 18 Mar 2021 19:40:28 +0000 Subject: [PATCH 04/11] docs(eslint-plugin): [naming-convention] clarify literal regex notation vs. argument to RegExp (#3198) --- packages/eslint-plugin/docs/rules/naming-convention.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/naming-convention.md b/packages/eslint-plugin/docs/rules/naming-convention.md index ff9f8e79a3cf..4b28cffceafe 100644 --- a/packages/eslint-plugin/docs/rules/naming-convention.md +++ b/packages/eslint-plugin/docs/rules/naming-convention.md @@ -110,7 +110,7 @@ This can be useful if you want to enforce no particular format for a specific se The `custom` option defines a custom regex that the identifier must (or must not) match. This option allows you to have a bit more finer-grained control over identifiers, letting you ban (or force) certain patterns and substrings. Accepts an object with the following properties: -- `regex` - accepts a regular expression (anything accepted into `new RegExp(regex)`). +- `regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)` - `match` - true if the identifier _must_ match the `regex`, false if the identifier _must not_ match the `regex`. ### `filter` @@ -121,7 +121,7 @@ You can use this to include or exclude specific identifiers from specific config Accepts an object with the following properties: -- `regex` - accepts a regular expression (anything accepted into `new RegExp(regex)`). +- `regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)` - `match` - true if the identifier _must_ match the `regex`, false if the identifier _must not_ match the `regex`. Alternatively, `filter` accepts a regular expression (anything accepted into `new RegExp(filter)`). In this case, it's treated as if you had passed an object with the regex and `match: true`. From 56af98964f7c7653de1ef0c0509857d057a05abc Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 18 Mar 2021 20:52:23 +0100 Subject: [PATCH 05/11] refactor(eslint-plugin): [no-floating-promises] update code to use AST instead of ts nodes (#3195) --- .../src/rules/no-floating-promises.ts | 65 ++++++++++--------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-floating-promises.ts b/packages/eslint-plugin/src/rules/no-floating-promises.ts index afaa61cd4722..905dfd06fcff 100644 --- a/packages/eslint-plugin/src/rules/no-floating-promises.ts +++ b/packages/eslint-plugin/src/rules/no-floating-promises.ts @@ -60,13 +60,11 @@ export default util.createRule({ return { ExpressionStatement(node): void { - const { expression } = parserServices.esTreeNodeToTSNodeMap.get(node); - if (options.ignoreIIFE && isAsyncIife(node)) { return; } - if (isUnhandledPromise(checker, expression)) { + if (isUnhandledPromise(checker, node.expression)) { if (options.ignoreVoid) { context.report({ node, @@ -107,34 +105,34 @@ export default util.createRule({ function isUnhandledPromise( checker: ts.TypeChecker, - node: ts.Node, + node: TSESTree.Node, ): boolean { // First, check expressions whose resulting types may not be promise-like - if ( - ts.isBinaryExpression(node) && - node.operatorToken.kind === ts.SyntaxKind.CommaToken - ) { + if (node.type === AST_NODE_TYPES.SequenceExpression) { // Any child in a comma expression could return a potentially unhandled // promise, so we check them all regardless of whether the final returned // value is promise-like. - return ( - isUnhandledPromise(checker, node.left) || - isUnhandledPromise(checker, node.right) - ); + return node.expressions.some(item => isUnhandledPromise(checker, item)); } - if (ts.isVoidExpression(node) && !options.ignoreVoid) { + if ( + !options.ignoreVoid && + node.type === AST_NODE_TYPES.UnaryExpression && + node.operator === 'void' + ) { // Similarly, a `void` expression always returns undefined, so we need to // see what's inside it without checking the type of the overall expression. - return isUnhandledPromise(checker, node.expression); + return isUnhandledPromise(checker, node.argument); } // Check the type. At this point it can't be unhandled if it isn't a promise - if (!isPromiseLike(checker, node)) { + if ( + !isPromiseLike(checker, parserServices.esTreeNodeToTSNodeMap.get(node)) + ) { return false; } - if (ts.isCallExpression(node)) { + if (node.type === AST_NODE_TYPES.CallExpression) { // If the outer expression is a call, it must be either a `.then()` or // `.catch()` that handles the promise. return ( @@ -142,17 +140,17 @@ export default util.createRule({ !isPromiseThenCallWithRejectionHandler(node) && !isPromiseFinallyCallWithHandler(node) ); - } else if (ts.isConditionalExpression(node)) { + } else if (node.type === AST_NODE_TYPES.ConditionalExpression) { // We must be getting the promise-like value from one of the branches of the // ternary. Check them directly. return ( - isUnhandledPromise(checker, node.whenFalse) || - isUnhandledPromise(checker, node.whenTrue) + isUnhandledPromise(checker, node.alternate) || + isUnhandledPromise(checker, node.consequent) ); } else if ( - ts.isPropertyAccessExpression(node) || - ts.isIdentifier(node) || - ts.isNewExpression(node) + node.type === AST_NODE_TYPES.MemberExpression || + node.type === AST_NODE_TYPES.Identifier || + node.type === AST_NODE_TYPES.NewExpression ) { // If it is just a property access chain or a `new` call (e.g. `foo.bar` or // `new Promise()`), the promise is not handled because it doesn't have the @@ -225,30 +223,35 @@ function isFunctionParam( return false; } -function isPromiseCatchCallWithHandler(expression: ts.CallExpression): boolean { +function isPromiseCatchCallWithHandler( + expression: TSESTree.CallExpression, +): boolean { return ( - ts.isPropertyAccessExpression(expression.expression) && - expression.expression.name.text === 'catch' && + expression.callee.type === AST_NODE_TYPES.MemberExpression && + expression.callee.property.type === AST_NODE_TYPES.Identifier && + expression.callee.property.name === 'catch' && expression.arguments.length >= 1 ); } function isPromiseThenCallWithRejectionHandler( - expression: ts.CallExpression, + expression: TSESTree.CallExpression, ): boolean { return ( - ts.isPropertyAccessExpression(expression.expression) && - expression.expression.name.text === 'then' && + expression.callee.type === AST_NODE_TYPES.MemberExpression && + expression.callee.property.type === AST_NODE_TYPES.Identifier && + expression.callee.property.name === 'then' && expression.arguments.length >= 2 ); } function isPromiseFinallyCallWithHandler( - expression: ts.CallExpression, + expression: TSESTree.CallExpression, ): boolean { return ( - ts.isPropertyAccessExpression(expression.expression) && - expression.expression.name.text === 'finally' && + expression.callee.type === AST_NODE_TYPES.MemberExpression && + expression.callee.property.type === AST_NODE_TYPES.Identifier && + expression.callee.property.name === 'finally' && expression.arguments.length >= 1 ); } From 6a25faf5cfa4d21a7546d9866819f4e017308fb2 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 18 Mar 2021 20:55:21 +0100 Subject: [PATCH 06/11] fix(typescript-estree): [ts 4.2] add support for import type equal declaration (#3189) --- .../import-equal-type-declaration.src.ts | 1 + ...mport-export-equal-type-declaration.src.ts | 1 + packages/types/src/ts-estree.ts | 1 + packages/typescript-estree/package.json | 2 +- packages/typescript-estree/src/convert.ts | 1 + .../tests/ast-alignment/fixtures-to-test.ts | 2 + .../semantic-diagnostics-enabled.test.ts.snap | 4 + .../import-equal-declaration.src.ts.shot | 1 + .../import-equal-type-declaration.src.ts.shot | 262 ++++++++++++++++ ...mport-export-equal-declaration.src.ts.shot | 1 + ...-export-equal-type-declaration.src.ts.shot | 280 ++++++++++++++++++ yarn.lock | 99 +++---- 12 files changed, 593 insertions(+), 62 deletions(-) create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/import-equal-type-declaration.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/import-export-equal-type-declaration.src.ts create mode 100644 packages/typescript-estree/tests/snapshots/typescript/basics/import-equal-type-declaration.src.ts.shot create mode 100644 packages/typescript-estree/tests/snapshots/typescript/basics/import-export-equal-type-declaration.src.ts.shot diff --git a/packages/shared-fixtures/fixtures/typescript/basics/import-equal-type-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/import-equal-type-declaration.src.ts new file mode 100644 index 000000000000..fca40db5fc03 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/import-equal-type-declaration.src.ts @@ -0,0 +1 @@ +import type foo = require('bar'); diff --git a/packages/shared-fixtures/fixtures/typescript/basics/import-export-equal-type-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/import-export-equal-type-declaration.src.ts new file mode 100644 index 000000000000..98798d0c07ae --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/import-export-equal-type-declaration.src.ts @@ -0,0 +1 @@ +export import type foo = require('bar'); diff --git a/packages/types/src/ts-estree.ts b/packages/types/src/ts-estree.ts index 9fee42b8ff9b..e296b5668ae0 100644 --- a/packages/types/src/ts-estree.ts +++ b/packages/types/src/ts-estree.ts @@ -1423,6 +1423,7 @@ export interface TSImportEqualsDeclaration extends BaseNode { type: AST_NODE_TYPES.TSImportEqualsDeclaration; id: Identifier; moduleReference: EntityName | TSExternalModuleReference; + importKind: 'type' | 'value'; isExport: boolean; } diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index a5b1865c01c8..009bd688fa25 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -51,7 +51,7 @@ }, "devDependencies": { "@babel/code-frame": "^7.12.13", - "@babel/parser": "^7.13.4", + "@babel/parser": "^7.13.11", "@babel/types": "^7.13.0", "@types/babel__code-frame": "*", "@types/debug": "*", diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 28442094c2cd..0c0b552e2d59 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -2690,6 +2690,7 @@ export class Converter { type: AST_NODE_TYPES.TSImportEqualsDeclaration, id: this.convertChild(node.name), moduleReference: this.convertChild(node.moduleReference), + importKind: node.isTypeOnly ? 'type' : 'value', isExport: hasModifier(SyntaxKind.ExportKeyword, node), }); } 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 4acae2c6a5bd..cab81a426fe1 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -395,6 +395,8 @@ tester.addFixturePatternConfig('typescript/basics', { 'export-assignment', 'import-equal-declaration', 'import-export-equal-declaration', + 'import-equal-type-declaration', + 'import-export-equal-type-declaration', // babel treats declare and types as not a module 'export-declare-const-named-enum', 'export-declare-named-enum', diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap index eb7e5c687e68..7094769a4ad6 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap @@ -1929,8 +1929,12 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-equal-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-equal-type-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-export-equal-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-export-equal-type-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-type-default.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-type-empty.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/import-equal-declaration.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/import-equal-declaration.src.ts.shot index 9dd23441d108..99c14c70ea9b 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/import-equal-declaration.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/import-equal-declaration.src.ts.shot @@ -22,6 +22,7 @@ Object { ], "type": "Identifier", }, + "importKind": "value", "isExport": false, "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/import-equal-type-declaration.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/import-equal-type-declaration.src.ts.shot new file mode 100644 index 000000000000..1e5a56be081c --- /dev/null +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/import-equal-type-declaration.src.ts.shot @@ -0,0 +1,262 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`typescript basics import-equal-type-declaration.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + "importKind": "type", + "isExport": false, + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "moduleReference": Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 31, + ], + "raw": "'bar'", + "type": "Literal", + "value": "bar", + }, + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 32, + ], + "type": "TSExternalModuleReference", + }, + "range": Array [ + 0, + 33, + ], + "type": "TSImportEqualsDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 34, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "import", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 11, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 25, + ], + "type": "Identifier", + "value": "require", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 31, + ], + "type": "String", + "value": "'bar'", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 32, + "line": 1, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/import-export-equal-declaration.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/import-export-equal-declaration.src.ts.shot index 7c39128056b5..ac4b760010d0 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/import-export-equal-declaration.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/import-export-equal-declaration.src.ts.shot @@ -22,6 +22,7 @@ Object { ], "type": "Identifier", }, + "importKind": "value", "isExport": true, "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/import-export-equal-type-declaration.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/import-export-equal-type-declaration.src.ts.shot new file mode 100644 index 000000000000..f5763d6fe01c --- /dev/null +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/import-export-equal-type-declaration.src.ts.shot @@ -0,0 +1,280 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`typescript basics import-export-equal-type-declaration.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 19, + 22, + ], + "type": "Identifier", + }, + "importKind": "type", + "isExport": true, + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "moduleReference": Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 38, + ], + "raw": "'bar'", + "type": "Literal", + "value": "bar", + }, + "loc": Object { + "end": Object { + "column": 39, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 39, + ], + "type": "TSExternalModuleReference", + }, + "range": Array [ + 0, + 40, + ], + "type": "TSImportEqualsDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 41, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 13, + ], + "type": "Keyword", + "value": "import", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 18, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 22, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 32, + ], + "type": "Identifier", + "value": "require", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 32, + "line": 1, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 38, + ], + "type": "String", + "value": "'bar'", + }, + Object { + "loc": Object { + "end": Object { + "column": 39, + "line": 1, + }, + "start": Object { + "column": 38, + "line": 1, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; diff --git a/yarn.lock b/yarn.lock index 84441403778d..47f77143dcf6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16,22 +16,22 @@ dependencies: "@babel/highlight" "^7.12.13" -"@babel/compat-data@^7.13.0": - version "7.13.6" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.13.6.tgz#11972d07db4c2317afdbf41d6feb3a730301ef4e" - integrity sha512-VhgqKOWYVm7lQXlvbJnWOzwfAQATd2nV52koT0HZ/LdDH0m4DUDwkKYsH+IwpXb+bKPyBJzawA4I6nBKqZcpQw== +"@babel/compat-data@^7.13.8": + version "7.13.11" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.13.11.tgz#9c8fe523c206979c9a81b1e12fe50c1254f1aa35" + integrity sha512-BwKEkO+2a67DcFeS3RLl0Z3Gs2OvdXewuWjc1Hfokhb5eQWP9YRYH1/+VrVZvql2CfjOiNGqSAFOYt4lsqTHzg== "@babel/core@^7.1.0", "@babel/core@^7.7.5": - version "7.13.1" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.13.1.tgz#7ddd027176debe40f13bb88bac0c21218c5b1ecf" - integrity sha512-FzeKfFBG2rmFtGiiMdXZPFt/5R5DXubVi82uYhjGX4Msf+pgYQMCFIqFXZWs5vbIYbf14VeBIgdGI03CDOOM1w== + version "7.13.10" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.13.10.tgz#07de050bbd8193fcd8a3c27918c0890613a94559" + integrity sha512-bfIYcT0BdKeAZrovpMqX2Mx5NrgAckGbwT982AkdS5GNfn3KMGiprlBAtmBcFZRUmpaufS6WZFP8trvx8ptFDw== dependencies: "@babel/code-frame" "^7.12.13" - "@babel/generator" "^7.13.0" - "@babel/helper-compilation-targets" "^7.13.0" + "@babel/generator" "^7.13.9" + "@babel/helper-compilation-targets" "^7.13.10" "@babel/helper-module-transforms" "^7.13.0" - "@babel/helpers" "^7.13.0" - "@babel/parser" "^7.13.0" + "@babel/helpers" "^7.13.10" + "@babel/parser" "^7.13.10" "@babel/template" "^7.12.13" "@babel/traverse" "^7.13.0" "@babel/types" "^7.13.0" @@ -40,27 +40,27 @@ gensync "^1.0.0-beta.2" json5 "^2.1.2" lodash "^4.17.19" - semver "7.0.0" + semver "^6.3.0" source-map "^0.5.0" -"@babel/generator@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.13.0.tgz#bd00d4394ca22f220390c56a0b5b85568ec1ec0c" - integrity sha512-zBZfgvBB/ywjx0Rgc2+BwoH/3H+lDtlgD4hBOpEv5LxRnYsm/753iRuLepqnYlynpjC3AdQxtxsoeHJoEEwOAw== +"@babel/generator@^7.13.0", "@babel/generator@^7.13.9": + version "7.13.9" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.13.9.tgz#3a7aa96f9efb8e2be42d38d80e2ceb4c64d8de39" + integrity sha512-mHOOmY0Axl/JCTkxTU6Lf5sWOg/v8nUa+Xkt4zMTftX0wqmb6Sh7J8gvcehBw7q0AhrhAR+FDacKjCZ2X8K+Sw== dependencies: "@babel/types" "^7.13.0" jsesc "^2.5.1" source-map "^0.5.0" -"@babel/helper-compilation-targets@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.13.0.tgz#c9cf29b82a76fd637f0faa35544c4ace60a155a1" - integrity sha512-SOWD0JK9+MMIhTQiUVd4ng8f3NXhPVQvTv7D3UN4wbp/6cAHnB2EmMaU1zZA2Hh1gwme+THBrVSqTFxHczTh0Q== +"@babel/helper-compilation-targets@^7.13.10": + version "7.13.10" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.13.10.tgz#1310a1678cb8427c07a753750da4f8ce442bdd0c" + integrity sha512-/Xju7Qg1GQO4mHZ/Kcs6Au7gfafgZnwm+a7sy/ow/tV1sHeraRUHbjdat8/UvDor4Tez+siGKDk6zIKtCPKVJA== dependencies: - "@babel/compat-data" "^7.13.0" + "@babel/compat-data" "^7.13.8" "@babel/helper-validator-option" "^7.12.17" browserslist "^4.14.5" - semver "7.0.0" + semver "^6.3.0" "@babel/helper-function-name@^7.12.13": version "7.12.13" @@ -153,28 +153,28 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.12.17.tgz#d1fbf012e1a79b7eebbfdc6d270baaf8d9eb9831" integrity sha512-TopkMDmLzq8ngChwRlyjR6raKD6gMSae4JdYDB8bByKreQgG0RBTuKe9LRxW3wFtUnjxOPRKBDwEH6Mg5KeDfw== -"@babel/helpers@^7.13.0": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.13.0.tgz#7647ae57377b4f0408bf4f8a7af01c42e41badc0" - integrity sha512-aan1MeFPxFacZeSz6Ld7YZo5aPuqnKlD7+HZY75xQsueczFccP9A7V05+oe0XpLwHK3oLorPe9eaAUljL7WEaQ== +"@babel/helpers@^7.13.10": + version "7.13.10" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.13.10.tgz#fd8e2ba7488533cdeac45cc158e9ebca5e3c7df8" + integrity sha512-4VO883+MWPDUVRF3PhiLBUFHoX/bsLTGFpFK/HqvvfBZz2D57u9XzPVNFVBTc0PW/CWR9BXTOKt8NF4DInUHcQ== dependencies: "@babel/template" "^7.12.13" "@babel/traverse" "^7.13.0" "@babel/types" "^7.13.0" "@babel/highlight@^7.10.4", "@babel/highlight@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.12.13.tgz#8ab538393e00370b26271b01fa08f7f27f2e795c" - integrity sha512-kocDQvIbgMKlWxXe9fof3TQ+gkIPOUSEYhJjqUjvKMez3krV7vbzYCDq39Oj11UAVK7JqPVGQPlgE85dPNlQww== + version "7.13.10" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.13.10.tgz#a8b2a66148f5b27d666b15d81774347a731d52d1" + integrity sha512-5aPpe5XQPzflQrFwL1/QoeHkP2MsA4JCntcXHRhEsdsfPVkvPi2w7Qix4iV7t5S/oC9OodGrggd8aco1g3SZFg== dependencies: "@babel/helper-validator-identifier" "^7.12.11" chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.13.0", "@babel/parser@^7.13.4": - version "7.13.10" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.10.tgz#8f8f9bf7b3afa3eabd061f7a5bcdf4fec3c48409" - integrity sha512-0s7Mlrw9uTWkYua7xWr99Wpk2bnGa0ANleKfksYAES8LpWH4gW1OUr42vqKNf0us5UQNfru2wPqMqRITzq/SIQ== +"@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.13.0", "@babel/parser@^7.13.10", "@babel/parser@^7.13.11": + version "7.13.11" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.11.tgz#f93ebfc99d21c1772afbbaa153f47e7ce2f50b88" + integrity sha512-PhuoqeHoO9fc4ffMEVk4qb/w/s2iOSWohvbHxLtxui0eBg3Lg5gN1U8wp1V1u61hOWkPQJJyJzGH6Y+grwkq8Q== "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -261,9 +261,9 @@ "@babel/helper-plugin-utils" "^7.12.13" "@babel/runtime@^7.11.0", "@babel/runtime@^7.7.6": - version "7.13.6" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.6.tgz#86e0fad6cbb46a680e21c1aa4748717a058d345a" - integrity sha512-Y/DEVhSQ91u27rxq7D0EH/sewS6+x06p/MgO1VppbDHMzYXLZrAR5cFjCom78e9RUw1BQAq6qJg6fXc/ep7glA== + version "7.13.10" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.10.tgz#47d42a57b6095f4468da440388fdbad8bebf0d7d" + integrity sha512-4QPkjJq6Ns3V/RgpEahRk+AGfL0eO6RHHtTWoNNr5mO49G6B5+X6d6THgWEAvTrznU5xYpbAlVKRYcsCgh/Akw== dependencies: regenerator-runtime "^0.13.4" @@ -2066,17 +2066,7 @@ aggregate-error@^3.0.0: clean-stack "^2.0.0" indent-string "^4.0.0" -ajv@^6.10.0, ajv@^6.12.3: - version "6.12.4" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.4.tgz#0614facc4522127fa713445c6bfd3ebd376e2234" - integrity sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ajv@^6.12.4: +ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -2992,7 +2982,7 @@ contains-path@^0.1.0: resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a" integrity sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo= -conventional-changelog-angular@^5.0.11: +conventional-changelog-angular@^5.0.11, conventional-changelog-angular@^5.0.3: version "5.0.12" resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-5.0.12.tgz#c979b8b921cbfe26402eb3da5bbfda02d865a2b9" integrity sha512-5GLsbnkR/7A89RyHLvvoExbiGbd9xKdKqDTrArnPbOqBqG/2wIosu0fHwpeIRI8Tl94MhVNBXcLJZl92ZQ5USw== @@ -3000,14 +2990,6 @@ conventional-changelog-angular@^5.0.11: compare-func "^2.0.0" q "^1.5.1" -conventional-changelog-angular@^5.0.3: - version "5.0.11" - resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-5.0.11.tgz#99a3ca16e4a5305e0c2c2fae3ef74fd7631fc3fb" - integrity sha512-nSLypht/1yEflhuTogC03i7DX7sOrXGsRn14g131Potqi6cbGbGEE9PSDEHKldabB6N76HiSyw9Ph+kLmC04Qw== - dependencies: - compare-func "^2.0.0" - q "^1.5.1" - conventional-changelog-conventionalcommits@^4.3.1: version "4.5.0" resolved "https://registry.yarnpkg.com/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.5.0.tgz#a02e0b06d11d342fdc0f00c91d78265ed0bc0a62" @@ -7794,11 +7776,6 @@ semver-compare@^1.0.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" - integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== - semver@7.3.4, semver@7.x, semver@^7.2.1, semver@^7.3.2: version "7.3.4" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97" From e3a3ea04757464aa2dded1ef46af8ad4e05246f2 Mon Sep 17 00:00:00 2001 From: Nikita Stefaniak Date: Thu, 18 Mar 2021 20:56:00 +0100 Subject: [PATCH 07/11] fix(eslint-plugin): [promise-function-async] bad fixer with computed and literal methods (#3163) --- .../src/rules/promise-function-async.ts | 35 +++++++++++++++++- .../rules/promise-function-async.test.ts | 36 +++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/src/rules/promise-function-async.ts b/packages/eslint-plugin/src/rules/promise-function-async.ts index ce624be643c1..68b1d42567c5 100644 --- a/packages/eslint-plugin/src/rules/promise-function-async.ts +++ b/packages/eslint-plugin/src/rules/promise-function-async.ts @@ -1,5 +1,6 @@ import { AST_NODE_TYPES, + AST_TOKEN_TYPES, TSESTree, } from '@typescript-eslint/experimental-utils'; import * as ts from 'typescript'; @@ -156,8 +157,40 @@ export default util.createRule({ (node.parent.type === AST_NODE_TYPES.Property && node.parent.method)) ) { - return fixer.insertTextBefore(node.parent.key, 'async '); + // this function is a class method or object function property shorthand + const method = node.parent; + + // the token to put `async` before + let keyToken = sourceCode.getFirstToken(method)!; + + // if there are decorators then skip past them + if ( + method.type === AST_NODE_TYPES.MethodDefinition && + method.decorators + ) { + const lastDecorator = + method.decorators[method.decorators.length - 1]; + keyToken = sourceCode.getTokenAfter(lastDecorator)!; + } + + // if current token is a keyword like `static` or `public` then skip it + while (keyToken.type === AST_TOKEN_TYPES.Keyword) { + keyToken = sourceCode.getTokenAfter(keyToken)!; + } + + // check if there is a space between key and previous token + const insertSpace = !sourceCode.isSpaceBetween!( + sourceCode.getTokenBefore(keyToken)!, + keyToken, + ); + + let code = 'async '; + if (insertSpace) { + code = ` ${code}`; + } + return fixer.insertTextBefore(keyToken, code); } + return fixer.insertTextBefore(node, 'async '); }, }); diff --git a/packages/eslint-plugin/tests/rules/promise-function-async.test.ts b/packages/eslint-plugin/tests/rules/promise-function-async.test.ts index 961047138c99..6a0451ed8580 100644 --- a/packages/eslint-plugin/tests/rules/promise-function-async.test.ts +++ b/packages/eslint-plugin/tests/rules/promise-function-async.test.ts @@ -1,3 +1,4 @@ +import { noFormat } from '@typescript-eslint/experimental-utils/src/eslint-utils'; import rule from '../../src/rules/promise-function-async'; import { getFixturesRootDir, RuleTester } from '../RuleTester'; @@ -630,6 +631,41 @@ class Test { public async test() { return Promise.resolve(123); } +} + `, + }, + { + code: noFormat` +class Test { + @decorator(async () => {}) + static protected[(1)]() { + return Promise.resolve(1); + } + public'bar'() { + return Promise.resolve(2); + } + private['baz']() { + return Promise.resolve(3); + } +} + `, + errors: [ + { line: 4, column: 3, messageId }, + { line: 7, column: 3, messageId }, + { line: 10, column: 3, messageId }, + ], + output: noFormat` +class Test { + @decorator(async () => {}) + static protected async [(1)]() { + return Promise.resolve(1); + } + public async 'bar'() { + return Promise.resolve(2); + } + private async ['baz']() { + return Promise.resolve(3); + } } `, }, From 0557a439327557f4c0369ae2dddc8282ba45bfe6 Mon Sep 17 00:00:00 2001 From: Matthias Kunnen Date: Sun, 21 Mar 2021 21:39:51 +0100 Subject: [PATCH 08/11] feat(eslint-plugin): [object-curly-spacing] support MappedType (#3176) --- .../src/rules/object-curly-spacing.ts | 39 +++- .../tests/rules/object-curly-spacing.test.ts | 187 +++++++++++++++++- 2 files changed, 214 insertions(+), 12 deletions(-) diff --git a/packages/eslint-plugin/src/rules/object-curly-spacing.ts b/packages/eslint-plugin/src/rules/object-curly-spacing.ts index 581e7ac15557..74161246a31a 100644 --- a/packages/eslint-plugin/src/rules/object-curly-spacing.ts +++ b/packages/eslint-plugin/src/rules/object-curly-spacing.ts @@ -63,7 +63,7 @@ export default createRule({ * @param token The token to use for the report. */ function reportNoBeginningSpace( - node: TSESTree.TSTypeLiteral, + node: TSESTree.TSMappedType | TSESTree.TSTypeLiteral, token: TSESTree.Token, ): void { const nextToken = context @@ -89,7 +89,7 @@ export default createRule({ * @param token The token to use for the report. */ function reportNoEndingSpace( - node: TSESTree.TSTypeLiteral, + node: TSESTree.TSMappedType | TSESTree.TSTypeLiteral, token: TSESTree.Token, ): void { const previousToken = context @@ -115,7 +115,7 @@ export default createRule({ * @param token The token to use for the report. */ function reportRequiredBeginningSpace( - node: TSESTree.TSTypeLiteral, + node: TSESTree.TSMappedType | TSESTree.TSTypeLiteral, token: TSESTree.Token, ): void { context.report({ @@ -137,7 +137,7 @@ export default createRule({ * @param token The token to use for the report. */ function reportRequiredEndingSpace( - node: TSESTree.TSTypeLiteral, + node: TSESTree.TSMappedType | TSESTree.TSTypeLiteral, token: TSESTree.Token, ): void { context.report({ @@ -162,7 +162,7 @@ export default createRule({ * @param last The last token to check (should be closing brace) */ function validateBraceSpacing( - node: TSESTree.TSTypeLiteral, + node: TSESTree.TSMappedType | TSESTree.TSTypeLiteral, first: TSESTree.Token, second: TSESTree.Token | TSESTree.Comment, penultimate: TSESTree.Token | TSESTree.Comment, @@ -175,7 +175,10 @@ export default createRule({ const openingCurlyBraceMustBeSpaced = options.arraysInObjectsException && - secondType === AST_NODE_TYPES.TSIndexSignature + [ + AST_NODE_TYPES.TSMappedType, + AST_NODE_TYPES.TSIndexSignature, + ].includes(secondType) ? !options.spaced : options.spaced; @@ -197,15 +200,19 @@ export default createRule({ isClosingBracketToken(penultimate)) || (options.objectsInObjectsException && isClosingBraceToken(penultimate)); - const penultimateType = - shouldCheckPenultimate && - sourceCode.getNodeByRangeIndex(penultimate.range[0])!.type; + const penultimateType = shouldCheckPenultimate + ? sourceCode.getNodeByRangeIndex(penultimate.range[0])!.type + : undefined; const closingCurlyBraceMustBeSpaced = (options.arraysInObjectsException && penultimateType === AST_NODE_TYPES.TSTupleType) || (options.objectsInObjectsException && - penultimateType === AST_NODE_TYPES.TSTypeLiteral) + penultimateType !== undefined && + [ + AST_NODE_TYPES.TSMappedType, + AST_NODE_TYPES.TSTypeLiteral, + ].includes(penultimateType)) ? !options.spaced : options.spaced; @@ -246,6 +253,18 @@ export default createRule({ const rules = baseRule.create(context); return { ...rules, + TSMappedType(node: TSESTree.TSMappedType): void { + const first = sourceCode.getFirstToken(node)!; + const last = sourceCode.getLastToken(node)!; + const second = sourceCode.getTokenAfter(first, { + includeComments: true, + })!; + const penultimate = sourceCode.getTokenBefore(last, { + includeComments: true, + })!; + + validateBraceSpacing(node, first, second, penultimate, last); + }, TSTypeLiteral(node: TSESTree.TSTypeLiteral): void { if (node.members.length === 0) { return; diff --git a/packages/eslint-plugin/tests/rules/object-curly-spacing.test.ts b/packages/eslint-plugin/tests/rules/object-curly-spacing.test.ts index 5c28cbef7ed7..ecde35b775ff 100644 --- a/packages/eslint-plugin/tests/rules/object-curly-spacing.test.ts +++ b/packages/eslint-plugin/tests/rules/object-curly-spacing.test.ts @@ -570,6 +570,71 @@ ruleTester.run('object-curly-spacing', rule, { code: 'const x:{[key: string]: [number]}', }, + // default - mapped types + { + code: "const x:{[k in 'union']: number}", + }, + { + code: "const x:{ // line-comment\n[k in 'union']: number\n}", + }, + { + code: "const x:{// line-comment\n[k in 'union']: number\n}", + }, + { + code: + "const x:{/* inline-comment */[k in 'union']: number/* inline-comment */}", + }, + { + code: "const x:{\n[k in 'union']: number\n}", + }, + { + code: "const x:{[k in 'union']: {[k in 'union']: number}}", + }, + { + code: "const x:{[k in 'union']: [number]}", + }, + { + code: "const x:{[k in 'union']: value}", + }, + + // never - mapped types + { + code: "const x:{[k in 'union']: {[k in 'union']: number} }", + options: ['never', { objectsInObjects: true }], + }, + { + code: "const x:{[k in 'union']: {[k in 'union']: number}}", + options: ['never', { objectsInObjects: false }], + }, + { + code: "const x:{[k in 'union']: () => {[k in 'union']: number} }", + options: ['never', { objectsInObjects: true }], + }, + { + code: "const x:{[k in 'union']: () => {[k in 'union']: number}}", + options: ['never', { objectsInObjects: false }], + }, + { + code: "const x:{[k in 'union']: [ number ]}", + options: ['never', { arraysInObjects: false }], + }, + { + code: "const x:{ [k in 'union']: value}", + options: ['never', { arraysInObjects: true }], + }, + { + code: "const x:{[k in 'union']: value}", + options: ['never', { arraysInObjects: false }], + }, + { + code: "const x:{ [k in 'union']: [number] }", + options: ['never', { arraysInObjects: true }], + }, + { + code: "const x:{[k in 'union']: [number]}", + options: ['never', { arraysInObjects: false }], + }, + // never - object literal types { code: 'const x:{f: {g: number} }', @@ -612,6 +677,69 @@ ruleTester.run('object-curly-spacing', rule, { options: ['never', { arraysInObjects: false }], }, + // always - mapped types + { + code: "const x:{ [k in 'union']: number }", + options: ['always'], + }, + { + code: "const x:{ // line-comment\n[k in 'union']: number\n}", + options: ['always'], + }, + { + code: + "const x:{ /* inline-comment */ [k in 'union']: number /* inline-comment */ }", + options: ['always'], + }, + { + code: "const x:{\n[k in 'union']: number\n}", + options: ['always'], + }, + { + code: "const x:{ [k in 'union']: [number] }", + options: ['always'], + }, + + // always - mapped types - objectsInObjects + { + code: "const x:{ [k in 'union']: { [k in 'union']: number } }", + options: ['always', { objectsInObjects: true }], + }, + { + code: "const x:{ [k in 'union']: { [k in 'union']: number }}", + options: ['always', { objectsInObjects: false }], + }, + { + code: "const x:{ [k in 'union']: () => { [k in 'union']: number } }", + options: ['always', { objectsInObjects: true }], + }, + { + code: "const x:{ [k in 'union']: () => { [k in 'union']: number }}", + options: ['always', { objectsInObjects: false }], + }, + + // always - mapped types - arraysInObjects + { + code: "type x = { [k in 'union']: number }", + options: ['always'], + }, + { + code: "const x:{ [k in 'union']: [number] }", + options: ['always', { arraysInObjects: true }], + }, + { + code: "const x:{ [k in 'union']: value }", + options: ['always', { arraysInObjects: true }], + }, + { + code: "const x:{[k in 'union']: value }", + options: ['always', { arraysInObjects: false }], + }, + { + code: "const x:{[k in 'union']: [number]}", + options: ['always', { arraysInObjects: false }], + }, + // always - object literal types { code: 'const x:{}', @@ -642,7 +770,7 @@ ruleTester.run('object-curly-spacing', rule, { options: ['always'], }, - // always - objectsInObjects + // always - literal types - objectsInObjects { code: 'const x:{ f: { g: number } }', options: ['always', { objectsInObjects: true }], @@ -660,7 +788,7 @@ ruleTester.run('object-curly-spacing', rule, { options: ['always', { objectsInObjects: false }], }, - // always - arraysInObjects + // always - literal types - arraysInObjects { code: 'const x:{ f: [number] }', options: ['always', { arraysInObjects: true }], @@ -1912,6 +2040,7 @@ ruleTester.run('object-curly-spacing', rule, { }, // object literal types + // never - literal types { code: 'type x = { f: number }', output: 'type x = {f: number}', @@ -1930,6 +2059,7 @@ ruleTester.run('object-curly-spacing', rule, { output: 'type x = {f: number}', errors: [{ messageId: 'unexpectedSpaceBefore' }], }, + // always - literal types { code: 'type x = {f: number}', output: 'type x = { f: number }', @@ -1951,5 +2081,58 @@ ruleTester.run('object-curly-spacing', rule, { options: ['always'], errors: [{ messageId: 'requireSpaceBefore' }], }, + + // never - mapped types + { + code: "type x = { [k in 'union']: number }", + output: "type x = {[k in 'union']: number}", + errors: [ + { messageId: 'unexpectedSpaceAfter' }, + { messageId: 'unexpectedSpaceBefore' }, + ], + }, + { + code: "type x = { [k in 'union']: number}", + output: "type x = {[k in 'union']: number}", + errors: [{ messageId: 'unexpectedSpaceAfter' }], + }, + { + code: "type x = {[k in 'union']: number }", + output: "type x = {[k in 'union']: number}", + errors: [{ messageId: 'unexpectedSpaceBefore' }], + }, + // always - mapped types + { + code: "type x = {[k in 'union']: number}", + output: "type x = { [k in 'union']: number }", + options: ['always'], + errors: [ + { messageId: 'requireSpaceAfter' }, + { messageId: 'requireSpaceBefore' }, + ], + }, + { + code: "type x = {[k in 'union']: number }", + output: "type x = { [k in 'union']: number }", + options: ['always'], + errors: [{ messageId: 'requireSpaceAfter' }], + }, + { + code: "type x = { [k in 'union']: number}", + output: "type x = { [k in 'union']: number }", + options: ['always'], + errors: [{ messageId: 'requireSpaceBefore' }], + }, + // Mapped and literal types mix + { + code: "type x = { [k in 'union']: { [k: string]: number } }", + output: "type x = {[k in 'union']: {[k: string]: number}}", + errors: [ + { messageId: 'unexpectedSpaceAfter' }, + { messageId: 'unexpectedSpaceAfter' }, + { messageId: 'unexpectedSpaceBefore' }, + { messageId: 'unexpectedSpaceBefore' }, + ], + }, ], }); From 5cc5d2ef6d924d301e87f7bcf599352310e74b2c Mon Sep 17 00:00:00 2001 From: JounQin Date: Mon, 22 Mar 2021 04:49:00 +0800 Subject: [PATCH 09/11] feat(eslint-plugin): [unbound-method] improve error message (#3203) * docs: highlight `this: void` and arrow function for unbound-method close #3201 * Update packages/eslint-plugin/docs/rules/unbound-method.md Co-authored-by: Brad Zacher * feat: check if the first param is `this` add new message `unboundWithoutThisAnnotation` Co-authored-by: Brad Zacher --- .../docs/rules/unbound-method.md | 2 + .../eslint-plugin/src/rules/unbound-method.ts | 97 ++++++++++++------- .../tests/rules/unbound-method.test.ts | 36 +++---- 3 files changed, 81 insertions(+), 54 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/unbound-method.md b/packages/eslint-plugin/docs/rules/unbound-method.md index a9a4fe396a24..15063dbb4f3b 100644 --- a/packages/eslint-plugin/docs/rules/unbound-method.md +++ b/packages/eslint-plugin/docs/rules/unbound-method.md @@ -4,6 +4,8 @@ Warns when a method is used outside of a method call. Class functions don't preserve the class scope when passed as standalone variables. +If your function does not access `this`, [you can annotate it with `this: void`](https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function), or consider using an arrow function instead. + ## Rule Details Examples of **incorrect** code for this rule diff --git a/packages/eslint-plugin/src/rules/unbound-method.ts b/packages/eslint-plugin/src/rules/unbound-method.ts index 2ec66bc2aa33..ecf9e6528190 100644 --- a/packages/eslint-plugin/src/rules/unbound-method.ts +++ b/packages/eslint-plugin/src/rules/unbound-method.ts @@ -16,7 +16,7 @@ interface Config { export type Options = [Config]; -export type MessageIds = 'unbound'; +export type MessageIds = 'unbound' | 'unboundWithoutThisAnnotation'; /** * The following is a list of exceptions to the rule @@ -121,6 +121,9 @@ const getNodeName = (node: TSESTree.Node): string | null => const getMemberFullName = (node: TSESTree.MemberExpression): string => `${getNodeName(node.object)}.${getNodeName(node.property)}`; +const BASE_MESSAGE = + 'Avoid referencing unbound methods which may cause unintentional scoping of `this`.'; + export default util.createRule({ name: 'unbound-method', meta: { @@ -132,8 +135,11 @@ export default util.createRule({ requiresTypeChecking: true, }, messages: { - unbound: - 'Avoid referencing unbound methods which may cause unintentional scoping of `this`.', + unbound: BASE_MESSAGE, + unboundWithoutThisAnnotation: + BASE_MESSAGE + + '\n' + + 'If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead.', }, schema: [ { @@ -160,6 +166,26 @@ export default util.createRule({ context.getFilename(), ); + function checkMethodAndReport( + node: TSESTree.Node, + symbol: ts.Symbol | undefined, + ): void { + if (!symbol) { + return; + } + + const { dangerous, firstParamIsThis } = checkMethod(symbol, ignoreStatic); + if (dangerous) { + context.report({ + messageId: + firstParamIsThis === false + ? 'unboundWithoutThisAnnotation' + : 'unbound', + node, + }); + } + } + return { MemberExpression(node: TSESTree.MemberExpression): void { if (isSafeUse(node)) { @@ -179,14 +205,8 @@ export default util.createRule({ } const originalNode = parserServices.esTreeNodeToTSNodeMap.get(node); - const symbol = checker.getSymbolAtLocation(originalNode); - if (symbol && isDangerousMethod(symbol, ignoreStatic)) { - context.report({ - messageId: 'unbound', - node, - }); - } + checkMethodAndReport(node, checker.getSymbolAtLocation(originalNode)); }, 'VariableDeclarator, AssignmentExpression'( node: TSESTree.VariableDeclarator | TSESTree.AssignmentExpression, @@ -219,13 +239,10 @@ export default util.createRule({ return; } - const symbol = initTypes.getProperty(property.key.name); - if (symbol && isDangerousMethod(symbol, ignoreStatic)) { - context.report({ - messageId: 'unbound', - node, - }); - } + checkMethodAndReport( + node, + initTypes.getProperty(property.key.name), + ); } }); } @@ -234,44 +251,52 @@ export default util.createRule({ }, }); -function isDangerousMethod(symbol: ts.Symbol, ignoreStatic: boolean): boolean { +function checkMethod( + symbol: ts.Symbol, + ignoreStatic: boolean, +): { dangerous: boolean; firstParamIsThis?: boolean } { const { valueDeclaration } = symbol; if (!valueDeclaration) { // working around https://github.com/microsoft/TypeScript/issues/31294 - return false; + return { dangerous: false }; } switch (valueDeclaration.kind) { case ts.SyntaxKind.PropertyDeclaration: - return ( - (valueDeclaration as ts.PropertyDeclaration).initializer?.kind === - ts.SyntaxKind.FunctionExpression - ); + return { + dangerous: + (valueDeclaration as ts.PropertyDeclaration).initializer?.kind === + ts.SyntaxKind.FunctionExpression, + }; case ts.SyntaxKind.MethodDeclaration: case ts.SyntaxKind.MethodSignature: { const decl = valueDeclaration as | ts.MethodDeclaration | ts.MethodSignature; const firstParam = decl.parameters[0]; - const thisArgIsVoid = + const firstParamIsThis = firstParam?.name.kind === ts.SyntaxKind.Identifier && - firstParam?.name.escapedText === 'this' && + firstParam?.name.escapedText === 'this'; + const thisArgIsVoid = + firstParamIsThis && firstParam?.type?.kind === ts.SyntaxKind.VoidKeyword; - return ( - !thisArgIsVoid && - !( - ignoreStatic && - tsutils.hasModifier( - valueDeclaration.modifiers, - ts.SyntaxKind.StaticKeyword, - ) - ) - ); + return { + dangerous: + !thisArgIsVoid && + !( + ignoreStatic && + tsutils.hasModifier( + valueDeclaration.modifiers, + ts.SyntaxKind.StaticKeyword, + ) + ), + firstParamIsThis, + }; } } - return false; + return { dangerous: false }; } function isSafeUse(node: TSESTree.Node): boolean { diff --git a/packages/eslint-plugin/tests/rules/unbound-method.test.ts b/packages/eslint-plugin/tests/rules/unbound-method.test.ts index 911206b1f219..3075e93fe67a 100644 --- a/packages/eslint-plugin/tests/rules/unbound-method.test.ts +++ b/packages/eslint-plugin/tests/rules/unbound-method.test.ts @@ -42,7 +42,7 @@ function addContainsMethodsClassInvalid( errors: [ { line: 18, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], })); @@ -298,7 +298,7 @@ Promise.resolve().then(console.log); errors: [ { line: 10, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -310,7 +310,7 @@ const x = console.log; errors: [ { line: 3, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -325,15 +325,15 @@ function foo(arg: ContainsMethods | null) { errors: [ { line: 20, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, { line: 21, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, { line: 22, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -375,7 +375,7 @@ ContainsMethods.unboundStatic; errors: [ { line: 8, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -390,7 +390,7 @@ const x = CommunicationError.prototype.foo; errors: [ { line: 5, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -400,7 +400,7 @@ const x = CommunicationError.prototype.foo; errors: [ { line: 1, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -419,7 +419,7 @@ instance.unbound = x; // THIS SHOULD NOT errors: [ { line: 9, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -447,7 +447,7 @@ const { unbound } = new Foo(); errors: [ { line: 5, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -476,7 +476,7 @@ let unbound; errors: [ { line: 6, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -505,7 +505,7 @@ const { foo } = CommunicationError.prototype; errors: [ { line: 5, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -520,7 +520,7 @@ let foo; errors: [ { line: 6, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -532,7 +532,7 @@ const { log } = console; errors: [ { line: 3, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -541,7 +541,7 @@ const { log } = console; errors: [ { line: 1, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -562,7 +562,7 @@ class OtherClass extends BaseClass { { line: 8, column: 15, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, @@ -584,7 +584,7 @@ class OtherClass extends BaseClass { { line: 9, column: 9, - messageId: 'unbound', + messageId: 'unboundWithoutThisAnnotation', }, ], }, From 7ad343b067040f6ea816b129323d110d4bc2e830 Mon Sep 17 00:00:00 2001 From: Florian Adonis Date: Sun, 21 Mar 2021 23:51:50 +0300 Subject: [PATCH 10/11] fix(eslint-plugin): [member-delimiter-style] correct invalid fix for multiline with params on the same line (#3177) --- .../src/rules/member-delimiter-style.ts | 93 +++++++++++++++---- .../rules/member-delimiter-style.test.ts | 18 ++++ 2 files changed, 93 insertions(+), 18 deletions(-) diff --git a/packages/eslint-plugin/src/rules/member-delimiter-style.ts b/packages/eslint-plugin/src/rules/member-delimiter-style.ts index 64147b37cf2a..de0a60f013cf 100644 --- a/packages/eslint-plugin/src/rules/member-delimiter-style.ts +++ b/packages/eslint-plugin/src/rules/member-delimiter-style.ts @@ -1,4 +1,5 @@ import { + TSESLint, TSESTree, AST_NODE_TYPES, } from '@typescript-eslint/experimental-utils'; @@ -11,6 +12,9 @@ type TypeOptions = { delimiter?: Delimiter; requireLast?: boolean; }; +type TypeOptionsWithType = TypeOptions & { + type: string; +}; // eslint-disable-next-line @typescript-eslint/consistent-type-definitions type BaseOptions = { multiline?: TypeOptions; @@ -29,6 +33,20 @@ type MessageIds = | 'unexpectedSemi' | 'expectedComma' | 'expectedSemi'; +type LastTokenType = TSESTree.Token; + +interface MakeFixFunctionParams { + optsNone: boolean; + optsSemi: boolean; + lastToken: LastTokenType; + missingDelimiter: boolean; + lastTokenLine: string; + isSingleLine: boolean; +} + +type MakeFixFunctionReturnType = + | ((fixer: TSESLint.RuleFixer) => TSESLint.RuleFix) + | null; const definition = { type: 'object', @@ -54,6 +72,47 @@ const definition = { additionalProperties: false, }; +const isLastTokenEndOfLine = (token: string, line: string): boolean => { + const positionInLine = line.indexOf(token); + + return positionInLine === line.length - 1; +}; + +const makeFixFunction = ({ + optsNone, + optsSemi, + lastToken, + missingDelimiter, + lastTokenLine, + isSingleLine, +}: MakeFixFunctionParams): MakeFixFunctionReturnType => { + // if removing is the action but last token is not the end of the line + if ( + optsNone && + !isLastTokenEndOfLine(lastToken.value, lastTokenLine) && + !isSingleLine + ) { + return null; + } + + return (fixer: TSESLint.RuleFixer): TSESLint.RuleFix => { + if (optsNone) { + // remove the unneeded token + return fixer.remove(lastToken); + } + + const token = optsSemi ? ';' : ','; + + if (missingDelimiter) { + // add the missing delimiter + return fixer.insertTextAfter(lastToken, token); + } + + // correct the current delimiter + return fixer.replaceText(lastToken, token); + }; +}; + export default util.createRule({ name: 'member-delimiter-style', meta: { @@ -127,7 +186,7 @@ export default util.createRule({ */ function checkLastToken( member: TSESTree.TypeElement, - opts: TypeOptions, + opts: TypeOptionsWithType, isLast: boolean, ): void { /** @@ -147,10 +206,14 @@ export default util.createRule({ const lastToken = sourceCode.getLastToken(member, { includeComments: false, }); + if (!lastToken) { return; } + const sourceCodeLines = sourceCode.getLines(); + const lastTokenLine = sourceCodeLines[lastToken?.loc.start.line - 1]; + const optsSemi = getOption('semi'); const optsComma = getOption('comma'); const optsNone = getOption('none'); @@ -193,22 +256,14 @@ export default util.createRule({ }, }, messageId, - fix(fixer) { - if (optsNone) { - // remove the unneeded token - return fixer.remove(lastToken); - } - - const token = optsSemi ? ';' : ','; - - if (missingDelimiter) { - // add the missing delimiter - return fixer.insertTextAfter(lastToken, token); - } - - // correct the current delimiter - return fixer.replaceText(lastToken, token); - }, + fix: makeFixFunction({ + optsNone, + optsSemi, + lastToken, + missingDelimiter, + lastTokenLine, + isSingleLine: opts.type === 'single-line', + }), }); } } @@ -239,7 +294,9 @@ export default util.createRule({ node.type === AST_NODE_TYPES.TSInterfaceBody ? interfaceOptions : typeLiteralOptions; - const opts = isSingleLine ? typeOpts.singleline : typeOpts.multiline; + const opts = isSingleLine + ? { ...typeOpts.singleline, type: 'single-line' } + : { ...typeOpts.multiline, type: 'multi-line' }; members.forEach((member, index) => { checkLastToken(member, opts ?? {}, index === members.length - 1); diff --git a/packages/eslint-plugin/tests/rules/member-delimiter-style.test.ts b/packages/eslint-plugin/tests/rules/member-delimiter-style.test.ts index c69e54e2af00..fa75383df8e3 100644 --- a/packages/eslint-plugin/tests/rules/member-delimiter-style.test.ts +++ b/packages/eslint-plugin/tests/rules/member-delimiter-style.test.ts @@ -851,6 +851,24 @@ interface Foo { }, { code: ` +type Test = { + a: { + one: 1 + }; b: 2 +}; + `, + output: null, + options: [{ multiline: { delimiter: 'none' } }], + errors: [ + { + messageId: 'unexpectedSemi', + line: 5, + column: 5, + }, + ], + }, + { + code: ` interface Foo { name: string age: number From e8239191590c62cdfd449054c845bd1e516ae370 Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 22 Mar 2021 17:02:44 +0000 Subject: [PATCH 11/11] chore: publish v4.19.0 --- CHANGELOG.md | 19 +++++++++++++++++++ lerna.json | 2 +- packages/eslint-plugin-internal/CHANGELOG.md | 8 ++++++++ packages/eslint-plugin-internal/package.json | 4 ++-- packages/eslint-plugin-tslint/CHANGELOG.md | 8 ++++++++ packages/eslint-plugin-tslint/package.json | 6 +++--- packages/eslint-plugin/CHANGELOG.md | 18 ++++++++++++++++++ packages/eslint-plugin/package.json | 6 +++--- packages/experimental-utils/CHANGELOG.md | 8 ++++++++ packages/experimental-utils/package.json | 8 ++++---- packages/parser/CHANGELOG.md | 8 ++++++++ packages/parser/package.json | 10 +++++----- packages/scope-manager/CHANGELOG.md | 8 ++++++++ packages/scope-manager/package.json | 8 ++++---- packages/shared-fixtures/CHANGELOG.md | 11 +++++++++++ packages/shared-fixtures/package.json | 2 +- packages/types/CHANGELOG.md | 11 +++++++++++ packages/types/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 11 +++++++++++ packages/typescript-estree/package.json | 8 ++++---- packages/visitor-keys/CHANGELOG.md | 8 ++++++++ packages/visitor-keys/package.json | 4 ++-- 22 files changed, 148 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f45f0792dacc..0de3cfd54a34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.19.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.18.0...v4.19.0) (2021-03-22) + + +### Bug Fixes + +* **eslint-plugin:** [member-delimiter-style] correct invalid fix for multiline with params on the same line ([#3177](https://github.com/typescript-eslint/typescript-eslint/issues/3177)) ([7ad343b](https://github.com/typescript-eslint/typescript-eslint/commit/7ad343b067040f6ea816b129323d110d4bc2e830)) +* **eslint-plugin:** [promise-function-async] bad fixer with computed and literal methods ([#3163](https://github.com/typescript-eslint/typescript-eslint/issues/3163)) ([e3a3ea0](https://github.com/typescript-eslint/typescript-eslint/commit/e3a3ea04757464aa2dded1ef46af8ad4e05246f2)) +* **typescript-estree:** [ts 4.2] add support for import type equal declaration ([#3189](https://github.com/typescript-eslint/typescript-eslint/issues/3189)) ([6a25faf](https://github.com/typescript-eslint/typescript-eslint/commit/6a25faf5cfa4d21a7546d9866819f4e017308fb2)) + + +### Features + +* **eslint-plugin:** [object-curly-spacing] support MappedType ([#3176](https://github.com/typescript-eslint/typescript-eslint/issues/3176)) ([0557a43](https://github.com/typescript-eslint/typescript-eslint/commit/0557a439327557f4c0369ae2dddc8282ba45bfe6)) +* **eslint-plugin:** [unbound-method] improve error message ([#3203](https://github.com/typescript-eslint/typescript-eslint/issues/3203)) ([5cc5d2e](https://github.com/typescript-eslint/typescript-eslint/commit/5cc5d2ef6d924d301e87f7bcf599352310e74b2c)), closes [#3201](https://github.com/typescript-eslint/typescript-eslint/issues/3201) + + + + + # [4.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.17.0...v4.18.0) (2021-03-15) diff --git a/lerna.json b/lerna.json index fc89ed9ca0ea..c7fb57b16818 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "4.18.0", + "version": "4.19.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md index 15f4b61168fc..7861946d900b 100644 --- a/packages/eslint-plugin-internal/CHANGELOG.md +++ b/packages/eslint-plugin-internal/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.19.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.18.0...v4.19.0) (2021-03-22) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal + + + + + # [4.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.17.0...v4.18.0) (2021-03-15) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index 1734089a88b9..f229f2dcac3d 100644 --- a/packages/eslint-plugin-internal/package.json +++ b/packages/eslint-plugin-internal/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-internal", - "version": "4.18.0", + "version": "4.19.0", "private": true, "main": "dist/index.js", "scripts": { @@ -14,7 +14,7 @@ }, "dependencies": { "@types/prettier": "*", - "@typescript-eslint/experimental-utils": "4.18.0", + "@typescript-eslint/experimental-utils": "4.19.0", "prettier": "*" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index d44f760fa34e..cd88303c8f7d 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.19.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.18.0...v4.19.0) (2021-03-22) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + + + + + # [4.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.17.0...v4.18.0) (2021-03-15) **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 9b3f6addba39..49658a2247d7 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": "4.18.0", + "version": "4.19.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/experimental-utils": "4.18.0", + "@typescript-eslint/experimental-utils": "4.19.0", "lodash": "^4.17.15" }, "peerDependencies": { @@ -48,6 +48,6 @@ }, "devDependencies": { "@types/lodash": "*", - "@typescript-eslint/parser": "4.18.0" + "@typescript-eslint/parser": "4.19.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 1a8c08249cab..b4dd710df609 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.19.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.18.0...v4.19.0) (2021-03-22) + + +### Bug Fixes + +* **eslint-plugin:** [member-delimiter-style] correct invalid fix for multiline with params on the same line ([#3177](https://github.com/typescript-eslint/typescript-eslint/issues/3177)) ([7ad343b](https://github.com/typescript-eslint/typescript-eslint/commit/7ad343b067040f6ea816b129323d110d4bc2e830)) +* **eslint-plugin:** [promise-function-async] bad fixer with computed and literal methods ([#3163](https://github.com/typescript-eslint/typescript-eslint/issues/3163)) ([e3a3ea0](https://github.com/typescript-eslint/typescript-eslint/commit/e3a3ea04757464aa2dded1ef46af8ad4e05246f2)) + + +### Features + +* **eslint-plugin:** [object-curly-spacing] support MappedType ([#3176](https://github.com/typescript-eslint/typescript-eslint/issues/3176)) ([0557a43](https://github.com/typescript-eslint/typescript-eslint/commit/0557a439327557f4c0369ae2dddc8282ba45bfe6)) +* **eslint-plugin:** [unbound-method] improve error message ([#3203](https://github.com/typescript-eslint/typescript-eslint/issues/3203)) ([5cc5d2e](https://github.com/typescript-eslint/typescript-eslint/commit/5cc5d2ef6d924d301e87f7bcf599352310e74b2c)), closes [#3201](https://github.com/typescript-eslint/typescript-eslint/issues/3201) + + + + + # [4.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.17.0...v4.18.0) (2021-03-15) diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index dc4023088e75..7783332ecaaa 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "4.18.0", + "version": "4.19.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -44,8 +44,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/experimental-utils": "4.18.0", - "@typescript-eslint/scope-manager": "4.18.0", + "@typescript-eslint/experimental-utils": "4.19.0", + "@typescript-eslint/scope-manager": "4.19.0", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "lodash": "^4.17.15", diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index 9e5adeddf9c9..8fbedca81985 100644 --- a/packages/experimental-utils/CHANGELOG.md +++ b/packages/experimental-utils/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.19.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.18.0...v4.19.0) (2021-03-22) + +**Note:** Version bump only for package @typescript-eslint/experimental-utils + + + + + # [4.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.17.0...v4.18.0) (2021-03-15) **Note:** Version bump only for package @typescript-eslint/experimental-utils diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index e81bde7eb2a8..033793fe03b1 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "4.18.0", + "version": "4.19.0", "description": "(Experimental) Utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -40,9 +40,9 @@ }, "dependencies": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/scope-manager": "4.18.0", - "@typescript-eslint/types": "4.18.0", - "@typescript-eslint/typescript-estree": "4.18.0", + "@typescript-eslint/scope-manager": "4.19.0", + "@typescript-eslint/types": "4.19.0", + "@typescript-eslint/typescript-estree": "4.19.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" }, diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index 8819d640f26a..f241bd08fbaf 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.19.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.18.0...v4.19.0) (2021-03-22) + +**Note:** Version bump only for package @typescript-eslint/parser + + + + + # [4.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.17.0...v4.18.0) (2021-03-15) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index b92208c48f9f..9cc7802caefa 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "4.18.0", + "version": "4.19.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -44,14 +44,14 @@ "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" }, "dependencies": { - "@typescript-eslint/scope-manager": "4.18.0", - "@typescript-eslint/types": "4.18.0", - "@typescript-eslint/typescript-estree": "4.18.0", + "@typescript-eslint/scope-manager": "4.19.0", + "@typescript-eslint/types": "4.19.0", + "@typescript-eslint/typescript-estree": "4.19.0", "debug": "^4.1.1" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/experimental-utils": "4.18.0", + "@typescript-eslint/experimental-utils": "4.19.0", "glob": "*", "typescript": "*" }, diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md index ca967ed97850..88c0cf7a037b 100644 --- a/packages/scope-manager/CHANGELOG.md +++ b/packages/scope-manager/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.19.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.18.0...v4.19.0) (2021-03-22) + +**Note:** Version bump only for package @typescript-eslint/scope-manager + + + + + # [4.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.17.0...v4.18.0) (2021-03-15) **Note:** Version bump only for package @typescript-eslint/scope-manager diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index d82525e8cf08..dcfa875412e8 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/scope-manager", - "version": "4.18.0", + "version": "4.19.0", "description": "TypeScript scope analyser for ESLint", "keywords": [ "eslint", @@ -39,12 +39,12 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "4.18.0", - "@typescript-eslint/visitor-keys": "4.18.0" + "@typescript-eslint/types": "4.19.0", + "@typescript-eslint/visitor-keys": "4.19.0" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/typescript-estree": "4.18.0", + "@typescript-eslint/typescript-estree": "4.19.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index b771cc0bac00..1eb1200c709e 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. +# [4.19.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.18.0...v4.19.0) (2021-03-22) + + +### Bug Fixes + +* **typescript-estree:** [ts 4.2] add support for import type equal declaration ([#3189](https://github.com/typescript-eslint/typescript-eslint/issues/3189)) ([6a25faf](https://github.com/typescript-eslint/typescript-eslint/commit/6a25faf5cfa4d21a7546d9866819f4e017308fb2)) + + + + + # [4.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.17.0...v4.18.0) (2021-03-15) **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 ee3e1e508233..54046c06a67a 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "4.18.0", + "version": "4.19.0", "private": true } diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index ba20b0a516ad..c647367cf3e0 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/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. +# [4.19.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.18.0...v4.19.0) (2021-03-22) + + +### Bug Fixes + +* **typescript-estree:** [ts 4.2] add support for import type equal declaration ([#3189](https://github.com/typescript-eslint/typescript-eslint/issues/3189)) ([6a25faf](https://github.com/typescript-eslint/typescript-eslint/commit/6a25faf5cfa4d21a7546d9866819f4e017308fb2)) + + + + + # [4.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.17.0...v4.18.0) (2021-03-15) **Note:** Version bump only for package @typescript-eslint/types diff --git a/packages/types/package.json b/packages/types/package.json index 199c898b3842..c24cc541bc59 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/types", - "version": "4.18.0", + "version": "4.19.0", "description": "Types for the TypeScript-ESTree AST spec", "keywords": [ "eslint", diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index 98252b65820e..cabba9f41bfb 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.19.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.18.0...v4.19.0) (2021-03-22) + + +### Bug Fixes + +* **typescript-estree:** [ts 4.2] add support for import type equal declaration ([#3189](https://github.com/typescript-eslint/typescript-eslint/issues/3189)) ([6a25faf](https://github.com/typescript-eslint/typescript-eslint/commit/6a25faf5cfa4d21a7546d9866819f4e017308fb2)) + + + + + # [4.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.17.0...v4.18.0) (2021-03-15) **Note:** Version bump only for package @typescript-eslint/typescript-estree diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 009bd688fa25..a174adf4d8c1 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "4.18.0", + "version": "4.19.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -41,8 +41,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "4.18.0", - "@typescript-eslint/visitor-keys": "4.18.0", + "@typescript-eslint/types": "4.19.0", + "@typescript-eslint/visitor-keys": "4.19.0", "debug": "^4.1.1", "globby": "^11.0.1", "is-glob": "^4.0.1", @@ -59,7 +59,7 @@ "@types/is-glob": "*", "@types/semver": "*", "@types/tmp": "*", - "@typescript-eslint/shared-fixtures": "4.18.0", + "@typescript-eslint/shared-fixtures": "4.19.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md index a3754372477d..5756220219ff 100644 --- a/packages/visitor-keys/CHANGELOG.md +++ b/packages/visitor-keys/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.19.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.18.0...v4.19.0) (2021-03-22) + +**Note:** Version bump only for package @typescript-eslint/visitor-keys + + + + + # [4.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.17.0...v4.18.0) (2021-03-15) **Note:** Version bump only for package @typescript-eslint/visitor-keys diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index fb20068e9f5e..a1dde093e65c 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/visitor-keys", - "version": "4.18.0", + "version": "4.19.0", "description": "Visitor keys used to help traverse the TypeScript-ESTree AST", "keywords": [ "eslint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "4.18.0", + "@typescript-eslint/types": "4.19.0", "eslint-visitor-keys": "^2.0.0" }, "devDependencies": {