perf(linter): swap the order of checks for no_caller (#844)

This commit is contained in:
Boshen 2023-09-03 10:19:27 +08:00 committed by GitHub
parent 815db57a25
commit 6f270f1198
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -51,14 +51,14 @@ declare_oxc_lint!(
impl Rule for NoCaller {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
let AstKind::MemberExpression(MemberExpression::StaticMemberExpression(expr)) = node.kind()
else {
return;
};
if expr.object.is_specific_id("arguments")
&& (expr.property.name == "callee" || expr.property.name == "caller")
if let AstKind::MemberExpression(MemberExpression::StaticMemberExpression(expr)) =
node.kind()
{
ctx.diagnostic(NoCallerDiagnostic(expr.property.span));
if (expr.property.name == "callee" || expr.property.name == "caller")
&& expr.object.is_specific_id("arguments")
{
ctx.diagnostic(NoCallerDiagnostic(expr.property.span));
}
}
}
}