Coder Social home page Coder Social logo

eslint-plugin-ngrx's Introduction

eslint-plugin-ngrx

Installation

With ng-add

Install and configure the ESLint NgRx Plugin with the ng-add command. This command:

  • adds ngrx-eslint-plugin as a dev dependency;
  • adds the plugin to the ESLint plugins property;
  • adds the recommended config to the extends property of ESLint;
ng add ngrx-eslint-plugin

Manual

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 Configurable
ngrx/no-dispatch-in-effects An Effect should not call store.dispatch suggestion warn (Possible Errors) No 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 No
ngrx/no-effect-decorator The createEffect creator function is preferred problem warn (Best Practices) Yes No
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 No
ngrx/no-multiple-actions-in-effects An Effect should not return multiple actions. problem warn (Best Practices) No 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 No
ngrx/prefer-effect-callback-in-block-statement A block statement is easier to troubleshoot. suggestion warn (Best Practices) Yes No
ngrx/use-effects-lifecycle-interface Ensures classes implement lifecycle interfaces corresponding to the declared lifecycle methods suggestion warn (Best Practices) Yes No
rxjs/no-cyclic-action Forbids effects that re-emit filtered actions. problem error (Possible Errors) No No
rxjs/no-unsafe-catch Forbids unsafe catchError usage in effects. problem error (Possible Errors) No No
rxjs/no-unsafe-first Forbids unsafe first/take usage in effects. problem error (Possible Errors) No No
rxjs/no-unsafe-switchmap Forbids unsafe switchMap usage in effects. problem error (Possible Errors) No No

store

Name Description Recommended Category Fixable Configurable
ngrx/avoid-combining-selectors Prefer combining selectors at the selector level with createSelector suggestion warn (Best Practices) No No
ngrx/avoid-dispatching-multiple-actions-sequentially It is recommended to only dispatch one action at a time. problem warn (Best Practices) No 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 No
ngrx/good-action-hygiene Enforces the use of good action hygiene. suggestion warn (Best Practices) No No
ngrx/no-multiple-global-stores There should only be one global store injected suggestion warn (Best Practices) No No
ngrx/no-reducer-in-key-names Avoid the word "reducer" in the reducer key names suggestion warn (Best Practices) No No
ngrx/no-typed-global-store The global store should not be typed. suggestion warn (Best Practices) Yes No
ngrx/on-function-explicit-return-type On function should have an explicit return type problem warn (Possible Errors) No No
ngrx/prefer-inline-action-props Prefer using inline types instead of interfaces/classes. suggestion warn (Best Practices) No No
ngrx/select-style Selectors can be used either with 'select' as a pipeable operator or as a method problem warn (Best Practices) No Yes
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 No

Configurations

Name Description
recommended The recommended config
store Only the recommended global store config
effects Only the recommended effects config
all All rules are enabled
strict All rules are enable and give errors

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

πŸ’»

David

πŸ“–

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

eslint-plugin-ngrx's People

Contributors

allcontributors[bot] avatar armenvardanyan95 avatar cartant avatar jsaguet avatar legiew avatar michaeldeboey avatar patoncrispy avatar rafaelss95 avatar timdeschryver avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.