This section documents version-specific API changes — prioritize recent major/minor releases.
-
BREAKING: parser inference for tsconfig.json — now uses "json" instead of "jsonc" by default since v3.2.5, adding trailing commas. Override with overrides in .prettierrc if you need the old "jsonc" parser source
-
NEW: Plugin type definitions for printers export — v3.8.1 added explicit types for Printer objects accessed via prettier/plugins/* imports, replacing any types source
-
BREAKING: module-sync condition removed from package.json — v3.5.2 removed this export condition; require("prettier") now uses CommonJS version exclusively. ESM-only plugins no longer work via require() source
-
NEW: "Import Attributes" syntax support — v3.1.1 added support for TypeScript 5.3 import attributes: import x from "./x.json" with { type: "json" } source
-
BREAKING: prettier.getFileInfo() internal refactor — v3.7.3 fixed a regression that broke VSCode plugin loading when calling this API source
-
NEW: Plugin type definition for printer.preprocess — v3.0.1 added missing Printer.preprocess?: (ast, options) => T | Promise<T> type, required for AST preprocessing in custom plugins source
-
NEW: Plugin type definition for printer.getVisitorKeys() — v3.0.1 added explicit method signature to support custom AST traversal source
-
NEW: Improved typing for AstPath.map() — v3.0.1 added proper readonly array support to AstPath type parameter signatures, fixing TypeScript strictness source
-
NEW: Support for Angular v18 @let declaration — v3.3.3 added template variable syntax: @let name = 'Frodo'; source
-
NEW: CLI option --no-error-on-unmatched-pattern — v3.1.1 allows skipping symbolic links without throwing errors source
-
FIXED: cursorOffset option compatibility — v3.1.1 clarified in docs that cursorOffset is compatible with rangeStart/rangeEnd (was incorrectly documented as incompatible) source
-
NEW: Support TypeScript 5.2 using / await using declarations — v3.0.3 added explicit resource management: using foo = new Foo(); source
-
NEW: Support TypeScript 5.0 const type parameters — v2.8.5 added support for const modifiers in generics source
-
NEW: Support TypeScript 5.0 export type * declarations — v2.8.5 added type-only re-export syntax source
-
NEW: Angular v21.2 support with @default never; — v3.8.2 added exhaustive switch checking syntax in Angular templates source
-
FIXED: Plugin type export for plugins/estree.d.ts — v3.0.1 added export {} to make it a proper module, fixing TypeScript "File is not a module" error source
-
Prefer asynchronous APIs over synchronous ones — the main Prettier entry points are async for a reason, and @prettier/sync should only be used when synchronous operation is unavoidable source
-
Use formatWithCursor in editor integrations to preserve cursor position across formatting operations — translates unformatted cursor positions to formatted ones, preventing jarring jumps source
-
Resolve config dynamically with resolveConfig(filePath) before formatting — reads the config tree from the file's directory upward, enabling per-directory configuration rules source
-
Use getFileInfo(filePath) to check if a file is ignored and which parser applies before attempting to format — prevents wasted processing on excluded files and reveals parser mismatches source
-
Never place parser at the top level of configuration — only use it inside overrides blocks; top-level parser disables automatic file-extension inference for all files source
-
Use overrides to apply different formatting rules based on file patterns, extensions, or directories — allows Prettier to enforce different styles for different parts of the codebase without multiple configs source
-
Import the Config type with type-only syntax in .prettierrc.ts: import { type Config } not import { Config } — type-only imports are erased at runtime, preventing module resolution errors source
-
Declare plugins both in the plugins array and as dependencies in package.json when building shareable configs — ensures plugins are installed alongside the shared config and available to all consuming projects source
-
Use eslint-config-prettier to disable ESLint's conflicting stylistic rules — this is the recommended approach to coexist Prettier and ESLint without tool conflicts source
-
Avoid eslint-plugin-prettier and similar "run Prettier as a linter rule" plugins — slower than running Prettier directly, creates distracting editor squiggles, and adds unnecessary indirection source
-
Use --ignore-unknown flag when watching files with onchange or similar tools — skips processing files Prettier doesn't recognize, reducing unnecessary overhead source
-
Pin Prettier to an exact version in CI/CD pipelines — ensures all developers and CI systems format code identically, preventing formatting drift and CI failures source
-
Understand that printWidth is a guide, not a hard limit — it specifies the preferred line length for readability, not a maximum like ESLint's max-len; Prettier will make both shorter and longer lines to optimize formatting source
-
Enable EditorConfig integration for cross-tool compatibility — Prettier reads .editorconfig files and converts them to Prettier config, allowing teams to use a single source of truth for indent style and width source