user11638983
user11638983

Reputation:

How to ignore semicolons with "tslint:recomended"

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?

Upvotes: 10

Views: 14399

Answers (2)

Alvaro
Alvaro

Reputation: 2069

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!

Upvotes: 20

nash11
nash11

Reputation: 8680

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

Upvotes: 3

Related Questions