Skip to content

ng generate with lint fix results in "no such file or directory" error #12480

@probert94

Description

@probert94

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
- [X] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

NodeJS: v8.10.0
npm: 6.4.1

Angular CLI: 6.2.4
Node: 8.10.0
OS: win32 x64
Angular: 6.1.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.8.4
@angular-devkit/build-angular     0.8.4
@angular-devkit/build-optimizer   0.8.4
@angular-devkit/build-webpack     0.8.4
@angular-devkit/core              0.8.4
@angular-devkit/schematics        0.8.4
@angular/cli                      6.2.4
@ngtools/webpack                  6.2.4
@schematics/angular               0.8.4
@schematics/update                0.8.4
rxjs                              6.2.2
typescript                        2.9.2
webpack                           4.20.2

Repro steps

  1. Create a new project using ng new
  2. Edit the angular.json-File and add a Schematics-Configuration with the lintFix-Option:
	"schematics": {
		"@schematics/angular:component": {
			"lintFix": true
		}
	},

This Code can be inserted right before the projects-Node.

  1. Add a fixable tslint-rule, which collides with the default schematics.
    Examples are:
	"linebreak-style": [
		true,
		"CRLF"
	],
	"quotemark": [
		true,
		"double"
	],
  1. Create a component using ng generate component

The log given by the failure

>ng g component test
CREATE src/app/test/test.component.html (23 bytes)
CREATE src/app/test/test.component.spec.ts (614 bytes)
CREATE src/app/test/test.component.ts (261 bytes)
CREATE src/app/test/test.component.css (0 bytes)
UPDATE src/app/app.module.ts (388 bytes)
ENOENT: no such file or directory, scandir 'C:\Users\User\Angular\project\src\app\src\app\test'

Note, that it looks for project\src\app\src\app\test instead of project\src\app\test

Desired functionality

I would expect, that the lintFix-Option fixes all lint errors in the newly generated component.ts and component.spec.ts files. However, those files still use "LF" instead of "CRLF" and they still have Single-quotes instead of Double-Quotes.

Mention any other details that might be useful

The lintFix-Option disappeared in angular/cli@6.0 as mentioned in #11034 and came back with #11648.
It should be part of angular/cli@6.2.x and it is part of it's schematics schema file

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions