# eslint-plugin-hyper-fetch 中文文档

规范地址：https://npmcn.com/package/eslint-plugin-hyper-fetch/

版本：9\.4\.0
npm 元数据更新时间：2026-11-03T14:32:44.318Z
中文译文更新时间：2026-11-03T14:54:48.251Z
软件包许可：Apache-2\.0

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

原始 npm 页面：https://www.npmjs.com/package/eslint-plugin-hyper-fetch
原文对照：https://npmcn.com/package/eslint-plugin-hyper-fetch/?lang=original
项目主页：https://hyperfetch.bettertyped.com/
源码仓库：https://github.com/BetterTyped/hyper-fetch

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

- 包体积（解压后）：12 MB，35 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：react \>= 16\.8\.0，eslint \>= 8\.0\.0，@hyper-fetch/core \*，@hyper-fetch/sockets \*
- 首次发布：2025-06-25T17:00:14.775Z
- 最新版本发布：2026-11-03T14:32:43.932Z
- 已发布版本数：34（近 12 个月 16 个）

## 中文简介

Eslint HyperFetch插件

## 安装

```sh
npm install eslint-plugin-hyper-fetch
```

也可以使用：`pnpm add eslint-plugin-hyper-fetch`、`yarn add eslint-plugin-hyper-fetch`、`bun add eslint-plugin-hyper-fetch`

## README

# 🧹Hyper Fetch ESLint插件

**ESLint规则强制HyperFetch最佳实践，并尽早捕获类型问题。**

 [![GitHub stars](https://img.shields.io/github/stars/BetterTyped/hyper-fetch?style=flat)](https://github.com/BetterTyped/hyper-fetch)[![npm version](https://img.shields.io/npm/v/eslint-plugin-hyper-fetch) ](https://www.npmjs.com/package/eslint-plugin-hyper-fetch)[![License](https://img.shields.io/github/license/BetterTyped/hyper-fetch) ](https://github.com/BetterTyped/hyper-fetch/blob/main/License.md)[![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?logo=typescript&logoColor=white)](https://github.com/BetterTyped/hyper-fetch)

## 📖约

这个ESLint插件提供了针对HyperFetch的静态分析规则。它可以捕获诸如打字错误之类的通用类型问题， 的值缺失或使用错误 `createClient` 和 `createRequest` 在参数导致运行时之前键入参数 错误。

## 🎯关键功能

-   🔮 **在类型错误运行之前捕获它们** ——验证 `createClient` 和 `createRequest` lint时的通用参数
-   ✨ **没有更多的排版 `any`** -检测拼写错误的键，如 `rsponse` 而不是 `response`
-   🔧 **即插即用** —使用推荐的预置规则或逐个配置规则

## 🚀快速入门

```bash
npm install -D eslint-plugin-hyper-fetch
```

```json
{
  "extends": ["plugin:hyper-fetch/recommended"]
}
```

或者配置单独的规则：

```json
{
  "plugins": ["hyper-fetch"],
  "rules": {
    "hyper-fetch/client-generic-types": "error",
    "hyper-fetch/request-generic-types": "error"
  }
}
```

## 📚文档

-   [ESLint插件文档](https://hyperfetch.bettertyped.com/docs/integrations/plugin-eslint)
-   [开始](https://hyperfetch.bettertyped.com/docs/getting-started/quick-start)

## 💡例子

### 捕获不正确的泛型类型

```ts
// ❌ This will be flagged by hyper-fetch/request-generic-types
const getUser = client.createRequest<{
  rsponse: User; // Typo: "rsponse" instead of "response"
}>()({
  endpoint: "/users/:userId",
  method: "GET",
});
```

```ts
// ✅ Correct usage — no lint error
const getUser = client.createRequest<{
  response: User;
}>()({
  endpoint: "/users/:userId",
  method: "GET",
});
```

## 许可证

[麻省理工学院](https://github.com/BetterTyped/hyper-fetch/blob/main/License.md)

## 常见问题

### eslint-plugin-hyper-fetch 是什么？

Eslint HyperFetch插件

### 如何安装 eslint-plugin-hyper-fetch？

在项目目录运行 npm install eslint-plugin-hyper-fetch，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\>= 16\.8\.0）、eslint（\>= 8\.0\.0）、@hyper-fetch/core（\*）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### eslint-plugin-hyper-fetch 支持 TypeScript 吗？

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

### eslint-plugin-hyper-fetch 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### eslint-plugin-hyper-fetch 可以商用吗？

eslint-plugin-hyper-fetch 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### eslint-plugin-hyper-fetch 还在维护吗？

最新版本 9\.4\.0 发布于 2026/11/03（今天）；至今共发布 34 个版本，其中过去 12 个月发布了 16 个；首次发布于 2025/06/26。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

