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

Javascript 如何忽略tslint的特定目录或文件?,javascript,ide,typescript,webstorm,tslint,Javascript,Ide,Typescript,Webstorm,Tslint,所使用的IDE是WebStorm 11.0.3,tslint已配置并工作,但由于它试图解析大型*.d.ts库文件而挂起 有没有办法忽略特定的文件或目录?有谁遇到了问题。不幸的是,排除文件只有一个悬而未决的问题: 因此,恐怕答案是否定的。更新 如所述,您现在可以更新tslint.jsonCLI选项: { "extends": "tslint:latest", "linterOptions": { "exclude": [ "bin", "

所使用的IDE是WebStorm 11.0.3,tslint已配置并工作,但由于它试图解析大型*.d.ts库文件而挂起

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

有谁遇到了问题。不幸的是,排除文件只有一个悬而未决的问题:

因此,恐怕答案是否定的。

更新

如所述,您现在可以更新tslint.jsonCLI选项:

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


此功能已在中引入

现在可以添加--exclude(或-e),请参见此处

CLI

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

当前正在使用Visual Studio代码和禁用tslint的命令是

/* tslint:disable */
要注意的事情。上述禁用将禁用该页面上的所有tslint规则。如果要禁用特定规则,可以指定一个/多个规则

/* tslint:disable comment-format */
/* tslint:disable:rule1 rule2 rule3 etc.. */
或者启用规则

/* tslint:enable comment-format */

< P>除米迦勒的回答外,请考虑第二种方式:加入TSLILT.JSON/P> 例如,您可能有带有以下行的
tslint.json

{
  "linterOptions": {
    "exclude": [
      "someDirectory/*.d.ts"
    ]
  }
}

tslint v5.8.0
开始,您可以在
linterOptions
项下设置
exclude
属性,输入
tslint.json
文件:

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

有关这方面的详细信息。

linterOptions当前仅由CLI处理。
如果不使用CLI,则根据使用的代码库,需要在其他地方设置忽略。webpack、tsconfig等

我不得不使用**/*语法排除文件夹中的文件:

    "linterOptions": {
        "exclude": [
          "src/auto-generated/**/*",
          "src/app/auto-generated/**/*"
        ]
    },

可以通过定义exclude参数来修改package.json中的lint脚本,从而确认在版本tslint 5.11.0上它是否工作:

"lint": "ng lint --exclude src/models/** --exclude package.json"
干杯

作为补充

要禁用下一行的所有规则
//tslint:禁用下一行

要禁用下一行的特定规则,请执行以下操作:
//tslint:禁用下一行:规则1规则2…

要禁用当前行的所有规则,请执行以下操作:
someCode();//tslint:禁用行


要禁用当前行的特定规则,请执行以下操作:
someCode();//tslint:disable line:rule1

在代码示例中添加该部分

"linterOptions": {
"exclude": [
  "node_modules/**/*.",
  "db/**/*.",
  "integrations/**/*."
]

},,

你知道如何排除多个路径吗?重复几次排除参数对更新的小更正:它应该是
linterOptions
而不是
cliOptions
另外值得一提的是,排除目录中的glob模式应该与
tslint.json
相关,这应该标记为回答正确(并于2017年11月更新)。正确的方法是将
cliOptions
替换为
linterOptions
。从所有答案中,这是唯一有效的答案。谢谢您是指其他答案,还是只是想提供问题的替代答案?
"linterOptions": {
"exclude": [
  "node_modules/**/*.",
  "db/**/*.",
  "integrations/**/*."
]