如何忽略 tslint 的特定目录或文件?

新手上路,请多包涵

正在使用的 IDE 是 WebStorm 11.0.3,tslint 已配置并且可以工作,但是它挂起,因为它尝试解析大型 *.d.ts 库文件。

有没有办法忽略特定的文件或目录?

原文由 user3330840 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.5k
2 个回答

tslint v5.8.0 更新

正如 Saugat Acharya 所述,您现在可以更新 tslint.json CLI 选项:

 {
  "extends": "tslint:latest",
  "linterOptions": {
      "exclude": [
          "bin",
          "lib/*generated.js"
      ]
  }
}

此拉取请求中的 更多信息。


此功能已在 tslint 3.6 中引入

tslint \"src/**/*.ts\" -e \"**/__test__/**\"

您现在可以在此处添加 –exclude(或 -e)查看 PR

命令行界面

usage: tslint [options] file ...

Options:

-c, --config          configuration file
--force               return status code 0 even if there are lint errors
-h, --help            display detailed help
-i, --init            generate a tslint.json config file in the current working directory
-o, --out             output file
-r, --rules-dir       rules directory
-s, --formatters-dir  formatters directory
-e, --exclude         exclude globs from path expansion
-t, --format          output format (prose, json, verbose, pmd, msbuild, checkstyle)  [default: "prose"]
--test                test that tslint produces the correct output for the specified directory
-v, --version         current version

你正在考虑使用

-e, --exclude         exclude globs from path expansion

原文由 Michael 发布,翻译遵循 CC BY-SA 4.0 许可协议

作为补充

禁用 下一行的所有规则 // tslint:disable-next-line

禁用 下一行的特定规则// tslint:disable-next-line:rule1 rule2...

禁用 当前行的所有规则someCode(); // tslint:disable-line

禁用 当前行的特定规则someCode(); // tslint:disable-line:rule1

原文由 AlbertK 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题