diff --git a/crates/rome_js_formatter/src/utils/assignment_like.rs b/crates/rome_js_formatter/src/utils/assignment_like.rs index 0cb63fca0ff..50e50699c99 100644 --- a/crates/rome_js_formatter/src/utils/assignment_like.rs +++ b/crates/rome_js_formatter/src/utils/assignment_like.rs @@ -1,5 +1,4 @@ use crate::js::auxiliary::initializer_clause::FormatJsInitializerClauseOptions; -use crate::js::expressions::arrow_function_expression::FormatJsArrowFunctionExpressionOptions; use crate::prelude::*; use crate::utils::member_chain::is_member_call_chain; use crate::utils::object::write_member_name; @@ -439,7 +438,7 @@ impl JsAnyAssignmentLike { let width = write_member_name(&name.into(), f)?; let text_width_for_break = (u8::from(f.options().tab_width()) + MIN_OVERLAP_FOR_BREAK) as usize; - width < text_width_for_break && property_annotation.is_none() + width < text_width_for_break }; write!(f, [property_annotation.format()])?; @@ -918,7 +917,7 @@ impl Format for JsAnyAssignmentLike { self.write_operator(f)?; } - match layout { + match &layout { AssignmentLikeLayout::OnlyLeft => Ok(()), AssignmentLikeLayout::Fluid => { let group_id = f.group_id("assignment_like"); @@ -993,7 +992,7 @@ impl Format for JsAnyAssignmentLike { /// [Prettier applies]: https://github.com/prettier/prettier/blob/a043ac0d733c4d53f980aa73807a63fc914f23bd/src/language-js/print/assignment.js#L329 fn is_poorly_breakable_member_or_call_chain( expression: &JsAnyExpression, - f: &Formatter, + f: &mut Formatter, ) -> SyntaxResult { let threshold = f.options().line_width().value() / 4; @@ -1042,11 +1041,7 @@ fn is_poorly_breakable_member_or_call_chain( } for call_expression in call_expressions { - if is_member_call_chain( - call_expression.clone(), - f.comments(), - f.options().tab_width(), - )? { + if is_member_call_chain(&call_expression, f)? { return Ok(false); } @@ -1190,13 +1185,9 @@ pub(crate) fn with_assignment_layout( impl Format for WithAssignmentLayout<'_> { fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { match self.expression { - JsAnyExpression::JsArrowFunctionExpression(arrow) => arrow - .format() - .with_options(FormatJsArrowFunctionExpressionOptions { - assignment_layout: self.layout, - ..FormatJsArrowFunctionExpressionOptions::default() - }) - .fmt(f), + JsAnyExpression::JsArrowFunctionExpression(arrow) => { + arrow.format().with_options(self.layout).fmt(f) + } expression => expression.format().fmt(f), } }