TransWikia.com

JSLint: Disallow state. in Redux connect functon

Stack Overflow Asked by hakunin on November 27, 2021

Need to write a (custom) ESLint rule for this:

Good:

connect((state, props) => {
  return {
     organizations: Organization.getActive(state, props.user),
    ...
    <prop>: Model.scope(state, prop...),  

  };
})(MyComponent);

Bad: All the stuff in there

connect((state, props) => {
  return {
     organizations: state.organizations, //archived? suspended? or really all?
  };
})(MyComponent);

Bad: Filtering in place.

connect((state, props) => {
  return {
     organizations: filter(state.organizations, {
       status: Organization.ACTIVE
     }),
  };
})(MyComponent);

All that should be needed is to disallow state.<something> within the connect function as a starting point and make tweaks as needed.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP