
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
eslint-plugin-cypress
Advanced tools
An ESLint plugin for your Cypress tests.
Note: If you installed ESLint globally then you must also install eslint-plugin-cypress globally.
Prerequisites: ESLint v9 or v10. Lower versions are no longer supported.
npm install eslint eslint-plugin-cypress --save-dev
or
yarn add eslint eslint-plugin-cypress --dev
ESLint as of v10 and this plugin no longer support the use of the deprecated eslintrc-type config file format.
You must use a Flat config file format.
This is the default in ESLint v9, and in ESLint v10 it is the only config format available.
To set up a configuration, add a file eslint.config.mjs to the root directory of your Cypress project and include the following instructions to import the available configurations using:
import pluginCypress from 'eslint-plugin-cypress'
The configuration eslint-plugin-cypress/flat, which was deprecated in plugin version 5.0.0, is no longer available.
Migrate to using the equivalent configuration eslint-plugin-cypress by dropping the /flat suffix.
Refer to ESLint v10 Configuration File Resolution for hierarchical use of configuration files.
There are two specific configurations available:
| Configuration | Content |
|---|---|
configs.globals | defines globals cy, Cypress, expect, assert and chai used in Cypress test specs as well as globals.browser and globals.mocha from globals. There are no default rules enabled in this configuration. |
configs.recommended | enables recommended Rules. It includes also configs.global (see above). |
These rules enforce some of the best practices recommended for using Cypress.
💼 Configurations enabled in.
✅ Set in the recommended configuration.
❌ Deprecated.
| Name | Description | 💼 | ❌ |
|---|---|---|---|
| assertion-before-screenshot | require screenshots to be preceded by an assertion | ||
| no-assigning-return-values | disallow assigning return values of cy calls | ✅ | |
| no-async-before | disallow using async/await in Cypress before methods | ||
| no-async-tests | disallow using async/await in Cypress test cases | ✅ | |
| no-chained-get | disallow chain of cy.get() calls | ||
| no-debug | disallow using cy.debug() calls | ||
| no-force | disallow using force: true with action commands | ||
| no-pause | disallow using cy.pause() calls | ||
| no-unnecessary-waiting | disallow waiting for arbitrary time periods | ✅ | |
| no-xpath | disallow using cy.xpath() calls | ❌ | |
| require-data-selectors | require data-* attribute selectors | ||
| unsafe-to-chain-command | disallow actions within chains | ✅ |
In the following sections, different examples of possible configuration file contents are given, together with some brief explanations. Adapt these examples according to your needs.
The examples use the defineConfig() helper, introduced with ESLint 9.22.0. Refer to the blog article Evolving flat config with extends for background information. If you are using ESLint <9.22.0, import defineConfig from @eslint/config-helpers instead of from eslint/config.
All rules are available by importing from eslint-plugin-cypress and can be individually activated.
errorimport { defineConfig } from 'eslint/config'
import pluginCypress from 'eslint-plugin-cypress'
export default defineConfig([
{
plugins: {
cypress: pluginCypress,
},
rules: {
'cypress/unsafe-to-chain-command': 'error',
},
},
])
The eslint-plugin-cypress recommended rules configs.recommended are activated, except for
offimport { defineConfig } from 'eslint/config'
import pluginCypress from 'eslint-plugin-cypress'
export default defineConfig([
{
files: ['cypress/**/*.js'],
extends: [
pluginCypress.configs.recommended,
],
rules: {
'cypress/no-unnecessary-waiting': 'off',
},
},
])
The configs.globals are activated.
import { defineConfig } from 'eslint/config'
import pluginCypress from 'eslint-plugin-cypress'
export default defineConfig([
{
files: ['cypress/**/*.js'],
extends: [
pluginCypress.configs.globals,
],
},
])
You can disable specific rules per file, for a portion of a file, or for a single line. See the ESLint rules documentation. For example ...
Disable the cypress/no-unnecessary-waiting rule for the entire file by placing this at the start of the file:
/* eslint-disable cypress/no-unnecessary-waiting */
Disable the cypress/no-unnecessary-waiting rule for only a portion of the file:
it('waits for a second', () => {
...
/* eslint-disable cypress/no-unnecessary-waiting */
cy.wait(1000)
/* eslint-enable cypress/no-unnecessary-waiting */
...
})
Disable the cypress/no-unnecessary-waiting rule for a specific line:
it('waits for a second', () => {
...
cy.wait(1000) // eslint-disable-line cypress/no-unnecessary-waiting
...
})
You can also disable a rule for the next line:
it('waits for a second', () => {
...
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000)
...
})
Cypress is built on top of Mocha and Chai. See the following sections for information on using ESLint plugins eslint-plugin-mocha and eslint-plugin-chai-friendly together with eslint-plugin-cypress.
.only and .skipDuring test spec development, Mocha exclusive tests .only or Mocha inclusive tests .skip may be used to control which tests are executed, as described in the Cypress documentation Excluding and Including Tests. To apply corresponding rules, you can install and use eslint-plugin-mocha@^11 plugin version or above. The rule mocha/no-exclusive-tests detects the use of .only and the mocha/no-pending-tests rule detects the use of .skip.
eslint-plugin-mocha@^11 is added to the example Cypress recommended.
The settings for individual mocha rules from the configs.recommended option are changed.
error instead of warnoff instead of errornpm install eslint-plugin-mocha@^11 --save-dev
import { defineConfig } from 'eslint/config'
import pluginMocha from 'eslint-plugin-mocha'
import pluginCypress from 'eslint-plugin-cypress'
export default defineConfig([
{
files: ['cypress/**/*.js'],
extends: [
pluginMocha.configs.recommended,
pluginCypress.configs.recommended,
],
rules: {
'mocha/no-exclusive-tests': 'error',
'mocha/no-pending-tests': 'error',
'mocha/no-mocha-arrows': 'off',
'cypress/no-unnecessary-waiting': 'off',
},
},
])
Using an assertion such as expect(value).to.be.true can fail the ESLint rule no-unused-expressions even though it's not an error in this case. To fix this, you can install and use eslint-plugin-chai-friendly.
eslint-plugin-chai-friendly is combined with the Cypress plugin eslint-plugin-cypress.
The recommended rules for both plugins are used: pluginCypress.configs.recommended and pluginChaiFriendly.configs.recommendedFlat:
npm install eslint-plugin-chai-friendly@^1.0.1 --save-dev
import { defineConfig } from 'eslint/config'
import pluginCypress from 'eslint-plugin-cypress'
import pluginChaiFriendly from 'eslint-plugin-chai-friendly'
export default defineConfig([
{
files: ['cypress/**/*.js'],
extends: [
pluginCypress.configs.recommended,
pluginChaiFriendly.configs.recommendedFlat,
],
rules: {
'cypress/no-unnecessary-waiting': 'off',
},
},
])
Please see our Contributing Guideline which explains how to contribute rules or other fixes and features to the repo.
This package provides linting rules for Jest, another popular testing framework. It is similar to eslint-plugin-cypress in that it offers a set of rules tailored to the specific testing framework to encourage best practices.
Similar to eslint-plugin-cypress, this package offers linting rules for Mocha, a test framework for Node.js and the browser. It helps maintain code quality and adherence to Mocha-specific conventions.
This package is designed for linting code that uses the Testing Library family of utilities. It provides rules that help enforce best practices when writing tests with Testing Library, similar to how eslint-plugin-cypress does for Cypress tests.
FAQs
An ESLint plugin for projects using Cypress
The npm package eslint-plugin-cypress receives a total of 3,213,550 weekly downloads. As such, eslint-plugin-cypress popularity was classified as popular.
We found that eslint-plugin-cypress demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.