prettier-plugin-multiline-arrays icon indicating copy to clipboard operation
prettier-plugin-multiline-arrays copied to clipboard

Doesn't work with zod

Open tech-meppem opened this issue 8 months ago • 0 comments

I have files I'm trying to generate, and then prettier, so I use this plugin via prettier API not CLI. But I have tested this via CLI too, and it doesn't seem to work.

Input file:

import { z } from "zod";

export const Params = z.tuple([
  z.number(),
  z.number(),
  z.number(),
  z.number(),
  z.number(),
  z.union([z.number(), z.null()]),
]);
export type Params = z.infer<typeof Params>;

I would expect (and want) that last line, z.union([ z.number(), z.null() ]) to be split into multiple newlines, so that the output would be:

import { z } from "zod";

export const Params = z.tuple([
  z.number(),
  z.number(),
  z.number(),
  z.number(),
  z.number(),
  z.union([
    z.number(),
    z.null()
  ]),
]);
export type Params = z.infer<typeof Params>;

But this doesn't seem to be happening.

Package json details:

    "prettier": "^3.5.3",
    "prettier-plugin-multiline-arrays": "^4.0.3",

API usage:

await format(zodStringOutput, {
  parser: 'typescript',
  plugins: [
    await import("prettier-plugin-multiline-arrays")
  ],
})

tech-meppem avatar Mar 21 '25 11:03 tech-meppem