Skip to content

timdeschryver/ngrx-tslint

Repository files navigation

NgRx TSLint

TSLint rules for NgRx. Heavily based on ReactiveX/rxjs-tslint

Table of Contents

Rules

ngrx-effects-operators

Migrates the ofType function to its pipeable equivalent.

BEFORE:
import { Effect, Actions } from '@ngrx/effects';

@Effect()
search = this.actions.ofType<SearchAnimals>(SEARCH_ANIMALS).pipe(
    debounceTime(3000),
    switchMap(...),
  );

AFTER:
import { Effect, Actions, ofType } from '@ngrx/effects';

@Effect()
search = this.actions.pipe(
    ofType<SearchAnimals>(SEARCH_ANIMALS),
    debounceTime(3000),
    switchMap(...),
  );

ngrx-chained-pipes

Because the rules above will create a new pipe chain you may end up with multiple pipes, this rule will combine both pipe chains.

BEFORE:
this.store.pipe(select(...)).pipe(map(...))

AFTER:
this.store.pipe(select(...), map(...))

Usage

Automatically run the migration:

npx ngrx-tslint-oftype

Or install the package, add the following rules to the tslint.confg and run TSLint on the project.

npm install ngrx-tslint-oftype --save-dev
{
  "rulesDirectory": ["node_modules/ngrx-tslint-oftype"],
  "rules": {
    "ngrx-effects-operators": true,
    "ngrx-chained-pipes": true
  }
}
./node_modules/.bin/tslint -c tslint.json -p src/tsconfig.app.json --fix

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published