Prettier plugin that forces array elements to wrap onto new lines, with control over how many elements appear per line via `multilineArraysWrapThreshold` (default -1, no auto wrap) and `multilineArraysLinePattern` (default '1', one element per line). TypeScript, JavaScript, and JSON supported. Current stable version 4.1.7, requires Prettier >=3.0.0 <4.0.0 and Node >=20. Ships TypeScript types. Differentiated by comment overrides per array and set/reset patterns. Maintained by electrovir.
npm install prettier-plugin-multiline-arraysVerified import paths — ran on the pinned version, not inferred.
Install and configure the plugin, then run Prettier to see multiline array formatting.
Upgrade Prettier to ^3.0.0 and ensure Node >=16 (v4.1.7 requires Node >=20).
Use ESM imports or dynamic import(). If you cannot switch to ESM, stay on v3.x.
Place 'prettier-plugin-multiline-arrays' before other plugins that modify formatting of arrays. Check the plugin's own Prettier config for reference.
If you need line-length enforcement, set a pattern that fits within your desired column width, or rely on Prettier's default wrapping by not setting this option.
Use `// prettier-multiline-arrays-set-threshold: 4` to apply to all subsequent arrays, then `// prettier-multiline-arrays-reset` to revert.
Switch to ESM (use import, add 'type': 'module' in package.json) or use dynamic import() in CommonJS: const plugin = await import('prettier-plugin-multiline-arrays');Ensure the plugin is installed: `npm install --save-dev prettier-plugin-multiline-arrays`. If using a monorepo, ensure it's in the root or hoisted.
Upgrade Prettier to ^3.0.0 and node to >=20 as required by the plugin's engine.