Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@arthurgeron/eslint-plugin-react-usememo

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arthurgeron/eslint-plugin-react-usememo

Enforce that all function components are wrapped in `React.memo`, and that all props and deps are wrapped in `useMemo`/`useCallback` so they don’t break memo.

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.8K
decreased by-7.98%
Maintainers
1
Weekly downloads
 
Created
Source

eslint-plugin-react-usememo

Enforce that all function components are wrapped in React.memo, and that all props and deps are wrapped in useMemo/useCallback so they don’t break memo.

Rationale: Why we memo all the things.

Installation

yarn add @arthurgeron/eslint-plugin-react-usememo --dev

or

npm install @arthurgeron/eslint-plugin-react-usememo --save-dev

Usage

To enable the plugin add the following to the plugin property your eslintrc file:

plugins: ["@arthurgeron/react-usememo"],

Then enable any rules as you like, example:

rules: {
    "@arthurgeron/react-usememo/require-usememo": [2],
},

Rules

require-memo

Requires all function components to be wrapped in React.memo().
May be useful when used with overrides in your eslint config, I do not recommend enabling this globally.

Requires complex values (objects, arrays, functions, and JSX) that get passed props or referenced as a hook dependency to be wrapped in React.useMemo() or React.useCallback().

Options:

  • {strict: true}: Fails even in cases where it is difficult to determine if the value in question is a primitive (string or number) or a complex value (object, array, etc.).

require-usememo-children Advanced

Requires complex values (objects, arrays, functions, and JSX) that get passed as children to be wrapped in React.useMemo() or React.useCallback().

Options:

  • {strict: true}: Fails even in cases where it is difficult to determine if the value in question is a primitive (string or number) or a complex value (object, array, etc.).

FAQs

Package last updated on 22 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc