@cypress/eslint-plugin-dev

中文文档
7.0.0发布于 2026/08/27MITCommonJS近 30 天下载 3792

Common ESLint rules shared by Cypress development-only packages

此软件包已被标记为弃用

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

原始使用文档
文档目录14 节
  1. Installation
  2. Usage
  3. Presets
  4. general
  5. tests
  6. react
  7. Configuration Examples
  8. Custom Rules:
  9. Editors
  10. VSCode
  11. Atom
  12. Sublime Text
  13. License
  14. Changelog

[Internal] Cypress Developer ESLint Plugin

Common ESLint rules shared by Cypress packages.

⚠️ This package for internal development of Cypress. Here's the Official Cypress ESLint Plugin meant for users of Cypress.

Installation

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

Usage

⚠️ Currently does not support ESLint version 9

For Eslint 8, use version 6.x.x

For Eslint 7 and below, use version 5.x.x

  1. install the following devDependencies:
@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
  1. add the following to your root level .eslintrc.json:
{
  "plugins": [
    "@cypress/dev"
  ],
  "extends": [
    "plugin:@cypress/dev/general"
  ]
}

Note: also add "plugin:@cypress/dev/react", if you are using React

Note: if you have a test/ directory, you should create a .eslintrc.json file inside of it, and add:

{
  "extends": [
    "plugin:@cypress/dev/tests"
  ]
}
  1. add the following to your .eslintignore:
# don't ignore hidden files, useful for formatting json config files
!.*
  1. (optional) Install and configure your text editor's ESLint Plugin Extension to lint and auto-fix files using ESLint, detailed below

  2. (optional) Install husky and enable the lint pre-commit hook:

package.json:

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

Note: the lint-pre-commit hook will automatically lint your staged files, and only --fix and git add them if there are no unstaged changes existing in that file (this protects partially staged files from being added in the hook).
To auto-fix all staged & unstaged files, run ./node_modules/.bin/lint-changed --fix

Presets

general

Should usually be used at the root of the package.

requires you to install the following devDependencies:

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

tests

Test-specific configuration and rules. Should be used within the test/ directory.

requires you to install the following devDependencies:

eslint-plugin-mocha

react

React and JSX-specific configuration and rules.

requires you to install the following devDependencies:

@babel/eslint-parser
eslint-plugin-react

Configuration Examples

Change some linting rules:

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

Stop your package.json from being formatted:

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

Custom Rules:

namedescriptionoptionsexample
@cypress/dev/arrow-body-multiline-bracesEnforces braces in arrow functions ONLY IN multiline function definitions[`[alwaysnever] always set this to 'always'`]
@cypress/dev/skip-commentEnforces a comment (// NOTE:) explaining a .skip added to it, describe, or context test blocks{ commentTokens: [array] tokens that indicate .skip explanation (default: ['NOTE:', 'TODO:', 'FIXME:'])}'@cypress/dev/skip-comment': ['error', { commentTokens: ['TODO:'] }]
@cypress/dev/no-return-beforeDisallows return statements before certain configurable tokens{ tokens: [array] tokens that cannot be preceded by 'return' (default: ['it', 'describe', 'context', 'expect'])}'@cypress/dev/no-return-before': ['error', { tokens: ['myfn'] }]

Editors

VSCode

Use plugin ESLint by Dirk Baeumer to lint and auto fix JS files using ESLint.
After installing, add the following to your User or Workspace (.vscode/settings.json) settings:

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

Atom

Install package linter-eslint (and its dependencies) to enable linting. Go into the settings for this package and enable "Fix on save" option to auto-fix white space issues and other things.

Sublime Text

Install ESLint-Formatter, then set the following settings:

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

License

This project is licensed under the terms of the MIT license.

Changelog

Changelog

版本与发布记录

@cypress/eslint-plugin-dev 共发布 27 个版本,首次发布于 2019/06/26;过去 12 个月发布了 1 个版本。

版本发布日期距今
7.0.0latest2026/08/272 个月前
6.0.02024/05/062 年前
5.3.32024/01/122 年前
5.3.22022/08/164 年前
5.3.12022/08/114 年前
5.3.02022/06/024 年前

关于 @cypress/eslint-plugin-dev 的常见问题

@cypress/eslint-plugin-dev 是什么?

Common ESLint rules shared by Cypress development-only packages注意:该包已被作者标记为弃用——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。作者已将其标记为弃用,新项目建议寻找替代方案。