我想测试我的代码pre-commit
。为了实现它,我安装了husky
, 和list-staged
.
这是配置:
"scripts": {
"test": "eslint --ext .ts,.tsx ./**/*",
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.(ts|tsx)": [
"npm run test"
]
所以,在理论上,我可以做类似的事情:
git add file.ts
git commit -m commit
而ESLint只会自动检查file.ts
. 但实际上它显示了pre-commit
. 即使file.ts
是唯一暂存的文件,ESLint 也会检查所有内容。
问题是什么?