docs: Add pre-commit hook with 🚫💩 lint-staged section to the README (#714)

master
Andrey Okonetchnikov 2017-02-16 02:52:03 +01:00 committed by James Long
parent 0e399f0414
commit 291871df53
1 changed files with 29 additions and 1 deletions

View File

@ -124,6 +124,34 @@ prettier --write 'src/**/*.js' 'bin/*.js'
In the future we will have better support for formatting whole projects.
#### Pre-commit hook for changed files
[🚫💩 lint-staged](https://github.com/okonet/lint-staged) can re-format your files that are marked as "staged" via `git add` before you commit.
Install it along with [pre-commit](https://github.com/observing/pre-commit) (or [husky](https://github.com/typicode/husky)):
```bash
npm install --save-dev lint-staged pre-commit
```
and add this config to your `package.json`:
```json
{
"scripts": {
"lint:staged": "lint-staged"
},
"lint-staged": {
"*.js": [
"prettier --write",
"git add"
]
},
"pre-commit": "lint:staged"
}
```
### API
The API is a single function exported as `format`. The options
@ -206,7 +234,7 @@ Install the [JavaScript Prettier extension](https://github.com/madskristensen/Ja
### Sublime Text
Sublime Text support is available through Package Control and
Sublime Text support is available through Package Control and
the [JsPrettier](https://packagecontrol.io/packages/JsPrettier) plug-in.
### JetBrains