npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-reselect-kit

v1.1.1

Published

ESLint plugin to enforce best practices when using reselect and reselect-kit libraries

Downloads

214

Readme

eslint-plugin-reselect-kit

ESLint rules that keep cached selectors and their key selectors in sync when using reselect-kit and @veksa/re-reselect.

A cached selector memoizes per key, so a key selector that reads different props than the selector itself produces cache entries that never hit - or collide. Both rules are type driven and both can fix what they find.

Installation

# npm
npm install eslint-plugin-reselect-kit --save-dev

# yarn
yarn add eslint-plugin-reselect-kit --dev

Requirements

| | | | --------------------------- | ----------------------------------------------- | | ESLint | 8.57, 9 or 10 - flat config or eslintrc | | @typescript-eslint/parser | 8.44 or later, configured with type information | | TypeScript | 5.4 up to 6.0 | | Node | 20, 22 or 24 |

CI runs the suite against every combination above. The TypeScript ceiling comes from @typescript-eslint, which supports >=4.8.4 <6.1.0.

Setup

Both rules read the types of your selectors, so the parser has to be pointed at a tsconfig.json. Without type information they report nothing.

// eslint.config.js
import tsParser from '@typescript-eslint/parser';
import { reselectKitPlugin } from 'eslint-plugin-reselect-kit';

export default [
  {
    files: ['**/*.ts', '**/*.tsx'],
    languageOptions: {
      parser: tsParser,
      parserOptions: {
        project: './tsconfig.json',
        tsconfigRootDir: import.meta.dirname,
      },
    },
  },
  ...reselectKitPlugin.configs.all,
];

configs.all registers the plugin under the reselect-kit namespace and turns both rules on as errors. To change a severity or pass options, add a block after it:

export default [
  ...reselectKitPlugin.configs.all,
  {
    rules: {
      'reselect-kit/require-key-selector': 'warn',
      'reselect-kit/no-different-props': ['error', { composer: 'arrayComposeKeySelectors' }],
    },
  },
];

eslintrc

The rules are also exposed on the module itself, so the legacy config format works without migrating. List the rules directly - extends: 'plugin:reselect-kit/all' is not available, because configs.all is a flat config array.

// .eslintrc.js
module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: true,
    tsconfigRootDir: __dirname,
  },
  plugins: ['reselect-kit'],
  rules: {
    'reselect-kit/no-different-props': 'error',
    'reselect-kit/require-key-selector': 'error',
  },
};

What the rules look at

Every call of the shape creator(...)(options) is checked, where creator is one of createCachedSelector, createCachedStructuredSelector or createCachedSequenceSelector.

The callee is resolved back to the declaration it came from, so a barrel module that renames a creator on the way out is still checked. Both an import alias and a plain re-binding are followed:

// utils/redux.ts
import {createCachedSelector} from '@veksa/re-reselect';

export {createCachedStructuredSelector as cachedStruct} from 'reselect-kit';
export const cachedSelector = createCachedSelector;

// anywhere.ts - checked, even though the calls use the local names
cachedStruct({...})({keySelector: ...});
cachedSelector([...], combiner)({keySelector: ...});

Two limits are worth knowing:

  • Options handed over as an expression (creator(...)(getOptions())) are reported but not fixed - there is no object literal to rewrite.
  • For a selector taking more than one parametric argument ((state, first: A, second: B) => ...) only the first is read as the props bag, since that is all createPropSelector can describe. The report and the fix cover A alone.

Rules

reselect-kit/no-different-props

Reports a cached selector whose key selector does not read exactly the props the selector itself declares - a different name, a different type, or a different optionality all count.

import { createCachedSelector } from '@veksa/re-reselect';
import { createPropSelector } from 'reselect-kit';

// error: selector parameters = { itemId: number }, key selector parameters = { id: number }
createCachedSelector(
  [(state: State, props: { itemId: number }) => state.items[props.itemId]],
  (item) => item,
)({
  keySelector: createPropSelector<{ id: number }>().id(),
});

The fix rewrites keySelector to match the selector and adds the imports it needs:

createCachedSelector(
  [(state: State, props: { itemId: number }) => state.items[props.itemId]],
  (item) => item,
)({
  keySelector: createPropSelector<{ itemId: number }>().itemId(),
});

A selector that takes no props at all is fixed to defaultKeySelector. When it takes more than one, the props are composed:

keySelector: stringComposeKeySelectors(
    createPropSelector<{ accountId: number }>().accountId(),
    createPropSelector<{ symbolId: number }>().symbolId()
),

Hand written key selectors are compared the same way, so (state: State, props: {itemId: number}) => props.itemId is accepted where the props line up.

Options

| Option | Default | Description | | ---------- | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | composer | 'stringComposeKeySelectors' | Helper the fix wraps multiple prop selectors in. Set it to 'arrayComposeKeySelectors', or to your own composer, and the fix imports that name instead. |

'reselect-kit/no-different-props': ['error', {composer: 'arrayComposeKeySelectors'}]

reselect-kit/require-key-selector

Reports a cached selector created without a keySelector, which leaves it memoizing under a single shared key.

// error: Cached selector can`t work without key selector
createCachedSelector([(state: State) => state.items], (items) => items)({});

The fix inserts defaultKeySelector and imports it:

import { defaultKeySelector } from 'reselect-kit';

createCachedSelector(
  [(state: State) => state.items],
  (items) => items,
)({
  keySelector: defaultKeySelector,
});

A keySelector arriving through a spread ({...createDefaultOptions()}) satisfies the rule.

Development

yarn compile        # type check
yarn lint           # oxlint
yarn fmt            # oxfmt, `yarn fmt:check` to verify only
yarn test           # run the rule tests
yarn test:coverage  # the suite is kept at 100%
yarn build          # emit lib/

Contributing

This project welcomes contributions and suggestions.

License

MIT