Skip to content

Commit eee34b2

Browse files
committed
feat: remove legacy eslintrc configuration
BREAKING CHANGE: Drop legacy configuration support Support for non-flat legacy configurations is removed eslint-plugin-cypress/flat is deprecated and replaced by eslint-plugin-cypress globals is updated to 16.2.0
1 parent 87e197b commit eee34b2

26 files changed

+68
-639
lines changed

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22.11.0
1+
22.16.0

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22.11.0
1+
22.16.0

CONTRIBUTING.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ To add a new rule:
3434
* Run `npm run lint`
3535
* Run `npm test` to run [Jest](https://jestjs.io/) (or run `npm start` to run [Jest](https://jestjs.io/) in [watchAll](https://jestjs.io/docs/cli#--watchall) mode where it remains active and reruns when source changes are made)
3636
* Make sure all tests are passing
37-
* Add the rule to [legacy.js](https://github.com/cypress-io/eslint-plugin-cypress/blob/master/legacy.js) and to [flat.js](https://github.com/cypress-io/eslint-plugin-cypress/blob/master/lib/flat.js)
37+
* Add the rule to [flat.js](https://github.com/cypress-io/eslint-plugin-cypress/blob/master/lib/flat.js)
3838
* Create a git commit with a commit message similar to: `feat: add rule <description>` (see [commit message conventions](https://github.com/semantic-release/semantic-release#commit-message-format))
3939
* Create a PR from your branch
4040

@@ -44,11 +44,6 @@ This plugin uses the ESLint [eslint-doc-generator](https://www.npmjs.com/package
4444
* Install with `npm install eslint-doc-generator -g`
4545
* Run `eslint-doc-generator` in the root directory of the plugin
4646

47-
## Legacy tests
48-
49-
* The directory [tests-legacy](https://github.com/cypress-io/eslint-plugin-cypress/tree/master/tests-legacy) contains tests which are compatible with the legacy [ESLint v8 RuleTester](https://eslint.org/docs/v8.x/integrate/nodejs-api#ruletester) utility. It is not expected to add new rules to this set of tests.
50-
* The directory [tests](https://github.com/cypress-io/eslint-plugin-cypress/tree/master/tests) is for tests compatible with the current [ESLint RuleTester](https://eslint.org/docs/latest/integrate/nodejs-api#ruletester).
51-
5247
## Merging pull requests
5348

5449
This information is for Cypress.io Members or Collaborators who merge pull requests:

ESLINTRC-CONFIG.md

Lines changed: 3 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,7 @@
11
# Cypress ESLint Plugin - Legacy Config
22

3-
This document supplements the [README](./README.md) document and describes how to use the Cypress ESLint Plugin (`eslint-plugin-cypress`) in a [deprecated ESLint legacy config environment](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated). The use of flat configurations with this plugin is described in the [README](./README.md) document.
3+
This document previously described how to use the Cypress ESLint Plugin (`eslint-plugin-cypress`) with an [ESLint legacy config environment](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated).
44

5-
Usage with ESLint `9.x` is described.
5+
This form of configuration was deprecated with the release of ESLint `v9` and its use with `eslint-plugin-cypress` is no longer supported.
66

7-
## Deprecations
8-
9-
The use of `eslintrc` configurations with `eslint-plugin-cypress` is deprecated and support will be removed in a future version of this plugin. This is tied in to the ESLint announcement in the blog post [Flat config rollout plans](https://eslint.org/blog/2023/10/flat-config-rollout-plans/) from October 2023 which describes that the `eslintrc` configuration system is planned to be removed in the future ESLint `v10.0.0`. Users are encouraged to migrate to using a [flat configuration](https://eslint.org/docs/latest/use/configure/configuration-files).
10-
11-
## Installation
12-
13-
Use a minimum ESLint `9.x`.
14-
15-
```shell
16-
npm install eslint eslint-plugin-cypress --save-dev
17-
```
18-
19-
or
20-
21-
```shell
22-
yarn add eslint eslint-plugin-cypress --dev
23-
```
24-
25-
## Usage
26-
27-
To use a deprecated configuration with ESLint `v9`, such as `.eslintrc.json`, you must set the `ESLINT_USE_FLAT_CONFIG` environment variable to `false` (see [ESLint v9 > Configuration Files (Deprecated)](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated)). The following examples use `json` format for the content of the configuration file:
28-
29-
```json
30-
{
31-
"plugins": [
32-
"cypress"
33-
]
34-
}
35-
```
36-
37-
You can add rules - see [Rules](./README.md#rules) for a list of the available rules:
38-
39-
```json
40-
{
41-
"rules": {
42-
"cypress/no-assigning-return-values": "error",
43-
"cypress/no-unnecessary-waiting": "error",
44-
"cypress/assertion-before-screenshot": "warn",
45-
"cypress/no-force": "warn",
46-
"cypress/no-async-tests": "error",
47-
"cypress/no-async-before": "error",
48-
"cypress/no-pause": "error",
49-
"cypress/no-debug": "error"
50-
}
51-
}
52-
```
53-
54-
You can allow certain globals provided by Cypress:
55-
56-
```json
57-
{
58-
"env": {
59-
"cypress/globals": true
60-
}
61-
}
62-
```
63-
64-
## Recommended configuration
65-
66-
Use the recommended configuration and you can forego configuring _plugins_, _rules_, and _env_ individually. See [Rules](./README.md#rules) for which rules are included in the recommended configuration.
67-
68-
```json
69-
{
70-
"extends": [
71-
"plugin:cypress/recommended"
72-
]
73-
}
74-
```
75-
76-
## Rules
77-
78-
See the [Rules](./README.md#rules) list in the main [README](./README.md) document.
79-
80-
## Mocha and Chai
81-
82-
Cypress 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`.
83-
84-
## Mocha `.only` and `.skip`
85-
86-
During 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@^10](https://www.npmjs.com/package/eslint-plugin-mocha). This is the highest plugin version that still supports legacy configurations. 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-skipped-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/v10.5.0/docs/rules/no-skipped-tests.md) rule detects the use of `.skip`:
87-
88-
```sh
89-
npm install --save-dev eslint-plugin-mocha@^10
90-
```
91-
92-
In your `.eslintrc.json`:
93-
94-
```json
95-
{
96-
"plugins": [
97-
"cypress",
98-
"mocha"
99-
],
100-
"rules": {
101-
"mocha/no-exclusive-tests": "warn",
102-
"mocha/no-skipped-tests": "warn"
103-
}
104-
}
105-
```
106-
107-
Or you can simply use the `cypress/recommended` and `mocha/recommended` configurations together, for example:
108-
109-
```json
110-
{
111-
"extends": [
112-
"plugin:cypress/recommended",
113-
"plugin:mocha/recommended"
114-
]
115-
}
116-
```
117-
118-
## Chai and `no-unused-expressions`
119-
120-
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](https://www.npmjs.com/package/eslint-plugin-chai-friendly).
121-
122-
```sh
123-
npm install --save-dev eslint-plugin-chai-friendly
124-
```
125-
126-
In your `.eslintrc.json`:
127-
128-
```json
129-
{
130-
"plugins": [
131-
"cypress",
132-
"chai-friendly"
133-
],
134-
"rules": {
135-
"no-unused-expressions": 0,
136-
"chai-friendly/no-unused-expressions": 2
137-
}
138-
}
139-
```
140-
141-
Or you can simply add its `recommended` config:
142-
143-
```json
144-
{
145-
"extends": ["plugin:chai-friendly/recommended"]
146-
}
147-
```
7+
Users who were previously using a deprecated configuration environment should migrate to a [flat configuration](https://eslint.org/docs/latest/use/configure/configuration-files).

FLAT-CONFIG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
# Cypress ESLint Plugin - Flat Config
22

3-
Please refer to the [README](./README.md) document where the previous contents of this document, describing how to use `eslint-plugin-cypress` with an ESLint `v9` (default) [flat configuration](https://eslint.org/docs/latest/use/configure/configuration-files), can now be found.
4-
5-
For instructions on using a deprecated [eslintrc-type](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated) config file from previous ESLint `v8` versions and below, please refer to the [ESLINTRC-CONFIG](./ESLINTRC-CONFIG.md) document.
3+
Please refer to the [README](./README.md) document which describes how to use `eslint-plugin-cypress` with an ESLint `v9` (default) [flat configuration](https://eslint.org/docs/latest/use/configure/configuration-files).

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,27 @@ yarn add eslint eslint-plugin-cypress --dev
1818

1919
## Usage
2020

21-
ESLint `v9` uses a [Flat config file](https://eslint.org/docs/latest/use/configure/configuration-files) format with filename `eslint.config.*js` by default. For instructions on using a deprecated [eslintrc-type](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated) config file from previous ESLint versions, please refer to the [ESLINTRC-CONFIG](./ESLINTRC-CONFIG.md) document.
21+
ESLint `v9` uses a [Flat config file](https://eslint.org/docs/latest/use/configure/configuration-files) format with filename `eslint.config.*js` by default. This plugin no longer supports the use of a deprecated [eslintrc-type](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated) config file from previous ESLint versions.
2222

23-
To set up a flat configuration, add a file `eslint.config.mjs` to the root directory of your Cypress project and include the following instructions to import the available flat configurations using:
23+
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:
2424

2525
```shell
26-
import pluginCypress from 'eslint-plugin-cypress/flat'
26+
import pluginCypress from 'eslint-plugin-cypress'
27+
```
28+
29+
For backwards compatibility with previous plugin versions `3.3.0` - `4.3.0`, the following equivalent deprecated form is also supported. This is planned to be removed in a future major version:
30+
31+
```shell
32+
import pluginCypress from 'eslint-plugin-cypress/flat' # deprecated
2733
```
2834

2935
## Configurations
3036

31-
There are two specific flat configurations available:
37+
There are two specific configurations available:
3238

3339
| Configuration | Content |
3440
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
35-
| `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). This version no longer specifies `languageOptions` for `ecmaVersion` and `sourceType` - see ESLint [JavaScript languageOptions](https://eslint.org/docs/latest/use/configure/language-options#specifying-javascript-options). There are no default rules enabled in this configuration. |
41+
| `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. |
3642
| `configs.recommended` | enables [recommended Rules](#rules). It includes also `configs.global` (see above). |
3743

3844
## Rules
@@ -67,11 +73,11 @@ In the following sections, different examples of possible configuration file con
6773

6874
### Cypress
6975

70-
All rules from `eslint-plugin-cypress` are available through `eslint-plugin-cypress/flat` and can be individually activated.
76+
All rules from `eslint-plugin-cypress` are available through `eslint-plugin-cypress` and can be individually activated.
7177
- [cypress/unsafe-to-chain-command](https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/unsafe-to-chain-command.md) is activated and set to `error`
7278

7379
```js
74-
import pluginCypress from 'eslint-plugin-cypress/flat'
80+
import pluginCypress from 'eslint-plugin-cypress'
7581
export default [
7682
{
7783
plugins: {
@@ -90,7 +96,7 @@ The `eslint-plugin-cypress` [recommended rules](#rules) `configs.recommended` ar
9096
- [cypress/no-unnecessary-waiting](https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-unnecessary-waiting.md) which is set to `off`
9197

9298
```js
93-
import pluginCypress from 'eslint-plugin-cypress/flat'
99+
import pluginCypress from 'eslint-plugin-cypress'
94100
export default [
95101
pluginCypress.configs.recommended,
96102
{
@@ -106,7 +112,7 @@ export default [
106112
The `configs.globals` are activated.
107113

108114
```js
109-
import pluginCypress from 'eslint-plugin-cypress/flat'
115+
import pluginCypress from 'eslint-plugin-cypress'
110116
export default [
111117
pluginCypress.configs.globals
112118
]
@@ -177,7 +183,7 @@ npm install eslint-plugin-mocha@^11 --save-dev
177183

178184
```js
179185
import pluginMocha from 'eslint-plugin-mocha'
180-
import pluginCypress from 'eslint-plugin-cypress/flat'
186+
import pluginCypress from 'eslint-plugin-cypress'
181187
export default [
182188
pluginMocha.configs.recommended,
183189
pluginCypress.configs.recommended,
@@ -205,7 +211,7 @@ npm install eslint-plugin-chai-friendly@^1.0.1 --save-dev
205211
```
206212

207213
```js
208-
import pluginCypress from 'eslint-plugin-cypress/flat'
214+
import pluginCypress from 'eslint-plugin-cypress'
209215
import pluginChaiFriendly from 'eslint-plugin-chai-friendly'
210216
export default [
211217
pluginCypress.configs.recommended,

circle.yml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ version: 2.1
33
executors:
44
docker-executor:
55
docker:
6-
- image: cimg/node:22.14.0
6+
- image: cimg/node:22.16.0
77
resource_class: medium
88

99
workflows:
1010
main:
1111
jobs:
1212
- lint
13-
- test-v8
1413
- test-v9
1514

1615
- build-test-project
@@ -21,6 +20,7 @@ workflows:
2120
config-file: [
2221
# configurations correspond to examples in README
2322
'default',
23+
'default-deprecated', # using deprecated /flat
2424
'recommended',
2525
'globals',
2626
]
@@ -29,7 +29,6 @@ workflows:
2929
- release:
3030
requires:
3131
- lint
32-
- test-v8
3332
- test-v9
3433
- test-test-project
3534
filters:
@@ -52,23 +51,6 @@ jobs:
5251
name: Lint code
5352
command: npm run lint
5453

55-
test-v8:
56-
executor: docker-executor
57-
steps:
58-
- checkout
59-
- run:
60-
name: Install dependencies
61-
command: npm ci
62-
- run:
63-
name: Install ESLint 8
64-
command: npm install eslint@8
65-
- run:
66-
name: Show ESLint version
67-
command: npx eslint --version
68-
- run:
69-
name: Test ESLint 8
70-
command: npm run test:legacy
71-
7254
test-v9:
7355
executor: docker-executor
7456
steps:

jest.config-legacy.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

legacy.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

lib/flat.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ const plugin = {
55
meta: { name, version },
66
configs: {},
77
rules: {
8+
'assertion-before-screenshot': require('./rules/assertion-before-screenshot'),
89
'no-assigning-return-values': require('./rules/no-assigning-return-values'),
9-
'unsafe-to-chain-command': require('./rules/unsafe-to-chain-command'),
10-
'no-unnecessary-waiting': require('./rules/no-unnecessary-waiting'),
1110
'no-async-before': require('./rules/no-async-before'),
1211
'no-async-tests': require('./rules/no-async-tests'),
13-
'assertion-before-screenshot': require('./rules/assertion-before-screenshot'),
14-
'require-data-selectors': require('./rules/require-data-selectors'),
12+
'no-chained-get': require('./rules/no-chained-get'),
13+
'no-debug': require('./rules/no-debug'),
1514
'no-force': require('./rules/no-force'),
1615
'no-pause': require('./rules/no-pause'),
17-
'no-debug': require('./rules/no-debug'),
16+
'no-unnecessary-waiting': require('./rules/no-unnecessary-waiting'),
1817
'no-xpath': require('./rules/no-xpath'),
19-
'no-chained-get': require('./rules/no-chained-get'),
18+
'require-data-selectors': require('./rules/require-data-selectors'),
19+
'unsafe-to-chain-command': require('./rules/unsafe-to-chain-command'),
2020
},
2121
}
2222

0 commit comments

Comments
 (0)