-
-
Notifications
You must be signed in to change notification settings - Fork 539
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
feat(linter): eslint/no-useless-call #4393
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
/// | ||
/// ### Why is this bad? | ||
/// | ||
/// This rule is aimed to flag usage of Function.prototype.call() and Function.prototype.apply() that can be replaced with the normal function invocation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate more here? Maybe take the explanation from ESLint's website?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is from eslint website.
I think it will do more think than normal function.
} | ||
|
||
fn is_apply_member(call_expr: &CallExpression, member_expr: &StaticMemberExpression) -> bool { | ||
(member_expr.property.name == "call" && call_expr.arguments.len() >= 1) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use is_method_call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review, it has greatly benefited me. But it seem not. The call_expr.callee
should skip the chain expression
}; | ||
|
||
if is_validate_this_arg(ctx, expected_this, this_expr) { | ||
ctx.diagnostic(no_useless_call_diagnostic(call_expr.callee.span())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a fixer for this rule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to we can't fix the expression what had the chain expression.
And the fix way is from foo.call(undefined, 1, 2);
-> foo(1, 2);
?
CodSpeed Performance ReportMerging #4393 will degrade performances by 4.89%Comparing Summary
Benchmarks breakdown
|
Hi @poyoho 👋 any updates on this PR? |
I will keep following up slowly. 😁 |
Close as stale. Feel free to come back and finish this. |
No description provided.