Skip to content
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

perf(useArrowFunction): avoid useless checks #4465

Merged
merged 1 commit into from
Nov 4, 2024
Merged
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
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