Skip to content

Duplicate Lint Errors #5259

Closed
Closed
@dave11mj

Description

@dave11mj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions