在预提交中运行ESLint不会在警告时停止 [英] Running ESLint in precommit does not stop on warnings
问题描述
我正在向项目添加一些预提交和预推脚本。我使用Husky是因为它会在git上跟踪任何更改。
I'm adding some precommit and prepush scripts to my project. I'm using Husky because it keeps tracked on git any change.
在我的package.json上,我有:
On my package.json I have:
"precommit": "npm run lint && npm run test",
当任何测试或皮棉错误被发现我无法进行提交。
Which initially seems to be working fine, when any test or lint error was found I was unable to make the commit.
现在,我发现如果有警告,无论如何都会进行提交。
Now I found that if I have a warning, the commit happens anyway.
如何我配置了Husky或ESLint,以便在出现警告时停止提交?
How can I configure Husky, or maybe ESLint, to stop the commit when there are warnings?
我知道我可以覆盖所有的eslint配置,使其始终为错误[2],但我期望在那里是更好的东西
I know I could override all eslint configs to be always error [2], but I'm expecting there is something better
推荐答案
您需要指定-max-warnings
参数。
类似这样的东西:
"scripts": {
...
"lint": "eslint \"**/*.js\" --fix --max-warnings=0",
...
},
这篇关于在预提交中运行ESLint不会在警告时停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!