cypress-io / eslint-plugin-cypress

An ESLint plugin for projects that use Cypress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migrate from @cypress/eslint-plugin-dev to supported plugins

MikeMcC399 opened this issue Β· comments

Issue

The npm module @cypress/eslint-plugin-dev is not compatible with ESLint 8.x and so it prevents migration of this repository to ESLint 8.x. It is a general purpose linting plugin used internally in several other repos in the https://github.com/cypress-io ecosystem, such as in https://github.com/cypress-io/cypress, https://github.com/cypress-io/cypress-example-recipes, https://github.com/cypress-io/sec_sandbox-cypress, https://github.com/cypress-io/cypress-watch-preprocessor, https://github.com/cypress-io/cypress-browserify-preprocessor (archived) and https://github.com/cypress-io/eslint-plugin-json (archived).

  • The currently configured dependency @cypress/eslint-plugin-dev@3 uses @cypress/eslint-plugin-json. This json plugin was archived in Aug 2019, around 5 years ago, and due to its archived status it is no longer supported.

  • The most current version @cypress/eslint-plugin-dev@5 uses eslint-plugin-json-format. The last release for this replacement json plugin was in Sep 2019. Issues in this repository are not being addressed, so for practical purposes it is also unsupported.

  • @cypress/eslint-plugin-dev includes peerDependencies, some of which are not needed in this repository. This adds to deprecation warnings, vulnerabilities, and maintenance effort of the repo:

    • "@typescript-eslint/eslint-plugin": ">= 1.11.0"

    • "@typescript-eslint/parser": ">= 1.11.0"

    • "babel-eslint": "^7.2.3"

    • "eslint": ">= 3.2.1"

    • "eslint-plugin-json-format": ">= 2.0.0"

    • "eslint-plugin-mocha": " >= 4.11.0"

    • "eslint-plugin-react": "^7.22.0"

      There is no use of TypeScript or of React in this repo.

Note that peerDependencies do not work as they originally did.

In npm versions 3 through 6, peerDependencies were not automatically installed, and would raise a warning if an invalid version of the peer dependency was found in the tree. As of npm v7, peerDependencies are installed by default.

This change is awkward for the general use of @cypress/eslint-plugin-dev in this repo with the current npm v10 version which forces either the use of the npm --legacy-peer-deps option or installation of dependencies which are not all needed.

  • The repository also needs to be prepared for migration to ESLint 9.x (see request #155).

Consequence

In order to migrate the repo from ESLint 7.x to 8.x whilst preserving internal linting backwards compatibility, @cypress/eslint-plugin-dev should be replaced.

Suggestion

  1. Remove plugin dependencies used for internal linting:
    • @cypress/eslint-plugin-dev
    • @cypress/eslint-plugin-json
    • @typescript-eslint/eslint-plugin
    • @typescript-eslint/parser
  2. Replace by plugins recommended by the ESLint documentation section Linting a Plugin, using each plugin's recommended configuration:
  3. Use also
  4. Reconfigure and resolve any resulting linting issues.

Unless I hear alternative suggestions I will start work on a PR to implement the suggestion above, replacing @cypress/eslint-plugin-dev by standard plugins, so that internal linting of the plugin eslint-plugin-cypress can be migrated to ESLint 8.x and later to ESLint 9.x.

  • The draft PR to implement this proposal is #177

Unless I hear alternative suggestions I will start work on a PR to implement the suggestion above, replacing @cypress/eslint-plugin-dev by standard plugins, so that internal linting of the plugin eslint-plugin-cypress can be migrated to ESLint 8.x and later to ESLint 9.x.

I think directionally this makes the most sense and is likely a lot easier to maintain. Architecturally, it has been somewhat difficult to update and maintain cypress/eslint-plugin-dev inside eslint-plugin-cypress. I think most the rules that are implemented inside @cypress/eslint-plugin-dev are now covered by eslint-plugin-mocha which should make breaking that dependency out fairly straightforward (looks like you have that working in #177 πŸ™‚ )

@AtofStryker

I much appreciate your feedback, as working on this repo has been quite challenging for me. The repo hasn't been kept up to date at a base level for quite a long time, so there were multiple overlapping issues to overcome and I wanted to avoid introducing any unplanned breaking changes. Also I have little experience with ESLint to draw on.

You're right that I have everything already working for ESLint v7 and v8.

I expect that supporting v9 may be better done in another major version release after everything is cleaned up for v8. I'm leaving that discussion for later though.

I expect that supporting v9 may be better done in another major version release after everything is cleaned up for v8. I'm leaving that discussion for later though.

I think that is likely a wise choice. The changes from v7 to v8 as far as end user config is concerned were not large, but v8 to v9 looks to be a lot more of a lift for users. v9 is also fairly new at time of writing (2 weeks since publish), while v8 has been out for years

πŸŽ‰ This issue has been resolved in version 3.0.1 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€