@devbie/style-guide

中文文档
1.6.0发布于 2026/11/10MITTypeScriptES Module近 30 天下载 3024

Single source of truth for devbie ecosystem code style: shared prettier config and composable eslint flat layers (base, nest, next)

原始使用文档
文档目录7 节
  1. Exports
  2. Coverage: which entry each repo uses
  3. Usage
  4. prettier
  5. eslint (flat config)
  6. Version policy
  7. Changelog

@devbie/style-guide

Single source of truth for code style across the devbie ecosystem (newbie / fewbie / apits). See ADR-010 in worldzhy/devbie.

Exports

EntryContents
@devbie/style-guide/prettierCanonical prettier config (all repos)
@devbie/style-guide/eslint/baseBaseline eslint flat config for Node TypeScript
@devbie/style-guide/eslint/nestNest layer (Nest-specific rules, type-aware)
@devbie/style-guide/eslint/nextNext.js layer (canonical Next.js rules)

nest and next are layers, not standalone standards: every consumer composes [...base, ...nest] or [...base, ...next]. The baseline carries the shared language-level rules and prettier; a layer adds only its framework's rules. base alone covers CLIs, code generators, registries, and SDKs.

Coverage: which entry each repo uses

RepoComposition
devbie monorepo rootbase + nest scoped to packages/newbie
newbie-starterbase + nest
fewbie-starterbase + next
newbie-modulesbase + nest

Two structural facts drive this table:

  • newbie-modules is a pure source registry — module sources are copied into a consumer rather than built in place — but those sources are Nest code, so it composes [...base, ...nest] with injectable-should-be-provided scoped off: there is no host module graph in the registry for the rule to resolve providers against, and the host keeps the rule enabled where that graph exists.
  • The devbie monorepo root lints heterogeneous packages in one config: only packages/newbie is Nest framework code, while the CLIs, the generator and the SDKs are plain Node. ESLint flat config does not read package.json and nested eslint.config.mjs files are not inherited, so per-package differentiation must be expressed in the root config with files scoping — never with per-package config files or package.json entry fields.

next (and nest) must be loaded where the framework's packages are installed: eslint-config-next requires next at load time (declared as an optional peer, so base/nest consumers are never forced to install Next.js), and the Nest layer requires a TypeScript project for its four type-aware rules. The Nest plugin's own peer declarations carry the rest — nothing imports class-validator at lint runtime.

Usage

prettier

Delete any local .prettierrc and reference the shared config in package.json:

{
  "prettier": "@devbie/style-guide/prettier"
}

.prettierignore stays repo-local: it lists repo-specific build artifacts, not style decisions.

eslint (flat config)

eslint.config.mjs in the consumer repo:

import base from "@devbie/style-guide/eslint/base";
// Nest apps:      import nest from "@devbie/style-guide/eslint/nest";
// Next.js apps:   import next from "@devbie/style-guide/eslint/next";

export default [
  ...base,
  // ...nest or ...next, then repo-specific rules and ignores.
];

Consumers need eslint (^9 or ^10), prettier (^3.9.9) and typescript installed as their own dev dependencies (declared as peers of this package).

Version policy

All devbie packages stay on the 1.x line until the ecosystem launches; breaking style changes bump minor, not major. Dependency major upgrades of prettier/eslint follow the ecosystem-wide major-freeze policy: not by default, only as a deliberate milestone.

Changelog

  • 1.4.1 — the optional next peer widens to ^16.0.0. 1.4.0 declared ^16.4.2 (mirroring the dev dependency used by this package's own test suite), but npm enforces optional-peer ranges against installed copies, so consumers on Next.js 16.2 failed to install with ERESOLVE. The peer now states the actual contract: any Next.js 16.
  • 1.4.0 — the three eslint entries ship type declarations (exports map types alongside default), and the next layer switches off import/no-anonymous-default-export for eslint.config.* files so consumers can use the idiomatic export default [...base, ...next]. next is declared as an optional peer.
  • 1.3.1 — the internal core entry is inlined into base and removed. Nothing imported it directly (base was its only consumer), and keeping two files for one entry set made the loading order harder to read: nest and next each also end on prettierConfig, so there is no shared tail to factor out.
  • 1.3.0 — new nest layer backed by @darraghor/eslint-plugin-nestjs-typed (recommended flat config, four type-aware rules), and next reshaped into a layer. Consumers now compose [...base, ...nest] / [...base, ...next]; this also lets the devbie monorepo scope the Nest layer to packages/newbie via files instead of giving a Nest framework standard to its CLIs.
  • 1.2.0 — backend renamed to base and frontend removed. After apits and fewbie-cli joined the newbie monorepo (ADR-012/ADR-015), frontend had no consumer left, and backend no longer described its consumers (CLIs, code generators, registries — none of them backends). The pair is now named for what it is: base (the default) and next (the Next.js specialization). The react/react-hooks/jsx-a11y plugin dependencies are dropped; next gets those layers from eslint-config-next.
  • 1.1.3 — frontend pins the React version for rule evaluation (19.0) instead of detecting it: fewbie lints React template sources without a react package installed, where detection only emits a warning.
  • 1.1.2 — fix: next extends core plus the canonical Next rule set (eslint-config-next already bundles React/react-hooks/jsx-a11y, so spreading frontend on top redefined jsx-a11y and flat config rejected it). The frontend React layer is now scoped to JSX/TSX files, so Node code in frontend repos is not evaluated against React rules while React template sources are.
  • 1.1.1 — fix: frontend uses the flat variant of eslint-plugin-react-hooks (configs.flat["recommended-latest"]); 1.1.0 shipped the legacy shape and failed to load under flat config.
  • 1.1.0 — entries renamed to backend / frontend and layered: core is internal, frontend is framework-independent (React rules only), next adds the canonical Next.js rule set. nest was replaced by backend.
  • 1.0.0 — initial release (prettier, eslint/nest, eslint/next).

版本与发布记录

@devbie/style-guide 共发布 13 个版本,首次发布于 2026/10/21;过去 12 个月发布了 13 个版本。

版本发布日期距今
1.6.0latest2026/11/101 天前
1.5.02026/10/3012 天前
1.4.12026/10/2121 天前
1.4.02026/10/2121 天前
1.3.12026/10/2121 天前
1.3.02026/10/2121 天前

关于 @devbie/style-guide 的常见问题

@devbie/style-guide 是什么?

Single source of truth for devbie ecosystem code style: shared prettier config and composable eslint flat layers (base, nest, next)

如何安装 @devbie/style-guide?

在项目目录运行 npm install @devbie/style-guide,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(^9.0.0 || ^10.0.0)、prettier(^3.9.9)、typescript(>=5.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@devbie/style-guide 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@devbie/style-guide 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@devbie/style-guide 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@devbie/style-guide 可以商用吗?

@devbie/style-guide 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@devbie/style-guide 的下载量有多少?

根据 npm 官方下载统计,@devbie/style-guide 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,024 次,日均约 101 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@devbie/style-guide 还在维护吗?

最新版本 1.6.0 发布于 2026/11/10(1 天前);至今共发布 13 个版本,其中过去 12 个月发布了 13 个;首次发布于 2026/10/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。