How to ignore semicolons with "tslint:recomended"
Asked Answered
B

2

10

I want my tslint to ignore semicolons.

I would like to keep the rule "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. 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.

tslint documentation just gives the option to keep them always or delete always, but not ignore them.

Can someone help me?

Borchert answered 12/6, 2019 at 20:19 Comment(1)
palantir.github.io/tslint/rules/semicolon it can be ignored only for interfaces and classes based on other argumentSimone
C
20

As in the previous response, you can suppress tslint for a file or the next line. 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.

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.

Once you're there, add this entry to the rules list:

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

Hope it helps!

Corettacorette answered 12/6, 2019 at 21:19 Comment(3)
It should be noted that the keyboard commands work in Visual Studio Code (only?).Methoxychlor
@HereticMonkey Yes, VSCode for sure, I don't know if it would work in others. Thank you! Nice add to the solution.Corettacorette
This is what I wanted, and it works, perfectly. Thanks!!! Now it doesn't matter if I write a semicolon or not. Very good explanation and I like very much when the response contains context, even if it is not required. I appreciate this answer!!!!Borchert
T
3

You can suppress tslint rules for your file or the next line in your code by generating disable comments.

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. In your case, semicolon.

You can get more information on how to generate disable comments here

Tetragon answered 12/6, 2019 at 21:11 Comment(1)
Thanks. This links seems interesting!Borchert

© 2022 - 2024 — McMap. All rights reserved.