简体   繁体   English

如何从命令行为 vscode 获取正确的 linting?

[英]How to get proper linting from commandline for vscode?

Have searched far and wide and found numerous articles, videos etc. tangent to what I look for, but never a perfect solution.进行了广泛的搜索,发现了许多与我所寻找的内容相切的文章、视频等,但从来都不是完美的解决方案。

My main question is how to get proper linting (like the one that's inbuilt and enabled by default in vscode)?我的主要问题是如何获得正确的 linting(就像 vscode 中内置并默认启用的)?

The reason is to be able to enforce this in a continuous integration setting, for example a github action rule for pull requests.原因是能够在持续集成设置中强制执行此操作,例如用于拉取请求的 github 操作规则。

Example when using vscode default tslint:使用 vscode 默认 tslint 时的示例:

export class Foo {
readonly bar: string;

constructor(bar : string) {
  this.bar123 = bar; <-- Property 'bar123 ' does not exist on type 'Foo'. Did you mean 'bar'?ts(2551)
}

This is excellent.这是极好的。 Exactly what I want to include as a linting rule in the project?究竟我想在项目中包含什么作为 linting 规则? So I take control by disabling vscode tslint (which is deprecated now anyway,) and replace it with eslint with all the proper packages, parser options.因此,我通过禁用 vscode tslint(无论如何现在已弃用)来进行控制,并将其替换为 eslint 以及所有正确的包和解析器选项。 extends and other settings.扩展和其他设置。

Now it's silent.现在它沉默了。 No notification about unused properties.没有关于未使用属性的通知。 And several other problems too are silent.其他几个问题也没有解决。

Eslint is however working and can also easily be enabled to auto-format code on save.然而,Eslint 正在工作,并且也可以轻松启用以在保存时自动格式化代码。 So I am halfway there, but how to get the same quality linting?所以我已经完成了一半,但是如何获得相同质量的棉绒? Found it strange that none of the tutorials and articles even touched on this topic.奇怪的是,教程和文章都没有涉及到这个话题。

Answer is 'tsc', the compiler gives these errors and accessible from command line too.答案是“tsc”,编译器会给出这些错误,也可以从命令行访问。 Thanks to Tobias S leading me on the right track.感谢 Tobias S 带领我走上正轨。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM