我正尝试在angular5中使用带有lint-staged的赫斯基作为预提交的git钩子。Prettier只格式化暂存的文件。但是当我运行ng lint命令时,它在所有更改的文件上运行,而不是只在临时文件上运行(我修改了4个文件,但只有2个文件使用git add命令添加到临时区域。但是所有4个文件都检查了linting,这不是我所期望的)
下面是.lintstagedrc中的配置
"*.{ts,json}": [
"prettier --write",
"ng lint myProjName --files",
"git add"
],
"*.less": [
"prettier --write",
"npm run stylelint",
"git add"
]
}```
I debugged the issue to some extent. --files takes only the files which have been staged into the account. But still when the linters task completes, I get errors for non staged files as well.发布于 2020-01-27 20:57:44
--files标志是在Angular v7中添加的(可能是v7.1.2,除了this注释之外,我在changelogs中找不到任何引用)。
v7之前的版本不支持该标志,或者至少是not documented。
https://stackoverflow.com/questions/56726427
复制相似问题