@endo/eslint-plugin

中文文档
3.0.0发布于 2026/08/14Apache-2.0ES Module近 30 天下载 1.4万

ESLint plugin for using Endo

原始使用文档
文档目录16 节
  1. Installation
  2. Usage
  3. ESLint 9+ (Flat Config)
  4. ESLint 8 (Legacy Config)
  5. Shareable Configs
  6. recommended / flat/recommended
  7. recommended-requiring-type-checking / flat/recommended-requ…
  8. style / flat/style
  9. imports / flat/imports
  10. strict / flat/strict
  11. internal / flat/internal
  12. ses / flat/ses
  13. daemon / flat/daemon (deprecated)
  14. Rules
  15. Configuring Individual Rules
  16. Compatibility

@endo/eslint-plugin

ESLint rules and shareable configs for Hardened JavaScript and Endo packages.

Installation

npm install --save-dev eslint @endo/eslint-plugin

Usage

ESLint 9+ (Flat Config)

In your eslint.config.js (or .mjs/.cjs):

import endoPlugin from '@endo/eslint-plugin';

export default [
  // Apply the recommended rules for Hardened JS code.
  ...endoPlugin.configs['flat/recommended'],
];

ESLint 8 (Legacy Config)

In your .eslintrc.json (or .eslintrc.js, etc.):

{
  "extends": ["plugin:@endo/recommended"]
}

Shareable Configs

Core rules for code written to run under Hardened JavaScript (post-lockdown()).

// flat config
...endoPlugin.configs['flat/recommended']

// legacy
{ "extends": ["plugin:@endo/recommended"] }

Breaking change (v3): This config no longer bundles @jessie.js/eslint-plugin. Consumers who want the Jessie safe-await-separator rule and the use-jessie processor must install @jessie.js/eslint-plugin and configure it directly:

import jessie from '@jessie.js/eslint-plugin';
import endo from '@endo/eslint-plugin';

export default [
  ...endo.configs['flat/recommended'],
  ...jessie.configs['flat/recommended'],
  { processor: jessie.processors['use-jessie'] },
];

Extends recommended and adds the restrict-comparison-operands rule, which requires TypeScript type information.

// flat config
...endoPlugin.configs['flat/recommended-requiring-type-checking']

// legacy
{ "extends": ["plugin:@endo/recommended-requiring-type-checking"] }

style / flat/style

Opinionated JS coding-style rules: @stylistic/eslint-plugin, jsdoc, and prettier.

...endoPlugin.configs['flat/style']

imports / flat/imports

Rules about how packages should use imports: require file extensions, disallow extraneous dependencies, prefer named exports.

...endoPlugin.configs['flat/imports']

strict / flat/strict

style + imports + recommended in one config.

...endoPlugin.configs['flat/strict']

internal / flat/internal

The opinionated baseline used by all packages within the Endo monorepo itself. Extends strict and adds TypeScript-ESLint. Not intended for external use.

...endoPlugin.configs['flat/internal']

ses / flat/ses

Extends internal with strict global-variable restrictions for SES bootstrap code that runs before lockdown().

...endoPlugin.configs['flat/ses']

daemon / flat/daemon (deprecated)

Alias for internal/flat/internal.


Rules

RuleDescriptionFixable
@endo/assert-fail-as-throwMake assert.fail() count as a throw in ESLint's control-flow analysis—
@endo/harden-exportsEnsure each named export is immediately followed by harden()🔧
@endo/no-assign-to-exported-let-var-or-functionDisallow reassignment of exported let/var/function bindings—
@endo/no-harden-pattern-makerWarn when hardening pattern-maker return values (they are already hardened)—
@endo/no-multi-name-local-exportDisallow exporting the same local binding under multiple names—
@endo/no-polymorphic-callDisallow method calls on non-local receiver objects—
@endo/restrict-comparison-operandsRestrict </>/<=/>= to operands of compatible types—

Configuring Individual Rules

// flat config
export default [
  {
    plugins: { '@endo': endoPlugin },
    rules: {
      '@endo/harden-exports': 'error',
      '@endo/no-polymorphic-call': 'warn',
    },
  },
];
// legacy (.eslintrc.json)
{
  "plugins": ["@endo"],
  "rules": {
    "@endo/harden-exports": "error",
    "@endo/no-polymorphic-call": "warn"
  }
}

Compatibility

ESLint versionHow to use
9.xeslint.config.js flat config, use flat/* configs
8.x.eslintrc.* legacy config, use bare config names

The plugin ships both legacy (recommended, internal, …) and flat (flat/recommended, flat/internal, …) configs so you can use whichever ESLint version your project requires.

版本与发布记录

@endo/eslint-plugin 共发布 54 个版本,首次发布于 2021/06/02;过去 12 个月发布了 3 个版本。

版本发布日期距今
3.0.0latest2026/08/142 个月前
2.6.02026/06/125 个月前
2.5.02026/05/285 个月前
2.4.02025/07/121.3 年前
2.3.22025/06/181.4 年前
2.3.12025/06/031.4 年前

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

@endo/eslint-plugin 是什么?

ESLint plugin for using Endo

如何安装 @endo/eslint-plugin?

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

@endo/eslint-plugin 支持 TypeScript 吗?

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

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

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

@endo/eslint-plugin 可以商用吗?

@endo/eslint-plugin 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

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

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

@endo/eslint-plugin 还在维护吗?

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