# @croct/eslint-plugin 中文文档

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

版本：0\.9\.2
npm 元数据更新时间：2026-05-25T20:46:32.930Z
中文译文更新时间：2026-11-11T01:08:24.917Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40croct/eslint-plugin
原文对照：https://npmcn.com/package/%40croct/eslint-plugin/?lang=original
项目主页：https://github.com/croct-tech/coding-standard-js
源码仓库：https://github.com/croct-tech/coding-standard-js

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

- 包体积（解压后）：12.1 MB，5 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：15 个
- peer 依赖：@typescript-eslint/parser \>= 8，eslint \>= 10
- 首次发布：2022-02-08T20:07:59.370Z
- 最新版本发布：2026-05-25T20:46:32.459Z
- 近 30 天下载量：5208（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：28（近 12 个月 7 个）

## 中文简介

ESLint规则和预设适用于所有Croct JavaScript项目.

## 安装

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

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

## README

[![Croct](https://cdn.croct.io/brand/logo/repo-icon-green.svg)](https://croct.com/)  
**JavaScript 编码标准**  
一组 [ESLint 语录](https://eslint.org/) 规则适用于所有 Croct JavaScript 项目.

[![Version](https://img.shields.io/npm/v/@croct/eslint-plugin)](https://www.npmjs.com/package/@croct/eslint-plugin) [![Build](https://github.com/croct-tech/coding-standard-js/actions/workflows/branch-validations.yaml/badge.svg)](https://github.com/croct-tech/coding-standard-js/actions/workflows/branch-validations.yaml)  
  
[\* 释放](https://github.com/croct-tech/coding-standard-js/releases) • 妇女 [QQ 报告错误](https://github.com/croct-tech/coding-standard-js/issues) • 妇女 [请求特性](https://github.com/croct-tech/coding-standard-js/issues)

## 安装

建议安装软件包的方式是通过 [国家预防机制](https://npmjs.com/)它与模块捆绑器,例如 网页包或浏览器:

```sh
npm i -D @croct/eslint-plugin
```

此插件使用 ESLint 的 [平面配置格式](https://eslint.org/docs/latest/use/configure/configuration-files) (ESLint v9+) (英语).

### Java 脚本

对于 JavaScript 工程, 创建 `eslint.config.mjs` 文件 :

```js
import { defineConfig } from 'eslint/config';
import croct from '@croct/eslint-plugin';

export default defineConfig(
    croct.configs.javascript,
);
```

### 类型脚本

对于类型脚本项目,创建 `eslint.config.mjs` 文件 :

```js
import { defineConfig } from 'eslint/config';
import croct from '@croct/eslint-plugin';

export default defineConfig(
    croct.configs.typescript,
);
```

TypeScript配置包括了JavaScript预设,因此没有必要同时包含两者.

### 反应

对于反应项目,创建 `eslint.config.mjs` 文件 :

```js
import { defineConfig } from 'eslint/config';
import croct from '@croct/eslint-plugin';

export default defineConfig(
    croct.configs.react,
);
```

React配置包括了JavaScript预设,因此没有必要包含两者.

### 齐压

对于 Cypress 工程,创建 `eslint.config.mjs` 文件 :

```js
import { defineConfig } from 'eslint/config';
import croct from '@croct/eslint-plugin';

export default defineConfig(
    croct.configs.cypress,
);
```

Cypress配置包括了JavaScript预设,因此没有必要包含两者.

### 自定义规则

您可以添加自定义规则或覆盖已有的规则 :

```js
import { defineConfig } from 'eslint/config';
import croct from '@croct/eslint-plugin';

export default defineConfig(
    croct.configs.typescript,
    {
        files: ['src/**/*.ts'],
        rules: {
            '@typescript-eslint/explicit-function-return-type': 'off',
        },
    },
);
```

关于现有预设和规则的清单,见 [参考文件](https://npmcn.com/package/%40croct/eslint-plugin/docs/README.md)。 。 。 .

## 基本用途

运行以下命令以检查工程是否符合编码标准:

```sh
eslint
```

## 捐款

对一揽子计划的贡献总是受到欢迎的!

-   报告任何错误或问题 [问题跟踪器](https://github.com/croct-tech/coding-standard-js/issues)。 。 。 .
-   重大改动,请 [打开一个问题](https://github.com/croct-tech/coding-standard-js/issues) 首先讨论你想要改变什么.
-   请确保酌情更新测试.

## 测试

在运行测试套件之前,开发依赖必须安装:

```sh
npm i
```

然后,运行所有测试:

```sh
npm run test
```

## 版权通知

版权:"2015-2021 Croct Limited","All Rights"保留地.

本文所载的所有资料均为并仍然是克罗克有限公司的财产。 本文所载的知识、设计和技术概念是Croct Limiteds专有的,可能由美国和外国专利、正在处理的专利所涵盖,并受贸易秘密或版权法的保护。 严格禁止传播这种信息或复制这种材料,除非事先得到克罗克特有限公司的书面许可.

## 常见问题

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

ESLint规则和预设适用于所有Croct JavaScript项目\.

### 如何安装 @croct/eslint-plugin？

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

### @croct/eslint-plugin 支持 TypeScript 吗？

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

### @croct/eslint-plugin 支持 ESM 还是 CommonJS？

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

### @croct/eslint-plugin 可以商用吗？

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

### @croct/eslint-plugin 的下载量有多少？

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

### @croct/eslint-plugin 还在维护吗？

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

