Angular CLI: 6.0.0
Node: 8.11.1
OS: linux x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.6.0
@angular-devkit/build-angular 0.6.0
@angular-devkit/build-optimizer 0.6.0
@angular-devkit/core 0.6.0
@angular-devkit/schematics 0.6.0
@ngtools/webpack 6.0.0
@schematics/angular 0.6.0
@schematics/update 0.6.0
rxjs 6.1.0
typescript 2.7.2
webpack 4.6.0
Run the following command in a Angular v6 project:
ng lint --fix
Terminal output:
Architect commands with multiple targets cannot specify overrides.
As a developer I would like to use the fix flag to lint my code on the development machine. I am aware that I am able to add the fix option in angular.json per Angular workspace documentation and @angular-devkit/build-angular:tslint. Doing so will cause the CI machine to also "auto fix" linting errors. The desired functionality is to allow developers to easily auto fix linting errors while the CI machine should simply fail upon encountering linting errors.
I have exactly the same issue. I have two npm scripts:
"lint": "ng lint",
"lint-fix": "ng lint --fix",
lint is used in a CI script, while lint-fix is used as a Git pre-commit hook.
I think per this SO solution we need to specify the 'library' first, before any 'overrides', i.e. --fix. So for my project it's either web2 or web2-e2e. I was able to fix my source file with:
$ ng lint web2 --fix
Fixed 7 error(s) in /home/isaac/Development/csci4140/web2/src/app/components/bill-new/bill-new.component.ts
<...>
All files pass linting.
Awesome! :) I guess the documentation needs an update then. The following is what I have in my scripts now:
"lint": "ng lint project-foo && ng lint project-foo-e2e",
"lint-fix": "ng lint project-foo --fix && ng lint project-foo-e2e --fix",
This works for me :
"lint" : "ng run
And then in your angular.json in the lint section, do the following :
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
....
"fix": true // Use this line
}
Hope it will help
@kvincent3 the problem with using the fix option in angular.json is that your CI pipeline will now use that option as well when you have it check for linting errors. The fix option is in my view only for the developers before they Git-commit their work.
Hi
I think, I have the same issue as you
I tried this code:
"lint:check": "ng run paul:lint --type-check",
"lint:fix": "yarn-or-npm run lint:check -- --fix",
But this is the output:
(I guess the linter try to lint the node_modules folder ?)
The 'curly' rule threw an error in 'C:/Users/AAA/Documents/projets/paul/paul-cs/src/app/shared/helper
TypeError: Cannot read property 'pos' of undefined
The 'no-string-throw' rule threw an error in 'C:/Users/AAA/Documents/projets/paul/paul-cs/src/app/sha
TypeError: Cannot read property 'kind' of undefined
The 'no-arg' rule threw an error in 'C:/Users/AAA/Documents/projets/paul/paul-cs/src/app/shared/state
TypeError: Cannot read property 'text' of undefined
<--- Last few GCs --->
[12280:0000000000458B60] 14500 ms: Mark-sweep 705.1 (754.5) -> 705.0 (754.5) MB, 362.5 / 0.0 ms alloc
[12280:0000000000458B60] 14945 ms: Mark-sweep 705.0 (754.5) -> 704.9 (714.5) MB, 444.7 / 0.0 ms last
[12280:0000000000458B60] 15333 ms: Mark-sweep 704.9 (714.5) -> 704.9 (714.5) MB, 388.1 / 0.0 ms last
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 000002DDA35257C1 <JSObject>
1: _loop_1(aka _loop_1) [C:\Users\AAA\Documents\projets\paul\paul-cs\node_modules\tslint\lib\rule
<undefined>,identifier=000000F7F0DEE979 <IdentifierObject map = 000002EDAEEC6C49>)
2: /* anonymous */(aka /* anonymous */) [C:\Users\AAA\Documents\projets\paul\paul-cs\node_modules
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node_module_register
2: v8::internal::FatalProcessOutOfMemory
3: v8::internal::FatalProcessOutOfMemory
4: v8::internal::Factory::NewUninitializedFixedArray
5: v8::internal::WasmDebugInfo::SetupForTesting
6: v8::internal::interpreter::BytecodeArrayRandomIterator::UpdateOffsetFromIndex
7: 000000BFF98843C1
error Command failed with exit code 3.
ng lint is set to false by default
ng lint --fix=true
worked for me
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._
Most helpful comment
Awesome! :) I guess the documentation needs an update then. The following is what I have in my scripts now: