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

ng lint shows all errors twice #11633

Closed
johnpapa opened this issue Jul 24, 2018 · 5 comments · Fixed by #11636
Closed

ng lint shows all errors twice #11633

johnpapa opened this issue Jul 24, 2018 · 5 comments · Fixed by #11636

Comments

@johnpapa
Copy link
Contributor

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [X ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Angular CLI: 6.0.8
Node: 8.11.1
OS: darwin x64
Angular: 6.0.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.6.8
@angular/cli                      6.0.8
@ngtools/webpack                  6.0.8
@schematics/angular               0.6.8
@schematics/update                0.6.8
rxjs                              6.2.2
typescript                        2.7.2
webpack                           4.8.3

Repro steps

Add some invalid typescript such as a function with a var statement that is also not used anywhere.

export class AppComponent {
  title = 'app';
  bar() {
    var foo = 1;
  }
}

The log given by the failure

▶ng lint ngtest --format stylish
/Users/papa/_play/ngtest/src/app/app.component.ts:11:5
ERROR: 11:5  no-var-keyword  Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: 11:5  no-var-keyword  Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: 11:9  prefer-const    Identifier 'foo' is never reassigned; use 'const' instead of 'var'.
ERROR: 11:9  prefer-const    Identifier 'foo' is never reassigned; use 'const' instead of 'var'.

Lint errors found in the listed files.

Desired functionality

Error messages should only show up once, not twice

Mention any other details that might be useful

@alan-agius4
Copy link
Collaborator

Hi @johnpapa,

I tried to replicate this locally and unfortunately I didn't manage. I also created a unit test to verify this on different environments alan-agius4@b28a82d#diff-02f9144e97f6ac8d7e153c4ecdf5a5a6R35

My local specs

λ ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.0.8
Node: 8.9.0
OS: win32 x64
Angular: 6.0.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.6.8
@angular/cli                      6.0.8
@angular/pwa                      0.6.8
@ngtools/webpack                  6.0.8
@schematics/angular               0.6.8
@schematics/update                0.6.8
rxjs                              6.2.1
typescript                        2.7.2
webpack                           4.8.3


C:\git\ng-cli-ngsw    master± 
λ ng lint ng-cli-ngsw --format stylish
C:/git/ng-cli-ngsw/src/app/app.module.ts:4:5
ERROR: 4:5  no-var-keyword  Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: 4:9  prefer-const    Identifier 'foo' is never reassigned; use 'const' instead of 'var'.
ERROR: 6:2  eofline         file should end with a newline

Lint errors found in the listed files.

Can you maybe create a small reproduction that replicates this?

Thanks,
Alan

@filipesilva
Copy link
Contributor

@alan-agius4 I can repro myself actually. I replaced AppComponent and ran the following command:

kamik@RED-X1C6 MINGW64 /d/sandbox/latest-project (master)
$ ng lint latest-project --format stylish
D:/sandbox/latest-project/src/app/app.component.ts:11:5
ERROR: 11:5  no-var-keyword  Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: 11:5  no-var-keyword  Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: 11:9  prefer-const    Identifier 'foo' is never reassigned; use 'const' instead of 'var'.
ERROR: 11:9  prefer-const    Identifier 'foo' is never reassigned; use 'const' instead of 'var'.

@filipesilva
Copy link
Contributor

I think what's missing your your repro is that new projects use an array of tsconfigs:

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

But the current config in the test dir uses a single one.

filipesilva pushed a commit that referenced this issue Jul 24, 2018
@johnpapa
Copy link
Contributor Author

Thanks for the help

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

Successfully merging a pull request may close this issue.

3 participants