Angular-cli: All errors assumed to be lint errors

Created on 20 May 2016  路  26Comments  路  Source: angular/angular-cli

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Mac OSX 10.9.5

  1. Versions. Please run ng --version. If there's nothing outputted, please
    run in a Terminal:
    node --version
    And paste the result here.

v5.6.0

  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.

Run ng lint the rule loader throws an error but this line assumes it is a lint error showing the following confusing message.

> tslint "src/**/*.ts"


Lint errors found in the listed files.
  1. The log given by the failure. Normally this include a stack trace and some
    more information.
[Error: Command failed: /bin/sh -c npm run lint
/project-folder/node_modules/tslint/lib/ruleLoader.js:29
        throw new Error(errorMessage);
        ^

Error: Could not find the following rules specified in the configuration:
host-parameter-decorator
input-parameter-decorator
output-parameter-decorator
attribute-parameter-decorator
input-property-directive
output-property-directive
    at Object.loadRules (/project-folder/node_modules/tslint/lib/ruleLoader.js:29:15)
    at Linter.lint (/project-folder/node_modules/tslint/lib/tslint.js:25:44)
    at processFile (/project-folder/node_modules/tslint/lib/tslint-cli.js:118:29)
    at Array.forEach (native)
    at Object.<anonymous> (/project-folder/node_modules/tslint/lib/tslint-cli.js:128:41)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
  1. Mention any other details that might be useful.

Thanks! We'll be in touch soon.

easy (hours) 2 (required) bufix

Most helpful comment

https://github.com/angular/angular-cli/pull/848 fixes this issue.

Until @hansl does a release, change the bottom part of your tslint.json to: https://github.com/angular/angular-cli/pull/848/files#diff-53fb140e7018814de9f2e231a3eb95a1R65

All 26 comments

https://github.com/angular/angular-cli/pull/848 fixes this issue.

Until @hansl does a release, change the bottom part of your tslint.json to: https://github.com/angular/angular-cli/pull/848/files#diff-53fb140e7018814de9f2e231a3eb95a1R65

Confirmed, that fixed it. But we may want to look at how it's swallowing useful error information as well.

@daniellmb very good point. It's a problem that ng lint swallows errors and it can lead to hard debugging scenarios. I have a solution in mind.

It seems this problem may have resurfaced on 1.0.0-beta.6. I just reproduced with an empty project.

ng lint should also be a bit more friendly as mentioned in https://github.com/angular/angular-cli/issues/967#issuecomment-223385125

After updating to angular 2.0.2 ng lint now returns the following even though previously no lint errors existed:

> tslint "src/**/*.ts"
Lint errors found in the listed files.

Suggestions mentioned in the comment above (https://github.com/angular/angular-cli/pull/848/files#diff-53fb140e7018814de9f2e231a3eb95a1R65) are already present in tslint.json.

UPD: The actual errors are not caught by ng lint anymore. The output is the same.
ng lint is broken with 2.0.2 update with settings that worked under 2.0.1.

2567

@vkniazeu what output do you get from npm run lint?

@filipesilva I left the relevant stack trace in the description of https://github.com/angular/angular-cli/issues/2567.
Here it is:

13 info lifecycle [email protected]~lint: Failed to exec lint script
14 verbose stack Error: [email protected] lint: `tslint "src/**/*.ts"`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (C:\Users\...\npm\node_modules\npm\lib\utils\lifecycle.js:255:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (C:\Users\V...\npm\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:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:877:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

I just upgraded "codelyzer" to "1.0.0-beta.1" - the only change and now ng lint always returns success even if there are problems with the code (those do get caught with ng serve correctly).

ng lint
> [email protected] lint C:\projects\abc
> tslint "src/**/*.ts"
All files pass linting.

npm run lint returns nothing, even though code errors exist:

C:\projects\abc>npm run lint
> [email protected] lint C:\projects\abc
> tslint "src/**/*.ts"
C:\projects\abc>

In summary: ng lint is now always a success as if ignoring all errors.

@vkniazeu I had seen that stack trace, but was also interested in the actual console log of npm run lint since that runs tslint directly and I had hoped there was more information there.

@mgechev (the mainteiner of codelyzer) also submitted https://github.com/angular/angular-cli/pull/2615, updating the version use to 1.0.0-beta.1. He mentions that some template-related rules might not work currently though.

Using that version, I got at least src/app/app.component.ts[12, 21]: Missing semicolon errors. What kind of errors are you not getting @vkniazeu?

@filipesilva I think I was rushing my tests before and, rather than introducing a tslint error, I would introduce a transpilation/compilation problem, which would be caught by ng serve as expected.
I just tested breaking a few concrete rules from tslint.json, and they were caught properly by ng lint.
I think we are back in business and this one can be closed.
Thank you!

I want to leave this open because we still swallow errors in the command. I'm happy to hear that there isn't a problem with tslint proper though!

I am getting the same thing using the latest CLI 25.5

@daniellmb @daBishMan would you share the output of:

cat node_modules/codelyzer/package.json | grep version

Most likely the issue is caused by upgrading of already existing project to the new CLI. This kept the old tslint.json configuration and respectively kept non existing rules.

For further information about the codelyzer's configuration, please take a look here.

$ cat node_modules/codelyzer/package.json | grep version
"version": "2.0.0-beta.4"

This confirms my theory. You need to update your tslint.json and drop the missing rules.

@daBishMan This is what the new projects use for tslint.json https://github.com/angular/angular-cli/blob/master/packages/angular-cli/blueprints/ng2/files/tslint.json

Try using that and see if you have the same issue.

many thanks @delasteve I will give this a try much appreciated.

and also many thanks to @mgechev for your help as well.

I will update this issue ASAP with the result after I update my rule file.

@delasteve @mgechev the new results is much better, it was the tslint file for sure. If you can help me answer one more question, I am getting the following error, which is on an html page, it is due to the implementation of a third party control we are using. How can I suppress this error in HTML file?

`$ ng lint

[email protected] lint C:gitgigGIG-TalentSearch-Client
tslint "src//.ts" --project src/tsconfig.json --type-check && tslint "e2e//.ts" --project e2e/tsconfig.json --type-check

c:/git/gig/gig-talentsearch-client/src/app/search/search-results-navigation/search-results-navigation.component.html[29, 32]: The property "numPages" that you're trying to access does not exist in the class declaration.

Lint errors found in the listed files.`

I believe it's this error: https://github.com/mgechev/codelyzer/blob/master/src/templatesUsePublicRule.ts

Judging by the looks of the rule without seeing your code, you may have declared something private that you're trying to use in a template. That, or you are trying to access something in the file that you haven't declared as a class property.

@daBishMan Can you try without the "--type-check" ? Still seeing no output ?
Also, I do not think it matters, but why do you have 2 slashes before "*.ts" ?

Without --type-check works, this is how angular-cli generates it.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajjejosefsson picture rajjejosefsson  路  3Comments

hartjo picture hartjo  路  3Comments

ericel picture ericel  路  3Comments

hareeshav picture hareeshav  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments