Skip to content

Commit

Permalink
fix: lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Kazuhiro-Mimaki committed Apr 21, 2024
1 parent 02473e3 commit b733e8d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions crates/biome_js_analyze/src/lint/nursery/no_array_constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,14 @@ impl Rule for NoArrayConstructor {
AnyJsExpression::JsCallExpression(call_expression) => {
let callee = call_expression.callee().ok()?;
let arguments = call_expression.arguments().ok()?;
return validate(callee, arguments);
validate(&callee, &arguments)
}
AnyJsExpression::JsNewExpression(new_expression) => {
let callee = new_expression.callee().ok()?;
let arguments = new_expression.arguments()?;
return validate(callee, arguments);
}
_ => {
return None;
validate(&callee, &arguments)
}
_ => None,
}
}

Expand All @@ -80,19 +78,19 @@ impl Rule for NoArrayConstructor {
}
}

fn validate(callee: AnyJsExpression, arguments: JsCallArguments) -> Option<()> {
fn validate(callee: &AnyJsExpression, arguments: &JsCallArguments) -> Option<()> {
let len = arguments.args().into_iter().count();
if callee.text() == "Array" {
if len == 1
&& !matches!(
arguments.args().into_iter().nth(0)?.ok()?,
arguments.args().into_iter().next()?.ok()?,
AnyJsCallArgument::JsSpread(_)
)
{
return None;
}
return Some(());
Some(())
} else {
return None;
None
}
}

0 comments on commit b733e8d

Please sign in to comment.