1.6.1 • Published 3 years ago

nice-package-json v1.6.1

Weekly downloads
23
License
MIT
Repository
github
Last release
3 years ago

nice-package-json

Build Status

An opinionated formatter for package.json files

Usage

Print a formatted package.json file from the current working directory:

$ npx nice-package-json

Format and overwrite the package.json in the current working directory:

$ npx nice-package-json --write

Or format a file named something other than package.json:

$ npx nice-package-json --write pkg.json

Compare with the current package.json file:

$ npx nice-package-json | diff package.json -

Format each package.json in a Yarn-managed monorepo:

$ yarn add -DW nice-package-json # only run once
$ yarn workspaces run nice-package-json --write

Programmatically

const nicePkg = require("nice-package-json");
const pkg = require("./package.json");
await fs.writeFile("package.json", nicePackageJson(pkg));

Formatting

  • 2-space indent
  • Dependencies are always alphabetized
  • Keys will be sorted into the following order:
    • name
    • private
    • version
    • description
    • keywords
    • engines
    • type
    • browser
    • main
    • module
    • svelte
    • bin
    • files
    • homepage
    • bugs
    • repository
    • author
    • contributors
    • license
    • scripts
    • dependencies
    • devDependencies
    • bundledDependencies
    • optionalDependencies
    • peerDependencies
    • publishConfig
    • config
    • workspaces
    • Everything else, sorted alphabetically (e.g. eslintConfig, jest, etc.)
  • Values of the following keys will be sorted alphabetically:
    • contributors (by name or value)
    • engines (by key)
    • files
    • keywords
    • publishConfig (by key)
    • repository (by key)
    • scripts (by key)
1.6.1

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago