|
1 | 1 | use oxc_ast::{ |
2 | 2 | AstKind, |
3 | | - ast::{Argument, Expression}, |
| 3 | + ast::{Argument, CallExpression, Expression}, |
4 | 4 | }; |
5 | 5 | use oxc_diagnostics::OxcDiagnostic; |
6 | 6 | use oxc_macros::declare_oxc_lint; |
@@ -56,14 +56,14 @@ declare_oxc_lint!( |
56 | 56 |
|
57 | 57 | impl Rule for NoArrayMethodThisArgument { |
58 | 58 | fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) { |
59 | | - check_array_prototype_methods(node, ctx); |
60 | | - check_array_from(node, ctx); |
| 59 | + let AstKind::CallExpression(call_expr) = node.kind() else { return }; |
| 60 | + |
| 61 | + check_array_prototype_methods(call_expr, ctx); |
| 62 | + check_array_from(call_expr, ctx); |
61 | 63 | } |
62 | 64 | } |
63 | 65 |
|
64 | | -fn check_array_prototype_methods<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>) { |
65 | | - let AstKind::CallExpression(call_expr) = node.kind() else { return }; |
66 | | - |
| 66 | +fn check_array_prototype_methods(call_expr: &CallExpression, ctx: &LintContext) { |
67 | 67 | if !is_method_call( |
68 | 68 | call_expr, |
69 | 69 | None, |
@@ -96,9 +96,7 @@ fn check_array_prototype_methods<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>) |
96 | 96 | )); |
97 | 97 | } |
98 | 98 |
|
99 | | -fn check_array_from<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>) { |
100 | | - let AstKind::CallExpression(call_expr) = node.kind() else { return }; |
101 | | - |
| 99 | +fn check_array_from(call_expr: &CallExpression, ctx: &LintContext) { |
102 | 100 | if !is_method_call(call_expr, Some(&["Array"]), Some(&["from", "fromAsync"]), Some(3), Some(3)) |
103 | 101 | || call_expr.arguments.first().is_some_and(|arg| matches!(arg, Argument::SpreadElement(_))) |
104 | 102 | || call_expr.arguments.get(2).is_some_and(|arg| matches!(arg, Argument::SpreadElement(_))) |
|
0 commit comments