diff --git a/README.md b/README.md index b82b415..e5750f8 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,7 @@ console.log(Object.keys(sorted)) - [node-pre-gyp](https://github.com/mapbox/node-pre-gyp) - [npm-package-json-lint](https://npmpackagejsonlint.org/) - [oclif](https://oclif.io/) +- [pnpm](https://pnpm.io/) - [Prettier](https://prettier.io/) - [remark](https://remark.js.org/) - [semantic-release](https://github.com/semantic-release/semantic-release) @@ -409,6 +410,7 @@ The default order is exported as a `sortOrder` object. 1. `galleryBanner` 1. `preview` 1. `markdown` +1. `pnpm` diff --git a/defaultRules.md b/defaultRules.md index 234be5d..970a7df 100644 --- a/defaultRules.md +++ b/defaultRules.md @@ -106,6 +106,7 @@ _Note: when a specific key order is used, any other keys will be sorted in the e | galleryBanner | Key sort | | preview | | | markdown | | +| pnpm | Key sort (deep) | ## Special Rules diff --git a/index.js b/index.js index 0aa2a9f..2558022 100755 --- a/index.js +++ b/index.js @@ -312,6 +312,7 @@ const fields = [ /* vscode */ { key: 'galleryBanner', over: sortObject }, /* vscode */ { key: 'preview' }, /* vscode */ { key: 'markdown' }, + { key: 'pnpm', over: sortObjectBy(undefined, true) }, ] const defaultSortOrder = fields.map(({ key }) => key) diff --git a/tests/fields.js b/tests/fields.js index c9d569f..bc6bc1b 100644 --- a/tests/fields.js +++ b/tests/fields.js @@ -258,3 +258,57 @@ test('badges', (t) => { 'Should sort `badges[]`', ) }) + +test('pnpm', macro.sortObject, { + path: 'pnpm', + value: { + overrides: { + 'aws-sdk@1.2345.0': '1.123.0', + 'react-native-notifications@^3.4.5': '3.4.5', + 'antd@^2.23.4': '2.23.4', + }, + patchedDependencies: { + 'esbuild-sass-plugin@1.20.0': 'foo.patch', + 'domino@4.5.6': 'bar.patch', + 'es5-ext@0.12.3': 'baz.patch', + }, + packageExtensions: { + '@rjsf/core': { + dependencies: { + tslib: '*', + }, + }, + 'follow-redirects': { + dependencies: { + debug: '4.3.4', + }, + }, + }, + allowNonAppliedPatches: true, + }, + expect: { + allowNonAppliedPatches: true, + overrides: { + 'antd@^2.23.4': '2.23.4', + 'aws-sdk@1.2345.0': '1.123.0', + 'react-native-notifications@^3.4.5': '3.4.5', + }, + packageExtensions: { + '@rjsf/core': { + dependencies: { + tslib: '*', + }, + }, + 'follow-redirects': { + dependencies: { + debug: '4.3.4', + }, + }, + }, + patchedDependencies: { + 'domino@4.5.6': 'bar.patch', + 'es5-ext@0.12.3': 'baz.patch', + 'esbuild-sass-plugin@1.20.0': 'foo.patch', + }, + }, +}) diff --git a/tests/snapshots/cli.js.snap b/tests/snapshots/cli.js.snap index 0433670..87200f1 100644 Binary files a/tests/snapshots/cli.js.snap and b/tests/snapshots/cli.js.snap differ diff --git a/tests/snapshots/deps.js.snap b/tests/snapshots/deps.js.snap index 366d861..4d621cf 100644 Binary files a/tests/snapshots/deps.js.snap and b/tests/snapshots/deps.js.snap differ diff --git a/tests/snapshots/eslint.js.snap b/tests/snapshots/eslint.js.snap index 4ecd658..4d7a898 100644 Binary files a/tests/snapshots/eslint.js.snap and b/tests/snapshots/eslint.js.snap differ diff --git a/tests/snapshots/fields.js.snap b/tests/snapshots/fields.js.snap index 1f4b8d8..7c58082 100644 Binary files a/tests/snapshots/fields.js.snap and b/tests/snapshots/fields.js.snap differ diff --git a/tests/snapshots/main.js.md b/tests/snapshots/main.js.md index d9dd5e1..5174023 100644 --- a/tests/snapshots/main.js.md +++ b/tests/snapshots/main.js.md @@ -84,6 +84,7 @@ Generated by [AVA](https://avajs.dev). "packageManager": "packageManager",␊ "peerDependencies": "peerDependencies",␊ "peerDependenciesMeta": "peerDependenciesMeta",␊ + "pnpm": "pnpm",␊ "pre-commit": "pre-commit",␊ "preferGlobal": "preferGlobal",␊ "prettier": "prettier",␊ @@ -222,7 +223,8 @@ Generated by [AVA](https://avajs.dev). "badges": "badges",␊ "galleryBanner": "galleryBanner",␊ "preview": "preview",␊ - "markdown": "markdown"␊ + "markdown": "markdown",␊ + "pnpm": "pnpm"␊ }`, pretty: true, } diff --git a/tests/snapshots/main.js.snap b/tests/snapshots/main.js.snap index 59217ec..99888a0 100644 Binary files a/tests/snapshots/main.js.snap and b/tests/snapshots/main.js.snap differ diff --git a/tests/snapshots/prettier.js.snap b/tests/snapshots/prettier.js.snap index 7ae48bc..4561efa 100644 Binary files a/tests/snapshots/prettier.js.snap and b/tests/snapshots/prettier.js.snap differ