简体   繁体   English

在 tsconfig.json 和 tslint.json 中设置规则有什么区别?

[英]what is the difference between setting rules in tsconfig.json vs tslint.json?

It seems like they both achieve the same result.似乎他们都达到了相同的结果。 With TSLint, I had to install a plugin in VSCode?使用 TSLint,我必须在 VSCode 中安装插件吗? This probably is not preferable should someone in my team use a different editor.如果我的团队中有人使用不同的编辑器,这可能不是可取的。

tsconfig.json receives the configuration for the typescript compiler like allowing javascript files, the location of your files, etc. tsconfig.json接收打字稿编译器的配置,例如允许 javascript 文件、文件的位置等。

tslint.json is the configuration for TSLint, TSLint helps you to detect bad coding practices or follow a coding style, you can configure its options like disallow unused variables, no logging to the console, etc. Also, TSLint is not just a plugin for vscode, so someone in your team can use the editor of its preference and still use TSLint. tslint.jsontslint.json的配置,TSLint 可以帮助您检测不良的编码实践或遵循编码风格,您可以配置其选项,例如禁止未使用的变量、不记录到控制台等。此外,TSLint 不仅仅是一个插件vscode,因此您团队中的某个人可以使用其偏好的编辑器,并且仍然使用 TSLint。

See this links:请参阅此链接:

TSConfig : Deals with the compiler. TSConfig :处理编译器。 Throws an error on compiling bad code.在编译错误代码时引发错误。 So in Anguar "ng serve" will give you an error Ex Error => error TS6138: Property 'dialog' is declared but its value is never read.所以在 Anguar 中,“ng serve”会给你一个错误 Ex Error => error TS6138: Property 'dialog' is created but its value is never read。

TsLint : Its to ensure best practice is followed. TsLint :它确保遵循最佳实践。 It does not throw an error on compilation.它不会在编译时引发错误。 However, it shows a red line on the code to tell you that your style of coding needs some changes.但是,它会在代码上显示一条红线,告诉您您的编码风格需要进行一些更改。 On VScode , you need to install a plugin to detect tslint.在 VScode 上,你需要安装一个插件来检测 tslint。 On webstorm , it is inbuilt在 webstorm 上,它是内置的

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

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