从Angular项目中的tslint中排除node_modules

时间:2017-03-15 15:54:42

标签: angularjs tslint

我正在尝试配置codelyzer,以便我可以在项目中的所有源文件上运行tslint,但显然不包括node_modules。

我在package.json中配置了我的脚本,就像这样

"lint": "tslint --type-check --project tsconfig.json"

所以如果我理解tslint应该使用tsconfig.json来检查哪些文件应该lint。 当我运行npm run lint时,我的app.component.ts出错,这很好,但我也从node_modules中的文件中得到一些错误,类似这样的

Error: Error encountered resolving symbol values statically. Calling function 'ɵmakeDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function
    at simplify (/Users/david/Documents/work/my-angular-seed/node_modules/@angular/compiler/bundles/compiler.umd.js:21818:58)
    at simplifyCall (/Users/david/Documents/work/my-angular-seed/node_modules/@angular/compiler/bundles/compiler.umd.js:21624:28)
    at simplify (/Users/david/Documents/work/my-angular-seed/node_modules/@angular/compiler/bundles/compiler.umd.js:21806:52)
    at simplifyInContext (/Users/david/Documents/work/my-angular-seed/node_modules/@angular/compiler/bundles/compiler.umd.js:21831:28)
    at simplify (/Users/david/Documents/work/my-angular-seed/node_modules/@angular/compiler/bundles/compiler.umd.js:21667:40)
    at simplifyInContext (/Users/david/Documents/work/my-angular-seed/node_modules/@angular/compiler/bundles/compiler.umd.js:21831:28)
    at simplify (/Users/david/Documents/work/my-angular-seed/node_modules/@angular/compiler/bundles/compiler.umd.js:21789:52)
    at simplify (/Users/david/Documents/work/my-angular-seed/node_modules/@angular/compiler/bundles/compiler.umd.js:21649:60)
    at simplifyInContext (/Users/david/Documents/work/my-angular-seed/node_modules/@angular/compiler/bundles/compiler.umd.js:21831:28)
    at recordedSimplifyInContext (/Users/david/Documents/work/my-angular-seed/node_modules/@angular/compiler/bundles/compiler.umd.js:21844:28) 'node_modules/@angular/core/typings/core.d.ts'

我的tsconfig.json看起来像这样

{
  "compilerOptions": {
    "target": "es5",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noEmitHelpers": false,
    "pretty": true,
    "sourceMap": true,
    "lib": ["es5", "dom"],
    "strictNullChecks": false
  },
  "include": [
    "src/**/*"
  ],
  "exclude": [
    "node_modules"
  ],
  "awesomeTypescriptLoaderOptions": {
    "useWebpackText": true,
    "forkChecker": true,
    "useCache": true
  },
  "compileOnSave": false,
  "buildOnSave": false
}

和我的tslint.json是npm site

中的标准版本

有谁知道我做错了什么? 感谢

修改

我收到了github repo for codelyzer的回复。 似乎问题出现在beta版本中,所以我将package.json更新到版本2.0.1并解决了问题。

现在唯一的问题是,当我通过package.json脚本执行tslint时出现错误我收到错误,但是如果我在命令行中运行它,那么它可以正常工作。

tslint --project tsconfig.json

11 silly lifecycle my-angular-seed@1.0.0~lint: Args: [ '-c', 'tslint --project tsconfig.json' ]
12 silly lifecycle my-angular-seed@1.0.0~lint: Returned: code: 2  signal: null
13 info lifecycle my-angular-seed@1.0.0~lint: Failed to exec lint script
14 verbose stack Error: my-angular-seed@1.0.0 lint: `tslint --project tsconfig.json`
14 verbose stack Exit status 2
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:192:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:192:7)
14 verbose stack     at maybeClose (internal/child_process.js:890:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

0 个答案:

没有答案