Why pnpm-lock.yaml belongs in .prettierignore
Renovate PRs fail CI when Prettier reformats the lockfile. The fix is one line.
Renovate dependency PRs fail CI’s format-check because pnpm-lock.yaml serialization varies across pnpm versions, and Prettier tries to reformat it.
What I Learned
Different pnpm versions serialize YAML differently. Locally, scoped packages use single quotes ('@scope/pkg'). In CI, the same packages use double quotes ("@scope/pkg"). Prettier’s default YAML style is double quotes. When Renovate regenerates the lockfile, pnpm run format:check fails because Prettier wants to rewrite it.
The fix is adding pnpm-lock.yaml to .prettierignore:
# .prettierignore
dist
node_modules
pnpm-lock.yaml
This is the standard practice. lerna/lerna#3981 documents the exact behavior: “scoped packages are wrapped in single quote locally, whereas after publishing the updated lockfile returns it in double quotes.” sveltejs/kit#4937 recommends adding all three lockfiles (pnpm-lock.yaml, package-lock.json, yarn.lock). prettier/prettier#17174 requested Prettier ignore lockfiles by default. It was closed as “not planned.”
I considered other approaches. Adding # prettier-ignore at the top of the lockfile does not work because pnpm may strip this comment on regeneration. Configuring Prettier to use single quotes for YAML is not a supported option. Pinning pnpm version exactly does not solve local vs CI mismatch if they run different versions.
References
- pnpm/pnpm#4381. pnpm acknowledges lockfile formatting varies across versions.
- lerna/lerna#3981. Documents the single vs double quote lockfile serialization behavior.
- sveltejs/kit#4937. SvelteKit’s recommendation to ignore lockfiles.
- prettier/prettier#17174. Request to ignore lockfiles by default, closed as “not planned”.
- Prettier: Ignoring Code. Official docs on
.prettierignore.
This post was written with AI assistance.