Repository: prettier/prettier
File: src/language-css/print/parenthesized-value-group.js (JavaScript)

Code before:
  if (
    parent &&
    isURLFunctionNode(parent) &&
    (node.groups.length === 1 ||
      (node.groups.length > 0 &&
        node.groups[0].type === "value-comma_group" &&
        node.groups[0].groups.length > 0 &&
        node.groups[0].groups[0].type === "value-word" &&
        node.groups[0].groups[0].value.startsWith("data:")))
  ) {
    return [
      node.open ? print("open") : "",
      join(",", groupDocs),
      node.close ? print("close") : "",
    ];
  }

  if (!node.open) {
    const forceHardLine = shouldBreakList(path);
    assertDocArray(groupDocs);
    const parts = join(
      forceHardLine ? hardline : line,
      groupDocs.map((doc, i) =>
        i === groupDocs.length - 1 ? doc : [doc, ","],
      ),
    );
    return indent(forceHardLine ? [hardline, parts] : group(fill(parts)));
  }

  const parts = path.map(({ node: child, isLast, index }) => {
    let doc = groupDocs[index];

    // Key/Value pair in open paren already indented
    if (
      isKeyValuePairNode(child) &&
      child.type === "value-comma_group" &&
      child.groups &&
      child.groups[0].type !== "value-paren_group" &&
      child.groups[2]?.type === "value-paren_group"
    ) {
      doc = mapDoc(doc, (d) => {
        if (getDocType(d) === DOC_TYPE_LABEL && d.label === "colon") {
          return group(d);
        }
        return d;
      });
      doc = group(dedent(doc));
    }

    const parts = [doc, isLast ? printTrailingComma(path, options) : ","];


Review comment (refactor):
Maybe we can use a `chunk()` utility

```js
join(forceHardLine ? hardline : line, chunk(join(',', groupDocs), 2))
```

But still not look good..

Code after:
    ({ node }) => (typeof node === "string" ? node : print()),
    "groups",
  );

  if (
    parent &&
    isURLFunctionNode(parent) &&
    (node.groups.length === 1 ||
      (node.groups.length > 0 &&
        node.groups[0].type === "value-comma_group" &&
        node.groups[0].groups.length > 0 &&
        node.groups[0].groups[0].type === "value-word" &&
        node.groups[0].groups[0].value.startsWith("data:")))
  ) {
    return [
      node.open ? print("open") : "",
      join(",", groupDocs),
      node.close ? print("close") : "",
    ];
  }

  if (!node.open) {
    const forceHardLine = shouldBreakList(path);
    assertDocArray(groupDocs);
    const withComma = chunk(join(",", groupDocs), 2);
    const parts = join(forceHardLine ? hardline : line, withComma);
    return indent(forceHardLine ? [hardline, parts] : group(fill(parts)));
  }

  const parts = path.map(({ node: child, isLast, index }) => {
    let doc = groupDocs[index];

    // Key/Value pair in open paren already indented
    if (
      isKeyValuePairNode(child) &&
      child.type === "value-comma_group" &&
      child.groups &&
      child.groups[0].type !== "value-paren_group" &&
      child.groups[2]?.type === "value-paren_group" &&
      getDocType(doc) === DOC_TYPE_GROUP &&
      getDocType(doc.contents) === DOC_TYPE_INDENT &&
      getDocType(doc.contents.contents) === DOC_TYPE_FILL
    ) {
      doc = group(dedent(doc));
    }

    const parts = [doc, isLast ? printTrailingComma(path, options) : ","];

    if (
      !isLast &&
      child.type === "value-comma_group" &&