Registry / devops / prettier-plugin-merge

prettier-plugin-merge

JSON →
library0.10.1jsnpmunverified

A Prettier plugin (v0.10.1) that sequentially merges the formatting results of other Prettier plugins, overcoming Prettier's built-in limitation of using only the last applicable plugin per language. It enables combining multiple plugins like Tailwind CSS class sorting, import ordering, or brace style. Requires Prettier v3+ and Node.js 18+. Released under MIT. Maintenance active with regular updates.

npm install prettier-plugin-merge
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-ME
P
prettier-plugin-merge
devopsjavascriptv0.10.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
import prettierPluginMerge from 'prettier-plugin-merge'
const prettierPluginMerge = require('prettier-plugin-merge')
ESM-only since v0.8.0. CommonJS require will fail.
plugins config
{ "plugins": [ "prettier-plugin-tailwindcss", "prettier-plugin-classnames", "prettier-plugin-merge" ] }
{ "plugins": [ "prettier-plugin-merge", "prettier-plugin-tailwindcss" ] }
The merge plugin MUST be listed last in the plugins array.
overrides
{ "overrides": [ { "files": ["*.md", "*.mdx"], "options": { "plugins": [] } } ] }
To prevent unintended formatting inside Markdown/MDX code blocks, you can override to clear plugins for those files.

Shows installation, config file setup, and programmatic usage with multiple plugins merged via prettier-plugin-merge.

// Install: npm install -D prettier prettier-plugin-merge prettier-plugin-tailwindcss prettier-plugin-classnames // In .prettierrc (JSON) { "plugins": [ "prettier-plugin-tailwindcss", "prettier-plugin-classnames", "prettier-plugin-merge" ] } // Or programmatically (ESM) import prettier from 'prettier'; const code = ` <div class="mt-2 p-4 bg-white text-black"> Hello </div> `; const formatted = await prettier.format(code, { parser: 'html', plugins: [ 'prettier-plugin-tailwindcss', 'prettier-plugin-classnames', 'prettier-plugin-merge' ] }); console.log(formatted); // Expected output: Tailwind classes sorted, class names sorted/merged.
Debug
Known issues
breakingDropped support for Prettier v2 in v0.8.0. Upgrade to Prettier v3+.
fix
Update Prettier to v3 or later: npm install -D prettier@latest
affects: >=0.8.0
breakingIncreased minimum Node.js version to 18 in v0.8.0.
fix
Use Node.js 18 or later: nvm install 18
affects: >=0.8.0
gotchaThe plugin MUST be listed last in the plugins array. If not, preceding plugins may not be merged correctly.
fix
Ensure 'prettier-plugin-merge' is the last entry in the plugins array.
affects: *
gotchaDoes not support Markdown and MDX directly; if used with code blocks in Markdown/MDX, unintended formatting may occur.
fix
Add an override to clear plugins for *.md and *.mdx files.
affects: *
deprecatedVersion 0.7.x and earlier support Prettier v2, but Prettier v2 is now outdated. Migrate to Prettier v3.
fix
Upgrade to latest version and Prettier v3.
affects: <0.8.0
Errors
Common errors & fixes
Error: Cannot find module 'prettier-plugin-merge'
Missing installation or not in node_modules.
fix
Run npm install -D prettier-plugin-merge
Error: Cannot use import statement outside a module
Using ESM import in CommonJS project.
fix
Add "type": "module" to package.json or use require (if your version supports CJS, but v0.8+ is ESM-only).
Error: [prettier-plugin-merge] The plugin must be the last in the 'plugins' array.
Plugin not listed last in configuration.
fix
Move 'prettier-plugin-merge' to the end of the plugins array in .prettierrc or config.
Upgrade
Version history
0.10.1latest on npm
Audit
Dependencies
prettierrequiredPeer dependency: plugin requires Prettier v3 to function.
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-merge — npm install prettier-plugin-merge · libregistry