@@ -314,19 +314,19 @@ impl<'a> AssignmentLike<'a, '_> {
314314 }
315315
316316 let right_expression = self . get_right_expression ( ) ;
317+ if let Some ( expr) = right_expression {
318+ if let Some ( layout) = self . chain_formatting_layout ( expr) {
319+ return layout;
320+ }
317321
318- if let Some ( layout) = right_expression. and_then ( |expr| self . chain_formatting_layout ( expr) ) {
319- return layout;
320- }
321-
322- if let Some ( Expression :: CallExpression ( call_expression) ) =
323- & right_expression. map ( AsRef :: as_ref)
324- && call_expression
325- . callee
326- . get_identifier_reference ( )
327- . is_some_and ( |ident| ident. name == "require" )
328- {
329- return AssignmentLikeLayout :: NeverBreakAfterOperator ;
322+ if let Expression :: CallExpression ( call_expression) = expr. as_ref ( )
323+ && call_expression
324+ . callee
325+ . get_identifier_reference ( )
326+ . is_some_and ( |ident| ident. name == "require" )
327+ {
328+ return AssignmentLikeLayout :: NeverBreakAfterOperator ;
329+ }
330330 }
331331
332332 if self . should_break_after_operator ( right_expression, f) {
@@ -359,10 +359,8 @@ impl<'a> AssignmentLike<'a, '_> {
359359 return AssignmentLikeLayout :: BreakAfterOperator ;
360360 }
361361
362- let is_poorly_breakable = match & right_expression {
363- Some ( expression) => is_poorly_breakable_member_or_call_chain ( expression, f) ,
364- None => false ,
365- } ;
362+ let is_poorly_breakable =
363+ right_expression. is_some_and ( |expr| is_poorly_breakable_member_or_call_chain ( expr, f) ) ;
366364
367365 if is_poorly_breakable {
368366 return AssignmentLikeLayout :: BreakAfterOperator ;
@@ -581,17 +579,19 @@ fn should_break_after_operator<'a>(
581579) -> bool {
582580 let is_jsx = matches ! ( right. as_ref( ) , Expression :: JSXElement ( _) | Expression :: JSXFragment ( _) ) ;
583581
582+ if is_jsx {
583+ return false ;
584+ }
585+
586+ let comments = f. comments ( ) ;
584587 let source_text = f. source_text ( ) ;
585- for comment in f. comments ( ) . comments_before ( right. span ( ) . start ) {
586- if !is_jsx
587- && ( source_text. lines_after ( comment. span . end ) > 0
588- || source_text. is_own_line_comment ( comment) )
589- {
588+ for comment in comments. comments_before ( right. span ( ) . start ) {
589+ if source_text. lines_after ( comment. span . end ) > 0 {
590590 return true ;
591591 }
592592
593593 // Needs to wrap a parenthesis for the node, so it won't break.
594- if f . comments ( ) . is_type_cast_comment ( comment) {
594+ if comments. is_type_cast_comment ( comment) {
595595 return false ;
596596 }
597597 }
0 commit comments