TSLINT 配置:排除外部模块

TSLINT config : exclude external modules

我正在使用配置了 tslint 的 angular2 webpack starter。

我也用ngx-datables(目录@swimlane直接在node_modules)。

我有很多警告,例如:

 @ ./~/@swimlane/ngx-datatable/src/utils/index.ts 14:0-32
 @ ./~/@swimlane/ngx-datatable/src/components/datatable.component.ts
 @ ./~/@swimlane/ngx-datatable/src/components/index.ts
 @ ./~/@swimlane/ngx-datatable/src/index.ts
 @ ./src/app/adherent/list/adherent-list.component.ts
 @ ./src/app/adherent/list/index.ts
 @ ./src/app/adherent/index.ts
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.browser.ts
 @ multi (webpack)-dev-server/client?http://localhost:3000 ./src/main.browser.ts

不过,我的配置应该做得很好:

tsconfig.json :

...
"exclude": [
    "node_modules",
    "dist"
  ],
...

tsconfig.webpack.json :

...
"exclude": [
    "node_modules",
    "dist",
    "src/**/*.spec.ts",
    "src/**/*.e2e.ts"
  ],
...

tslint.json :

...
"exclude": [
     "node_modules"
  ],
...

我也试过 "**/node_modules/**"。但是什么都没有改变,我仍然有警告。

您应该对其中的所有文件夹使用 /**

"exclude": [
     "node_modules/**"
  ],
...

我在 webpack 中使用相同的 angular2-starter,我的解决方案是添加 node_modules 文件夹以排除,它在 webpack.dev.js 文件中,我已经更改:

exclude: [/\.(spec|e2e)\.ts$/]

exclude: [/\.(spec|e2e)\.ts$/, /node_modules/]

并且有效,@Aravind 提供的解决方案令人遗憾地无效。