{"id":20391,"library":"prettier-plugin-multiline-arrays","title":"prettier-plugin-multiline-arrays","description":"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.","status":"active","version":"4.1.7","language":"javascript","source_language":"en","source_url":"https://github.com/electrovir/prettier-plugin-multiline-arrays","tags":["javascript","array","format","multiline","plugin","prettier","printer","typescript"],"install":[{"cmd":"npm install prettier-plugin-multiline-arrays","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-multiline-arrays","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-multiline-arrays","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This is a Prettier plugin and requires Prettier >=3.0.0 <4.0.0 as a peer dependency.","package":"prettier","optional":false}],"imports":[{"note":"ESM-only since v4. The package ships ESM. CJS require will fail. Use dynamic import or configure your project for ESM.","wrong":"const prettierPluginMultilineArrays = require('prettier-plugin-multiline-arrays')","symbol":"default","correct":"import prettierPluginMultilineArrays from 'prettier-plugin-multiline-arrays'"},{"note":"Register the plugin by name in the plugins array. Do not use a file path. The plugin name string is sufficient.","wrong":"plugins: ['./node_modules/prettier-plugin-multiline-arrays']","symbol":"options (Prettier config usage)","correct":"// In prettier.config.mjs:\nexport default {\n  plugins: ['prettier-plugin-multiline-arrays'],\n  multilineArraysWrapThreshold: 3,\n  multilineArraysLinePattern: '2 1'\n}"}],"quickstart":{"code":"// Install: npm install --save-dev prettier prettier-plugin-multiline-arrays\n\n// prettier.config.mjs\nexport default {\n  plugins: ['prettier-plugin-multiline-arrays'],\n  multilineArraysWrapThreshold: 2, // wrap arrays with >2 elements\n  multilineArraysLinePattern: '2 1', // first line 2 items, second line 1, repeat\n};\n\n// Example input (before formatting):\nconst arr = ['a', 'b', 'c', 'd'];\n\n// After prettier (with above config):\nconst arr = [\n  'a', 'b',\n  'c', 'd',\n];","lang":"typescript","description":"Install and configure the plugin, then run Prettier to see multiline array formatting."},"warnings":[{"fix":"Upgrade Prettier to ^3.0.0 and ensure Node >=16 (v4.1.7 requires Node >=20).","message":"v4.0.0 dropped support for Prettier 2.x and earlier. Requires Prettier >=3.0.0.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use ESM imports or dynamic import(). If you cannot switch to ESM, stay on v3.x.","message":"v4.0.0 switched to ESM-only. CommonJS require() will fail.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Place 'prettier-plugin-multiline-arrays' before other plugins that modify formatting of arrays. Check the plugin's own Prettier config for reference.","message":"Plugin order among multiple plugins can affect behavior. The documentation recommends rearranging if other plugins interfere.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `// prettier-multiline-arrays-set-threshold: 4` to apply to all subsequent arrays, then `// prettier-multiline-arrays-reset` to revert.","message":"Comment overrides (e.g., `// prettier-multiline-arrays-next-threshold: 4`) apply to the next line only. For persistent overrides, use `set-` variants.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'-1':29 '1':36 '20':56 '3.0.0':52 '4.0.0':53 '4.1.7':49 'appear':23 'array':5,10,65,73 'auto':31 'comment':62 'control':18 'current':46 'default':28,35 'differenti':60 'electrovir':71 'element':11,22,38 'forc':9 'format':74 'javascript':42,72 'json':44 'line':16,25,40 'maintain':69 'mani':21 'multilin':4,75 'multilinearrayslinepattern':34 'multilinearrayswrapthreshold':27 'new':15 'node':55 'one':37 'onto':14 'overrid':63 'pattern':68 'per':24,39,64 'plugin':3,7,76 'prettier':2,6,51,77 'prettier-plugin-multiline-array':1 'printer':78 'requir':50 'set/reset':67 'ship':57 'stabl':47 'support':45 'type':59 'typescript':41,58,79 'version':48 'via':26 'wrap':13,32","created_at":"2026-04-25T11:22:52.399913+00:00","updated_at":"2026-04-25T11:22:52.399913+00:00","problems":[{"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');","cause":"The package is ESM-only from v4, but you are using require() in a CommonJS context.","error":"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."},{"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.","cause":"Plugin not installed or not in the correct node_modules path.","error":"[prettier] Cannot find module 'prettier-plugin-multiline-arrays'"},{"fix":"Upgrade Prettier to ^3.0.0 and node to >=20 as required by the plugin's engine.","cause":"Incompatible Prettier version - this plugin requires Prettier 3.x.","error":"TypeError: Cannot read properties of undefined (reading 'length')","affected_versions":">=4.0.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/electrovir/prettier-plugin-multiline-arrays","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/prettier-plugin-multiline-arrays","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}