@cratis/eslint-plugin-arc

中文文档
22.184.0发布于 2026/11/10MITES Module零依赖构建来源已验证近 30 天下载 2.9万

Cratis Arc ESLint rules: skip generated proxies and keep MVVM view models React-free. Compose on top of @cratis/eslint-config.

原始使用文档
文档目录3 节
  1. Install
  2. Use
  3. no-hooks-in-view-model options

@cratis/eslint-plugin-arc

ESLint rules for projects that consume Cratis Arc. Compose these on top of the Cratis base config, @cratis/eslint-config.

Rule / processorWhat it does
skip-generated-proxies (processor)Skips Arc-generated proxy files wholesale. They carry a // @generated by Cratis header (and a **DO NOT EDIT** banner), cannot be edited, and are regenerated by the build — so any finding on them is un-actionable. Keyed on the header because proxies sit intermixed with hand-written .ts.
no-hooks-in-view-modelDisallows React hook calls inside MVVM view models (classes named *ViewModel). A view model must be a plain, React-free class; inject Cratis abstractions instead of calling hooks.
no-direct-mobx-react-importDisallows direct imports from mobx-react or mobx-react-lite. The MobX binding is an internal detail of @cratis/arc.react.mvvm, which re-exports observer (the sanctioned leaf observer boundary) — import it from there so the binding can evolve without breaking consumers.

Install

yarn add -D @cratis/eslint-plugin-arc @cratis/eslint-config eslint

Use

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

export default [
    ...cratis.configs.consumer,
    ...arc.configs.recommended,
    // …your project rules
];

no-hooks-in-view-model options

'@cratis/arc/no-hooks-in-view-model': ['error', {
    classSuffix: 'ViewModel',          // class-name suffix that marks a view model
    hookPattern: '^use[A-Z]',          // bare-identifier calls treated as hooks
    additionalHooks: ['injectQuery'],  // extra call names to forbid
}]

Only bare-identifier calls (useState(...)) are flagged — member calls like this.useDefaults() are not, so view-model methods that merely start with use are safe.

版本与发布记录

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

版本发布日期距今
22.184.0latest2026/11/10今天
22.183.02026/11/10今天
22.182.12026/11/101 天前
22.182.02026/11/101 天前
22.180.02026/11/101 天前
22.179.02026/11/091 天前

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

@cratis/eslint-plugin-arc 是什么?

Cratis Arc ESLint rules: skip generated proxies and keep MVVM view models React-free. Compose on top of @cratis/eslint-config.

如何安装 @cratis/eslint-plugin-arc?

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

@cratis/eslint-plugin-arc 支持 TypeScript 吗?

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

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

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

@cratis/eslint-plugin-arc 可以商用吗?

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

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

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

@cratis/eslint-plugin-arc 还在维护吗?

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