Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running lint fails after installing angular2-notifications

I have created a new Angular4 project using Angular-CLI recently.

The problem I am having is after installing angular2-notifications , I get an error when running the ng lint command.

Error :

Failed to load C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\angular2-notifications\tslint.json: Could not find custom rule directory: C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\angular2-notifications\node_modules\codelyzer

Stacktrace :

at new FatalError (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\tslint\lib\error.js:40:23)
at Object.findConfiguration (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\tslint\lib\configuration.js:47:15)
at files.forEach (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\tasks\lint.js:36:50)
at Array.forEach (native)
at lintConfigs.map (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\tasks\lint.js:30:19)
at Array.map (native)
at Class.run (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\tasks\lint.js:21:14)
at Class.run (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\commands\lint.js:45:25)
at Class.Command.validateAndRun (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\ember-cli\lib\models\command.js:128:15)
at C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\ember-cli\lib\cli\cli.js:92:22

I have turned to Google for this issue, without any luck. I have been to the GitHub repo and had no luck there either.

Then I went in the actual tslint.json file of angular2-notifications package.

I see this at the top :

"rulesDirectory": [
    "node_modules/codelyzer"
],

When I remove those 3 lines, the ng lint command works.

My question is, am I missing something here? I need this command to work and I don't think that modifying the package is an acceptable solution. Is this a bug in the package itself which I should report to them?

Thank you

like image 676
Gabriel Bourgault Avatar asked Jun 01 '17 00:06

Gabriel Bourgault


1 Answers

Exclude node_modules from your lint config in angular-cli.json:

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

The angular2-notifications project obviously shouldn't break ng lint for users. Still, I suppose it is also somewhat fair to say that a project shouldn't be trying to lint code that shouldn't be edited.

like image 147
ggranum Avatar answered Nov 02 '22 14:11

ggranum