嗨,我安装了husky
&以便为暂存文件提供&lint-stage
的预提交钩子。lint
tests
当我转到 时,预提交挂钩起作用,git commit -m 'something'
并触发了命令。
到目前为止,我在文件方面拥有的是:
.husky/pre-commit
:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
.package.json
:
"lint-staged": {
"*.{ts,tsx}": "eslint --cache --fix",
"*": "react-scripts test --env=jest-environment-jsdom-fourteen"
}
当 i git commit ..
,(2 个文件,1 个 *.test.ts * 和 1 个 *.ts)时,它会启动linter
& the test
,但测试永远不会完成,除非我打破它(ctrl+c)。
- * .test.ts文件,其中有错误。
只有当我打破它时,我才会在屏幕上看到错误:
我还注意到lint-staged:
,当我git commit..
:
最初我是这样的:
"lint-staged": {
"*.{ts,tsx}": "eslint --cache --fix",
"*.test.{ts, tsx}": "react-scripts test --env=jest-environment-jsdom-fourteen"
}
它变成了这样:
"lint-staged": {
"*.{ts,tsx}": "eslint --cache --fix",
"*": "react-scripts test --env=jest-environment-jsdom-fourteen"
}
欢迎对我错过的配置提供任何帮助。