Skip to content

Commit

Permalink
perf(useArrowFunction): avoid useless checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos committed Nov 4, 2024
1 parent 058ff16 commit ef61354
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl Rule for UseArrowFunction {
}
}

/// Returns `true` if `function_expr` needs parenthesis when turned into an arrow function.
/// Returns `true` if `function_expression` needs parenthesis when turned into an arrow function.
fn needs_parentheses(function_expression: &JsFunctionExpression) -> bool {
function_expression.syntax().parent().is_some_and(|parent| {
// Copied from the implementation of `NeedsParentheses` for `JsArrowFunctionExpression`
Expand Down Expand Up @@ -308,8 +308,7 @@ impl Visitor for AnyThisScopeVisitor {
scope,
has_this: false,
});
}
if matches!(
} else if matches!(
node.kind(),
JsSyntaxKind::JS_THIS_EXPRESSION | JsSyntaxKind::JS_NEW_TARGET_EXPRESSION
) {
Expand All @@ -321,11 +320,9 @@ impl Visitor for AnyThisScopeVisitor {
}
}
WalkEvent::Leave(node) => {
if let Some(exit_scope) = AnyThisScope::cast_ref(node) {
if AnyThisScope::can_cast(node.kind()) {
if let Some(scope_metadata) = self.stack.pop() {
if scope_metadata.scope == exit_scope {
ctx.match_query(ActualThisScope(scope_metadata));
}
ctx.match_query(ActualThisScope(scope_metadata));
}
}
}
Expand Down

0 comments on commit ef61354

Please sign in to comment.