[英]Having trouble running ng lint on a directory
I'm attempting to use the linter that comes with Angular 8, but I've neglected TSLint errors for a while.我正在尝试使用 Angular 8 附带的 linter,但我已经有一段时间忽略了 TSLint 错误。 I'm hoping to slowly clean up the errors, and I'm searching for a way to run the linter on entire directories, some of which may have multiple subdirectories.
我希望慢慢清理错误,我正在寻找一种在整个目录上运行 linter 的方法,其中一些目录可能有多个子目录。
I've looked at the Angular documentation for ng lint , but I'm not finding anything helpful (or I may be overlooking something).我查看了 ng lint 的 Angular 文档,但没有找到任何有用的信息(或者我可能忽略了某些内容)。 What I thought I was looking for was the
--files
flag, but I must be doing something wrong, because when I run ng lint --files
, I can only get it to work with a single file, and not an entire directory.我以为我在寻找的是
--files
标志,但我一定做错了什么,因为当我运行ng lint --files
时,我只能让它处理单个文件,而不是整个目录。
For example, using ng lint --files src/app/+register/registration.component.ts
works perfectly.例如,使用
ng lint --files src/app/+register/registration.component.ts
效果很好。
Does anybody have any thoughts on this?有人对此有任何想法吗? I'd love some help.
我需要一些帮助。
Thanks in advance!提前致谢!
You can use a glob, or wildcard, to get the functionality you need.您可以使用通配符或通配符来获得所需的功能。 Example below.
下面举例。
ng lint --files=src/app/folder/**/*.ts
After some digging, I found this solution:经过一番挖掘,我找到了这个解决方案:
ng lint [ Project name ] --files '[ Directory path ]/*.ts'
Change between the brackets with your own options.使用您自己的选项在括号之间进行更改。
You can use [ ** ] for the unknown directory.您可以将 [ ** ] 用于未知目录。
For those like me who visit this question some years later with a newer Angular version:对于像我这样几年后使用更新的 Angular 版本访问此问题的人:
ng lint --lint-file-patterns=src/app/your/path/**/*.ts
tested on Angular 14在 Angular 14 上测试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.