Skip to content

refactor(eslint-plugin): use direct ts type guards instead of tsutils #3193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/eslint-plugin/src/rules/no-floating-promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand All @@ -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
);
Expand All @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function getTypeParametersFromType(
}

return findFirstResult(declarations, decl =>
tsutils.isClassLikeDeclaration(decl) ||
ts.isClassLike(decl) ||
ts.isTypeAliasDeclaration(decl) ||
ts.isInterfaceDeclaration(decl)
? decl.typeParameters
Expand Down
12 changes: 6 additions & 6 deletions packages/eslint-plugin/src/rules/return-await.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down