Registry / devops / zprint-clj

zprint-clj

JSON →
library0.8.0jsnpmunverified

zprint-clj v0.8.0 is a Node.js wrapper for ZPrint, a powerful Clojure source code formatter. It provides a CLI and programmatic API to format .clj, .cljs, .cljc, and .edn files. The wrapper leverages the ZPrint Clojure core and offers features like hang mode for better formatting output. It is released with moderate cadence under the MIT license. Key differentiators include native integration with npm workflows, CLI support for formatting and check modes, and configuration via .zprintrc EDN files.

npm install zprint-clj
INSTALL
IMPORT
SIG · ZPRINT-CLJ
Z
zprint-clj
devopsjavascriptv0.8.0
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.

format
const format = require('zprint-clj');
import format from 'zprint-clj';
The package is CommonJS and does not support ESM named exports. The main export is a function that takes (text, path, opts).
zprint-clj
const zp = require('zprint-clj'); const formatted = zp(input, filePath, opts);
const { format } = require('zprint-clj');
The default export is the format function itself; destructuring will not work.
cli
./node_modules/.bin/zprint-clj -i "src/**/*.clj" -o ./
zprint-clj -i src/**/*.clj -o ./
Glob patterns must be quoted to avoid shell expansion. The CLI is the only way to format multiple files.

Shows how to use the zprint-clj API to format a Clojure file programmatically with hang mode enabled.

// Install: npm i zprint-clj const format = require('zprint-clj'); const fs = require('fs'); const path = require('path'); const input = fs.readFileSync('example.clj', 'utf8'); const filePath = 'example.clj'; const opts = { isHangEnabled: true }; const output = format(input, filePath, opts); console.log(output);
Debug
Known issues
breakingThe default export changed from an object to a function in v0.7.0. Previously require('zprint-clj') returned an object with a format method.
fix
Update to const format = require('zprint-clj'); and call format(text, path, opts) instead of zp.format(...).
affects: <0.7.0
gotchaGlob patterns passed to CLI must be quoted to prevent shell expansion.
fix
Use double quotes: zprint-clj -i "./src/**/*.clj" -o ./
affects: >=0.0.0
gotchaThe API function expects the file path as second argument; omitting it or passing a wrong path may lead to incorrect formatting or errors.
fix
Always provide the absolute or relative path to the file being formatted.
affects: >=0.0.0
deprecatedUsing the .zprintrc file in the home directory is deprecated; prefer placing it in the project root.
fix
Create .zprintrc in the same directory where zprint-cli is run.
affects: >=0.6.0
gotchaHang mode (isHangEnabled) significantly slows down formatting; it is off by default.
fix
Only enable when needed; for large files it may cause noticeable delay.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'zprint-clj'
Package not installed or installed globally while trying to require locally.
fix
Run 'npm install zprint-clj' in your project directory.
TypeError: format is not a function
Using destructured require or importing as ESM default.
fix
Use 'const format = require('zprint-clj');' (no destructuring).
zprint-clj: No files matched "src/**/*.clj"
Glob not quoted or no files match pattern.
fix
Use double quotes around the glob and verify file paths exist.
Upgrade
Version history
0.8.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
37 hits · last 30 days
node
32
Resources