问题是什么
正常应该这样(版本不一样会导致输出格式不同)
但是无限循环 log
解决方案
在 github issue 已经有人提过了,其实这个问题我在去年就遇到了,只是没怎么在意,因为只是显示问题,结果没啥问题。
哈哈哈,只要能跑就行,过程不重要,经典。
下面是 issue
Why "lint-staged" log is different when is triggered by husky (v6)? #968
其实解决方案最近才出来,下面链接是解决方案
Definitive cross-platform lint-staged config (explained)
在 pre-commit 文件中
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# 新加的一行
# If tty is available, apply fix from https://github.com/typicode/husky/issues/968#issuecomment-1176848345
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then exec >/dev/tty 2>&1; fi
npx --no -- lint-staged
但是这个可能和版本有关系
如果这么设置了就去修改版本
{
"devDependencies": {
"husky": "=8.0.3",
"lint-staged": "=13.2.1"
}
}