如何使用 tslint lint 整个文件夹 [英] How to lint entire folder using tslint

查看:40
本文介绍了如何使用 tslint lint 整个文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 tslint 对整个文件夹进行 lint?

Is that possible to lint entire folder using tslint?

使用 eslint 可以执行 eslint ./src 来验证整个文件夹.

Using eslint it is possible to do eslint ./src to validate whole folder.

当我尝试对 tslint 执行相同操作时 - 我收到错误 错误:EISDIR:对目录的非法操作.在网站上的示例中 - 他们展示了如何验证单个文件,但通常情况并非如此.

When i try to do the same for tslint - i am getting an error Error: EISDIR: illegal operation on a directory. In their examples on the site - they show how to validate single file, which is not the case usually.

是否可以仅从命令行验证我的项目而无需诸如 gulp-tslint 之类的额外内容?

Is that possible to validate my project without extra things like gulp-tslint, just from the command line?

推荐答案

您可以使用 glob 来 lint 多个文件.

You can use a glob to lint multiple files.

通常,如果您只是按原样传递一个 glob,您的 shell 将展开它并将生成的文件传递给 TSLint.因此,例如,在启用了 globstar 选项的 bash 4+ 中,您可以执行以下操作来整理所有 .ts.tsx 文件:

Normally, if you just pass a glob as is, your shell will expand it and pass the resulting files to TSLint. So for example, in bash 4+ with the globstar option enabled, you could do the following to lint all .ts and .tsx files:

tslint src/**/*.ts{,x}

尽管使用可以跨平台和外壳一致工作的命令,但您可能会更好.为此,您可以在引号中传递 glob.在引号中时,glob 将按原样传递给 TSLint,后者将使用 node-glob 处理它.然后,您可以运行以下命令以获得与上述相同的结果:

You're probably better off though using a command that will work consistently across platforms and shells though. For this, you can pass the glob in quotes. When in quotes, the glob will get passed as is to TSLint which will handle it with node-glob. You could then run the following command to get the same results as above:

tslint 'src/**/*.ts?(x)'

这篇关于如何使用 tslint lint 整个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