reduxjs / redux-toolkit

The official, opinionated, batteries-included toolset for efficient Redux development
https://redux-toolkit.js.org
MIT License
10.7k stars 1.17k forks source link

Redux-related lint rules? #3911

Open markerikson opened 10 months ago

markerikson commented 10 months ago

Maybe it's worth coming up with our own set of lint rules (no x => x selectors?)

EskiMojo14 commented 10 months ago

other previously suggested rules:

EskiMojo14 commented 10 months ago

a no no-op selector lint rule seems a little less necessary now it's checked in runtime, but i suppose it would be nice to be done with static code analysis too

nevnein commented 10 months ago

No immediate destructuring of object returned from useSelector

(Btw I was exploring this, but then I noticed eslint is on the verge of releasing a pretty big v9, so I guess I'll wait for that)

EskiMojo14 commented 10 months ago

we'd probably want to put reselect related rules under the same plugin as well - we can always offer a "reselect-only" config

some community-made packages we may want to see if we agree with any rules from:

EskiMojo14 commented 8 months ago

another thing to possibly catch:

const middleware: Middleware =>
  api =>
  next =>
  async (action) => {}

the final function for a middleware should never use the async keyword, because then every dispatch returns a promise.

markerikson commented 8 months ago

While it's not a "lint rule" thing per se, there was a request here for some form of static analysis that would make it easier to jump from an action creator in a component file straight to the corresponding reducer:

EskiMojo14 commented 5 months ago

based on https://phryneas.de/redux-typescript-no-discriminating-union - a lint rule that prevents dispatches without an action creator

Faithfinder commented 4 months ago

"No connect in Function Components" is something I'd like now in our codebase with developers stuck in 10 year old paradigms