# @fido\.id/eslint-config-fido 中文文档

规范地址：https://npmcn.com/package/%40fido.id/eslint-config-fido/

版本：2\.2\.2
npm 元数据更新时间：2025-09-14T19:00:55.048Z
中文译文更新时间：2026-11-14T17:15:41.963Z
软件包许可：MIT

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

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

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

- 包体积（解压后）：47.9 kB，25 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- Node.js 要求：\>=18\.18
- 运行依赖：6 个
- peer 依赖：eslint \>=9\.34\.0 \<10\.0\.0，prettier \>=3\.6，typescript \>=4\.2\.0
- 首次发布：2022-09-23T12:06:47.304Z
- 最新版本发布：2025-09-14T19:00:54.829Z
- 近 30 天下载量：5820（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：11（近 12 个月 0 个）

## 中文简介

Fido.id 共享 ESLint 配置,旨在改进反应应用程序的代码质量

## 安装

```sh
npm install @fido.id/eslint-config-fido
```

也可以使用：`pnpm add @fido.id/eslint-config-fido`、`yarn add @fido.id/eslint-config-fido`、`bun add @fido.id/eslint-config-fido`

## README

# 埃斯林特- 配置- fido

用于 Typescript & React 项目的共享ESLint配置.

## 目录

-   [安装](https://npmcn.com/package/%40fido.id/eslint-config-fido/#readme-installation)
-   [使用量](https://npmcn.com/package/%40fido.id/eslint-config-fido/#readme-usage)
    -   [导出配置](https://npmcn.com/package/%40fido.id/eslint-config-fido/#readme-exported-configurations)
-   [CLI 使用量](https://npmcn.com/package/%40fido.id/eslint-config-fido/#readme-cli-usage)
-   [自定义 pretier](https://npmcn.com/package/%40fido.id/eslint-config-fido/#readme-customizing-prettier)
-   [自定义规则](https://npmcn.com/package/%40fido.id/eslint-config-fido/#readme-custom-rules)
-   [哲学](https://npmcn.com/package/%40fido.id/eslint-config-fido/#readme-philosophy)

## 安装

```sh
yarn add --dev @fido.id/eslint-config-fido
```

您还需要安装 `eslint` 财务报告和审定财务报表 `prettier`数字 :

```sh
yarn add --dev eslint prettier
```

## 使用量

### 导出配置

此套件会导出两个主要配置 :

-   **建议**:所有TypeScript项目的基本规则(没有React/JSX特定规则).
-   **反应**: 以附加规则来扩展基础配置 React/JSX 项目.

### 实例:eslint.config.js

```js
const fido = require("@fido.id/eslint-config-fido");
module.exports = [
  // For TypeScript projects:
  ...fido.configs.recommended,
  // For React/JSX projects, use:
  // ...fido.configs.react,
  {
    rules: {
      // your custom rules here
    },
  },
];
```

## CLI 使用量

这个软件包为运行测试、内嵌和安装依赖性提供了CLI:

-   `./cli start` 在多克容器内安装所有项目依赖性.
-   `./cli tests` 进行所有测试.
-   `./cli tests --fix` ——运行起伏并自动解决问题.

> **说明:** CLI要求多克安装和运行在您的系统中.

## 自定义 pretier

如果您想要自定义 Pretier 设置, 请创建一个名为 `.prettierrc` 在您的工程目录中。 此文件必须像这样声明 Pretier 配置 :

```js
{
  "printWidth": 100,
  "tabWidth": 2,
  "singleQuote": true,
  "jsxBracketSameLine": true,
  "trailingComma": "es5"
}
```

## 自定义规则

此套件提供以下自定义的ESLint规则:

| 规则名称 | 说明 | 有效示例 | 无效的示例 | 解释 |
| --- | --- | --- | --- | --- |
| `no-nested-ternary-operators` | 损坏嵌入式三角操作器,以提高可读性. | `const x = a ? b : c;` | `const x = a ? (b ? 1 : 2) : 3;` | 巢穴取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取来. 有取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取. |
| `prefer-early-returns` | 更喜欢提前返回(保护条款),而不是只包含一个如果的区块. | `function f(a){ if (!a) return; doWork(a); }` | `function f(a,b){ if (a > 0) { doA(); } else if (b > 0) { doB(); } else { doC(); } }` | 避免了深筑巢,并通过使用护卫条款而不是其他/else-if来提高代码清晰度. |
| `prefer-object-parameters` | 为具有许多参数的函数偏好一个单一对象参数,以提高可读性和可扩展性. | `function foo({a, b, c, d, e}) {}` | `function foo(a, b, c, d, e) {}` | 当一个函数需要超过一组参数(默认:4)时,使用单个对象参数而不是多个位置参数. |
| `mui-prefer-components` | 在JSX中存在等同物时,优于原生HTML元素的材料UI组件. | `<Box><Typography>Text</Typography></Box>` | `<div><p>Text</p></div>` | 强制使用MUI组件(如Box,Typography,Button)来代替JSX中的原生HTML标记来与设计系统保持一致. |

## 哲学

这个配置旨在将严重的问题(例如:语法错误)标记为错误,而语法问题则标记为警告. 这让你的团队应用诸如"确保承诺没有出错,但如果承诺没有引入警告,则忽略警告"的政策

## 常见问题

### @fido\.id/eslint-config-fido 是什么？

Fido\.id 共享 ESLint 配置,旨在改进反应应用程序的代码质量

### 如何安装 @fido\.id/eslint-config-fido？

在项目目录运行 npm install @fido\.id/eslint-config-fido，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：eslint（\>=9\.34\.0 \<10\.0\.0）、prettier（\>=3\.6）、typescript（\>=4\.2\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @fido\.id/eslint-config-fido 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/fido\.id\_\_eslint-config-fido 是否存在。

### @fido\.id/eslint-config-fido 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @fido\.id/eslint-config-fido 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=18\.18。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @fido\.id/eslint-config-fido 可以商用吗？

@fido\.id/eslint-config-fido 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @fido\.id/eslint-config-fido 的下载量有多少？

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

### @fido\.id/eslint-config-fido 还在维护吗？

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

