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