From 6c5e2cace38ac00d1e6d4c0b56b55f0f849b911f Mon Sep 17 00:00:00 2001 From: Jon Egeland Date: Sat, 2 Dec 2023 00:12:05 +0000 Subject: [PATCH] feedback --- .../src/js/bindings/parameters.rs | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/crates/biome_js_formatter/src/js/bindings/parameters.rs b/crates/biome_js_formatter/src/js/bindings/parameters.rs index 234448166512..b60a0c357252 100644 --- a/crates/biome_js_formatter/src/js/bindings/parameters.rs +++ b/crates/biome_js_formatter/src/js/bindings/parameters.rs @@ -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(¶meter, allow_type_annotations)) } /// Tests if the single parameter is "simple", as in a plain identifier with no @@ -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, }