我正在尝试将 husky 与 lint-staged 一起用于 angular5 中的预提交 git 钩子。Prettier 仅格式化暂存文件。但是当我运行 ng lint 命令时,它会在所有已更改的文件上运行,而不是仅在暂存文件上运行(我修改了 4 个文件,但使用 git add 命令仅将 2 个文件添加到暂存区。但是所有 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.