Duplicate Lint Errors
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 --versionand 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.
- Run
ng new lint-test - Run
cd lint-test - Run
ng g component components/test-lint - Open
src/app/components/test-lint/test-lint.component.tsand cause one lint error (e.g, use " instead of ') - Run
npm run lint - Notice how the lint errors are logged twice
The log given by the failure.
Normally this include a stack trace and some more information.
> [email protected] 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.
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
as per chat with @filipesilva , this may be due to the multiple TS projects now included in the CLI.
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
It seems that there's again a similar issue with @angular/[email protected] now, can someone confirm?
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 ?
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/**"
]
}
}
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"
}
}
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?)
CC: @filipesilva
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?
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.