For the ESLint version of this library see, eslint-plugin-ngrx
Use the ng-add command from the Angular CLI to be guided with the installation. We'll ask you for which rules you want to enable.
ng add ngrx-tslint-rules
First install ngrx-tslint-rules
as a dependency with the following command.
npm install ngrx-tslint-rules --save-dev
Next, add ngrx-tslint-rules
to your tslint.json
file, and the rules to the rules
config.
{
"extends": ["ngrx-tslint-rules"],
"rules": {
...
}
}
To enable all recommended rules, use the recommended
configuration file.
{
"extends": ["ngrx-tslint-rules/recommended"]
}
The recommended rules also export the rules from rxjs-tslint-rules that can be applied to NgRx
By default all rules are enabled
Rule | Description | Examples |
---|---|---|
ngrx-action-hygiene | Enforces the use of good action hygiene | Example |
ngrx-avoid-dispatching-multiple-actions-sequentially | It is recommended to only dispatch one action at a time | Example |
ngrx-effect-creator-and-decorator | An Effect should only use the effect creator (createEffect ) or the Effect decorator (@Effect ), but not both simultaneously |
Example |
ngrx-no-dispatch-in-effects | An Effect should not call store.dispatch , but should return an action |
Example |
ngrx-no-duplicate-action-types | An action type must be unique | Example |
ngrx-no-effect-decorator | The createEffect creator function is preferred | Example |
ngrx-no-effects-in-providers | The Effect should not be listed as a provider if it is added to the EffectsModule | Example |
ngrx-no-multiple-actions-in-effects | An Effect should not return multiple actions | Example |
ngrx-no-multiple-stores | Store should at most be one time injected | Example |
ngrx-no-reducer-in-key-names | Avoid the word "reducer" in the key names | Example |
ngrx-no-typed-store | A store should not be typed | Example |
ngrx-selector-for-select | Using string or props drilling is not preferred, use a selector instead | Example |
To enable optional rules add them to the rules
section in your tslint.json
file.
{
"extends": ["ngrx-tslint-rules"],
"rules": {
"ngrx-on-reducer-explicit-return-type": true
}
}
Rule | Description | Examples |
---|---|---|
ngrx-on-reducer-explicit-return-type | Enforces type safety for on reducer callbacks |
Example |
MIT