@duro-app/eslint-config

中文文档
6.1.0发布于 2026/11/12MITTypeScriptES Module近 30 天下载 6425

Shareable ESLint flat config for the Duro design system: the design-system rules and UI-library policy for React apps, on top of @aval-adr/eslint-config.

原始使用文档
文档目录7 节
  1. Usage
  2. Presets
  3. What the policy enforces
  4. Adopting 3.0 with existing debt
  5. Escape hatches
  6. adr-lint rules (opt-in)
  7. Migrating from 5.x

@duro-app/eslint-config

Shareable ESLint flat config for the Duro stack — the policies CLAUDE.md and agent memory can only suggest, wired into the linter so every consumer repo gates them at commit time (via amont's built-in pre-commit-lint-js, which activates on the presence of a root ESLint config) and in CI.

Requires ESLint 9 or 10 (flat config). It keeps only the design-system and UI-library policy, as react. The general conventions (base, effect, tests) and the decided-rule bridge (adrLint) come from @aval-adr/eslint-config, which this package extends and declares as a peer: install both.

pnpm add -D @duro-app/eslint-config @aval-adr/eslint-config

Usage

// eslint.config.js (repo root — amont only detects a ROOT config)
import {react} from '@duro-app/eslint-config'
import {effect, tests} from '@aval-adr/eslint-config'

export default [
  {ignores: ['**/dist/**', '**/build/**']},
  ...react,
  ...tests,
  // Server-only packages in a monorepo can scope the effect preset:
  ...effect.map((c) => ({...c, files: ['apps/api/**/*.ts']})),
]

Presets

PresetFromComposesFor
react@duro-app/eslint-configaval base + classic react-hooks + the duro plugin + UI policyRSD / @duro-app/ui apps
base@aval-adr/eslint-config@eslint/js + typescript-eslint recommended, prettier interopevery TypeScript package
effect@aval-adr/eslint-configbase + @effect plugin + server-stack policyEffect services
tests@aval-adr/eslint-configaccessibility-first selectors (self-scoped to test/e2e files)any repo with tests

react reports its import bans as duro/no-restricted-imports, apart from effect's @typescript-eslint/no-restricted-imports and adr-lint's adr-lint/no-restricted-imports, so composing them keeps every ban: none of the three overrides another.

What the policy enforces

  • react: UI primitives come from @duro-app/ui only. react-aria, Spectrum, MUI, Radix, Chakra, headlessui, antd and @frontjutsu/ui are banned with a message that says where to add a missing component. Rich text goes through @fredericrous/lexical-multi, never raw lexical. It also carries everything in @duro-app/eslint-plugin: html.* elements, deep token imports, token values and the form kit.
  • effect and tests are documented with @aval-adr/eslint-config.

Severity is the one gating line: error gates at commit and CI, warn informs everywhere. Don't add --max-warnings=0 — promote a rule to error here instead if it earns gating.

Adopting 3.0 with existing debt

3.0 promotes duro/no-raw-design-values to error and adds duro/no-raw-breakpoint-query. A repo that already carries raw values keeps the gate for every new file and ratchets the old ones down with an explicit file list — never a glob, never --max-warnings:

// eslint.duro-baseline.js — delete a line when its file is migrated. Never add one.
export const RAW_VALUES_BASELINE = [
  'app/routes/legacy-dashboard.tsx',
  'app/components/OldChart/OldChart.tsx',
]
// eslint.config.js — after the presets, so last-wins downgrades only these
import {RAW_VALUES_BASELINE} from './eslint.duro-baseline.js'
export default [
  ...react,
  {files: RAW_VALUES_BASELINE, rules: {'duro/no-raw-design-values': 'warn'}},
]

Most findings carry a suggestion; the ESLint API can apply them in bulk (message.suggestions[0].fix). What is left is the handful that need a human choice — an off-palette color, an off-scale spacing.

Escape hatches

Flat config is last-wins — scope an override after the preset:

...react,
{
  // The one file allowed to import the raw engine reset:
  files: ['packages/editor/src/usePageNode.ts'],
  rules: {'duro/no-restricted-imports': 'off'},
}

adr-lint rules (opt-in)

adrLint and adrLintTyped add the decided code rules a linter matches exactly. Import them from @aval-adr/eslint-config and put them last. Their bans have their own rule id, so no stack option is needed (6.0 drops it):

import {react} from '@duro-app/eslint-config'
import {adrLint} from '@aval-adr/eslint-config'

export default [...react, ...adrLint()]

Migrating from 5.x

  • Add @aval-adr/eslint-config (^0.16.0) beside this package.
  • Import base, effect, tests and adrLint from it; keep react from here.
  • Drop stack from an adrLint call.
  • An override of no-restricted-imports for the UI bans becomes duro/no-restricted-imports.

版本与发布记录

@duro-app/eslint-config 共发布 79 个版本,首次发布于 2026/08/19;过去 12 个月发布了 79 个版本。

版本发布日期距今
6.1.0latest2026/11/121 天前
6.0.02026/11/085 天前
5.45.02026/11/0211 天前
5.44.02026/11/0211 天前
5.43.02026/11/0211 天前
5.42.02026/11/0211 天前

关于 @duro-app/eslint-config 的常见问题

@duro-app/eslint-config 是什么?

Shareable ESLint flat config for the Duro design system: the design-system rules and UI-library policy for React apps, on top of @aval-adr/eslint-config.

如何安装 @duro-app/eslint-config?

在项目目录运行 npm install @duro-app/eslint-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(^9.0.0 || ^10.0.0)、@aval-adr/eslint-config(>=0.16.0 <1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@duro-app/eslint-config 支持 TypeScript 吗?

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

@duro-app/eslint-config 支持 ESM 还是 CommonJS?

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

@duro-app/eslint-config 需要什么版本的 Node.js?

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

@duro-app/eslint-config 可以商用吗?

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

@duro-app/eslint-config 的下载量有多少?

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

@duro-app/eslint-config 还在维护吗?

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