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 --fix option.
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
Contributions
Describe the bug
When pnpm modifies pnpm-workspace.yaml, it deep sorts the keys, placing the
packagesproperty first, followed by other properties in alphabetical order:(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 addto 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
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
Contributions