Skip to content

Commit 47dc58f

Browse files
Merge pull request #234 from MikeMcC399/v9-only
feat: minimum version eslint v9
2 parents ce12040 + 061366e commit 47dc58f

File tree

6 files changed

+76
-112
lines changed

6 files changed

+76
-112
lines changed

FLAT-CONFIG.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22

33
This document supplements the [README](README.md) document and describes how to use the Cypress ESLint Plugin (`eslint-plugin-cypress`) in an ESLint flat config environment.
44

5-
Usage with ESLint `8.57.0` and ESLint `9.x` is described.
5+
Usage with ESLint `9.x` is described.
66

77
## Introduction
88

99
[ESLint v9.0.0](https://eslint.org/blog/2024/04/eslint-v9.0.0-released/) was released on April 5, 2024, establishing flat config as the default for this version.
1010

1111
Previously, ESLint had announced in their blog post [Flat config rollout plans](https://eslint.org/blog/2023/10/flat-config-rollout-plans/) in October 2023 that flat config was planned to be the default in ESLint `v9.0.0` and that the eslintrc configuration system is planned to be removed in the future ESLint `v10.0.0`.
1212

13-
Cypress ESLint Plugin (`eslint-plugin-cypress`) in release [3.2.0](https://github.com/cypress-io/eslint-plugin-cypress/releases/tag/v3.2.0) offered the first support of ESLint `9.x` flat config files using the [Backwards compatibility utility](https://eslint.org/blog/2022/08/new-config-system-part-2/#backwards-compatibility-utility). Current releases have removed the dependency on this utility and the examples in this document have been updated correspondingly.
14-
1513
The following information details installation and usage examples for `eslint-plugin-cypress` together with related plugins in an ESLint flat config environment.
1614

1715
## Installation
1816

19-
It is recommended to use a minimum ESLint `8.x` version [[email protected]](https://github.com/eslint/eslint/releases/tag/v8.57.0) or ESLint `9.x`.
17+
Use a minimum ESLint `9.x`.
2018

2119
```shell
2220
npm install eslint eslint-plugin-cypress --save-dev
@@ -38,10 +36,10 @@ import pluginCypress from 'eslint-plugin-cypress/flat'
3836

3937
There are two specific flat configurations available:
4038

41-
| Configuration | Content |
42-
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
43-
| `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). Additionally, `languageOptions` of `ecmaVersion: 2019` and `sourceType: 'module'` for backwards compatibility with earlier versions of this plugin are defined. There are no default rules enabled in this configuration. |
44-
| `configs.recommended` | enables [recommended Rules](README.md#rules). It includes also `configs.global` (see above) |
39+
| Configuration | Content |
40+
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
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). 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. |
42+
| `configs.recommended` | enables [recommended Rules](README.md#rules). It includes also `configs.global` (see above) |
4543

4644
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.
4745

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Note: If you installed ESLint globally then you must also install `eslint-plugin
66

77
## Installation
88

9-
Prerequisites: [ESLint](https://www.npmjs.com/package/eslint) `v7`, `v8` or `v9`.
10-
This plugin supports the use of [Flat config files](https://eslint.org/docs/latest/use/configure/configuration-files) with ESLint `8.57.0` and above.
9+
Prerequisites: [ESLint](https://www.npmjs.com/package/eslint) `v9`. Lower versions are no longer supported.
10+
This plugin supports the use of [Flat config files](https://eslint.org/docs/latest/use/configure/configuration-files) with ESLint `9.0.0` and above.
1111

1212
```sh
1313
npm install eslint-plugin-cypress --save-dev
@@ -17,15 +17,11 @@ or
1717
yarn add eslint-plugin-cypress --dev
1818
```
1919

20-
## Deprecations
21-
22-
The use of ESLint `v7` and `v8` with `eslint-plugin-cypress` is deprecated and support will be removed in a future version of this plugin. ESLint `v7` reached end-of-life on Apr 9, 2022 and ESLint `v8` reached end-of-life on Oct 5, 2024. Users are encouraged to migrate to ESLint `v9`. See [ESLint Version Support](https://eslint.org/version-support/) for ESLint's current release lines.
23-
2420
## Usage
2521

26-
If you are using ESLint `v7` or `v8`, then add an `.eslintrc.json` file to the root directory of your Cypress project with the contents shown below. You can continue to use this format with ESLint `v9` if you 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)).
22+
ESLint `v9` uses a [Flat config file](https://eslint.org/docs/latest/use/configure/configuration-files) format with filename `eslint.config.*js` by default. Please refer to [Flat config installation and configuration details](FLAT-CONFIG.md).
2723

28-
ESLint `v9` uses a [Flat config file](https://eslint.org/docs/latest/use/configure/configuration-files) format with filename `eslint.config.*js` by default. Please refer to [additional Flat config installation and configuration details](FLAT-CONFIG.md). (You may also use this with ESLint `8.57.0`.)
24+
You can continue to use a deprecated configuration `.eslintrc.json` with ESLint `v9` if you 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)).
2925

3026
```json
3127
{

circle.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ workflows:
55
main:
66
jobs:
77
- lint
8-
- test-v7
98
- test-v8
109
- test-v9
1110
- release:
1211
requires:
1312
- lint
14-
- test-v7
1513
- test-v8
1614
- test-v9
1715
filters:
@@ -35,27 +33,6 @@ jobs:
3533
name: Lint code
3634
command: npm run lint
3735

38-
test-v7:
39-
docker:
40-
- image: cimg/node:20.12.2
41-
steps:
42-
- checkout
43-
- run:
44-
name: Install dependencies
45-
command: npm ci
46-
- run:
47-
name: Remove unneeded plugins # minimum [email protected] required
48-
command: npm uninstall eslint-plugin-eslint-plugin eslint-plugin-n
49-
- run:
50-
name: Install ESLint 7
51-
command: npm install eslint@7
52-
- run:
53-
name: Show ESLint version
54-
command: npx eslint --version
55-
- run:
56-
name: Test ESLint 7
57-
command: npm run test:legacy
58-
5936
test-v8:
6037
docker:
6138
- image: cimg/node:20.12.2

lib/flat.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ const commonGlobals =
2727
chai: false,
2828
}, globals.browser, globals.mocha)
2929

30-
const commonLanguageOptions = {
31-
ecmaVersion: 2019,
32-
sourceType: 'module'
33-
}
34-
3530
Object.assign(plugin.configs, {
3631
globals: {
3732
name: 'cypress/globals',
@@ -41,7 +36,6 @@ Object.assign(plugin.configs, {
4136
languageOptions: {
4237
globals:
4338
commonGlobals,
44-
...commonLanguageOptions
4539
}
4640
}
4741
})
@@ -61,7 +55,6 @@ Object.assign(plugin.configs, {
6155
languageOptions: {
6256
globals:
6357
commonGlobals,
64-
...commonLanguageOptions
6558
}
6659
}
6760
})

package-lock.json

Lines changed: 63 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,16 @@
2323
},
2424
"homepage": "https://github.com/cypress-io/eslint-plugin-cypress#readme",
2525
"peerDependencies": {
26-
"eslint": ">=7"
26+
"eslint": ">=9"
2727
},
2828
"dependencies": {
29-
"globals": "^13.20.0"
29+
"globals": "^15.11.0"
3030
},
3131
"devDependencies": {
32-
"@eslint/eslintrc": "^3.1.0",
33-
"@eslint/js": "^9.11.1",
3432
"eslint": "^9.12.0",
3533
"eslint-plugin-eslint-plugin": "^6.2.0",
3634
"eslint-plugin-mocha": "^10.5.0",
37-
"eslint-plugin-n": "^17.10.3",
35+
"eslint-plugin-n": "^17.11.1",
3836
"husky": "^9.1.6",
3937
"jest": "^29.7.0",
4038
"semantic-release": "24.1.2"

0 commit comments

Comments
 (0)