I'm using husky v4.3.0
lint-staged 10.4.0
prettier v2.1
on create-react-app
.
package.json:
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/**/*.{ts, tsx}": [
"eslint --fix",
"git add"
],
"src/**/*.{ts, tsx, css, md, mdx, html}": [
"prettier --write",
"git add"
]
},
I found a smiliar question lint-staged not running on precommit, I tried the different answers mentioned such as:
- Delete the node modules and reinstall the packages
- Rebuild the packages with npm rebuild
- reinstall husky and lint-staged
Whenever I commit anything the lint-staged was not executed to run the lint and prettier. How can I fix that?
The problem is due to the
git
version. I usedgit v2.9.0
and husky v4 acceptsgit >= 2.13.0
.Reference: https://github.com/typicode/husky/tree/master