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:
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 used git v2.9.0
and husky v4 accepts git >= 2.13.0
.
Existing hooks are kept. Requires Node >= 10 and Git >= 2.13.0.