11import { doc } from 'prettier' ;
2+ import { rightOperandPrinter } from './printers/right-operand-printer.js' ;
23import { logical } from './logical.js' ;
34
4- const { group, indent, line } = doc . builders ;
5+ const { group, indent } = doc . builders ;
56
67const indentIfNecessaryBuilder = ( path ) => ( document ) => {
78 let node = path . getNode ( ) ;
@@ -20,18 +21,17 @@ const indentIfNecessaryBuilder = (path) => (document) => {
2021
2122export const comparison = {
2223 match : ( op ) => [ '<' , '>' , '<=' , '>=' , '==' , '!=' ] . includes ( op ) ,
23- print : ( node , path , print ) => {
24+ print : ( node , path , print , options ) => {
2425 const indentIfNecessary = indentIfNecessaryBuilder ( path ) ;
2526
26- const right = [ node . operator , line , path . call ( print , 'right' ) ] ;
27+ const right = rightOperandPrinter ( node , path , print , options ) ;
2728 // If it's a single binary operation, avoid having a small right
2829 // operand like - 1 on its own line
2930 const shouldGroup =
3031 node . left . type !== 'BinaryOperation' &&
3132 path . getParentNode ( ) . type !== 'BinaryOperation' ;
3233 return group ( [
3334 path . call ( print , 'left' ) ,
34- ' ' ,
3535 indentIfNecessary ( shouldGroup ? group ( right ) : right )
3636 ] ) ;
3737 }
0 commit comments