@aurelienbbn/oxlint-plugin-alchemy

中文文档
0.1.1发布于 2026/10/14MITTypeScriptES Module构建来源已验证近 30 天下载 2073

Custom oxlint rules for Alchemy v2 (Infrastructure as Effects) stacks and runtimes.

原始使用文档
文档目录4 节
  1. What fires
  2. Limits
  3. Registered contract inventory
  4. Credited concepts

@aurelienbbn/oxlint-plugin-alchemy

npm downloads CI license node

4 oxlint rules for Alchemy v2 (Infrastructure as Effects): code that type-checks and deploys, then misbehaves because it runs in the wrong phase or the wrong scope.

[!NOTE] Release candidate. Checked against alchemy 2.0.0-beta.79. No consumer has calibrated it yet.

pnpm add -D @aurelienbbn/oxlint-plugin-alchemy oxlint   # oxlint >=1.82.0 <2.0.0
{
  "jsPlugins": ["@aurelienbbn/oxlint-plugin-alchemy"],
  "rules": {
    "alchemy/config-in-init": "error",
    "alchemy/no-disposable-in-instance-scope": "error",
    "alchemy/worker-env-secret-literal": "error",
    "alchemy/workflow-io-outside-task": "error"
  }
}

No preset. No autofix: every fix needs a choice (where the value is read, where the resource lives, what the step is called), so every rule reports only.

What fires

export default Cloudflare.Worker(
  "Api",
  { main: import.meta.url, env: { STRIPE_SECRET: "sk_live_..." } }, // ❌ worker-env-secret-literal: bound as plain_text
  Effect.gen(function* () {
    const pool = yield* Effect.acquireRelease(openPool, close); // ❌ no-disposable-in-instance-scope: never released on workerd
    const apiKey = yield* Config.Redacted("API_KEY"); // ✅ read in the init, so Alchemy binds it
    return {
      fetch: Effect.gen(function* () {
        const host = yield* Config.String("HOST"); // ❌ config-in-init: never bound, missing at runtime
        const again = yield* Config.Redacted("API_KEY"); // ✅ already bound by the init
      }),
    };
  }),
);

