简体   繁体   English

如何使用“tslint:recomended”忽略分号

[英]How to ignore semicolons with "tslint:recomended"

I want my tslint to ignore semicolons.我希望我的 tslint 忽略分号。

I would like to keep the rule "extends": "tslint:recommended" .我想保留规则"extends": "tslint:recommended" Right now, I just can´t follow this rule, which forces me to use semicolon always, or use this other one "semicolon": [true, "never"] , which forces me to delete all semicolons.现在,我不能遵循这个规则,这迫使我总是使用分号,或者使用另一个"semicolon": [true, "never"] ,这迫使我删除所有分号。 I just want to ignore them.我只想无视他们。 I can do it by deleting the "extends": "tslint:recommended" but I would like to keep this rule and just ignore semicolons.我可以通过删除"extends": "tslint:recommended"来做到这一点,但我想保留这条规则而忽略分号。

tslint documentation just gives the option to keep them always or delete always, but not ignore them. tslint 文档只是提供了始终保留或始终删除的选项,但不能忽略它们。

Can someone help me?有人能帮我吗?

As in the previous response, you can suppress tslint for a file or the next line.与之前的响应一样,您可以取消文件或下一行的tslint But if you want to edit the rules for your entire directory, check the tslint.json file, this is your global configuration for the project you're on.但是,如果您想编辑整个目录的规则,请检查tslint.json文件,这是您所在项目的全局配置。

You could probably find this file in the root folder of your app.您可能会在应用程序的根文件夹中找到此文件。 If not, try pressing cmd + P (mac) or ctrl + P (windows) and enter tslint.json .如果没有,请尝试按cmd + P (mac) 或ctrl + P (windows) 并输入tslint.json

Once you're there, add this entry to the rules list:到达那里后,将此条目添加到规则列表中:

{
  ...
  "rules": {
    ...
    "semicolon":false
  }
}

Hope it helps!希望能帮助到你!

You can suppress tslint rules for your file or the next line in your code by generating disable comments.您可以通过生成禁用注释来抑制文件或代码中的下一行的tslint规则。

If you want to disable a rule for the entire file, then at the top of your file, add如果要为整个文件禁用规则,请在文件顶部添加

/* tslint:disable:<rule name>

If you want to disable a rule for the next line, then above the line for which you want to disable the rule, add如果要禁用下一行的规则,请在要禁用规则的行上方添加

// tslint:disable-next-line:<rule name>

where <rule name> is the name of your rule.其中<rule name>是您的规则的名称。 In your case, semicolon .在你的情况下, semicolon

You can get more information on how to generate disable comments here您可以在此处获取有关如何生成禁用评论的更多信息

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

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