# @endo/eslint-plugin 中文文档

规范地址：https://npmcn.com/package/%40endo/eslint-plugin/

版本：3\.0\.0
npm 元数据更新时间：2026-08-13T22:52:09.357Z
中文译文更新时间：2026-11-13T16:56:58.266Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40endo/eslint-plugin
原文对照：https://npmcn.com/package/%40endo/eslint-plugin/?lang=original
项目主页：https://github.com/endojs/endo#readme
源码仓库：https://github.com/endojs/endo

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：164 kB，66 个文件
- 模块格式：ES Module
- TypeScript 类型：未声明
- 运行依赖：11 个
- peer 依赖：eslint ^8\.57\.0 \|\| ^9\.0\.0 \|\| ^10\.0\.0，typescript \>=4\.8\.4 \<7\.0\.0
- 首次发布：2021-06-02T00:54:28.204Z
- 最新版本发布：2026-08-13T22:52:09.181Z
- 近 30 天下载量：14303（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：54（近 12 个月 3 个）

## 中文简介

使用 Endo 的 ESLint 插件

## 安装

```sh
npm install @endo/eslint-plugin
```

也可以使用：`pnpm add @endo/eslint-plugin`、`yarn add @endo/eslint-plugin`、`bun add @endo/eslint-plugin`

## README

# @endo/eslint-plugin (英语)

ESLint 规则和可共享配置 [硬化 Java 脚本](https://hardenedjs.org/) 财务报告和审定财务报表 [远藤](https://github.com/endojs/endo) 软件包.

## 安装

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

* * *

## 使用量

### ESLint 9+ (Flat Config) (中文(简体) )

在你身边 `eslint.config.js` (或 `.mjs`编号 :`.cjs`:

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

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

### ESLint 8( 列克西配置)

在你身边 `.eslintrc.json` (或 `.eslintrc.js`等 :

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

* * *

## 可分享配置

### `recommended` 编号 : `flat/recommended`

用于在 Hardened JavaScript (后-) 下运行的代码的核心规则`lockdown()`) (中文(简体) ).

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

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

> **中断更改( v3 ) :** 这个配置不再捆绑 `@jessie.js/eslint-plugin`想要杰西的消费者 `safe-await-separator` 规则和规则 `use-jessie` 处理器必须安装 `@jessie.js/eslint-plugin` 并直接配置:
> 
> ```js
> 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'] },
> ];
> ```

### `recommended-requiring-type-checking` 编号 : `flat/recommended-requiring-type-checking`

扩展 `recommended` 添加 [`restrict-comparison-operands`](https://npmcn.com/package/%40endo/eslint-plugin/docs/rules/restrict-comparison-operands.md) 规则,它需要 TypeScript 类型信息.

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

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

### `style` 编号 : `flat/style`

认为JS编码式的规则: [@stylistic/slint-plugin (英语)](https://eslint.style/), (中文(简体) ), [日记](https://github.com/gajus/eslint-plugin-jsdoc),以及 [更美丽](https://github.com/prettier/eslint-config-prettier)。 。 。 .

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

### `imports` 编号 : `flat/imports`

关于软件包应如何使用导入的规则:要求文件扩展名,不允许的外相依赖性,更喜欢命名的导出.

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

### `strict` 编号 : `flat/strict`

`style` + 键 `imports` + 键 `recommended` 在一个配置.

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

### `internal` 编号 : `flat/internal`

所有软件包使用的有意见基线 _在远东独行道内部_扩展 `strict` 并添加 TypeScript-ESLint 。 无意外用.

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

### `ses` 编号 : `flat/ses`

扩展 `internal` 严格全球可变限制以前运行的 SES 靴套代码 `lockdown()`。 。 。 .

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

### `daemon` 编号 : `flat/daemon` _(折旧)_

别名 `internal`编号 :`flat/internal`。 。 。 .

* * *

## 规则

| 规则 | 说明 | 可修复 |
| --- | --- | --- |
| [@ endo/ sassert- fail- as- throw (英语)](https://npmcn.com/package/%40endo/eslint-plugin/docs/rules/assert-fail-as-throw.md) | 制作 `assert.fail()` 计为 ESLint 控制流分析中的一掷 | —— 说 |
| [@ endo/ harden- 导出](https://npmcn.com/package/%40endo/eslint-plugin/docs/rules/harden-exports.md) | 确保每个命名的导出立即被后面 `harden()` | 🔧 |
| [@endo/ no-assign-to-exported-let-var-or-函数](https://npmcn.com/package/%40endo/eslint-plugin/docs/rules/no-assign-to-exported-let-var-or-function.md) | 取消对导出方的重新安排 `let`编号 :`var`编号 :`function` 约束 | —— 说 |
| [@ endo/ no-harden- pattern- makes (没有硬度)](https://npmcn.com/package/%40endo/eslint-plugin/docs/rules/no-harden-pattern-maker.md) | 当硬化图案生成器返回值时警告( 它们已经被硬化) | —— 说 |
| [@endo/no-多名-本地出口](https://npmcn.com/package/%40endo/eslint-plugin/docs/rules/no-multi-name-local-export.md) | 拒绝以多个名称导出相同的本地绑定 | —— 说 |
| [@ endo/ no- polymorphic- call( 无效)](https://npmcn.com/package/%40endo/eslint-plugin/docs/rules/no-polymorphic-call.md) | 拒绝方法调用非本地接收对象 | —— 说 |
| [@endo/retracted-comparidson-operands (英语)](https://npmcn.com/package/%40endo/eslint-plugin/docs/rules/restrict-comparison-operands.md) | 限制 `<`编号 :`>`编号 :`<=`编号 :`>=` 改为相容类型的操作 | —— 说 |

* * *

## 配置个别规则

```js
// flat config
export default [
  {
    plugins: { '@endo': endoPlugin },
    rules: {
      '@endo/harden-exports': 'error',
      '@endo/no-polymorphic-call': 'warn',
    },
  },
];
```

```json
// legacy (.eslintrc.json)
{
  "plugins": ["@endo"],
  "rules": {
    "@endo/harden-exports": "error",
    "@endo/no-polymorphic-call": "warn"
  }
}
```

* * *

## 兼容性

| ESLint 版本( E) | 如何使用 |
| --- | --- |
| 9.x (中文(简体) ) | `eslint.config.js` 平面配置, 使用 `flat/*` 配置 |
| 8.x 电话 | `.eslintrc.*` 常规配置, 使用空配置名称 |

插件同时传送遗产( E)`recommended`, (中文(简体) ), `internal`,)并平 (`flat/recommended`, (中文(简体) ), `flat/internal`,...)配置,这样您就可以使用您项目所需的任意ESLint版本.

## 常见问题

### @endo/eslint-plugin 是什么？

使用 Endo 的 ESLint 插件

### 如何安装 @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 和提交记录判断。

