Skip to content

Commit

Permalink
refactor: no-array-constructor with guard clause
Browse files Browse the repository at this point in the history
  • Loading branch information
Kazuhiro-Mimaki committed Apr 23, 2024
1 parent 99d7c6b commit 96c6d19
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions crates/biome_js_analyze/src/lint/nursery/no_array_constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,17 @@ impl Rule for NoArrayConstructor {
}

fn validate(callee: &AnyJsExpression, arguments: &JsCallArguments) -> Option<()> {
if callee.text() != "Array" {
return None;
}
let mut args_iter = arguments.args().into_iter();
let first_arg = args_iter.next();
let second_arg = args_iter.next();
if callee.text() == "Array" {
if first_arg.is_some()
&& second_arg.is_none()
&& !matches!(first_arg?.ok()?, AnyJsCallArgument::JsSpread(_))
{
return None;
}
Some(())
} else {
None
if first_arg.is_some()
&& second_arg.is_none()
&& !matches!(first_arg?.ok()?, AnyJsCallArgument::JsSpread(_))
{
return None;
}
Some(())
}

0 comments on commit 96c6d19

Please sign in to comment.