How to exclude a folder from tslint?

2019-02-17 07:10发布

问题:

I like to exclude the test folder form linting with tslint in vscode. So I have placed an exclude into my tslint.json config file. Unfortunately the exclude statement is not working. Does any one know how to set the exclude up?

 {
    "exclude": "tests/**/*.ts",
    "rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
    "rules": {
        "export-name": true,
        ...
     }
}

回答1:

It seems that this is an open feature request. Futher information can be found here: https://github.com/palantir/tslint/issues/73

Update: for those who use vscode with tslint as editor/lintinig you can add the following to the vscode config:

 // Configure glob patterns of file paths to exclude from linting
"tslint.exclude": "**/PATH_eg_TESTS/**/*.ts"


回答2:

Latest update: this can now be set in in tslint.json (the following configuration works with tslint 5.11)

{
  "linterOptions": {
    "exclude": [
      "bin",
      "build",
      "config",
      "coverage",
      "node_modules"
    ]
  }
}