【发布时间】:2021-10-21 03:52:26
【问题描述】:
您好,我安装了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"
}
当我 git commit ..,(2 个文件,1 个 *.test.ts * 和 1 个 *.ts)时,它会启动 linter 和 test,但测试永远不会完成,除非我打破它(ctrl +c)。
- *.test.ts 文件,里面有错误。
只有当我打破它时,我才会在屏幕上看到错误:
我还注意到lint-staged: 对象,当我git commit.. 时,它变成了package.json:
一开始我是这样的:
"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"
}
欢迎对我错过的配置提供任何帮助。
【问题讨论】:
标签: git package.json githooks husky lint-staged