# @cypress/eslint-plugin-dev 中文文档

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

版本：7\.0\.0
npm 元数据更新时间：2026-09-09T19:09:36.049Z
中文译文更新时间：2026-11-11T07:33:09.755Z
软件包许可：MIT

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

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

弃用说明：Package no longer supported\. Contact Support at https://www\.npmjs\.com/support for more info\.

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

- 包体积（解压后）：29.7 kB，14 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：5 个
- peer 依赖：eslint ^= 8\.0\.0，eslint-plugin-mocha  \>= 8\.0\.0，eslint-plugin-react \>= 7\.22\.0，@babel/eslint-parser ^7\.28\.0，eslint-plugin-import \>= 2\.0\.0，@typescript-eslint/parser \>= 7\.0\.0，eslint-plugin-json-format \>= 2\.0\.1，@typescript-eslint/eslint-plugin \>= 7\.0\.0
- 首次发布：2019-06-25T16:08:14.631Z
- 最新版本发布：2026-08-26T23:21:19.763Z
- 近 30 天下载量：3792（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：27（近 12 个月 1 个）

## 中文简介

Cypress只开发软件包共用的 ESLint 规则

## 安装

```sh
npm install @cypress/eslint-plugin-dev
```

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

## README

# \[内部\] Cypress 开发者 ESLint 插件

