简体   繁体   English

在目录上运行 ng lint 时遇到问题

[英]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.

相关问题 “lint-staged”软件包在Intellij构思中运行“ng lint --fix”后没有提交更新的文件 - “lint-staged” package is not committing the updated files after running “ng lint --fix” in Intellij idea “ng lint”安静选项? - "ng lint" quiet option? ng lint 找不到自定义规则目录:在 gitlab CI 上使用 Angular CLI 的 codelyzer - ng lint Could not find custom rule directory: codelyzer with Angular CLI on gitlab CI 在干净的 Angular 项目中运行“ng lint”时,eslint 会为另一个文件夹中完全不同的项目提供错误 - When running "ng lint" in a clean Angular project eslint gives errors for a completely different project in another folder ng2 / typescript中的Redux,无法使用CombineReducers - Redux in ng2/typescript, having trouble using combineReducers Angular中的ng lint --format = stylish和ng lint有什么区别 - What is difference between `ng lint --format=stylish` and `ng lint` in Angular Angular 6 ng lint combineLatest 已弃用 - Angular 6 ng lint combineLatest is deprecated 运行ng build --prod时不生成目录dist - Does not generate directory dist when running ng build --prod 使用 `ng lint` 命令打印 linted 文件的日志 - print logs for the linted files with `ng lint` command angular 项目中 ng lint 期间未处理的异常 - Unhandled exception during ng lint in angular project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM