Registry / testing / prettier-plugin-compactify

prettier-plugin-compactify

JSON →
library0.1.6jsnpmunverified

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.

npm install prettier-plugin-compactify
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-CO
P
prettier-plugin-compactify
testingjavascriptv0.1.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
✓ module.exports = require('prettier-plugin-compactify')
✗ import plugin from 'prettier-plugin-compactify'
CommonJS only; no ESM export. Use require() or reference by string in Prettier config.

Shows installation, configuration, and effect of collapsing object literals to single line.

// Install npm install --save-dev prettier prettier-plugin-compactify // .prettierrc { "plugins": ["prettier-plugin-compactify"] } // Input file test.js const obj = { foo: "bar" } // Run prettier npx prettier --write test.js // Output: const obj = { foo: "bar" }
Debug
Known issues
gotchaPlugin modifies formatting before Prettier runs; complex nested objects may be incorrectly collapsed.
fix
Review output manually for unexpected formatting; consider disabling for specific files via // prettier-ignore
affects: >=0.1.0
breakingRequires Prettier >=2.0; not compatible with Prettier 1.x.
fix
Upgrade Prettier to version 2 or later.
affects: >=0.1.0
gotchaPlugin does not support ESM imports; use CommonJS require or string plugin name.
fix
Configure plugins array in .prettierrc with the package name string instead of an import.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'prettier-plugin-compactify'
Module not installed or Prettier cannot resolve it.
fix
Ensure prettier-plugin-compactify is installed as a devDependency and Prettier config is correct.
TypeError: Cannot read properties of undefined (reading 'someProperty')
Plugin might not be compatible with the installed Prettier version.
fix
Check Prettier version (>=2.x) and reinstall plugin.
Upgrade
Version history
0.1.6latest on npm
Audit
Dependencies
prettierrequiredpeer dependency required for the plugin to function
Agent activity
2 hits · last 30 days
node
2
Resources
prettier-plugin-compactify — npm install prettier-plugin-compactify · libregistry