Registry / devops / wp-prettier

wp-prettier

JSON →
library3.0.3jsnpmunverified

A fork of Prettier (opinionated code formatter) maintained by Automattic. Adds a `--paren-spacing` command line option that inserts extra spaces inside parentheses, matching the formatting style used in projects like Calypso and Gutenberg. Current stable version is 3.0.3, based on Prettier 3.x. Released on demand when new Prettier versions are rebased; versioning uses alpha/beta suffixes (e.g., 2.0.5-beta-1). Supports JavaScript, TypeScript, CSS, HTML, JSON, Markdown, YAML, GraphQL, and more. Alternative to upstream Prettier for WordPress ecosystem projects.

npm install wp-prettier
INSTALL
IMPORT
SIG · WP-PRETTIER
W
wp-prettier
devopsjavascriptv3.0.3
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

default
import prettier from 'prettier'
const prettier = require('prettier')
ESM is the primary module system for wp-prettier; CommonJS require may work but is discouraged.
format
import { format } from 'prettier'
import { format } from 'wp-prettier'
Use 'prettier' as the package name in imports, not 'wp-prettier', because you install with alias: npm i --save-dev 'prettier@npm:wp-prettier@latest'.
resolveConfig
import { resolveConfig } from 'prettier'
Available in both CJS and ESM. Returns a promise with resolved config options.
Config
import type { Config } from 'prettier'
TypeScript type import for Prettier configuration objects.
getFileInfo
import { getFileInfo } from 'prettier'
Returns metadata about how a file will be parsed; works with both sync and async usage.

Demonstrates programmatic usage of wp-prettier with the custom `parenSpacing` option to format JavaScript code with extra spaces inside parentheses.

import prettier from 'prettier'; const code = `const foo = (x) => { return x + 1; };`; const formatted = await prettier.format(code, { parser: 'babel', parenSpacing: true, singleQuote: true, trailingComma: 'all', }); console.log(formatted); // Output with parenSpacing: // const foo = ( x ) => { return x + 1; };
wp-prettier --version
Debug
Known issues
gotchaInstall via npm alias, not directly as 'wp-prettier'
fix
Run `npm i --save-dev 'prettier@npm:wp-prettier@latest'` instead of `npm i wp-prettier`.
affects: >=3.0.0
breakingv3.0 dropped support for Node.js <14
fix
Upgrade to Node.js 14 or later.
affects: >=3.0.0
deprecatedv3.0 removed some deprecated API options (e.g., `--stdin-filepath` must be `--stdin-filepath`)
fix
Update scripts to use the newer CLI syntax; review Prettier 3 migration guide.
affects: >=3.0.0
gotchaVersioning uses alpha/beta suffixes – be careful with semver ranges
fix
Use exact versions or pin to a specific release to avoid unexpected alpha/beta updates.
affects: >=2.0.0
deprecated`--paren-spacing` option is specific to wp-prettier; not available in upstream Prettier
fix
Use wp-prettier alias with `parenSpacing: true` in config or CLI flag `--paren-spacing`.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'prettier'
Package installed as 'wp-prettier' but imported as 'prettier' without npm alias.
fix
Install with alias: `npm i --save-dev 'prettier@npm:wp-prettier@latest'` and then import from 'prettier'.
Unknown option: --paren-spacing
Using upstream Prettier instead of wp-prettier.
fix
Ensure you are using the wp-prettier fork: verify package.json has `"prettier": "npm:wp-prettier@^3.0.0"`.
Error: Configuration file does not support the 'parenSpacing' option
Using a config file (e.g., .prettierrc) that includes `parenSpacing`, but the parser does not recognize it.
fix
Add `--paren-spacing` flag or set `parenSpacing: true` in config; note that it only affects JavaScript/TypeScript/JSX parsers.
Upgrade
Version history
3.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
18
Resources