eslint-plugin-use-selector-with
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

eslint-plugin-use-selector-with

ESLint plugin for rules around proper useSelectorWith usage.

Installation

yarn add --dev eslint eslint-plugin-use-selector-with

Usage

Add use-selector-with to the plugins section of your ESLint configuration file:

{
  plugins: ['use-selector-with'];
}

Rules

Includes two rules, both of which are auto-fixable and have no configuration options:

We recommend extending from plugin:use-selector-with/recommended to enable both of them:

{
  "extends": ["plugin:use-selector-with/recommended"]
}

If you want more fine control over the rules, you may configure them individually per ESLint's Configuring Rules docs:

{
  "rules": {
    "use-selector-with/prefer-use-selector-with": "warn"
  }
}

prefer-use-selector-with

Enforces using useSelectorWith instead of passing a function expression to useSelector.

Examples of failing code with this rule:

const value = useSelector((state) => getValueFromState(state, 'id'));

Examples of passing code with this rule:

const value = useSelectorWith(getValueFromState, 'id');

unnecessary-use-selector-with

Enforces using useSelector instead of useSelectorWith if there are no args to pass to the selector.

Examples of failing code with this rule:

const value = useSelectorWith(state, getValueFromState);

Examples of passing code with this rule:

const value = useSelector(getValueFromState);

Package Sidebar

Install

npm i eslint-plugin-use-selector-with

Weekly Downloads

422

Version

0.1.2

License

MIT

Unpacked Size

18.4 kB

Total Files

20

Last publish

Collaborators

  • codecademy