TSLint rules for NgRx. Heavily based on ReactiveX/rxjs-tslint
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(...),
);
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(...))
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
MIT