【发布时间】:2019-11-05 15:53:06
【问题描述】:
我正在尝试将 husky 与 lint-staged 一起用于 angular5 中的预提交 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.
【问题讨论】:
标签: husky lint-staged