Include pre-commit plugin (#1493)
* Update README.md * Update README.md * Update README.md * Update README.md
This commit is contained in:
1 parent
ed24bff251
commit
c2bdcbe996
1 file changed
+22
-1
@@ -158,7 +158,9 @@ 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.
|
||||
You can use this with a pre-commit tool. This can re-format your files that are marked as "staged" via `git add` before you commit.
|
||||
|
||||
##### 1. [lint-staged](https://github.com/okonet/lint-staged)
|
||||
|
||||
Install it along with [husky](https://github.com/typicode/husky):
|
||||
|
||||
@@ -184,6 +186,25 @@ and add this config to your `package.json`:
|
||||
|
||||
See https://github.com/okonet/lint-staged#configuration for more details about how you can configure lint-staged.
|
||||
|
||||
|
||||
##### 2. [pre-commit](https://github.com/pre-commit/pre-commit)
|
||||
|
||||
Just copy the following config in your pre-commit config yaml file
|
||||
|
||||
```yaml
|
||||
|
||||
- repo: https://github.com/awebdeveloper/pre-commit-prettier
|
||||
sha: '' # Use the sha or tag you want to point at
|
||||
hooks:
|
||||
- id: prettier
|
||||
additional_dependencies: ['prettier@1.1.0']
|
||||
|
||||
```
|
||||
|
||||
Find more info from [here](https://github.com/awebdeveloper/pre-commit-prettier)
|
||||
|
||||
##### 3. bash script
|
||||
|
||||
Alternately you can just save this script as `.git/hooks/pre-commit` and give it execute permission:
|
||||
|
||||
```bash
|
||||
|
||||
Reference in new issue
Block a user