Skip to content
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

All errors assumed to be lint errors #867

Closed
daniellmb opened this issue May 20, 2016 · 26 comments · Fixed by #4248
Closed

All errors assumed to be lint errors #867

daniellmb opened this issue May 20, 2016 · 26 comments · Fixed by #4248
Assignees
Labels
effort1: easy (hours) P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix

Comments

@daniellmb
Copy link

daniellmb commented May 20, 2016

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.

@delasteve
Copy link
Contributor

#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

@hansl hansl closed this as completed May 20, 2016
@daniellmb
Copy link
Author

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

@filipesilva
Copy link
Contributor

@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.

@filipesilva filipesilva self-assigned this Jun 7, 2016
@filipesilva filipesilva added type: bug/fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Jun 7, 2016
@Memeplexx
Copy link

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

@filipesilva
Copy link
Contributor

ng lint should also be a bit more friendly as mentioned in #967 (comment)

@vkniazeu
Copy link

vkniazeu commented Oct 7, 2016

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.

@vkniazeu
Copy link

vkniazeu commented Oct 7, 2016

#2567

@filipesilva
Copy link
Contributor

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

@vkniazeu
Copy link

@filipesilva I left the relevant stack trace in the description of #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)

@vkniazeu
Copy link

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.

@vkniazeu
Copy link

vkniazeu commented Oct 10, 2016

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>

@vkniazeu
Copy link

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

@filipesilva
Copy link
Contributor

@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 #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?

@vkniazeu
Copy link

@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!

@filipesilva
Copy link
Contributor

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!

@hansl hansl modified the milestone: RC1 Nov 11, 2016
@daBishMan
Copy link

I am getting the same thing using the latest CLI 25.5

@mgechev
Copy link
Member

mgechev commented Jan 18, 2017

@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.

@daBishMan
Copy link

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

@mgechev
Copy link
Member

mgechev commented Jan 18, 2017

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

@delasteve
Copy link
Contributor

delasteve commented Jan 18, 2017

@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.

@daBishMan
Copy link

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.

@daBishMan
Copy link

@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:\git\gig\GIG-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.`

@delasteve
Copy link
Contributor

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.

@catull
Copy link
Contributor

catull commented Jan 23, 2017

@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" ?

@daBishMan
Copy link

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

delasteve added a commit to delasteve/angular-cli that referenced this issue Jan 27, 2017
Closes angular#867, angular#3993

BREAKING CHANGE: In order to use the new `ng lint` command,
  the following section will have to be added to the project's
  `angular-cli.json` at the root level of the json object.

  ```json
  "lint": [
    {
      "files": "<%= sourceDir %>/**/*.ts",
      "project": "<%= sourceDir %>/tsconfig.json"
    },
    {
      "files": "e2e/**/*.ts",
      "project": "e2e/tsconfig.json"
    }
  ],
  ```

Alternatively, you can run `ng update`.
delasteve added a commit to delasteve/angular-cli that referenced this issue Jan 27, 2017
Closes angular#867, angular#3993

BREAKING CHANGE: In order to use the new `ng lint` command,
  the following section will have to be added to the project's
  `angular-cli.json` at the root level of the json object.

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

Alternatively, you can run `ng update`.
delasteve added a commit to delasteve/angular-cli that referenced this issue Jan 27, 2017
Closes angular#867, angular#3993

BREAKING CHANGE: In order to use the updated `ng lint` command,
  the following section will have to be added to the project's
  `angular-cli.json` at the root level of the json object.

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

Alternatively, you can run `ng update`.
delasteve added a commit to delasteve/angular-cli that referenced this issue Jan 28, 2017
Closes angular#867, angular#3993

BREAKING CHANGE: In order to use the updated `ng lint` command,
  the following section will have to be added to the project's
  `angular-cli.json` at the root level of the json object.

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

Alternatively, you can run `ng update`.
filipesilva pushed a commit that referenced this issue Jan 28, 2017
Closes #867, #3993

BREAKING CHANGE: 

In order to use the updated `ng lint` command, the following section will have to be added to the project's `angular-cli.json` at the root level of the json object.

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

Alternatively, you can run `ng update`.
MRHarrison pushed a commit to MRHarrison/angular-cli that referenced this issue Feb 9, 2017
Closes angular#867, angular#3993

BREAKING CHANGE: 

In order to use the updated `ng lint` command, the following section will have to be added to the project's `angular-cli.json` at the root level of the json object.

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

Alternatively, you can run `ng update`.
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort1: easy (hours) P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants