Skip to content

Angular CLI gotcha when an RxJS function is used only in a unit test #14

@balassy

Description

@balassy

I have the following rxjs.imports.ts file in an Angular 4 project:

import 'rxjs/add/observable/of';

I have the following rule in the tslint.json file:

"rxjs-add": {
  "options": [{
    "file": "./src/rxjs.imports.ts"
  }],
  "severity": "error"
}

The following error is thrown when I run tslint:

ERROR: (rxjs-add) C:/Git/MyProject/src/rxjs.imports.ts[3, 1]: 
Unused patched observable in ./src/rxjs.imports.ts: of

I am using Observable.of(...) in my code, however only in one single .spec.ts file. It seems that the error is thrown during linting the application files, because if I remove the following block from the lint section of the .angular-cli.json file, the error disappears:

{
  "project": "src/tsconfig.app.json",
  "exclude": "**/node_modules/**"
},

Do you have any recommendation on how can I fix this, or this is just another gotcha that would be useful to add to the README?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions