Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion crates/oxc_linter/src/generated/rule_runner_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2984,7 +2984,8 @@ impl RuleRunner for crate::rules::unicorn::no_array_for_each::NoArrayForEach {
impl RuleRunner
for crate::rules::unicorn::no_array_method_this_argument::NoArrayMethodThisArgument
{
const NODE_TYPES: Option<&AstTypesBitset> = None;
const NODE_TYPES: Option<&AstTypesBitset> =
Some(&AstTypesBitset::from_types(&[AstType::CallExpression]));
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use oxc_ast::{
AstKind,
ast::{Argument, Expression},
ast::{Argument, CallExpression, Expression},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
Expand Down Expand Up @@ -56,14 +56,14 @@ declare_oxc_lint!(

impl Rule for NoArrayMethodThisArgument {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
check_array_prototype_methods(node, ctx);
check_array_from(node, ctx);
let AstKind::CallExpression(call_expr) = node.kind() else { return };

check_array_prototype_methods(call_expr, ctx);
check_array_from(call_expr, ctx);
}
}

fn check_array_prototype_methods<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>) {
let AstKind::CallExpression(call_expr) = node.kind() else { return };

fn check_array_prototype_methods(call_expr: &CallExpression, ctx: &LintContext) {
if !is_method_call(
call_expr,
None,
Expand Down Expand Up @@ -96,9 +96,7 @@ fn check_array_prototype_methods<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>)
));
}

fn check_array_from<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>) {
let AstKind::CallExpression(call_expr) = node.kind() else { return };

fn check_array_from(call_expr: &CallExpression, ctx: &LintContext) {
if !is_method_call(call_expr, Some(&["Array"]), Some(&["from", "fromAsync"]), Some(3), Some(3))
|| call_expr.arguments.first().is_some_and(|arg| matches!(arg, Argument::SpreadElement(_)))
|| call_expr.arguments.get(2).is_some_and(|arg| matches!(arg, Argument::SpreadElement(_)))
Expand Down
Loading