@cratis/eslint-config

中文文档
7.34.0发布于 2026/11/11MITES Module构建来源已验证近 30 天下载 4093

Shared Cratis ESLint flat-config presets. consumer is for projects that build on Cratis; internal adds the Cratis-authoring rules (MIT license header) used inside the Cratis product repos.

原始使用文档
文档目录7 节
  1. Install
  2. TypeScript 7
  3. React rules
  4. Use — a project built on Cratis
  5. Use — inside a Cratis product repo
  6. Building blocks
  7. Verify the published peer graph

@cratis/eslint-config

Shared ESLint flat-config presets for Cratis projects.

Two audiences, deliberately separated:

PresetForAdds
consumerProjects that build on Cratis (other products, apps)House TypeScript/React hygiene + for_* BDD spec relaxations
internalThe Cratis product repos (Arc, Components, Fundamentals, …)Everything in consumer plus the Cratis MIT license-header rule

The license header is a Cratis authoring concern, so it lives only in internal — consumers never inherit it.

Install

yarn add -D @cratis/eslint-config eslint

eslint and the TypeScript programmatic API are peer dependencies. The parser, TypeScript rules, and other plugins used by these presets ship transitively.

TypeScript 7

TypeScript 7.0 supplies the native tsc compiler but not the JavaScript compiler API required by typescript-eslint. Use TypeScript's supported side-by-side setup:

npm install -D @cratis/eslint-config eslint@latest \
  '@typescript/native@npm:typescript@latest' \
  'typescript@npm:@typescript/typescript6@latest'

The build still runs TypeScript 7's tsc; the separate compatibility package supplies the API used by lint tools and names its older compiler executable tsc6.

React rules

JSX syntax and references are handled by the TypeScript parser and rules. These presets do not enable any react/* rules, and no longer install or register eslint-plugin-react implicitly. This avoids its incompatible ESLint 10 peer dependency.

If a custom configuration enables additional React-specific rules, register a compatible plugin explicitly in that configuration. The legacy react/display-name and react/react-in-jsx-scope entries remain disabled, and settings.react.version remains detect, so consumers that supply their own React plugin keep those defaults.

Use — a project built on Cratis

// eslint.config.mjs
import cratis from '@cratis/eslint-config';

export default [
    ...cratis.configs.consumer,
    // …your project-specific rules layered on top
];

If you consume Cratis Arc proxies or Cratis Components, also compose the product rule packages:

import cratis from '@cratis/eslint-config';
import arc from '@cratis/eslint-plugin-arc';
import components from '@cratis/eslint-plugin-components';

export default [
    ...cratis.configs.consumer,
    ...arc.configs.recommended,         // skips generated proxies, MVVM view-model discipline
    ...components.configs.recommended,  // no raw primereact dialogs, subpath-only imports
    // …your project rules
];

Use — inside a Cratis product repo

// eslint.config.mjs
import cratis from '@cratis/eslint-config';

export default cratis.configs.internal;

Building blocks

configs.base (hygiene + ignores) and configs.specs (for_* relaxations) are exported too, so you can compose your own preset. Named exports base, specs, consumer, internal, and ignores are also available.

Verify the published peer graph

From the repository root, run:

node Source/ESLintConfig/scripts/verify-peer-graph.mjs

The check packs this workspace and installs the tarball into an isolated consumer under .ai-work/, using the latest ESLint and TypeScript/compiler-API packages. It requires strict peer resolution and a clean complete dependency tree, then verifies the packed presets against JSX and representative consumer/internal rules. CI runs this in addition to the preset specs; workspace hoisting must not hide a broken published dependency graph.

版本与发布记录

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

版本发布日期距今
7.34.0latest2026/11/11今天
7.33.12026/11/037 天前
7.33.02026/11/037 天前
7.32.12026/11/038 天前
7.32.02026/11/029 天前
7.31.02026/11/029 天前

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

@cratis/eslint-config 是什么?

Shared Cratis ESLint flat-config presets. consumer is for projects that build on Cratis; internal adds the Cratis-authoring rules (MIT license header) used inside the Cratis product repos.

如何安装 @cratis/eslint-config?

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

@cratis/eslint-config 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cratis__eslint-config 是否存在。

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

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

@cratis/eslint-config 可以商用吗?

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

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

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

@cratis/eslint-config 还在维护吗?

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