Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shellscape/prettier-plugin-package
An opinionated package.json formatter plugin for Prettier
https://github.com/shellscape/prettier-plugin-package
Last synced: 15 days ago
JSON representation
An opinionated package.json formatter plugin for Prettier
- Host: GitHub
- URL: https://github.com/shellscape/prettier-plugin-package
- Owner: shellscape
- License: mpl-2.0
- Created: 2019-09-05T02:00:16.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-11T04:05:29.000Z (10 months ago)
- Last Synced: 2024-10-19T10:04:27.027Z (22 days ago)
- Language: JavaScript
- Size: 489 KB
- Stars: 87
- Watchers: 5
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/funding.yml
- License: LICENSE
Awesome Lists containing this project
- awesome - prettier-plugin-package - An opinionated package.json formatter plugin for Prettier (JavaScript)
README
[tests]: https://img.shields.io/circleci/project/github/shellscape/prettier-plugin-package.svg
[tests-url]: https://circleci.com/gh/shellscape/prettier-plugin-package[cover]: https://codecov.io/gh/shellscape/prettier-plugin-package/branch/master/graph/badge.svg
[cover-url]: https://codecov.io/gh/shellscape/prettier-plugin-package[size]: https://packagephobia.now.sh/badge?p=prettier-plugin-package
[size-url]: https://packagephobia.now.sh/result?p=prettier-plugin-package![banner](https://raw.githubusercontent.com/shellscape/prettier-plugin-package/master/assets/banner.svg?sanitize=true)
# prettier-plugin-package [![tests][tests]][tests-url] [![cover][cover]][cover-url] [![size][size]][size-url] [![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)
An opinionated `package.json` formatter plugin for [Prettier](https://prettier.io)
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](https://github.com/nodejs/Release) Node version (v8.0.0+), and `prettier` v2.0.0+.
For Prettier v1.x support, please use `[email protected]`.
## Install
Using npm:
```console
npm install prettier prettier-plugin-package --save-dev
```_Please consider donating if you find this project useful._
## Usage
Once installed, [Prettier plugins](https://prettier.io/docs/en/plugins.html) should be automatically recognized by Prettier. To use this plugin, confirm that it's installed and run Prettier using your preferred method. For example:
```console
$ 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](https://github.com/sindresorhus). Known keys, and their order are:
```js
[
// 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](./.github/CONTRIBUTING.md)
[LICENSE (Mozilla Public License)](./LICENSE)