I want to test my code on the pre-commit
hook. To achieve it I installed husky
, and list-staged
.
Here's the config:
"scripts": {
"test": "eslint --ext .ts,.tsx ./**/*",
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.(ts|tsx)": [
"npm run test"
]
So, in the theory, I can do something like:
git add file.ts
git commit -m commit
And ESLint will automatically check only file.ts
. But actually it shows all the exceptions during pre-commit
. Even if file.ts
is the only file that staged, ESLint checks everything.
What is the problem?