{"id":20871,"library":"wp-prettier","title":"wp-prettier","description":"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.","status":"active","version":"3.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/prettier/prettier","tags":["javascript","typescript"],"install":[{"cmd":"npm install wp-prettier","lang":"bash","label":"npm"},{"cmd":"yarn add wp-prettier","lang":"bash","label":"yarn"},{"cmd":"pnpm add wp-prettier","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM is the primary module system for wp-prettier; CommonJS require may work but is discouraged.","wrong":"const prettier = require('prettier')","symbol":"default","correct":"import prettier from 'prettier'"},{"note":"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'.","wrong":"import { format } from 'wp-prettier'","symbol":"format","correct":"import { format } from 'prettier'"},{"note":"Available in both CJS and ESM. Returns a promise with resolved config options.","wrong":null,"symbol":"resolveConfig","correct":"import { resolveConfig } from 'prettier'"},{"note":"TypeScript type import for Prettier configuration objects.","wrong":null,"symbol":"Config","correct":"import type { Config } from 'prettier'"},{"note":"Returns metadata about how a file will be parsed; works with both sync and async usage.","wrong":null,"symbol":"getFileInfo","correct":"import { getFileInfo } from 'prettier'"}],"quickstart":{"code":"import prettier from 'prettier';\n\nconst code = `const foo = (x) => { return x + 1; };`;\n\nconst formatted = await prettier.format(code, {\n  parser: 'babel',\n  parenSpacing: true,\n  singleQuote: true,\n  trailingComma: 'all',\n});\n\nconsole.log(formatted);\n// Output with parenSpacing:\n// const foo = ( x ) => { return x + 1; };","lang":"typescript","description":"Demonstrates programmatic usage of wp-prettier with the custom `parenSpacing` option to format JavaScript code with extra spaces inside parentheses."},"warnings":[{"fix":"Run `npm i --save-dev 'prettier@npm:wp-prettier@latest'` instead of `npm i wp-prettier`.","message":"Install via npm alias, not directly as 'wp-prettier'","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Upgrade to Node.js 14 or later.","message":"v3.0 dropped support for Node.js <14","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update scripts to use the newer CLI syntax; review Prettier 3 migration guide.","message":"v3.0 removed some deprecated API options (e.g., `--stdin-filepath` must be `--stdin-filepath`)","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Use exact versions or pin to a specific release to avoid unexpected alpha/beta updates.","message":"Versioning uses alpha/beta suffixes – be careful with semver ranges","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use wp-prettier alias with `parenSpacing: true` in config or CLI flag `--paren-spacing`.","message":"`--paren-spacing` option is specific to wp-prettier; not available in upstream Prettier","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install with alias: `npm i --save-dev 'prettier@npm:wp-prettier@latest'` and then import from 'prettier'.","cause":"Package installed as 'wp-prettier' but imported as 'prettier' without npm alias.","error":"Cannot find module 'prettier'"},{"fix":"Ensure you are using the wp-prettier fork: verify package.json has `\"prettier\": \"npm:wp-prettier@^3.0.0\"`.","cause":"Using upstream Prettier instead of wp-prettier.","error":"Unknown option: --paren-spacing"},{"fix":"Add `--paren-spacing` flag or set `parenSpacing: true` in config; note that it only affects JavaScript/TypeScript/JSX parsers.","cause":"Using a config file (e.g., .prettierrc) that includes `parenSpacing`, but the parser does not recognize it.","error":"Error: Configuration file does not support the 'parenSpacing' option"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}