11import { doc } from 'prettier' ;
2+ import { rightOperandPrinter } from './printers/right-operand-printer.js' ;
23
3- const { group, indent, line } = doc . builders ;
4+ const { group, indent } = doc . builders ;
45
56const indentIfNecessaryBuilder = ( path ) => ( document ) => {
67 let node = path . getNode ( ) ;
@@ -18,18 +19,17 @@ const indentIfNecessaryBuilder = (path) => (document) => {
1819
1920export const comparison = {
2021 match : ( op ) => [ '<' , '>' , '<=' , '>=' , '==' , '!=' ] . includes ( op ) ,
21- print : ( node , path , print ) => {
22+ print : ( node , path , print , options ) => {
2223 const indentIfNecessary = indentIfNecessaryBuilder ( path ) ;
2324
24- const right = [ node . operator , line , path . call ( print , 'right' ) ] ;
25+ const right = rightOperandPrinter ( node , path , print , options ) ;
2526 // If it's a single binary operation, avoid having a small right
2627 // operand like - 1 on its own line
2728 const shouldGroup =
2829 node . left . type !== 'BinaryOperation' &&
2930 path . getParentNode ( ) . type !== 'BinaryOperation' ;
3031 return group ( [
3132 path . call ( print , 'left' ) ,
32- ' ' ,
3333 indentIfNecessary ( shouldGroup ? group ( right ) : right )
3434 ] ) ;
3535 }
0 commit comments