Skip to content

Instantly share code, notes, and snippets.

@omariosouto
Created August 4, 2021 16:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omariosouto/5081f13a98514583156db69868934bc6 to your computer and use it in GitHub Desktop.
Save omariosouto/5081f13a98514583156db69868934bc6 to your computer and use it in GitHub Desktop.
1. `yarn add husky -D`
2. Adiciona no package.json: `"prepare": "husky install"`
3. roda `yarn prepare`
4. Adiciona o comando `npx husky add .husky/pre-commit "yarn lint:fix"`
====================================================
5. Lint staged
- instala `yarn add lint-staged -D`
- Ajusta pra rodar
```js
"lint-staged": "lint-staged"
},
"lint-staged": {
"*.js": [
"yarn lint:fix"
]
},
```
- Mexe no arquivo do pre-commit gerado pelo husky
====================================================
## Extgras
- Se você quiser ignorar por algum motivo --no-verify
- Yarn 2 é diferente
https://typicode.github.io/husky/#/?id=install
@rabelorp
Copy link

Toda vez que vou mudar de branch, o git fala pra eu fazer o commit de novo, toda santa hora ele faz isso, mas o husky já está commitado:

git checkout master
error: Your local changes to the following files would be overwritten by checkout:
.husky/commit-msg
.husky/pre-commit
.husky/prepare-commit-msg
Please commit your changes or stash them before you switch branches.
Aborting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment