如何从tslint中排除文件夹?

MBu*_*eld 8 lint tslint visual-studio-code

我想test在vscode中用tslint 排除文件夹形式.所以我在我的tslint.json配置文件中放了一个exclude.不幸的是,exclude语句不起作用.有没有人知道如何设置排除?

 {
    "exclude": "tests/**/*.ts",
    "rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
    "rules": {
        "export-name": true,
        ...
     }
}
Run Code Online (Sandbox Code Playgroud)

Jok*_*ter 6

最新更新:现在可以在tslint.json中进行设置(以下配置适用于tslint 5.11)

{
  "linterOptions": {
    "exclude": [
      "bin",
      "build",
      "config",
      "coverage",
      "node_modules"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

  • 应该注意的是最终的PR使用`linterOptions`而不是`cliOptions`:https://github.com/palantir/tslint/pull/2409#issuecomment-289464766 (2认同)

MBu*_*eld 5

这似乎是一个开放的功能请求.更多信息可以在这里找到:https://github.com/palantir/tslint/issues/73

更新: 对于使用带有tslint的vscode作为editor/lintinig的用户,可以将以下内容添加到vscode配置中:

 // Configure glob patterns of file paths to exclude from linting
"tslint.exclude": "**/PATH_eg_TESTS/**/*.ts"
Run Code Online (Sandbox Code Playgroud)