Default Rules
June 2, 2026 ยท View on GitHub
package.json fields are sorted by the order they are listed below. The default key sort order is alphabetical.
Note: when a specific key order is used, any other keys will be sorted in the end of the object
| Key | Rules |
|---|---|
| $schema | |
| name | |
| displayName | |
| version | |
| private | |
| description | |
| categories | Unique items |
| keywords | Unique items |
| homepage | |
| bugs | Key order: url, email |
| repository | Key order: type, url |
| funding | Key order: type, url |
| license | Key order: type, url |
| qna | |
| author | Key order: name, email, url |
| maintainers | Key order (per item): name, email, url |
| contributors | Key order (per item): name, email, url |
| publisher | |
| sideEffects | |
| type | |
| imports | |
| exports | |
| main | |
| svelte | |
| umd:main | |
| jsdelivr | |
| unpkg | |
| module | |
| source | |
| jsnext:main | |
| browser | |
| react-native | |
| types | |
| typesVersions | |
| typings | |
| style | |
| example | |
| examplestyle | |
| assets | |
| bin | Key sort |
| man | |
| directories | Key order: lib, bin, man, doc, example, test |
| files | Unique items |
| workspaces | |
| binary, | Key order: module_name, module_path, remote_path, package_name, host |
| scripts | Script sort |
| betterScripts | Script sort |
| wireit | Wireit sort |
| contributes | Key sort |
| activationEvents | Unique items |
| husky | Sorts the hooks field using git hook sort |
| simple-git-hooks | Key sort using git hook sort |
| pre-commit | |
| commitlint | Key sort |
| lint-staged | |
| nano-staged | |
| config | Key sort |
| nodemonConfig | Key sort |
| browserify | Key sort |
| babel | Key sort |
| browserslist | |
| xo | Key sort |
| prettier | Prettier sort |
| eslintConfig | ESLint sort |
| eslintIgnore | |
| npmpackagejsonlint | Key sort (also recognizes: npmPackageJsonLintConfig, npmpkgjsonlint) |
| release | Key sort |
| remarkConfig | Key sort |
| stylelint | |
| ava | Key sort |
| jest | Key sort |
| mocha | Key sort |
| nyc | Key sort |
| tap | Key sort |
| oclif | Key sort (deep) |
| resolutions | Key sort |
| dependencies | Key sort |
| devDependencies | Key sort |
| dependenciesMeta | Key sort (deep) |
| peerDependencies | Key sort |
| peerDependenciesMeta | Key sort (deep) |
| optionalDependencies | Key sort |
| bundledDependencies | Sort unique items |
| bundleDependencies | Sort unique items |
| extensionPack | Sort unique items |
| extensionDependencies | Sort unique items |
| flat | |
| packageManager | |
| engines | Key sort |
| engineStrict | Key sort |
| volta | Key order: node, npm, yarn |
| languageName | |
| os | |
| cpu | |
| preferGlobal | Key sort |
| publishConfig | Key sort |
| icon | |
| badges | Key order (per item): description, url, href |
| galleryBanner | Key sort |
| preview | |
| markdown | |
| pnpm | Key sort (deep) |
Special Rules
ESLint
Fields are sorted by the order they are listed below:
| Key | Rules |
|---|---|
| env | |
| parser | |
| parserOptions | |
| settings | |
| plugins | |
| extends | |
| rules | Group built-in rules first, then plugin rules. Each group is sorted |
| overrides | Key order (per item): files, excludedFiles |
| globals | |
| processor | |
| noInlineConfig | |
| reportUnusedDisableDirectives |
Git Hooks
Item order:
applypatch-msgpre-applypatchpost-applypatchpre-commitpre-merge-commitprepare-commit-msgcommit-msgpost-commitpre-rebasepost-checkoutpost-mergepre-pushpre-receiveupdatepost-receivepost-updatepush-to-checkoutpre-auto-gcpost-rewritesendemail-validatefsmonitor-watchmanp4-pre-submitpost-index-chang
Prettier
Keys are sorted alphabetically except for overrides, which is placed last. Keys are also sorted in overrides and overrides.options items.
Wireit
Script names are sorted alphabetically. Each script's properties use the order from wireit's own examples, with remaining properties sorted alphabetically:
| Key | Rules |
|---|---|
| command | |
| dependencies | Key order (per item): script, cascade |
| files | |
| output | |
| remaining | Alphabetical, with nested object key sorting |
Scripts
Keys are sorted alphabetically except for pre/post scripts. Those are placed before and after their corresponding base npm script.
An example - notice how preinstall and postinstall are placed before and after install:
{
"scripts": {
"build": "",
"preinstall": "",
"install": "",
"postinstall": "",
"lint": ""
}
}
Scripts for which the pre/post order is applied:
- install
- pack
- prepare
- publish
- restart
- shrinkwrap
- start
- stop
- test
- uninstall
- version