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

Duplicate Lint Errors #5259

Closed
dave11mj opened this issue Mar 6, 2017 · 11 comments
Closed

Duplicate Lint Errors #5259

dave11mj opened this issue Mar 6, 2017 · 11 comments

Comments

@dave11mj
Copy link
Contributor

dave11mj commented Mar 6, 2017

Please provide us with the following information:

OS?

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

OSX El Capitan Version 10.11.6

Versions.

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

@angular/cli: 1.0.0-rc.1
node: 6.9.5
os: darwin x64

Repro steps.

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

  1. Run ng new lint-test
  2. Run cd lint-test
  3. Run ng g component components/test-lint
  4. Open src/app/components/test-lint/test-lint.component.ts and cause one lint error (e.g, use " instead of ')
  5. Run npm run lint
  6. Notice how the lint errors are logged twice

The log given by the failure.

Normally this include a stack trace and some more information.

> linting-test@0.0.0 lint /path/to/lint-test
> ng lint

/path/to/lint-test/src/app/components/test-lint/test-lint.component.ts[4, 13]: " should be '
/path/to/lint-test/src/app/components/test-lint/test-lint.component.ts[4, 13]: " should be '
Lint errors found in the listed files.

Mention any other details that might be useful.

Through a bit of trial and error it seems the issue only occurs on files that are nested inside subfolders like components and are imported to other nested files. In this case it happens out of the box because ng new generates a test-lint.component.spec.ts file for each component which has an import { TestLintComponent } from './test-lint.component'; thus causing lint errors on the component to be reported twice.

A temporary fix in my particular case was to remove "include": [ "**/*.spec.ts" ] from src/tsconfig.spec.json since linting test specs was a priority to me.

It'd be nice to know more about the cause and if there is a better fix for this dilemma.

Thanks! ^^


Thanks! We'll be in touch soon.

@johnpapa
Copy link
Contributor

johnpapa commented Mar 7, 2017

I see the same issue.

$ ng lint
/Users/john/_play/angular-hello/src/app/app.component.ts[13, 5]: Identifier 'f' is never reassigned; use 'const' instead of 'let'.
/Users/john/_play/angular-hello/src/app/app.component.ts[13, 5]: Identifier 'f' is never reassigned; use 'const' instead of 'let'.
Lint errors found in the listed files.
$ ng -v --verbose
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.0.0-rc.1
http_parser: 2.7.0
node: 6.9.1
v8: 5.1.281.84
uv: 1.9.1
zlib: 1.2.8
ares: 1.10.1-DEV
icu: 57.1
modules: 48
openssl: 1.0.2j
os: darwin x64
@angular/common: 4.0.0-rc.2
@angular/compiler: 4.0.0-rc.2
@angular/core: 4.0.0-rc.2
@angular/flex-layout: 2.0.0-rc.1
@angular/forms: 4.0.0-rc.2
@angular/http: 4.0.0-rc.2
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 4.0.0-rc.2
@angular/platform-browser-dynamic: 4.0.0-rc.2
@angular/router: 4.0.0-rc.2
@angular/cli: 1.0.0-rc.1
@angular/compiler-cli: 4.0.0-rc.2

@johnpapa
Copy link
Contributor

johnpapa commented Mar 7, 2017

as per chat with @filipesilva , this may be due to the multiple TS projects now included in the CLI.

@deebloo
Copy link
Contributor

deebloo commented Mar 8, 2017

It seems like the linter runs once for each project? and since the tests should include the same components it is hitting the same code twice

asnowwolf pushed a commit to asnowwolf/angular-cli that referenced this issue Apr 12, 2017
For machine readable output formats, ng lint was concatenating multiple documents into a single file. This resulted in invalid JSON, XML, etc. The lint results are now aggregated and one full output is generated.

Fix angular#5259
Close angular#5224
@kamenminkov
Copy link

It seems that there's again a similar issue with @angular/cli@6.0.3 now, can someone confirm?

@eweap
Copy link

eweap commented May 29, 2018

After some tests, I found that commenting one of the two tsConfig entry in angular.json result to output the error one time. Maybe the linter run twice on files included in spec AND in app config ?

@vasiliy0s
Copy link

Same problem for me. Included two tsConfigs in angular.json:

        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }

@axelboc
Copy link

axelboc commented Aug 1, 2018

If tsconfig.spec.json includes all the files that tsconfic.app.json does, then specifying only tsconfig.spec.json in the linting config in angular.json is enough to lint everything perfectly:

"lint": {
 "builder": "@angular-devkit/build-angular:tslint",
  "options": {
    "tsConfig": "src/tsconfig.spec.json",
    "typeCheck": true,
    "format": "stylish"
  }
}

@psmyrdek
Copy link

psmyrdek commented Aug 3, 2018

I'd love to have a chance to include both spec and app tsconfigs of my project inside of angular.json/lint options, without caring about their content. Solution above is more like a temporary workaround (I have to admit it works fine), not a state we'd like to see here for ever IMO.

(I see that PR is still closed - is anyone aware of this issue?)

@psmyrdek
Copy link

psmyrdek commented Aug 6, 2018

CC: @filipesilva

@arthurspa
Copy link

arthurspa commented Feb 1, 2019

I'm also having duplicated error messages when running this:

ng lint --format=stylish --force my-app my-app-e2e

Any solution or workaround available?

@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 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
10 participants