{"name":"eslint-plugin-cypress","version":"5.2.1","keywords":["eslint","eslintplugin","cypress"],"author":{"name":"Cypress-io"},"license":"MIT","_id":"eslint-plugin-cypress@5.2.1","maintainers":[{"name":"chrisbreiding","email":"chris@chrisbreiding.com"},{"name":"cypress-npm-publisher","email":"cypress-npm-publisher@cypress.io"}],"homepage":"https://github.com/cypress-io/eslint-plugin-cypress#readme","bugs":{"url":"https://github.com/cypress-io/eslint-plugin-cypress/issues"},"dist":{"shasum":"0ce3fbe694174068403b3c0c2de252896317b97d","tarball":"http://registry-npm.ywwl.com/eslint-plugin-cypress/download/eslint-plugin-cypress-5.2.1.tgz","fileCount":31,"integrity":"sha512-HTJLbcd7fwJ4agbHinZ4FUIl38bUTJT3BmH8zdgS2V32LETmPqCtWHi3xlgZ2vpX0aW6kQoHCVVqHm8NxZJ9sA==","signatures":[{"sig":"MEUCIQC8Oef51+pv2LuRJw56bnLlVZh5BPHWQYahp2ef/IXWhAIgFCdi2XDyD/uY3EDtOaXesPmp+/MYDqVzuCCUJ1K4wiU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":55914,"size":13660,"noattachment":false,"key":"/eslint-plugin-cypress/-/eslint-plugin-cypress-5.2.1.tgz"},"main":"./lib/flat.js","types":"./lib/flat.d.ts","exports":{".":"./lib/flat.js","./flat":"./lib/flat.js"},"gitHead":"d600419330cd53d80cf2145f434ecd706807644c","scripts":{"lint":"eslint","test":"vitest run","format":"prettier --write .","prepare":"husky","lint-fix":"eslint --fix","format:check":"prettier --check .","semantic-release":"semantic-release"},"_npmUser":{"name":"cypress-npm-publisher","email":"cypress-npm-publisher@cypress.io"},"repository":{"url":"git+https://github.com/cypress-io/eslint-plugin-cypress.git","type":"git"},"_npmVersion":"10.9.3","description":"An ESLint plugin for projects using Cypress","directories":{},"_nodeVersion":"24.11.0","dependencies":{"globals":"^16.2.0"},"_hasShrinkwrap":false,"devDependencies":{"husky":"^9.1.7","eslint":"^9.39.1","vitest":"^4.0.4","prettier":"^3.6.2","@eslint/js":"^9.39.1","typescript":"^5.9.3","semantic-release":"24.2.7","typescript-eslint":"^8.45.0","eslint-plugin-mocha":"^11.1.0","@stylistic/eslint-plugin":"^5.4.0","eslint-plugin-eslint-plugin":"^7.0.0"},"peerDependencies":{"eslint":">=9"},"_npmOperationalInternal":{"tmp":"tmp/eslint-plugin-cypress_5.2.1_1767708967469_0.9464956084534077","host":"s3://npm-registry-packages-npm-production"},"readme":"# Cypress ESLint Plugin [![CircleCI](https://circleci.com/gh/cypress-io/eslint-plugin-cypress/tree/master.svg?style=svg)](https://circleci.com/gh/cypress-io/eslint-plugin-cypress/tree/master)\n\nAn [ESLint](https://eslint.org) plugin for your [Cypress](https://cypress.io) tests.\n\nNote: If you installed ESLint globally then you must also install `eslint-plugin-cypress` globally.\n\n## Installation\n\nPrerequisites: [ESLint](https://www.npmjs.com/package/eslint) `v10`. Lower versions are no longer supported.\n\n```sh\nnpm install eslint eslint-plugin-cypress --save-dev\n```\n\nor\n\n```sh\nyarn add eslint eslint-plugin-cypress --dev\n```\n\n## Usage\n\nESLint as of `v10` and this plugin no longer support the use of the deprecated [eslintrc-type](https://eslint.org/docs/v9.x/use/configure/configuration-files-deprecated) config file format.\nYou must use a [Flat config file](https://eslint.org/docs/latest/use/configure/configuration-files) format.\n\nTo 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:\n\n```shell\nimport pluginCypress from 'eslint-plugin-cypress'\n```\n\nThe configuration `eslint-plugin-cypress/flat`, which was deprecated in plugin version `5.0.0`, is no longer available.\nMigrate to using the equivalent configuration `eslint-plugin-cypress` by dropping the `/flat` suffix.\n\nRefer to ESLint `v10` [Configuration File Resolution](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file-resolution) for hierarchical use of configuration files.\n\n## Configurations\n\nThere are two specific configurations available:\n\n| Configuration         | Content                                                                                                                                                                                                                                                     |\n| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `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](https://www.npmjs.com/package/globals). There are no default rules enabled in this configuration. |\n| `configs.recommended` | enables [recommended Rules](#rules). It includes also `configs.global` (see above).                                                                                                                                                                         |\n\n## Rules\n\nThese rules enforce some of the [best practices recommended for using Cypress](https://on.cypress.io/best-practices).\n\n<!-- prettier-ignore-start -->\n<!-- begin auto-generated rules list -->\n\n💼 Configurations enabled in.\\\n✅ Set in the `recommended` configuration.\\\n🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\\\n❌ Deprecated.\n\n| Name                                                                     | Description                                                     | 💼 | 🔧 | ❌  |\n| :----------------------------------------------------------------------- | :-------------------------------------------------------------- | :- | :- | :- |\n| [assertion-before-screenshot](docs/rules/assertion-before-screenshot.md) | require screenshots to be preceded by an assertion              |    |    |    |\n| [no-and](docs/rules/no-and.md)                                           | enforce `.should()` over `.and()` for starting assertion chains |    | 🔧 |    |\n| [no-assigning-return-values](docs/rules/no-assigning-return-values.md)   | disallow assigning return values of `cy` calls                  | ✅  |    |    |\n| [no-async-before](docs/rules/no-async-before.md)                         | disallow using `async`/`await` in Cypress `before` methods      |    |    |    |\n| [no-async-tests](docs/rules/no-async-tests.md)                           | disallow using `async`/`await` in Cypress test cases            | ✅  |    |    |\n| [no-chained-get](docs/rules/no-chained-get.md)                           | disallow chain of `cy.get()` calls                              |    |    |    |\n| [no-debug](docs/rules/no-debug.md)                                       | disallow using `cy.debug()` calls                               |    |    |    |\n| [no-force](docs/rules/no-force.md)                                       | disallow using `force: true` with action commands               |    |    |    |\n| [no-pause](docs/rules/no-pause.md)                                       | disallow using `cy.pause()` calls                               |    |    |    |\n| [no-unnecessary-waiting](docs/rules/no-unnecessary-waiting.md)           | disallow waiting for arbitrary time periods                     | ✅  |    |    |\n| [no-xpath](docs/rules/no-xpath.md)                                       | disallow using `cy.xpath()` calls                               |    |    | ❌  |\n| [require-data-selectors](docs/rules/require-data-selectors.md)           | require `data-*` attribute selectors                            |    |    |    |\n| [unsafe-to-chain-command](docs/rules/unsafe-to-chain-command.md)         | disallow actions within chains                                  | ✅  |    |    |\n\n<!-- end auto-generated rules list -->\n<!-- prettier-ignore-end -->\n\n## Usage examples\n\nIn the following sections, different examples of possible configuration file contents are given, together with some brief explanations. Adapt these examples according to your needs.\n\n### Cypress\n\nAll rules are available by importing from `eslint-plugin-cypress` and can be individually activated.\n\n- [cypress/unsafe-to-chain-command](./docs/rules/unsafe-to-chain-command.md) is activated and set to `error`\n\n```js\nimport { defineConfig } from 'eslint/config'\nimport pluginCypress from 'eslint-plugin-cypress'\nexport default defineConfig([\n  {\n    plugins: {\n      cypress: pluginCypress,\n    },\n    rules: {\n      'cypress/unsafe-to-chain-command': 'error',\n    },\n  },\n])\n```\n\n### Cypress recommended\n\nThe `eslint-plugin-cypress` [recommended rules](#rules) `configs.recommended` are activated, except for\n\n- [cypress/no-unnecessary-waiting](./docs/rules/no-unnecessary-waiting.md) which is set to `off`\n\n```js\nimport { defineConfig } from 'eslint/config'\nimport pluginCypress from 'eslint-plugin-cypress'\nexport default defineConfig([\n  {\n    files: ['cypress/**/*.js'],\n    extends: [pluginCypress.configs.recommended],\n    rules: {\n      'cypress/no-unnecessary-waiting': 'off',\n    },\n  },\n])\n```\n\n### Cypress globals\n\nThe `configs.globals` are activated.\n\n```js\nimport { defineConfig } from 'eslint/config'\nimport pluginCypress from 'eslint-plugin-cypress'\nexport default defineConfig([\n  {\n    files: ['cypress/**/*.js'],\n    extends: [pluginCypress.configs.globals],\n  },\n])\n```\n\n### Typed Linting\n\nYou can activate typed linting for increased accuracy, if you want. This is purely optional and all rules continue to work without it. It uses a TypeScript parser to parse your entire project, instead of only the file being linted, which gives the plugin more information to work with. Be aware of the [performance penalty](https://typescript-eslint.io/getting-started/typed-linting/#performance) that this brings with it.\n\nFirst, install the `@typescript-eslint/parser` npm package:\n\n```sh\nnpm install @typescript-eslint/parser --save-dev\n```\n\nIf you already have a TypeScript codebase, you can skip the next step. If not, you need a `tsconfig.json`. The following minimal `tsconfig.json` does not compile or check your code and includes all .js files.\n\n```json\n{\n  \"include\": [\"**/*.js\"],\n  \"compilerOptions\": {\n    \"allowJs\": true,\n    \"checkJs\": false,\n    \"noEmit\": true\n  }\n}\n```\n\nThe last step is to extend your eslint config to use the `typescript-eslint` parser.\n\n```js\nimport { defineConfig } from 'eslint/config'\nimport typescriptParser from '@typescript-eslint/parser'\nexport default defineConfig([\n  {\n    languageOptions: {\n      parser: typescriptParser,\n      parserOptions: {\n        projectService: true,\n      },\n    },\n  },\n])\n```\n\n## Disable rules\n\nYou can disable specific rules per file, for a portion of a file, or for a single line. See the [ESLint rules](https://eslint.org/docs/latest/use/configure/rules#disable-rules) documentation. For example ...\n\nDisable the `cypress/no-unnecessary-waiting` rule for the entire file by placing this at the start of the file:\n\n```js\n/* eslint-disable cypress/no-unnecessary-waiting */\n```\n\nDisable the `cypress/no-unnecessary-waiting` rule for only a portion of the file:\n\n```js\nit('waits for a second', () => {\n  ...\n  /* eslint-disable cypress/no-unnecessary-waiting */\n  cy.wait(1000)\n  /* eslint-enable cypress/no-unnecessary-waiting */\n  ...\n})\n```\n\nDisable the `cypress/no-unnecessary-waiting` rule for a specific line:\n\n```js\nit('waits for a second', () => {\n  ...\n  cy.wait(1000) // eslint-disable-line cypress/no-unnecessary-waiting\n  ...\n})\n```\n\nYou can also disable a rule for the next line:\n\n```js\nit('waits for a second', () => {\n  ...\n  // eslint-disable-next-line cypress/no-unnecessary-waiting\n  cy.wait(1000)\n  ...\n})\n```\n\n## Mocha and Chai\n\nCypress is built on top of [Mocha](https://on.cypress.io/app/references/bundled-libraries#Mocha) and [Chai](https://on.cypress.io/app/references/bundled-libraries#Chai). See the following sections for information on using ESLint plugins [eslint-plugin-mocha](https://www.npmjs.com/package/eslint-plugin-mocha) and [eslint-plugin-chai-friendly](https://www.npmjs.com/package/eslint-plugin-chai-friendly) together with `eslint-plugin-cypress`.\n\n## Mocha `.only` and `.skip`\n\nDuring test spec development, [Mocha exclusive tests](https://mochajs.org/#exclusive-tests) `.only` or [Mocha inclusive tests](https://mochajs.org/#inclusive-tests) `.skip` may be used to control which tests are executed, as described in the Cypress documentation [Excluding and Including Tests](https://on.cypress.io/app/core-concepts/writing-and-organizing-tests#Excluding-and-Including-Tests). To apply corresponding rules, you can install and use [eslint-plugin-mocha@^11](https://www.npmjs.com/package/eslint-plugin-mocha) plugin version or above. The rule [mocha/no-exclusive-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-exclusive-tests.md) detects the use of `.only` and the [mocha/no-pending-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-pending-tests.md) rule detects the use of `.skip`.\n\n### Cypress and Mocha recommended\n\n[eslint-plugin-mocha](https://www.npmjs.com/package/eslint-plugin-mocha) is added to the example [Cypress recommended](#cypress-recommended).\n\nThe settings for individual `mocha` rules from the `configs.recommended` option are changed.\n\n- [mocha/no-exclusive-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-exclusive-tests.md)\n  and [mocha/no-pending-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-pending-tests.md)\n  are set to `error` instead of `warn`\n- [mocha/no-mocha-arrows](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-mocha-arrows.md)\n  and [mocha/no-async-in-sync-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/documentation/rules/no-async-in-sync-tests.md)\n  are set to `off` instead of `error`\n\n```shell\nnpm install eslint-plugin-mocha --save-dev\n```\n\n```js\nimport { defineConfig } from 'eslint/config'\nimport pluginMocha from 'eslint-plugin-mocha'\nimport pluginCypress from 'eslint-plugin-cypress'\nexport default defineConfig([\n  {\n    files: ['cypress/**/*.js'],\n    extends: [\n      pluginMocha.configs.recommended,\n      pluginCypress.configs.recommended,\n    ],\n    rules: {\n      'mocha/no-async-in-sync-tests': 'off', // for Cypress compatibility\n      'mocha/no-exclusive-tests': 'error',\n      'mocha/no-pending-tests': 'error',\n      'mocha/no-mocha-arrows': 'off',\n      'cypress/no-unnecessary-waiting': 'off',\n    },\n  },\n])\n```\n\n### Cypress and Chai recommended\n\nUsing 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](https://www.npmjs.com/package/eslint-plugin-chai-friendly).\n\n[eslint-plugin-chai-friendly](https://www.npmjs.com/package/eslint-plugin-chai-friendly) is combined with the Cypress plugin `eslint-plugin-cypress`.\n\nThe recommended rules for both plugins are used: `pluginCypress.configs.recommended` and `pluginChaiFriendly.configs.recommendedFlat`:\n\n```shell\nnpm install eslint-plugin-chai-friendly --save-dev\n```\n\n```js\nimport { defineConfig } from 'eslint/config'\nimport pluginCypress from 'eslint-plugin-cypress'\nimport pluginChaiFriendly from 'eslint-plugin-chai-friendly'\nexport default defineConfig([\n  {\n    files: ['cypress/**/*.js'],\n    extends: [\n      pluginCypress.configs.recommended,\n      pluginChaiFriendly.configs.recommendedFlat,\n    ],\n    rules: {\n      'cypress/no-unnecessary-waiting': 'off',\n    },\n  },\n])\n```\n\n## Contributing\n\nPlease see our [Contributing Guideline](./CONTRIBUTING.md) which explains how to contribute rules or other fixes and features to the repo.\n","publish_time":1767708967626,"_cnpm_publish_time":1767708967626,"dist-tags":{"latest":"7.0.3"}}