@aval-adr/eslint-config

中文文档
0.13.0发布于 2026/10/31MITTypeScriptES Module构建来源已验证

ESLint flat config for the decided code rules a linter matches exactly (ADR-0044)

原始使用文档
文档目录4 节
  1. Rules and the decided rule each enforces
  2. Narrowed, and why
  3. Deferred
  4. Dependencies

@aval-adr/eslint-config

ESLint flat config for the decided code rules (ADR-0044) that a linter matches exactly. Versioned with the adr-lint crate.

import { adrLint, adrLintTyped } from "@aval-adr/eslint-config";

export default [
  ...adrLint({
    restrictedImports: [
      { files: ["src/domain/**"], paths: ["fs"], patterns: [{ group: ["@mui/*"] }] },
    ],
  }),
];
  • adrLint({ restrictedImports = [] }) returns the config array. Each entry is { files?, paths?, patterns? }; entries with the same files (absent = all files) are concatenated into ONE @typescript-eslint/no-restricted-imports option, because flat config keeps only the last options of a rule. No entries, no such object.
  • adrLintTyped(options) is adrLint(options) plus the typed rule switch-exhaustiveness-check and parserOptions.projectService: true; it needs a tsconfig.json. adrLint alone sets no typed rule and no parserOptions.

Rules and the decided rule each enforces

ruledecided rule
linterOptions.reportUnusedDisableDirectives: "error"general.no-disabled-safety
@typescript-eslint/ban-ts-comment (ts-expect-error: allow-with-description, ts-ignore, ts-nocheck banned)general.no-disabled-safety
@eslint-community/eslint-comments/no-unlimited-disable, require-description, disable-enable-pairgeneral.no-disabled-safety
adr-lint/no-swallowed-catcherrors.never-swallowed
@typescript-eslint/no-restricted-imports (from restrictedImports)architecture.dependency-rule, domain.independent-of-infrastructure
@typescript-eslint/switch-exhaustiveness-check (typed only)types.exhaustive-matching

Narrowed, and why

  • errors.never-swallowed: ESLint's no-empty flags every empty block, and also catch {} // why, which the rule body allows. adr-lint/no-swallowed-catch reports only a catch with no statement and no comment anywhere in the clause (catch (e) /* why */ {} included) or on its closing-brace line.
  • general.no-disabled-safety: require-description asks a reason only of the directives that suppress; eslint-enable, global(s), exported and eslint-env suppress nothing and need none.

switch-exhaustiveness-check keeps its stock options, which are the rule body: a missing case is reported even behind a silent default, and a full switch whose default assigns to never passes.

Deferred

  • components.acyclic-dependencies: import/no-cycle is deferred. It needs eslint-plugin-import-x and a TS resolver in every consumer, and its lint time is unmeasured.

Dependencies

  • @eslint-community/eslint-plugin-eslint-comments: the maintained home of the disable-directive rules; owning them would mean parsing directive comments ourselves. It has no build script and no runtime dependencies beyond escape-string-regexp and ignore; if abandoned, the three rules move into adr-lint/ here.
  • eslint and typescript-eslint are peer dependencies the consumer already has.

版本与发布记录

@aval-adr/eslint-config 共发布 10 个版本,首次发布于 2026/10/26;过去 12 个月发布了 10 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.13.0latest2026/10/312 天前
0.12.02026/10/313 天前
0.11.02026/10/304 天前
0.10.02026/10/295 天前
0.9.02026/10/285 天前
0.8.12026/10/277 天前

关于 @aval-adr/eslint-config 的常见问题

@aval-adr/eslint-config 是什么?

ESLint平面配置为一个筛选器完全匹配的确定的代码规则(ADR-0044)

如何安装 @aval-adr/eslint-config?

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

@aval-adr/eslint-config 支持 TypeScript 吗?

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

@aval-adr/eslint-config 支持 ESM 还是 CommonJS?

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

@aval-adr/eslint-config 可以商用吗?

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

@aval-adr/eslint-config 还在维护吗?

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