Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
faultyserver committed Dec 2, 2023
1 parent bf60d37 commit 6c5e2ca
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions crates/biome_js_formatter/src/js/bindings/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,11 @@ pub(crate) fn has_only_simple_parameters(
parameters: &JsParameters,
allow_type_annotations: bool,
) -> bool {
for parameter in parameters.items().into_iter().flatten() {
if !is_simple_parameter(parameter, allow_type_annotations) {
return false;
}
}

true
parameters
.items()
.into_iter()
.flatten()
.all(|parameter| is_simple_parameter(&parameter, allow_type_annotations))
}

/// Tests if the single parameter is "simple", as in a plain identifier with no
Expand All @@ -403,18 +401,19 @@ pub(crate) fn has_only_simple_parameters(
/// {a, b} = {} => false
/// [a, b] => false
///
pub(crate) fn is_simple_parameter(parameter: AnyJsParameter, allow_type_annotations: bool) -> bool {
pub(crate) fn is_simple_parameter(
parameter: &AnyJsParameter,
allow_type_annotations: bool,
) -> bool {
match parameter {
AnyJsParameter::AnyJsFormalParameter(AnyJsFormalParameter::JsFormalParameter(param)) => {
match param.binding() {
Ok(AnyJsBindingPattern::AnyJsBinding(AnyJsBinding::JsIdentifierBinding(_))) => {
if !allow_type_annotations && param.type_annotation().is_some() {
return false;
}
param.initializer().is_none()
}
_ => false,
}
matches!(
param.binding(),
Ok(AnyJsBindingPattern::AnyJsBinding(
AnyJsBinding::JsIdentifierBinding(_)
))
) && (allow_type_annotations || param.type_annotation().is_none())
&& param.initializer().is_none()
}
_ => false,
}
Expand Down

0 comments on commit 6c5e2ca

Please sign in to comment.