Skip to content

Commit

Permalink
Merge pull request #203 from MikeMcC399/enable/eslint-v9
Browse files Browse the repository at this point in the history
feat: support eslint v9 through @eslint/eslintrc
  • Loading branch information
jennifer-shehane authored May 6, 2024
2 parents f38cc04 + 25e092e commit c40989d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
12 changes: 7 additions & 5 deletions FLAT-CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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.

Usage with ESLint `8.57.0` is described. An update to this document is planned to cover ESLint `9.x` additionally.
Usage with ESLint `8.57.0` and ESLint `9.x` is described.

## Introduction

Expand All @@ -12,20 +12,20 @@ Previously, ESLint had announced in their blog post [Flat config rollout plans](

The Cypress ESLint Plugin (`eslint-plugin-cypress`) is currently based on ESLint `8.x` and has not yet been migrated to support Flat Config natively. [ESLint's new config system, Part 2: Introduction to flat config](https://eslint.org/blog/2022/08/new-config-system-part-2/) from August 2022 introduced the [Backwards compatibility utility](https://eslint.org/blog/2022/08/new-config-system-part-2/#backwards-compatibility-utility). This gives the capability to use `eslint-plugin-cypress` in an ESLint flat config environment.

The following information details installation and usage examples for `eslint-plugin-cypress` together with related plugins in such an ESLint `8.57.0` flat config environment.
The following information details installation and usage examples for `eslint-plugin-cypress` together with related plugins in an ESLint flat config environment.

## Installation

It is recommended to use a minimum ESLint `v8.x` version [eslint@8.57.0](https://github.com/eslint/eslint/releases/tag/v8.57.0).
It is recommended to use a minimum ESLint `8.x` version [eslint@8.57.0](https://github.com/eslint/eslint/releases/tag/v8.57.0) or ESLint `9.x`.

```shell
npm install eslint@^8.57.0 @eslint/eslintrc eslint-plugin-cypress --save-dev
npm install eslint @eslint/eslintrc eslint-plugin-cypress@^3.1.1 --save-dev
```

or

```shell
yarn add eslint@^8.57.0 @eslint/eslintrc eslint-plugin-cypress --dev
yarn add eslint @eslint/eslintrc eslint-plugin-cypress@^3.1.1 --dev
```

## Usage examples
Expand Down Expand Up @@ -130,3 +130,5 @@ export default [
})
]
```

**Pending the resolution of issue https://github.com/ihordiachenko/eslint-plugin-chai-friendly/issues/32 [eslint-plugin-chai-friendly](https://www.npmjs.com/package/eslint-plugin-chai-friendly) cannot be used with ESLint `v9`.**
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Note: If you installed ESLint globally then you must also install `eslint-plugin

## Installation

Prerequisites: [ESLint](https://www.npmjs.com/package/eslint) `v7` or `v8`. ESLint `v9` is **not** supported yet.
Prerequisites: [ESLint](https://www.npmjs.com/package/eslint) `v7`, `v8` or `v9`.
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 through [@eslint/eslintrc](https://www.npmjs.com/package/@eslint/eslintrc).

```sh
npm install eslint-plugin-cypress --save-dev
Expand All @@ -18,9 +19,9 @@ yarn add eslint-plugin-cypress --dev

## Usage

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.
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).

Optionally, if you are using ESLint `v8` with a minimum version of `8.57.0`, you can use the [new configuration file](https://eslint.org/docs/v8.x/use/configure/configuration-files-new) format with filename `eslint.config.*js`. In this case, please refer to [additional Flat config installation and configuration details](FLAT-CONFIG.md).
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`.)

```json
{
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"homepage": "https://github.com/cypress-io/eslint-plugin-cypress#readme",
"peerDependencies": {
"eslint": ">=7 <9"
"eslint": ">=7"
},
"dependencies": {
"globals": "^13.20.0"
Expand Down

0 comments on commit c40989d

Please sign in to comment.