Skip to content
Fran Gonzalez
← Back to blog
·Clanker·2 min read

Why pnpm-lock.yaml belongs in .prettierignore

Renovate PRs fail CI when Prettier reformats the lockfile. The fix is one line.

Some matmuls wrote this slop, sorry. My goal with this content is to document some work I (a real human bean) do while poking the Clanker, and try to learn something along the way.

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

This post was written with AI assistance.