New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prettier-package-json

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-package-json - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

2

package.json

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "1.3.0",
"version": "1.3.1",
"main": "src/index.js",

@@ -9,0 +9,0 @@ "bin": {

@@ -5,2 +5,140 @@ # Prettier `package.json`

## Features
### Consistent key order
Keys in `package.json` will be sorted in an [opinionated order](src/defaultOptions.js) but may be configured to your own preferences.
Input:
```json
{
"description": "Prettier formatter for package.json files",
"name": "prettier-package-json",
"license": "MIT",
"version": "1.0.1",
"author": "Cameron Hunter <hello@cameronhunter.co.uk>"
}
```
Output:
```json
{
"name": "prettier-package-json",
"description": "Prettier formatter for package.json files",
"author": "Cameron Hunter <hello@cameronhunter.co.uk>",
"license": "MIT",
"version": "1.0.1"
}
```
### Sensibly sorted scripts
The `scripts` field is sorted alphabetically but keeps `pre` and `post` scripts surrounding their named script.
Input:
```json
{
"name": "prettier-package-json",
"version": "1.0.1",
"scripts": {
"test": "test",
"pretest": "pretest",
"version": "version",
"postversion": "postversion",
"build": "build"
}
}
```
Output:
```json
{
"name": "prettier-package-json",
"version": "1.0.1",
"scripts": {
"build": "build",
"pretest": "pretest",
"test": "test",
"version": "version",
"postversion": "postversion"
}
}
```
### Expand/contract author, contributors, and maintainers
The `author`, `contributors` and `maintainers` fields will be shortened to their string versions and sorted by name. Use
the `--expand-users` option if you prefer user objects.
Input:
```json
{
"name": "prettier-package-json",
"version": "1.0.1",
"author": {
"name": "Cameron Hunter",
"email": "hello@cameronhunter.co.uk",
"url": "https://cameronhunter.co.uk"
},
"contributors": [
"Barry",
"Adam <adam@email.com>"
]
}
```
Output:
```json
{
"name": "prettier-package-json",
"version": "1.0.1",
"author": "Cameron Hunter <hello@cameronhunter.co.uk> (https://cameronhunter.co.uk)",
"contributors": [
"Adam <adam@email.com>",
"Barry"
]
}
```
### Filter and sort files field
Some files are included or excluded automatically by `npm`, these are removed from the `files` field before sorting
alphabetically.
Input:
```json
{
"name": "prettier-package-json",
"version": "1.0.1",
"main": "src/index.js",
"files": [
"src/index.js",
"src",
"CHANGELOG.md",
"readme.md",
"package-lock.json"
]
}
```
Output:
```json
{
"name": "prettier-package-json",
"version": "1.0.1",
"main": "src/index.js",
"files": [
"src"
]
}
```
## Usage

@@ -7,0 +145,0 @@

@@ -14,2 +14,3 @@ module.exports = Object.freeze({

'contributors',
'maintainers',
'license',

@@ -16,0 +17,0 @@ 'homepage',

@@ -5,3 +5,3 @@

const sortScripts = require('./sort-scripts');
const sortContributors = require('./sort-contributors');
const sortUsers = require('./sort-contributors');
const sortFiles = require('./sort-files');

@@ -20,4 +20,5 @@

packageJson,
sortContributors('author', packageJson, opts),
sortContributors('contributors', packageJson, opts),
sortUsers('author', packageJson, opts),
sortUsers('contributors', packageJson, opts),
sortUsers('maintainers', packageJson, opts),
sort('man', packageJson),

@@ -24,0 +25,0 @@ sort('bin', packageJson),

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc