A unified plugin that formats output using Prettier. Current stable version is 2.0.1, released in 2024. It integrates with remark-cli, rehype-cli, or any unified-engine based tool to automatically run Prettier on processed files. Key differentiators: it uses Prettier's configuration file by default, supports Prettier plugins, and is fully typed with TypeScript. Unlike running Prettier separately, it ensures formatting happens as part of the unified pipeline, reducing overhead. Requires Node.js >=16, Prettier ^3.0.0, and unified ^11.
npm install unified-prettierVerified import paths — ran on the pinned version, not inferred.
Shows basic usage of unified-prettier with remark to format a markdown file, including passing Prettier options.
Upgrade unified to version 11 or stay on unified-prettier 1.x.
Use Node.js 16 or later.
Use dynamic import() or switch to ESM.
No action needed, but note that asynchronous Prettier API is not used.
Ensure the vfile has a path (or set it via file.path).
Switch to import syntax, or set type: module in package.json, or downgrade to v1.x.
Run npm install prettier@^3.0.0.
Ensure vfile.path is set, or expect that the output is unchanged without formatting.
Use import unifiedPrettier from 'unified-prettier'.