[![](https://img.shields.io/npm/v/@cypress/eslint-plugin-dev.svg?style=flat)](https://www.npmjs.com/package/@cypress/eslint-plugin-dev) [![](https://img.shields.io/circleci/build/gh/cypress-io/eslint-plugin-dev.svg)](https://circleci.com/gh/cypress-io/eslint-plugin-dev/tree/develop)

Cypress包共用的ESLint规则.

> 此软件包用于 _内部发展_ (原始内容存档于2012-10-12). of Cypress. 这是 [**官方 Cypress ESLint 插件**](https://github.com/cypress-io/eslint-plugin-cypress) 意为Cypress的用户.

## 安装

```
npm install --save-dev @cypress/eslint-plugin-dev
```

## 使用量

> ⚠️ 目前 **没有** 支持ESLint版本9

Eslint 8, 使用6. x.x版本

对于 Eslint 7 及以下,使用 5.x.x 版本

1.  安装以下 `devDependencies`数字 :

```sh
@cypress/eslint-plugin-dev
eslint-plugin-json-format
@typescript-eslint/parser
@typescript-eslint/eslint-plugin
eslint-plugin-mocha
eslint-plugin-import

# if you have react/jsx files
eslint-plugin-react
@babel/eslint-parser
```

2.  将以下添加到根位 `.eslintrc.json`数字 :

```json
{
  "plugins": [
    "@cypress/dev"
  ],
  "extends": [
    "plugin:@cypress/dev/general"
  ]
}
```

> 注:另加 `"plugin:@cypress/dev/react"`,如果您正在使用 `React`

> 注:如果您有 `test/` 目录,您应当创建 `.eslintrc.json` ,并添加:

```json
{
  "extends": [
    "plugin:@cypress/dev/tests"
  ]
}
```

3.  在您的 `.eslintignore`数字 :

```sh
# don't ignore hidden files, useful for formatting json config files
!.*
```

4.  (可选) 安装和配置 您的文本编辑器的 ESLint 插件扩展到 lint 和 自动固定文件, 使用 ESLint, [详细情况如下:](https://npmcn.com/package/%40cypress/eslint-plugin-dev/#readme-editors)
    
5.  (可选)安装 [`husky`](https://github.com/typicode/husky) 并启用线条 `pre-commit` 钩:
    

`package.json`数字 :

```json
  "husky": {
    "hooks": {
      "pre-commit": "lint-pre-commit"
    }
  },
```

> 说明: `lint-pre-commit` 钩子会自动插入您的已显示的文件, 而且只有 `--fix` 财务报告和审定财务报表 `git add` 如果该文件中没有未预设的更改(这可以保护部分已预设的文件不被添加到钩子中).  
> 要自动修复所有已阶段的文件, 运行 `./node_modules/.bin/lint-changed --fix`

## 预设

### 常规

_通常应在包的根部使用._

-   以多相为通.
-   自动修正 `json` 文档和排序 `package.json` 通过 [`eslint-plugin-json-format`](https://github.com/bkucera/eslint-plugin-json-format)

**需要您安装以下 `devDependencies`**数字 :

```sh
eslint-plugin-import
eslint-plugin-json-format
@typescript-eslint/parser
@typescript-eslint/eslint-plugin
```

### 测试

测试的具体配置和规则。 应在 `test/` 目录.

**需要您安装以下 `devDependencies`**数字 :

```sh
eslint-plugin-mocha
```

### 反应

反应和JSX的特定配置和规则.

**需要您安装以下 `devDependencies`**数字 :

```sh
@babel/eslint-parser
eslint-plugin-react
```

## 配置示例

更改一些折叠规则 :

```js
// .eslintrc.json
{
  "extends": [
    "plugin:@cypress/dev/general"
  ],
  "rules": {
    "comma-dangle": "off",
    "no-debugger": "warn"
  }
}
```

停下来 `package.json` 从格式化 :

```json
{
  "settings": {
    "json/sort-package-json": false
  }
}
```

### 自定义规则 :

| 名称 | 说明 | 选项 | 实例 |
| --- | --- | --- | --- |
| `@cypress/dev/arrow-body-multiline-braces` | 仅在多行函数定义中执行箭头函数中的括号 | \[\`永远 | 永远不要\] 总是把这个设定为"永远" |
| `@cypress/dev/skip-comment` | 执行评论( E)`// NOTE:`解释a `.skip` 添加到 `it`, (中文(简体) ), `describe`,或 `context` 测试块 | {注释键 : `[array] tokens that indicate .skip explanation (default: ['NOTE:', 'TODO:', 'FIXME:']`说吧 | `'@cypress/dev/skip-comment': ['error', { commentTokens: ['TODO:'] }]` |
| `@cypress/dev/no-return-before` | 否定 `return` 在某些可配置符号前的语句 | {令牌: `[array] tokens that cannot be preceded by 'return' (default: ['it', 'describe', 'context', 'expect']`说吧 | `'@cypress/dev/no-return-before': ['error', { tokens: ['myfn'] }]` |

## 编辑器

### 虚拟系统

使用插件 [Dirk Baeumer的ESLint 互联网档案馆的存檔,存档日期2013-12-02](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) 使用 ESLint 修改 JS 文件.  
安装后, 在您的用户或工作空间中添加以下内容( E)`.vscode/settings.json`设置 :

```json
{
  "eslint.validate": [
    { 
      "language": "javascript",
      "autoFix": true
    },
    {
      "language": "javascriptreact",
      "autoFix": true
    },
    {
      "language": "typescript",
      "autoFix": true
    },
    {
      "language": "typescriptreact",
      "autoFix": true
    },
    {
      "language": "json",
      "autoFix": true
    }
  ],
}
```

### 原子

安装软件包 [内嵌](https://atom.io/packages/linter-eslint) (及其从属关系)使出能起伏. 进入此软件包的设置 并启用“ Fix on save” 选项,可自动修正白色空间问题和其他问题.

### 下图文字

安装 [ESLint 格式文件](https://packagecontrol.io/packages/ESLint-Formatter), (中文(简体) ), 然后设置下列设置:

```json
{
  "format_on_save": true,
  "debug": true
}
```

## 许可证

本项目的许可条件如下: [麻省理工学院许可证](https://npmcn.com/LICENSE.md)。 。 。 .

## 更改日志

[更改日志](https://npmcn.com/package/%40cypress/eslint-plugin-dev/CHANGELOG.md)

## 常见问题

### @cypress/eslint-plugin-dev 是什么？

Cypress只开发软件包共用的 ESLint 规则注意：该包已被作者标记为弃用——Package no longer supported\. Contact Support at https://www\.npmjs\.com/support for more info\.

### 如何安装 @cypress/eslint-plugin-dev？

在项目目录运行 npm install @cypress/eslint-plugin-dev，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：eslint（^= 8\.0\.0）、eslint-plugin-mocha（ \>= 8\.0\.0）、eslint-plugin-react（\>= 7\.22\.0）、@babel/eslint-parser（^7\.28\.0）、eslint-plugin-import（\>= 2\.0\.0）、@typescript-eslint/parser（\>= 7\.0\.0）、eslint-plugin-json-format（\>= 2\.0\.1）、@typescript-eslint/eslint-plugin（\>= 7\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。它还提供命令行工具 lint-changed、lint-pre-commit，可以用 npx lint-changed 直接运行。

### @cypress/eslint-plugin-dev 支持 TypeScript 吗？

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

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

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

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

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

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

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

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

最新版本 7\.0\.0 发布于 2026/08/27（2 个月前）；至今共发布 27 个版本，其中过去 12 个月发布了 1 个；首次发布于 2019/06/26。作者已将其标记为弃用，新项目建议寻找替代方案。

