【问题标题】:How to exclude a folder from tslint?如何从 tslint 中排除文件夹?
【发布时间】:2017-01-16 05:51:46
【问题描述】:

我喜欢在 vscode 中排除 test 文件夹表单使用 tslint 进行 linting。所以我在我的 tslint.json 配置文件中放置了一个排除项。不幸的是,排除语句不起作用。有谁知道如何设置排除?

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

【问题讨论】:

    标签: javascript visual-studio-code lint tslint


    【解决方案1】:

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

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

    【讨论】:

    【解决方案2】:

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

    更新: 对于那些使用 tslint 作为编辑器/linting 的 VSCode,您可以将以下内容添加到 VSCode 配置中:

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

    【讨论】:

    • 它以数组形式为我工作:"tslint.exclude": "**/schematics/**/files/*.ts" 谢谢!
    【解决方案3】:

    这在 tslint: 6.1.2 中对我有用。

    在 tslint.json 所在的根文件夹中创建目录的文件路径。

    "linterOptions": {
      "exclude": [
        "libs/folder/folder/**",
        "apps/stuff/stuff/**"
      ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-05
      • 2011-05-04
      • 2015-06-04
      • 1970-01-01
      • 2016-11-23
      相关资源
      最近更新 更多