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

@zdecode/react-eslint-config

v0.0.7

Published

交互式生成自包含的 ESLint flat config(next / vite / 通用)

Readme

@zdecode/react-eslint-config

交互式 CLI 脚手架,为 React 项目一键生成自包含的 ESLint flat config。

支持 Next.jsVite、通用框架,可选 YAML / MDX / JSON 格式化。


特点

  • 脚手架而非共享配置 — 运行后在你的项目里生成一个完整的 eslint.config.mjs,不依赖本包,可随意修改
  • 依赖按需写入 — 自动把缺失的插件追加到项目 package.json#devDependencies,只写版本,不执行安装
  • 框架感知 — Next.js 走 eslint-config-next,Vite / 通用框架单独注册 eslint-plugin-react
  • 架构约束(Next.js 专属) — 通过 no-restricted-syntax AST 规则强制 Service / Action 层命名与结构规范

快速开始

在项目根目录(有 package.json 的地方)运行:

npx @zdecode/react-eslint-config

CLI 会交互式询问框架类型和可选格式化文件类型,然后生成 eslint.config.mjs 并更新 package.json

完成后执行安装:

pnpm install   # 或 npm install / yarn

非交互用法

适合脚本、CI、或 fixture 初始化场景:

| 参数 | 说明 | | ------------------------------------ | ---------------------------------- | | --framework <next\|vite\|fallback> | 指定框架(必填时跳过交互) | | --features <yml,mdx,json> | 指定要启用的格式化,逗号分隔 | | --all | 启用全部格式化(yml + mdx + json) | | --none | 不启用任何格式化 |

示例:

# Next.js,启用全部格式化
npx @zdecode/react-eslint-config --framework next --all

# Vite,只启用 JSON
npx @zdecode/react-eslint-config --framework vite --features json

# 通用框架,不启用额外格式化
npx @zdecode/react-eslint-config --framework fallback --none

框架说明

| 框架 | 说明 | | ---------- | -------------------------------------------------------------------------------------------------- | | next | 使用 eslint-config-next(Core Web Vitals + TypeScript 规则集),不单独注册 eslint-plugin-react | | vite | 单独注册 eslint-plugin-react,使用 reactRefresh.configs.vite | | fallback | 同 vite 配置,但 react-refresh 使用 recommended 预设,适合非 Vite 构建工具 |


生成的配置包含

核心(始终包含)

  • @eslint/js recommended
  • typescript-eslint recommended
  • @stylistic/eslint-plugin — 代码风格(缩进、引号、分号、JSX 格式等)
  • @eslint-react/eslint-plugin — React 最佳实践
  • eslint-plugin-react-hooks — Hooks 规则
  • eslint-plugin-react-refresh — HMR 安全导出检查
  • 全局忽略:distbuildoutnode_modules、锁文件等

可选格式化

| 特性 | 文件类型 | 插件 | | ------ | ----------------------------- | -------------------------------------------------------- | | yml | .yml / .yaml | eslint-plugin-yml | | mdx | .md / .mdx | eslint-plugin-mdx + eslint-plugin-format(Prettier) | | json | .json / .jsonc / .json5 | eslint-plugin-jsonc |

Next.js 专属

  • Service 层(*.service.ts):导出函数必须 async、包含 try-catch、命名以 Service 结尾
  • Action 层(*.action.ts):导出异步函数命名必须以 Action 结尾

注意事项

  • 运行前若项目已存在 eslint.config.js / eslint.config.mjs / eslint.config.cjs / eslint.config.ts,脚手架会中止以防覆盖
  • 用户 package.json 中已声明的依赖版本会被保留,不会被覆盖
  • 生成的文件直接 import 各 ESLint 插件,不会 import 本包,删除本包不影响运行

License

ISC