src/language-js/print/call-arguments.js/printCallArguments
function printCallArguments(path, options, print) {
  const node = path.getValue();
  const isDynamicImport = node.type === "ImportExpression";

  const args = getCallArguments(node);
  if (args.length === 0) {
    return [
      "(",
      printDanglingComments(path, options, /* sameIndent */ true),
      ")",
    ];
  }

  // useEffect(() => { ... }, [foo, bar, baz])
  if (isReactHookCallWithDepsArray(args)) {
    return ["(", print(["arguments", 0]), ", ", print(["arguments", 1]), ")"];
  }

  let anyArgEmptyLine = false;
  let hasEmptyLineFollowingFirstArg = false;
  const lastArgIndex = args.length - 1;
  const printedArguments = [];
  iterateCallArgumentsPath(path, (argPath, index) => {
    const arg = argPath.getNode();
    const parts = [print()];

    if (index === lastArgIndex) {
      // do nothing
    } else if (isNextLineEmpty(arg, options)) {
      if (index === 0) {
        hasEmptyLineFollowingFirstArg = true;
      }

      anyArgEmptyLine = true;
      parts.push(",", hardline, hardline);
    } else {
      parts.push(",", line);
    }

    printedArguments.push(parts);
  });

  const maybeTrailingComma =
    // Dynamic imports cannot have trailing commas
    !(isDynamicImport || (node.callee && node.callee.type === "Import")) &&
    shouldPrintComma(options, "all")
      ? ","
      : "";

  function allArgsBrokenOut() {
    return group(
      ["(", indent([line, ...printedArguments]), maybeTrailingComma, line, ")"],
      { shouldBreak: true }
    );
  }

  if (
    anyArgEmptyLine ||
    (path.getParentNode().type !== "Decorator" &&
      isFunctionCompositionArgs(args))
  ) {
    return allArgsBrokenOut();
  }

  const shouldGroupFirst = shouldGroupFirstArg(args);
  const shouldGroupLast = shouldGroupLastArg(args, options);
  if (shouldGroupFirst || shouldGroupLast) {
    if (
      shouldGroupFirst
        ? printedArguments.slice(1).some(willBreak)
        : printedArguments.slice(0, -1).some(willBreak)
    ) {
      return allArgsBrokenOut();
    }

    // We want to print the last argument with a special flag
    let printedExpanded = [];

    try {
      path.try(() => {
        iterateCallArgumentsPath(path, (argPath, i) => {
          if (shouldGroupFirst && i === 0) {
            printedExpanded = [
              [
                print([], { expandFirstArg: true }),
                printedArguments.length > 1 ? "," : "",
                hasEmptyLineFollowingFirstArg ? hardline : line,
                hasEmptyLineFollowingFirstArg ? hardline : "",
              ],
              ...printedArguments.slice(1),
            ];
          }
          if (shouldGroupLast && i === lastArgIndex) {
            printedExpanded = [
              ...printedArguments.slice(0, -1),
              print([], { expandLastArg: true }),
            ];
          }
        });
      });
    } catch (caught) {
      if (caught instanceof ArgExpansionBailout) {
        return allArgsBrokenOut();
      }
      /* istanbul ignore next */
      throw caught;
    }

    return [
      printedArguments.some(willBreak) ? breakParent : "",
      conditionalGroup([
        ["(", ...printedExpanded, ")"],
        shouldGroupFirst
          ? [
              "(",
              group(printedExpanded[0], { shouldBreak: true }),
              ...printedExpanded.slice(1),
              ")",
            ]
          : [
              "(",
              ...printedArguments.slice(0, -1),
              group(getLast(printedExpanded), { shouldBreak: true }),
              ")",
            ],
        allArgsBrokenOut(),
      ]),
    ];
  }

  const contents = [
    "(",
    indent([softline, ...printedArguments]),
    ifBreak(maybeTrailingComma),
    softline,
    ")",
  ];
  if (isLongCurriedCallExpression(path)) {
    // By not wrapping the arguments in a group, the printer prioritizes
    // breaking up these arguments rather than the args of the parent call.
    return contents;
  }

  return group(contents, {
    shouldBreak: printedArguments.some(willBreak) || anyArgEmptyLine,
  });
}