From 6f1e2266b548a55b2d848f856153cba5f613e8dc Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 16 Mar 2021 22:58:42 +0100 Subject: [PATCH] refactor(eslint-plugin): use direct ts type guards instead of tsutils --- .../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);