[英]How to prevent build with there are tslint errors?
Question Hi everyone,问题大家好
I am working in an angular 8 app that has tslint rules defined.我正在使用定义了 tslint 规则的 angular 8 应用程序。 The rules are working very nice when developers are coding but the problem that I have is the ng serve and ng build allow developers to build the app although there are TSlint errors.
当开发人员编码时,这些规则非常有效,但我遇到的问题是 ng serve 和 ng build 允许开发人员构建应用程序,尽管存在 TSlint 错误。 is there a way to force Tslint rules when the project is building so developers have to fix the TSlint errors before they can see in the browser?
有没有办法在项目构建时强制 Tslint 规则,以便开发人员必须修复 TSlint 错误,然后才能在浏览器中看到?
best Hmendezm最佳赫门德兹姆
Angular CLI doesn't provide a default watch param for lint as it provides for unit tests. Angular CLI 没有为 lint 提供默认监视参数,因为它提供了单元测试。 But we can create it easily by the following:
但是我们可以通过以下方式轻松创建它:
nodemon
as dev dependency.nodemon
作为开发依赖项。 npm i -D nodemon
"start": "ng serve", //please add if it is missing
"serve:watch": "nodemon --exec \"npm run lint && npm run start\" --ext ts",
npm run serve:watch
For every change, it will first run lint then it will refresh the browser.对于每次更改,它首先会运行 lint,然后刷新浏览器。 If anything fails then the
nodemon
will crash and you won't be able to see the changes.如果出现任何故障,则
nodemon
将崩溃,您将无法看到更改。
Thanks谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.