Skip to content

Exclude node_modules using tsconfig.json #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
davidanaya opened this issue Mar 15, 2017 · 4 comments
Closed

Exclude node_modules using tsconfig.json #268

davidanaya opened this issue Mar 15, 2017 · 4 comments

Comments

@davidanaya
Copy link

Hi,

I'm trying to configure codelyzer so that I can run tslint over all the source files in my project, but obviously excluding node_modules.

I configured my script in package.json like this

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

So if I understand tslint should use tsconfig.json to check which files should lint.
When I run npm run lint I get an error in my app.component.ts, which is fine, but I also get a few errors from files within node_modules, something like this

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'

My tsconfig.json looks like this

{
  "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
}

and my tslint.json is the standard version as in the npm site

Does anyone know what I'm doing wrong?
Thanks

@mgechev
Copy link
Owner

mgechev commented Mar 15, 2017

Hey @davidanaya! You must be using [email protected]? If so, the problem comes from the deep metadata collection which is performed by ngast. This is required in order to be able to parse component templates in the appropriate context.

Usually the problem occurs when the basePath and genDir properties are not presented in tsconfig.json. Once [email protected] is released, most such issues should have be already fixed. By then, you can use [email protected].

I'll close this issue since it's related to ngast, not codelyzer.

@mgechev mgechev closed this as completed Mar 15, 2017
@wachri
Copy link

wachri commented Mar 23, 2017

I have had the same problem. I could solve it with removing the.

"exclude": [
    "node_modules"
  ],

from the config. But no idea why this helps...

@leocaseiro
Copy link

leocaseiro commented Apr 27, 2017

Just to clarify. I was having the same issue and the exclude should be on your angular-cli.json

Eq:

{
    lint: [
        {
            "exclude": "**/node_modules/**/*"
        }
    ]
}

Via: angular/angular-cli#4350 (comment)

@anilkhichar
Copy link

The only working solution for me was to add files against all linting files

.angular-cli.json

"lint": [{
      "files": "src/**/*.ts",
      "project": "src/tsconfig.app.json"
    },
    {
      "files": "src/**/*.ts",
      "project": "src/tsconfig.spec.json"
    },
    {
      "files": "src/**/*.ts",
      "project": "e2e/tsconfig.e2e.json"
    }
  ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants