-
-
Notifications
You must be signed in to change notification settings - Fork 569
Description
Describe the bug
When pnpm modifies pnpm-workspace.yaml, it deep sorts the keys, placing the packages property first, followed by other properties in alphabetical order:
manifest = sortKeysByPriority({
priority: { packages: 0 },
deep: true,
}, manifest)
(https://github.com/pnpm/pnpm/blob/v10.25.0/workspace/manifest-writer/src/index.ts#L15-L18)
Issuing a pnpm command that modifies pnpm-workspace.yaml, such as pnpm add to a catalog, causes the whole file to be resorted and the "antfu/pnpm/pnpm-workspace-yaml-sort" rule to be violated.
This would be prevented if the "antfu/pnpm/pnpm-workspace-yaml-sort" rule enforced the same sort order used by pnpm.
Reproduction
git clone --depth=1 https://github.com/antfu/eslint-config && cd eslint-config && pnpm add --save-dev moment && pnpm install && pnpm lint
> @antfu/eslint-config@6.6.1 lint ██████████\eslint-config
> eslint██████████\eslint-config\pnpm-workspace.yaml
1:1 error Expected mapping keys to be in specified order. 'packages' should be after 'trustPolicy' yaml/sort-keys
4:1 error Expected mapping keys to be in specified order. 'catalog' should be after 'trustPolicy' yaml/sort-keys
9:1 error Expected mapping keys to be in specified order. 'catalogs' should be after 'trustPolicy' yaml/sort-keys
94:1 error Expected mapping keys to be in specified order. 'onlyBuiltDependencies' should be after 'trustPolicy' yaml/sort-keys✖ 4 problems (4 errors, 0 warnings)
4 errors and 0 warnings potentially fixable with the--fixoption.ELIFECYCLE Command failed with exit code 1.
System Info
System:
OS: Windows 11 10.0.26200
CPU: (12) x64 AMD Ryzen 5 PRO 4650U with Radeon Graphics
Memory: 1.14 GB / 7.37 GB
Binaries:
Node: 25.2.1 - C:\Program Files\nodejs\node.EXE
npm: 11.6.2 - C:\Program Files\nodejs\npm.CMD
pnpm: 10.25.0 - C:\Users\███\AppData\Local\Microsoft\WinGet\Links\pnpm.EXE
Browsers:
Chrome: 143.0.7499.41
Edge: Chromium (140.0.3485.66)Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- The provided reproduction is a minimal reproducible of the bug.
Contributions
- I am willing to submit a PR to fix this issue
- I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)