@trove/eslint-plugin-trove

1.3.2 • Public • Published

Eslint Plugin Trove Build Status

Rules

module-boundary:

  • Cannot reach into top-level @trove packages

no-state-prop:

  • Cannot access state properties directly inside mapStateToProps, must use function like getStatePropertyX(state)
  • Cannot access state properties directly inside createSelector

expect-gen-run:

  • Must invoke either run or toJSON when using expectGen

module-boundary

This rule will check all import/require to ensure it does not reach into a top-level notion-modules package

Valid
import { actionCreators } from '@trove/thread';
Invalid
import { actionCreators } from '@trove/thread/message';

no-state-prop

This rule will check mapStateToProps for code trying to access state properties directly.

Valid
import { connect } from 'react-redux';
import { getItem } from './selectors';

const App = () => {};

connect((state) => {
  return {
    item: getItem(state),
  };
})(App);
Invalid
import { connect } from 'react-redux';

const App = () => {};

connect((state) => {
  return {
    item: state.item,
  };
})(App);

This rule will check createSelector for code trying to access state properties directly.

Valid
import { createSelector } from 'reselect';
const getItem = (state) => state.item;

const getItemOpen = createSelector(
  getItem,
  (item) => item.open
);
Invalid
import { createSelector } from 'reselect';

const getItem = createSelector(
  (state) => state.item,
  (item) => item
);

expect-gen-run

This rule will check any use of expectGen to ensure .run() or .toJSON() is called.

Valid
expectGen(effect)
  .next()
  .run();
Valid
expectGen(effect)
  .next()
  .toJSON();
Invalid
expectGen(effect)
  .next();

Readme

Keywords

Package Sidebar

Install

npm i @trove/eslint-plugin-trove

Weekly Downloads

1

Version

1.3.2

License

MIT

Unpacked Size

44.5 kB

Total Files

12

Last publish

Collaborators

  • iankberry
  • adamkempa
  • akinnee
  • jimbol