src/language-js/print/binaryish.js/printBinaryishExpressions
function printBinaryishExpressions(
  path,
  print,
  options,
  isNested,
  isInsideParenthesis
) {
  const node = path.getValue();

  // Simply print the node normally.
  if (!isBinaryish(node)) {
    return [group(print())];
  }

  /** @type{Doc[]} */
  let parts = [];

  // We treat BinaryExpression and LogicalExpression nodes the same.

  // Put all operators with the same precedence level in the same
  // group. The reason we only need to do this with the `left`
  // expression is because given an expression like `1 + 2 - 3`, it
  // is always parsed like `((1 + 2) - 3)`, meaning the `left` side
  // is where the rest of the expression will exist. Binary
  // expressions on the right side mean they have a difference
  // precedence level and should be treated as a separate group, so
  // print them normally. (This doesn't hold for the `**` operator,
  // which is unique in that it is right-associative.)
  if (shouldFlatten(node.operator, node.left.operator)) {
    // Flatten them out by recursively calling this function.
    parts = path.call(
      (left) =>
        printBinaryishExpressions(
          left,
          print,
          options,
          /* isNested */ true,
          isInsideParenthesis
        ),
      "left"
    );
  } else {
    parts.push(group(print("left")));
  }

  const shouldInline = shouldInlineLogicalExpression(node);
  const lineBeforeOperator =
    (node.operator === "|>" ||
      node.type === "NGPipeExpression" ||
      (node.operator === "|" && options.parser === "__vue_expression")) &&
    !hasLeadingOwnLineComment(options.originalText, node.right);

  const operator = node.type === "NGPipeExpression" ? "|" : node.operator;
  const rightSuffix =
    node.type === "NGPipeExpression" && node.arguments.length > 0
      ? group(
          indent([
            softline,
            ": ",
            join(
              [softline, ":", ifBreak(" ")],
              path.map(print, "arguments").map((arg) => align(2, group(arg)))
            ),
          ])
        )
      : "";

  /** @type {Doc} */
  let right;
  if (shouldInline) {
    right = [operator, " ", print("right"), rightSuffix];
  } else {
    const isHackPipeline = isEnabledHackPipeline(options) && operator === "|>";
    const rightContent = isHackPipeline
      ? path.call(
          (left) =>
            printBinaryishExpressions(
              left,
              print,
              options,
              /* isNested */ true,
              isInsideParenthesis
            ),
          "right"
        )
      : print("right");
    right = [
      lineBeforeOperator ? line : "",
      operator,
      lineBeforeOperator ? " " : line,
      rightContent,
      rightSuffix,
    ];
  }

  // If there's only a single binary expression, we want to create a group
  // in order to avoid having a small right part like -1 be on its own line.
  const parent = path.getParentNode();
  const shouldBreak = hasComment(
    node.left,
    CommentCheckFlags.Trailing | CommentCheckFlags.Line
  );
  const shouldGroup =
    shouldBreak ||
    (!(isInsideParenthesis && node.type === "LogicalExpression") &&
      parent.type !== node.type &&
      node.left.type !== node.type &&
      node.right.type !== node.type);

  parts.push(
    lineBeforeOperator ? "" : " ",
    shouldGroup ? group(right, { shouldBreak }) : right
  );

  // The root comments are already printed, but we need to manually print
  // the other ones since we don't call the normal print on BinaryExpression,
  // only for the left and right parts
  if (isNested && hasComment(node)) {
    const printed = cleanDoc(printComments(path, parts, options));
    /* istanbul ignore else */
    if (isConcat(printed) || printed.type === "fill") {
      return getDocParts(printed);
    }

    return [printed];
  }

  return parts;
}