{"id":27249,"library":"prettier-plugin-compactify","title":"prettier-plugin-compactify","description":"A Prettier plugin that preprocesses JavaScript/TypeScript code to collapse object literals into compact single-line formatting. Version 0.1.6, actively maintained but early-stage. Unlike other Prettier plugins, it hooks into the parsing stage to enforce compact object notation, addressing a long-standing Prettier issue with unwanted newlines after opening braces. Requires Prettier >=2.x.","status":"active","version":"0.1.6","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install prettier-plugin-compactify","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-compactify","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-compactify","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for the plugin to function","package":"prettier","optional":false}],"imports":[{"note":"CommonJS only; no ESM export. Use require() or reference by string in Prettier config.","wrong":"import plugin from 'prettier-plugin-compactify'","symbol":"default","correct":"module.exports = require('prettier-plugin-compactify')"}],"quickstart":{"code":"// Install\nnpm install --save-dev prettier prettier-plugin-compactify\n\n// .prettierrc\n{\n  \"plugins\": [\"prettier-plugin-compactify\"]\n}\n\n// Input file test.js\nconst obj = {\n  foo: \"bar\"\n}\n\n// Run prettier\nnpx prettier --write test.js\n\n// Output: const obj = { foo: \"bar\" }","lang":"javascript","description":"Shows installation, configuration, and effect of collapsing object literals to single line."},"warnings":[{"fix":"Review output manually for unexpected formatting; consider disabling for specific files via // prettier-ignore","message":"Plugin modifies formatting before Prettier runs; complex nested objects may be incorrectly collapsed.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Upgrade Prettier to version 2 or later.","message":"Requires Prettier >=2.0; not compatible with Prettier 1.x.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Configure plugins array in .prettierrc with the package name string instead of an import.","message":"Plugin does not support ESM imports; use CommonJS require or string plugin name.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure prettier-plugin-compactify is installed as a devDependency and Prettier config is correct.","cause":"Module not installed or Prettier cannot resolve it.","error":"Error: Cannot find module 'prettier-plugin-compactify'"},{"fix":"Check Prettier version (>=2.x) and reinstall plugin.","cause":"Plugin might not be compatible with the installed Prettier version.","error":"TypeError: Cannot read properties of undefined (reading 'someProperty')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}