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-react-codemod

v0.3.1

Published

React specific codemod with ESLint's ability of autofix

Readme

eslint-plugin-react-codemod

English | 简体中文

一个基于 ESLint 自动修复能力实现的 React codemod 工具。灵感来自于eslint-plugin-command

文档站:ryo98-sl.github.io/eslint-plugin-react-codemod

它专注解决几类重复性的 React 重构:

  • 把不稳定的 JSX 值包装成 useMemouseCallback
  • 根据 JSX 使用场景自动创建 useRefuseState
  • 在可推断时补充相关 TypeScript 类型和 import
  • ahooksRadixjotaiMUI 等常见 React 技术栈提供可复用 preset
  • 支持通过 // useMemo// useRef// ignore 等邻近注释控制 codemod

这个插件面向 ESLint Flat Config,并假设你的项目已经使用 typescript

安装

pnpm add -D eslint-plugin-react-codemod

快速开始

// eslint.config.js

import reactCodemod from "eslint-plugin-react-codemod";

export default [
  reactCodemod(),
];

也可以直接组合官方 preset:

import reactCodemod from "eslint-plugin-react-codemod";

export default [
  reactCodemod(
    reactCodemod.compose(
      reactCodemod.presets.ahooks(),
      reactCodemod.presets.radix(),
    ),
  ),
];

你也可以通过注释指令强制或跳过某个 JSX prop:

<Modal
  // ignore
  onClose={() => console.log(size)}
  // useCallback
  onClick={() => console.log(size)}
/>

默认情况下,当检测到 CI=trueCI=1NODE_ENV=production 时,reactCodemod() 会关闭所有 rule,避免在生产类环境中误执行 codemod。你仍然可以显式手动开启:

import reactCodemod from "eslint-plugin-react-codemod";

export default [
  reactCodemod({
    wrapHook: ["warn"],
    createHook: ["warn"],
  }),
];

你可以直接利用编辑器的 ESLint 修复建议来完成代码修改。

或者执行:

eslint . --fix

完整示例、配置项和双语文档请查看:

限制说明

  • 当前主要面向 tsx / jsx 中的 React 函数组件
  • 依赖 TypeScript 类型信息时,需要 ESLint 能正确拿到项目类型服务
  • 自动生成的依赖数组与类型提取是启发式行为,复杂场景建议人工复核
  • 更适合批量执行小型 codemod,而不是替代大型 AST 迁移脚本

开发

bun install
bun test
bun build

License

MIT