{"id":20390,"library":"prettier-plugin-merge","title":"prettier-plugin-merge","description":"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.","status":"active","version":"0.10.1","language":"javascript","source_language":"en","source_url":"https://github.com/ony3000/prettier-plugin-merge","tags":["javascript","prettier","plugin","merge","sequential","formatting","multiple"],"install":[{"cmd":"npm install prettier-plugin-merge","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-merge","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-merge","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: plugin requires Prettier v3 to function.","package":"prettier","optional":false}],"imports":[{"note":"ESM-only since v0.8.0. CommonJS require will fail.","wrong":"const prettierPluginMerge = require('prettier-plugin-merge')","symbol":"default","correct":"import prettierPluginMerge from 'prettier-plugin-merge'"},{"note":"The merge plugin MUST be listed last in the plugins array.","wrong":"{\n  \"plugins\": [\n    \"prettier-plugin-merge\",\n    \"prettier-plugin-tailwindcss\"\n  ]\n}","symbol":"plugins config","correct":"{\n  \"plugins\": [\n    \"prettier-plugin-tailwindcss\",\n    \"prettier-plugin-classnames\",\n    \"prettier-plugin-merge\"\n  ]\n}"},{"note":"To prevent unintended formatting inside Markdown/MDX code blocks, you can override to clear plugins for those files.","wrong":"","symbol":"overrides","correct":"{\n  \"overrides\": [\n    {\n      \"files\": [\"*.md\", \"*.mdx\"],\n      \"options\": {\n        \"plugins\": []\n      }\n    }\n  ]\n}"}],"quickstart":{"code":"// Install: npm install -D prettier prettier-plugin-merge prettier-plugin-tailwindcss prettier-plugin-classnames\n\n// In .prettierrc (JSON)\n{\n  \"plugins\": [\n    \"prettier-plugin-tailwindcss\",\n    \"prettier-plugin-classnames\",\n    \"prettier-plugin-merge\"\n  ]\n}\n\n// Or programmatically (ESM)\nimport prettier from 'prettier';\n\nconst code = `\n  <div class=\"mt-2 p-4 bg-white text-black\">\n    Hello\n  </div>\n`;\n\nconst formatted = await prettier.format(code, {\n  parser: 'html',\n  plugins: [\n    'prettier-plugin-tailwindcss',\n    'prettier-plugin-classnames',\n    'prettier-plugin-merge'\n  ]\n});\n\nconsole.log(formatted);\n// Expected output: Tailwind classes sorted, class names sorted/merged.\n","lang":"javascript","description":"Shows installation, config file setup, and programmatic usage with multiple plugins merged via prettier-plugin-merge."},"warnings":[{"fix":"Update Prettier to v3 or later: npm install -D prettier@latest","message":"Dropped support for Prettier v2 in v0.8.0. Upgrade to Prettier v3+.","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"Use Node.js 18 or later: nvm install 18","message":"Increased minimum Node.js version to 18 in v0.8.0.","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"Ensure 'prettier-plugin-merge' is the last entry in the plugins array.","message":"The plugin MUST be listed last in the plugins array. If not, preceding plugins may not be merged correctly.","severity":"gotcha","affected_versions":"*"},{"fix":"Add an override to clear plugins for *.md and *.mdx files.","message":"Does not support Markdown and MDX directly; if used with code blocks in Markdown/MDX, unintended formatting may occur.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade to latest version and Prettier v3.","message":"Version 0.7.x and earlier support Prettier v2, but Prettier v2 is now outdated. Migrate to Prettier v3.","severity":"deprecated","affected_versions":"<0.8.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install -D prettier-plugin-merge","cause":"Missing installation or not in node_modules.","error":"Error: Cannot find module 'prettier-plugin-merge'"},{"fix":"Add \"type\": \"module\" to package.json or use require (if your version supports CJS, but v0.8+ is ESM-only).","cause":"Using ESM import in CommonJS project.","error":"Error: Cannot use import statement outside a module"},{"fix":"Move 'prettier-plugin-merge' to the end of the plugins array in .prettierrc or config.","cause":"Plugin not listed last in configuration.","error":"Error: [prettier-plugin-merge] The plugin must be the last in the 'plugins' array."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}