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

@1adybug/eslint

v0.0.11

Published

推荐的 ESLint 配置

Downloads

279

Readme

@1adybug/eslint

推荐的 ESLint Flat Config,内置 TypeScript、React、Next.js、Node.js 常见规则,并支持按目录拆分运行时环境。

安装

bun add -d eslint @1adybug/eslint

快速开始

eslint.config.mjs

import config from "@1adybug/eslint"

export default config

自定义配置

eslint.config.mjs

import { defineConfig } from "@1adybug/eslint"

export default defineConfig({
    next: true,
    react: true,
    node: {
        enabled: true,
        preset: "script",
        version: ">=24.0.0",
    },
})

参数说明

defineConfig(params) 支持以下参数:

  • next: boolean | FeatureOptions
  • react: boolean | FeatureOptions
  • node: boolean | FeatureOptions & { preset?: "script" | "module" | "recommended" | "mixed"; version?: string }
  • target: "browser" | "node" | "both"
  • directories: { web?: string | string[]; node?: string | string[]; mixed?: string | string[] }
  • ignores: string | string[]
  • rules: RulesConfig

FeatureOptions

  • enabled?: boolean
  • recommended?: boolean
  • extends?: string | config | (string | config)[]
  • rules?: RulesConfig

默认行为(开箱即用)

  1. 自动探测依赖
    检测到 next 时默认启用 Next;检测到 react(或启用 Next)时默认启用 React。
  2. target 默认推断
    Next 项目默认 "both";React 项目默认 "browser";其他默认 "node"
  3. Node 默认启用条件
    target !== "browser" 时默认启用 Node 规则。
  4. Node 默认版本
    目标项目未配置 package.json.engines.node 时,默认按 >=24.0.0 处理;可通过 node.version 覆盖。
  5. 目录默认值
    Next + both: web = ["**/*.{js,mjs,ts,tsx}"]node = ["shared/**/*.{js,mjs,ts,tsx}", "prisma/**/*.{js,mjs,ts,tsx}", "server/**/*.{js,mjs,ts,tsx}"]
    browser: web = ["**/*.{js,mjs,ts,tsx}"]
    node: node = ["**/*.{js,mjs,ts,tsx}"]
    both: mixed = ["**/*.{js,mjs,ts,tsx}"]
  6. 默认忽略目录
    node_modules/**, out/**, build/**, dist/**, public/**
  7. Next 额外忽略
    .next/**, next-env.d.ts
  8. 目录冲突保护
    同一个 glob 同时出现在 web/node/mixed 会直接报错。
  9. TypeScript 默认弃用检查
    TypeScript 文件默认开启 @typescript-eslint/no-deprecated,并自动启用 projectService;JavaScript 与声明文件不会应用这条规则。
  10. 内联对象类型提示
    默认对 const info: { name: string } = { name: "tom" }function getName({ name }: { name: string }) {} 这类内联对象类型给出警告,建议先提取为 typeinterface

示例

1) Next 全栈项目(目录分区)

import { defineConfig } from "@1adybug/eslint"

export default defineConfig({
    next: true,
    react: true,
    node: true,
    directories: {
        web: ["apps/web/**/*.{js,mjs,ts,tsx}"],
        node: ["apps/api/**/*.{js,mjs,ts,tsx}"],
        mixed: ["packages/shared/**/*.{js,mjs,ts,tsx}"],
    },
})

2) 纯 React 项目(关闭 Node 规则)

import { defineConfig } from "@1adybug/eslint"

export default defineConfig({
    react: true,
    node: false,
    target: "browser",
})

3) 纯 Node 库

import { defineConfig } from "@1adybug/eslint"

export default defineConfig({
    next: false,
    react: false,
    node: {
        enabled: true,
        preset: "module",
        version: ">=24.0.0",
        rules: {
            "n/no-process-exit": "off",
        },
    },
    target: "node",
})

Monorepo 使用

1) 根目录统一配置(规则基本一致时)

import { defineConfig } from "@1adybug/eslint"

export default defineConfig({
    next: true,
    react: true,
    node: { enabled: true, preset: "module" },
    directories: {
        web: ["apps/web/**/*.{js,mjs,ts,tsx}", "apps/admin/**/*.{js,mjs,ts,tsx}"],
        node: ["apps/api/**/*.{js,mjs,ts,tsx}", "tools/**/*.{js,mjs,ts,tsx}"],
        mixed: ["packages/**/*.{js,mjs,ts,tsx}"],
    },
    ignores: ["**/dist/**", "**/.turbo/**", "**/coverage/**"],
})

注意:

  1. 同一个 glob 不能同时出现在 web/node/mixed,否则会报错。
  2. next: true 时,Next 规则会应用到 web + mixed 目录。

2) 根配置 + 子项目配置(只有部分应用是 Next 时)

建议做法:

  1. 根目录配置通用规则,next: false
  2. apps/web 单独 eslint.config.mjs 开启 next: true
  3. apps/api 单独配置 node 规则。

这样可以避免把 Next 规则应用到非 Next 项目。

本仓库开发命令

bun run build
bun run dev