changesets / changesets

🦋 A way to manage your versioning and changelogs with a focus on monorepos
MIT License
8.36k stars 507 forks source link

changeset version does not respect prettier config since prettier 3.1.1 #1350

Closed TheHolyWaffle closed 1 month ago

TheHolyWaffle commented 2 months ago

Affected Packages

apply-release-plan

Problem

When having prettier version 3.1.1 or higher installed. It will not respect the prettier configuration when running changeset version.

This results in CHANGELOG.md files being created with invalid formatting, resulting in broken CI checks on formatting.

The problem happens at this line: https://github.com/changesets/changesets/blob/0bf89b3709e3e3df6ed5dbb8ece0fb000a55d5f4/packages/apply-release-plan/src/index.ts#L136

prettierConfig is null even though a .prettierrc file is present.

This is caused by changes introduced in 3.1.1 to how .prettierrc config is found. See changelog notes: https://github.com/prettier/prettier/blob/main/CHANGELOG.md#311

Proposed solution

Changing it to this fixes the prettier config resolving:

let prettierConfig = await prettierInstance.resolveConfig(cwd + '/package.json');
TheHolyWaffle commented 1 month ago

(Workaround for now is to run prettier --write . after using changeset version)