v2.1.0
An opinionated formatter for package.json files
Repository
Current version released
5 years ago
Versions
nice-package-json
An opinionated formatter for
package.jsonfiles
Installation
$ deno install --allow-{read,write} -n nice-package-json \
https://deno.land/x/nice_package_json/cli.tsUsage
Print a formatted package.json file from the current working directory:
$ nice-package-jsonFormat and overwrite the package.json in the current working directory:
$ nice-package-json --writeOr format a file named something other than package.json:
$ nice-package-json --write pkg.jsonCompare with the current package.json file:
$ nice-package-json | diff package.json -Format each package.json in a Yarn-managed monorepo:
$ yarn workspaces run nice-package-json --writeProgrammatically
import nicePackageJson from "https://deno.land/x/nice_package_json/mod.ts";
const contents = Deno.readTextFileSync("./package.json");
const json = JSON.parse(contents);
Deno.writeTextFileSync("./package.json", nicePackageJson(json));Formatting
- 2-space indent
- Dependencies are always alphabetized
- Keys will be sorted into the following order:
nameprivateversiondescriptionkeywordsenginestypebrowsermainmodulesveltebinfileshomepagebugsrepositoryauthorcontributorslicensescriptsdependenciesdevDependenciesbundledDependenciesoptionalDependenciespeerDependenciespublishConfigconfigworkspaces- Everything else, sorted alphabetically (e.g.
eslintConfig,jest, etc.)
- Values of the following keys will be sorted alphabetically:
contributors(bynameor value)engines(by key)fileskeywordspublishConfig(by key)repository(by key)scripts(by key)