export class Sync extends Cloudflare.Workflow<Sync>()(
  "Sync",
  Effect.gen(function* () {
    const kv = yield* Cloudflare.KV.ReadWriteNamespace(KV);
    return Effect.fn(function* (input: { id: string }) {
      yield* kv.put(input.id, "started"); // ❌ workflow-io-outside-task: runs again on every replay
      yield* Cloudflare.Workflows.task("store", kv.put(input.id, "done")); // ✅ checkpointed
    });
  }),
) {}
Exact triggers and scope per rule
Rule❌ Fires onMatched / ⏭️ skipped
config-in-initConfig.<constructor>(..., "KEY") (String, Redacted, Number, Port, schema, ...; Effect 3 lowercase names too) inside what the init returns (inline, or a const Effect.gen / Effect.fn handler returned by reference): handlers, RPC methods, the Durable Object instance effect, the Workflow body⏭️ keys also read in the init body or in the env prop of the same declaration, values the init yield*s inside the returned object or runs itself (yield* warmup), non-literal keys
no-disposable-in-instance-scopeEffect.acquireRelease, Effect.acquireDisposable, Effect.addFinalizer whose nearest function is a Runtime init generator, or the per-object constructor a Durable Object init returns⏭️ handlers and methods (per-event scope), arguments of Effect.scoped(...), Effect.acquireUseRelease (releases itself), helper functions
worker-env-secret-literala non-empty string literal, a template literal, process.env.X, or a ?? / || fallback of one, as the value of a secret-named key in a Cloudflare Worker env propKeys matching secretPattern (default SECRET, TOKEN, PASSWORD, API_KEY, PRIVATE_KEY, DSN, DATABASE_URL, ...) and not benignPattern (default PUBLIC, PUBLISHABLE, _TTL, _NAME, ...). ⏭️ Config.*, Redacted.make, ""
workflow-io-outside-taska method call on const x = yield* <Alchemy binding> (anything imported from alchemy/*) from the Workflow init, made directly in the Workflow body (Effect.fn(...), Effect.fn(name)(...), or an arrow returning Effect.gen)⏭️ calls inside Cloudflare.Workflows.task(...) arguments (effect and rollback), calls in nested functions, receivers yielded from your own services

Runtimes are recognized syntactically: Cloudflare.Worker, Cloudflare.DurableObject, Cloudflare.Workflow and AWS.Lambda.Function, called inline (X(id, props, init)), in class form (X<Self>()(id, props, init)), or as Tag.make(props, init) on a tag class declared in the same file. The init must be written inline as Effect.gen(...) or Effect.succeed(...), optionally piped.

Limits

  • Single-file view. Inits built in another file, passed by identifier, or composed from Layers are invisible. A Tag.make on a tag imported from another file is not recognized.
  • config-in-init false positive: a key bound by a different declaration (a Layer, the host Worker of a Workflow) is reported. Suppress the line, or read the key in this init too.
  • workflow-io-outside-task is deliberately narrow: only direct calls on yield* Alchemy bindings; I/O through your own services or helper functions is not seen.
  • Other Alchemy Platforms (ECS, Containers, Railway, Fly, ...) are not recognized: their instance-scope semantics differ (servers run finalizers on graceful exit).
Not shipped, and who owns it
ConcernOwner
secret-named Config.String instead of Config.Redactedeffect/require-redacted-secret-config in @aurelienbbn/oxlint-plugin-effect
Date.now(), Math.random(), timers inside Effects@effect/tsgo (global-date*, global-random*, global-timers-in-effect)
native WorkflowEntrypoint determinism, secret compares@aurelienbbn/oxlint-plugin-cloudflare
binding existence, Env types, deploy validityAlchemy's own types and alchemy deploy

Credit: every rule independently implements behavior documented by Alchemy (alchemy-run/alchemy, Apache-2.0): Secrets & Config, Runtime (instance scope vs request scope), Cloudflare Workers env bindings, Cloudflare Workflows replay semantics; no documentation text or code copied.

Registered contract inventory

Generated from package exports by pnpm catalog. Rule-specific options and limitations are described above and in the source tests.

Rule/checkTrigger or review scope
config-in-initRequire effect/Config keys read inside the handlers, Durable Object instance, or Workflow body returned by an Alchemy Runtime init to also be read in the init itself, where Alchemy binds them at deploy time.
no-disposable-in-instance-scopeForbid Effect.acquireRelease, Effect.acquireDisposable and Effect.addFinalizer directly in an Alchemy Runtime init (Cloudflare Worker, Durable Object, Workflow, AWS Lambda Function) outside the handlers it returns.
worker-env-secret-literalForbid string literals, template literals and process.env reads as values of secret-named keys (SECRET, TOKEN, PASSWORD, API_KEY, DSN, ...) in the env prop of an Alchemy Cloudflare Worker; bind them with Config.Redacted or a Redacted value.
workflow-io-outside-taskRequire method calls on bindings yielded from Alchemy in a Cloudflare Workflow init (KV, R2, D1, Durable Objects, ...) to run inside Cloudflare.Workflows.task() when made directly in the Workflow body.

Credited concepts

版本与发布记录

@aurelienbbn/oxlint-plugin-alchemy 共发布 2 个版本,首次发布于 2026/09/28;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.1latest2026/10/1424 天前
0.1.02026/09/281 个月前

关于 @aurelienbbn/oxlint-plugin-alchemy 的常见问题

@aurelienbbn/oxlint-plugin-alchemy 是什么?

Custom oxlint rules for Alchemy v2 (Infrastructure as Effects) stacks and runtimes.

如何安装 @aurelienbbn/oxlint-plugin-alchemy?

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

@aurelienbbn/oxlint-plugin-alchemy 支持 TypeScript 吗?

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

@aurelienbbn/oxlint-plugin-alchemy 支持 ESM 还是 CommonJS?

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

@aurelienbbn/oxlint-plugin-alchemy 需要什么版本的 Node.js?

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

@aurelienbbn/oxlint-plugin-alchemy 可以商用吗?

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

@aurelienbbn/oxlint-plugin-alchemy 的下载量有多少?

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

@aurelienbbn/oxlint-plugin-alchemy 还在维护吗?

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