@two-admin/prettier v0.0.5
@two-admin/prettier
Using the package
Installation
$ npm install --save-dev @two-admin/prettier
This will install the prettier and
onchange packages, as well as a .prettierrc.js
file,
containing the standard TWO configuration.
Scripts
Add the following scripts your package.json
.
"prettier": "prettier --write .",
"prettier:watch": "onchange \".\" -- prettier --write --ignore-unknown {{changed}}"
.
will format all files in the project. You can replace it to target a specific set of
files/directories. You can learn more about the required format
here.
Configuration
Import the standard TWO prettier configuration by adding the following line to your package.json
:
"prettier": "@two-admin/prettier"
Ignoring
By default, prettier will ignore the following:
**/.git
**/.svn
**/.hg
**/node_modules
You might want to create a .prettierignore
in your project root to ignore more files/directories.
This file uses the same patterns as a .gitignore
. Here's an example of what yours could look like:
tsconfig.json
vendor
dist
If you are using a .prettierignore
, you can pass the argument --exclude-path .prettierignore
to
onchange
in the prettier:watch
script, so that onchange won't be pointlessly triggered when
files that won't be formatted by prettier are saved:
"prettier:watch": "onchange \".\" --exclude-path .prettierignore -- prettier --write --ignore-unknown {{changed}}"
Developing the package
Formatting
You can use npm run prettier
to format files once and npm run prettier:watch
to format on save.
Publishing a new version to the NPM registry
Ensure you are logged in to the two-admin
NPM account via the command line:
$ npm login
Increment the version
property found in package.json
.
{
"name": "@two-admin/prettier",
"version": "0.0.1", // would likely become "0.0.2"
...
}
Publish the package:
$ npm run publish
Add a git tag, referencing the version:
$ git tag 0.0.2
$ git push --tags