Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for volta #257

Merged
merged 1 commit into from May 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions defaultRules.md
Expand Up @@ -92,6 +92,7 @@ _Note: when a specific key order is used, any other keys will be sorted in the e
| packageManager | |
| engines | Key sort |
| engineStrict | Key sort |
| volta | Key order: `node`, `npm`, `yarn` |
| languageName | |
| os | |
| cpu | |
Expand Down
3 changes: 3 additions & 0 deletions index.js
Expand Up @@ -124,6 +124,8 @@ const sortPrettierConfig = onObject(
]),
)

const sortVolta = sortObjectBy(['node', 'npm', 'yarn'])

// See https://docs.npmjs.com/misc/scripts
const defaultNpmScripts = new Set([
'install',
Expand Down Expand Up @@ -290,6 +292,7 @@ const fields = [
{ key: 'packageManager' },
{ key: 'engines', over: sortObject },
{ key: 'engineStrict', over: sortObject },
{ key: 'volta', over: sortVolta },
{ key: 'languageName' },
{ key: 'os' },
{ key: 'cpu' },
Expand Down
14 changes: 14 additions & 0 deletions tests/fields.js
Expand Up @@ -186,6 +186,20 @@ test('directories', macro.sortObject, {
},
})

test('volta', macro.sortObject, {
path: 'volta',
value: {
yarn: '0.0.0',
npm: '0.0.0',
node: '0.0.0',
},
expect: {
node: '0.0.0',
npm: '0.0.0',
yarn: '0.0.0',
},
})

test('contributors', (t) => {
const contributors = {
contributors: [
Expand Down
2 changes: 2 additions & 0 deletions tests/snapshots/main.js.md
Expand Up @@ -107,6 +107,7 @@ Generated by [AVA](https://avajs.dev).
"umd:main": "umd:main",␊
"unpkg": "unpkg",␊
"version": "version",␊
"volta": "volta",␊
"workspaces": "workspaces",␊
"xo": "xo"␊
}`,
Expand Down Expand Up @@ -201,6 +202,7 @@ Generated by [AVA](https://avajs.dev).
"packageManager": "packageManager",␊
"engines": "engines",␊
"engineStrict": "engineStrict",␊
"volta": "volta",␊
"languageName": "languageName",␊
"os": "os",␊
"cpu": "cpu",␊
Expand Down
Binary file modified tests/snapshots/main.js.snap
Binary file not shown.