docs: Add pre-commit hook with 🚫💩 lint-staged section to the README (#714)
parent
0e399f0414
commit
291871df53
30
README.md
30
README.md
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue