Registry / serialization / prettier-plugin-multiline-arrays

prettier-plugin-multiline-arrays

JSON →
library4.1.7jsnpmunverified

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-arrays
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-MU
P
prettier-plugin-multiline-arrays
serializationjavascriptv4.1.7
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import prettierPluginMultilineArrays from 'prettier-plugin-multiline-arrays'
✗ const prettierPluginMultilineArrays = require('prettier-plugin-multiline-arrays')
ESM-only since v4. The package ships ESM. CJS require will fail. Use dynamic import or configure your project for ESM.
options (Prettier config usage)
✓ // In prettier.config.mjs: export default { plugins: ['prettier-plugin-multiline-arrays'], multilineArraysWrapThreshold: 3, multilineArraysLinePattern: '2 1' }
✗ plugins: ['./node_modules/prettier-plugin-multiline-arrays']
Register the plugin by name in the plugins array. Do not use a file path. The plugin name string is sufficient.

Install and configure the plugin, then run Prettier to see multiline array formatting.

// Install: npm install --save-dev prettier prettier-plugin-multiline-arrays // prettier.config.mjs export default { plugins: ['prettier-plugin-multiline-arrays'], multilineArraysWrapThreshold: 2, // wrap arrays with >2 elements multilineArraysLinePattern: '2 1', // first line 2 items, second line 1, repeat }; // Example input (before formatting): const arr = ['a', 'b', 'c', 'd']; // After prettier (with above config): const arr = [ 'a', 'b', 'c', 'd', ];
Debug
Known issues
breakingv4.0.0 dropped support for Prettier 2.x and earlier. Requires Prettier >=3.0.0.
fix
Upgrade Prettier to ^3.0.0 and ensure Node >=16 (v4.1.7 requires Node >=20).
affects: >=4.0.0
breakingv4.0.0 switched to ESM-only. CommonJS require() will fail.
fix
Use ESM imports or dynamic import(). If you cannot switch to ESM, stay on v3.x.
affects: >=4.0.0
gotchaPlugin order among multiple plugins can affect behavior. The documentation recommends rearranging if other plugins interfere.
fix
Place 'prettier-plugin-multiline-arrays' before other plugins that modify formatting of arrays. Check the plugin's own Prettier config for reference.
affects: >=1.0.0
gotchaThe `multilineArraysLinePattern` option overrides Prettier's default line-length-based wrapping for arrays. Arrays may exceed the column limit if the pattern forces more items per line than can fit.
fix
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.
affects: >=1.0.0
gotchaComment overrides (e.g., `// prettier-multiline-arrays-next-threshold: 4`) apply to the next line only. For persistent overrides, use `set-` variants.
fix
Use `// prettier-multiline-arrays-set-threshold: 4` to apply to all subsequent arrays, then `// prettier-multiline-arrays-reset` to revert.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/prettier-plugin-multiline-arrays/dist/index.js from /path/to/not-supported.js not supported.
The package is ESM-only from v4, but you are using require() in a CommonJS context.
fix
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');
[prettier] Cannot find module 'prettier-plugin-multiline-arrays'
Plugin not installed or not in the correct node_modules path.
fix
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.
TypeError: Cannot read properties of undefined (reading 'length')
Incompatible Prettier version - this plugin requires Prettier 3.x.
fix
Upgrade Prettier to ^3.0.0 and node to >=20 as required by the plugin's engine.
Upgrade
Version history
4.1.7latest on npm
Audit
Dependencies
prettierrequiredThis is a Prettier plugin and requires Prettier >=3.0.0 <4.0.0 as a peer dependency.
Agent activity
10 hits · last 30 days
node
10
Resources
prettier-plugin-multiline-arrays — npm install prettier-plugin-multiline-arrays · libregistry