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 <project> --files` behaves differently #13399

Open
abhijeetkpawar opened this Issue Jan 10, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@abhijeetkpawar
Copy link

abhijeetkpawar commented Jan 10, 2019

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

Windows 10

$ node --version
v10.14.2

$ npm --version
6.5.0

$ ng --version

Angular CLI: 7.1.4  
Node: 10.14.2
OS: win32 x64  
Angular: 7.1.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic 
... router
Package                            Version
------------------------------------------------------------     
@angular-devkit/architect          0.11.4  
@angular-devkit/build-angular      0.11.4 
@angular-devkit/build-ng-packagr   0.11.4
@angular-devkit/build-optimizer    0.11.4
@angular-devkit/build-webpack      0.11.4
@angular-devkit/core               7.1.4 
@angular-devkit/schematics         7.1.4  
@ngtools/json-schema               1.1.0
@ngtools/webpack                   7.1.4 
@schematics/angular                7.1.4 
@schematics/update                 0.11.4   
ng-packagr                         4.4.5   
rxjs                               6.3.3
typescript                         3.1.6   
webpack                            4.23.1

Repro steps

  1. ng new lint-issue
  2. cd lint-issue/
  3. ng g library sample
  4. touch projects/sample/one.component.ts
  5. echo "" > projects/sample/one.component.ts
  6. ng lint sample
  7. ng lint sample -files projects/sample/one.component.ts

Step 6 succeeds, but step 7 gives error

The log given by the failure

File '<full-path>\lint-issue\projects\sample\one.component.ts' is not part of the TypeScript project 'projects/sample/tsconfig.lib.json,projects/sample/tsconfig.spec.json'.
Error: File '<full-path>\lint-issue\projects\sample\one.component.ts' is not part of the TypeScript project 'projects/sample/tsconfig.lib.json,projects/sample/tsconfig.spec.json'.
    at getFileContents (<full-path>\lint-issue\node_modules\@angular-devkit\build-angular\src\tslint\index.js:163:19)
    at lint (<full-path>\lint-issue\node_modules\@angular-devkit\build-angular\src\tslint\index.js:124:26)
    at Observable.rxjs_1.Observable.obs [as _subscribe] (<full-path>\lint-issue\node_modules\@angular-devkit\build-angular\src\tslint\index.js:61:37)
    at Observable._trySubscribe (<full-path>\lint-issue\node_modules\rxjs\internal\Observable.js:44:25)
    at Observable.subscribe (<full-path>\lint-issue\node_modules\rxjs\internal\Observable.js:30:22)
    at <full-path>\lint-issue\node_modules\rxjs\internal\util\subscribeTo.js:22:31
    at Object.subscribeToResult (<full-path>\lint-issue\node_modules\rxjs\internal\util\subscribeToResult.js:10:45)
    at MergeMapSubscriber._innerSub (<full-path>\lint-issue\node_modules\rxjs\internal\operators\mergeMap.js:82:29)
    at MergeMapSubscriber._tryNext (<full-path>\lint-issue\node_modules\rxjs\internal\operators\mergeMap.js:76:14)
    at MergeMapSubscriber._next (<full-path>\lint-issue\node_modules\rxjs\internal\operators\mergeMap.js:59:18)

Desired functionality

ng lint <project> command with and without files flag should perform in consistent way

@zuzusik

This comment has been minimized.

Copy link

zuzusik commented Jan 15, 2019

facing the same issue in our project

@alan-agius4

This comment has been minimized.

Copy link
Collaborator

alan-agius4 commented Jan 15, 2019

The issue here is that by default in the lint config there are two tsconfig provided.

"tsConfig": [
  "projects/lib/tsconfig.lib.json",
  "projects/lib/tsconfig.spec.json"
],

And the file in question, is only present in one of the compilation units, since most likely it is never referenced in a unit test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment