# @codeyourfuture/eslint-config-standard 中文文档

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

版本：8\.1\.1
npm 元数据更新时间：2026-02-18T18:32:22.080Z
中文译文更新时间：2026-11-10T08:29:25.566Z
软件包许可：ISC

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

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

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

- 包体积（解压后）：10.4 kB，5 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：^20\.9 \|\| \>=22
- 运行依赖：1 个
- peer 依赖：@eslint/js \>=9，eslint ^9 \|\| ^10
- 首次发布：2019-06-23T10:17:39.380Z
- 最新版本发布：2026-02-18T18:32:21.738Z
- 近 30 天下载量：5974（2026-10-10 至 2026-11-08，npm 官方下载统计）
- 已发布版本数：23（近 12 个月 4 个）

## 中文简介

所有 CYF 实例/项目的标准 ESLint 配置 .

## 安装

```sh
npm install @codeyourfuture/eslint-config-standard
```

也可以使用：`pnpm add @codeyourfuture/eslint-config-standard`、`yarn add @codeyourfuture/eslint-config-standard`、`bun add @codeyourfuture/eslint-config-standard`

## README

# CYF ESLint 配置

[![License](https://img.shields.io/npm/l/@codeyourfuture/eslint-config-standard.svg)](https://github.com/CodeYourFuture/eslint-config-standard/blob/main/LICENSE) [![Build Status](https://github.com/CodeYourFuture/eslint-config-standard/workflows/Node.js%20CI/badge.svg)](https://github.com/CodeYourFuture/eslint-config-standard/actions) [![NPM Version](https://img.shields.io/npm/v/@codeyourfuture/eslint-config-standard.svg)](https://www.npmjs.com/package/@codeyourfuture/eslint-config-standard)

所有 CYF 实例/项目的标准 ESLint 配置 .

## 版本

此配置使用 [交换器](https://semver.org/),解释如下:

-   **补丁** 释放(`x.y.z` - > (中文) `x.y.z+1`: bugfixs 和工具更新指以前通过的代码 线性 **应** 更新后继续通过.
    
-   **次要** 释放(`x.y.z` - > (中文) `x.y+1.0`:对现有规则的修改意味着先前失败的代码 线性 **可能** 现在通过,或者说新的配置表示之前通过 linting 的代码 **应** 继续通过.
    
-   **少校** 释放(`x.y.z` - > (中文) `x+1.0.0`:新规则,或对现行规则的修改,是指: 先前通过的 linting **不会** 再过一次.
    

在报告任何错误时请铭记这些定义 .

## 使用量

与 ESLint 本身一起安装此软件包 :

```bash
npm install --save-dev eslint @codeyourfuture/eslint-config-standard
```

然后创建一个 [ESLint 配置文件](https://eslint.org/docs/latest/use/configure/configuration-files) 并添加此配置 :

```javascript
import cyf from "@codeyourfuture/eslint-config-standard";

export default [...cyf.configs.standard];
```

或者,对于一些稍稍宽容的规则,你可以使用 `cyf.configs.lax`。 。 。 .

您也可以打电话 `cyf.configure` 包含一些要添加/覆盖您自己的设置的规则 :

```javascript
export default [...cyf.configure({
  // ...
})];
```

## 原则

1.  **只出错** - 不要教学习者忽略 _任意_ 输出,所有规则都应该是 `"error"` 或者说 `"off"`
2.  **最大限度的一致性** - 如果有选项(例如单行语句的括号,以箭头函数参数为括号),则与非选项相符合
3.  **最小化更改设置大小** - 保持承诺小 以便学习者可以专注于重要的变化

## 规则

此配置从 [ESLint 语录](https://eslint.org/) 财务报告和审定财务报表 [结构化](https://eslint.style/) 建议的规则随后增加如下:

| 配置 | 规则 | 设置 | 原则/理由说明 |
| --- | --- | --- | --- |
| 标准, 松动 | [`@stylistic/arrow-parens`](https://eslint.style/rules/default/arrow-parens) |  | 第二条、第三条 |
| 标准, 松动 | [`@stylistic/brace-style`](https://eslint.style/rules/default/brace-style) | `"1tbs", { "allowSingleLine": false }` |  |
| 标准, 松动 | [`@stylistic/comma-dangle`](https://eslint.style/rules/default/comma-dangle) | `"always-multiline"` | 3个 |
| 标准 | [`@stylistic/indent`](https://eslint.style/rules/default/indent) | `"tab", { "SwitchCase": 1 }` | 标签是 [更容易获得](https://www.reddit.com/r/javascript/comments/c8drjo/nobody_talks_about_the_real_reason_to_use_tabs/) |
| 标准 | [`@stylistic/linebreak-style`](https://eslint.style/rules/default/linebreak-style) | `"unix"` |  |
| 标准, 松动 | [`@stylistic/no-trailing-spaces`](https://eslint.style/rules/default/no-trailing-spaces) |  |  |
| 标准, 松动 | [`@stylistic/object-curly-spacing`](https://eslint.style/rules/default/object-curly-spacing) | `"always"` |  |
| 标准, 松动 | [`@stylistic/operator-linebreak`](https://eslint.style/rules/default/operator-linebreak) | `"before"` |  |
| 标准, 松动 | [`@stylistic/quote-props`](https://eslint.style/rules/default/quote-props) | `"as-needed"` | 3个 |
| 标准, 松动 | [`@stylistic/quotes`](https://eslint.style/rules/default/quotes) | `"double", { "avoidEscape": true, "allowTemplateLiterals": false }` | 更有可能需要 `'` 字符串内比 `"` |
| 标准, 松动 | [`@stylistic/semi`](https://eslint.style/rules/default/semi) |  | 学习者不应该忘记 [ASI 规则](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Automatic_semicolon_insertion) |
| 标准, 松动 | [`curly`](https://eslint.org/docs/rules/curly) |  | 2个 |
| 标准, 松动 | [`no-unused-vars`](https://eslint.org/docs/rules/no-unused-vars) | `{ "ignoreRestSiblings": true }` |  |
| 标准, 松动 | [`no-var`](https://eslint.org/docs/rules/no-var) |  | 坚持 `let` 财务报告和审定财务报表 `const` 更可预测的行为 |

## 发展

您可以复制此重播并运行 `npm install` 安装开发依赖。 提供了两个脚本:

-   `lint`: 使用 ESLint 版本作为 lint 的 dev 依赖性 `index.js` 违背自己的规则.
    
-   `test:examples`: 运行 `bin/examples.sh` 来对照 `pass.js` 财务报告和审定财务报表 `fail.js` 实例 内 `examples/`。 。 。 . `pass.js` 包含根据配置通过林入的代码, `fail.js` 包含失败的代码 .
    
-   `test:install`: 运行 `bin/test.sh` 创建软件包,安装 ESLint(由需要的版本定义) 环境变量 `ESLINT_VERSION`)和当前版本的这种配置,然后检查是否有 无版本相冲突与插件 `index.js`. e.g. (中文(简体) ). `ESLINT_VERSION=9 npm run test:install` 将测试此 配置与最新版本的ESLint 9.

## 常见问题

### @codeyourfuture/eslint-config-standard 是什么？

所有 CYF 实例/项目的标准 ESLint 配置 \.

### 如何安装 @codeyourfuture/eslint-config-standard？

在项目目录运行 npm install @codeyourfuture/eslint-config-standard，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@eslint/js（\>=9）、eslint（^9 \|\| ^10）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @codeyourfuture/eslint-config-standard 支持 TypeScript 吗？

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

### @codeyourfuture/eslint-config-standard 支持 ESM 还是 CommonJS？

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

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

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

### @codeyourfuture/eslint-config-standard 可以商用吗？

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

### @codeyourfuture/eslint-config-standard 的下载量有多少？

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

### @codeyourfuture/eslint-config-standard 还在维护吗？

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

