@endo/eslint-plugin

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

使用 Endo 的 ESLint 插件

中文使用文档
文档目录16 节
  1. 安装
  2. 使用量
  3. ESLint 9+ (Flat Config) (中文(简体) )
  4. ESLint 8( 列克西配置)
  5. 可分享配置
  6. recommended 编号 : flat/recommended
  7. recommended-requiring-type-checking 编号 : flat/recommended-r…
  8. style 编号 : flat/style
  9. imports 编号 : flat/imports
  10. strict 编号 : flat/strict
  11. internal 编号 : flat/internal
  12. ses 编号 : flat/ses
  13. daemon 编号 : flat/daemon (折旧)
  14. 规则
  15. 配置个别规则
  16. 兼容性

@endo/eslint-plugin (英语)

ESLint 规则和可共享配置 硬化 Java 脚本 财务报告和审定财务报表 远藤 软件包.

安装

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

使用量

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

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

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等 :

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

可分享配置

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

// 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 并直接配置:

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 添加 restrict-comparison-operands 规则,它需要 TypeScript 类型信息.

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

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

style 编号 : flat/style

认为JS编码式的规则: @stylistic/slint-plugin (英语), (中文(简体) ), 日记,以及 更美丽。 。 。 .

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

imports 编号 : flat/imports

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

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

strict 编号 : flat/strict

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

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

internal 编号 : flat/internal

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

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

ses 编号 : flat/ses

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

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

daemon 编号 : flat/daemon (折旧)

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


规则

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

配置个别规则

// 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"
  }
}

兼容性

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

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

版本与发布记录

@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 是什么?

使用 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 和提交记录判断。