【问题标题】:TSLINT config : exclude external modulesTSLINT 配置:排除外部模块
【发布时间】:2017-09-02 13:06:20
【问题描述】:

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

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

我有很多警告,例如:

 @ ./~/@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/**"。但没有任何改变,我仍然有警告。

【问题讨论】:

  • 我相信这个问题现在已经解决了,因为您可以 **/node-modules/** 或 `**//** 获取子文件夹及其内容。我正在使用 tslint 5.20.0

标签: angular typescript tslint linter


【解决方案1】:

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

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

【讨论】:

  • 这比原来的效果好得多:/node_modules/ 谢谢:)!
【解决方案2】:

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

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

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

并且有效,@Aravind 提供的解决方案效果不佳。

【讨论】:

    猜你喜欢
    • 2012-06-04
    • 2015-07-03
    • 1970-01-01
    • 1970-01-01
    • 2017-01-02
    • 1970-01-01
    • 2017-09-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多