Skip to content

Latest commit

 

History

History
114 lines (90 loc) · 14.3 KB

README.md

File metadata and controls

114 lines (90 loc) · 14.3 KB

eslint-plugin-ngrx

Installation

Install ESLint TypeScript parser

npm install @typescript-eslint/parser --save-dev

Install eslint-plugin-ngrx package

npm install eslint-plugin-ngrx --save-dev

Next, add eslint-plugin-ngrx to your ESLint config (for example in .eslintrc.js) and configure parser and parserOptions.

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2019,
    "project": "./tsconfig.json",
    "sourceType": "module"
  },
  "plugins": ["ngrx"],
  "rules": {
    "ngrx/select-style": "error"
  }
}

To enable the recommended configuration, add it to your ESLint configuration file.

{
  "extends": ["plugin:ngrx/recommended"]
}

Rules

effects

Name Description Recommended Category Fixable
ngrx/no-dispatch-in-effects An Effect should not call store.dispatch suggestion warn (Best Practices) No
ngrx/no-effect-decorator-and-creator An Effect should only use the effect creator (createEffect) or the effect decorator (@Effect), but not both simultaneously problem error (Possible Errors) No
ngrx/no-effect-decorator The createEffect creator function is preferred problem error (Possible Errors) Yes
ngrx/no-effects-in-providers An Effect should not be listed as a provider if it is added to the EffectsModule problem error (Possible Errors) No
ngrx/no-multiple-actions-in-effects An Effect should not return multiple actions. problem error (Possible Errors) No
ngrx/prefer-concat-latest-from Use concatLatestFrom instead of withLatestFrom to prevent the selector from firing until the correct action is dispatched. suggestion warn (Possible Errors) Yes
ngrx/prefer-effect-callback-in-block-statement A block statement is easier to troubleshoot. suggestion error (Best Practices) Yes
ngrx/use-effects-lifecycle-interface Ensures classes implement lifecycle interfaces corresponding to the declared lifecycle methods suggestion warn (Best Practices) Yes
rxjs/no-cyclic-action Forbids effects that re-emit filtered actions. problem error (Possible Errors) No
rxjs/no-unsafe-catch Forbids unsafe catchError usage in effects. problem error (Possible Errors) No
rxjs/no-unsafe-first Forbids unsafe first/take usage in effects. problem error (Possible Errors) No
rxjs/no-unsafe-switchmap Forbids unsafe switchMap usage in effects. problem error (Possible Errors) No

store

Name Description Recommended Category Fixable
ngrx/avoid-combining-selectors Prefer combining selectors at the selector level with createSelector suggestion warn (Best Practices) No
ngrx/avoid-dispatching-multiple-actions-sequentially It is recommended to only dispatch one action at a time. problem warn (Best Practices) No
ngrx/avoid-mapping-selectors Avoid to add mapping logic in the component, instead move that logic in the projector method of createSelector. suggestion warn (Best Practices) No
ngrx/good-action-hygiene Enforces the use of good action hygiene. suggestion warn (Best Practices) No
ngrx/no-multiple-global-stores There should only be one global store injected suggestion warn (Best Practices) No
ngrx/no-reducer-in-key-names Avoid the word "reducer" in the reducer key names suggestion warn (Best Practices) No
ngrx/no-typed-global-store Store should not be typed suggestion warn (Best Practices) Yes
ngrx/on-function-explicit-return-type On function should have an explicit return type problem error (Possible Errors) No
ngrx/prefer-inline-action-props Prefer using inline types instead of interfaces/classes. suggestion error (Best Practices) No
ngrx/select-style Selectors can be used either with 'select' as a pipeable operator or as a method problem false (Possible Errors) No
ngrx/use-selector-in-select Using a selector in a select method is preferred in favor of strings or props drilling suggestion warn (Best Practices) No

Migrating from ngrx-tslint-rules

If you were previously using TSLint for your project and especially the ngrx-tslint-rules package, you should check out the migration guide. You will find out how to replace the previous TSLint rule names by the new ESLint ones.

Contributors

Thanks goes to these wonderful people (emoji key):


Tim Deschryver

💻 🤔 🚇 ⚠️

Julien Saguet

💻 ⚠️ 🤔 📖

Stephen Cooper

🤔

Chris Paton

💻

Sebastian Weigel

💻

Rafael Santana

🤔 💻 ⚠️

Armen Vardanyan

📖

Michaël De Boey

💻

This project follows the all-contributors specification. Contributions of any kind welcome!