prettier-plugin-package

1.4.0last stable release 1 year ago
Complexity Score
Low
Open Issues
2
Dependent Projects
86
Weekly Downloadsglobal
30,166

License

  • MPL-2.0
    • Yesattribution
    • Permissivelinking
    • Copyleftdistribution
    • Copyleftmodification
    • Yespatent grant
    • Yesprivate use
    • Copyleftsublicensing
    • Notrademark grant

Downloads

Readme

[tests]: https://img.shields.io/circleci/project/github/shellscape/prettier-plugin-package.svg [tests-url]: https://circleci.com/gh/shellscape/prettier-plugin-package

prettier-plugin-package [![tests][tests]][tests-url]

An opinionated package.json formatter plugin for Prettier

Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing, taking various rules into account.

This plugin adds support for package.json files used within NPM modules.

Requirements

prettier-plugin-package is an evergreen module. 🌲 This module requires an LTS Node version (v8.0.0+), and prettier v2.0.0+.

For Prettier v1.x support, please use prettier-plugin-package@0.3.1.

Install

Using npm:

npm install prettier prettier-plugin-package --save-dev

Please consider donating if you find this project useful.

Usage

Once installed, Prettier plugins should be automatically recognized by Prettier. To use this plugin, confirm that it’s installed and run Prettier using your preferred method. For example:

$ npx prettier --write package.json

Rules

This plugin enforces its own set of opinionated rules:

Engines

Keys in engines are ordered alphabetically.

Files

Keys in files are ordered alphabetically (keeping the negations below), followed by README.md and LICENSE if they exist in the array.

Scripts

Keys in scripts are ordered alphabetically. Use prefixes wisely to properly order child scripts. e.g. lint, lint:ts.

Sorting

Top-level keys are sorted according to a style commonly seen in the packages of @sindresorhus. Known keys, and their order are:

[
  // meta
  'name',
  'version',
  'flat',
  'private',
  'publishConfig',
  'description',
  'license',
  'repository',
  'author',
  'homepage',
  'bugs',

  // entry
  'main',
  'bin',
  'module',
  'type',
  'exports',

  // constraints
  'engines',
  'cpu',
  'os',

  // content and util
  'scripts',
  'files',
  'keywords',

  // dependencies
  'bundledDependencies',
  'optionalDependencies',
  'peerDependencies',
  'peerDependenciesMeta',
  'dependencies',
  'devDependencies',
  'resolutions',

  // types
  'types',
  'typings'
]

Unknown keys, or keys not part of the list above, will be alphabetically sorted and added to the end of the file. Note that this list takes into account both npm and yarn keys.

Forthcoming

Forthcoming rules include:

  • Author format
  • Repository format

Meta

CONTRIBUTING

LICENSE (Mozilla Public License)

Dependencies

No runtime dependency information found for this package.

CVE IssuesActive
0
Scorecards Score
2.30
Test Coverage
100.00%
Follows Semver
Yes
Github Stars
87
Dependenciestotal
0
DependenciesOutdated
0
DependenciesDeprecated
0
Threat Modelling
No
Repo Audits
No

Learn how to distribute prettier-plugin-package in your own private NPM registry

npm config set registry  https://npm.cloudsmith.com/owner/repo
Processing...
Done
npm install prettier-plugin-package
Processing...
Done

12 Releases

NPM on Cloudsmith

Getting started with NPM on Cloudsmith is fast and easy.