Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New] add eslint 9 support #1009

Merged
merged 2 commits into from
Sep 1, 2024

Conversation

michaelfaith
Copy link
Contributor

This change adds support for eslint v9. All three example projects have been updated to use the latest eslint, and the root package's dev and peer deps have been updated.

In order to make this work with both v9 and older versions, I had to update the parser options helper to adjust the config passed into the RuleTester. It was also necessary update jest to a newer version, in order to resolve eslint's use of node:fs/promises.

image

Note: the removed test cases are exact duplicates of other tests. v9 fails tests when its determined to be an exact duplicate.

Closes: #978

This change adds support for eslint v9. All three example projects have been updated to use the latest eslint, and the root package's dev and peer deps have been updated.

In order to make this work with both v9 and older versions, I had to update the parser options helper to adjust the config passed into the `RuleTester`.
package.json Outdated Show resolved Hide resolved
__tests__/src/rules/no-static-element-interactions-test.js Outdated Show resolved Hide resolved
package.json Outdated
"jest": "^24.9.0",
"jest": "^29.7.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can't upgrade jest, because jest 24 is the last version that supports node 6.

Copy link
Contributor Author

@michaelfaith michaelfaith Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Ok, but jest 24 isn't able to resolve node:fs/promises which eslint uses (so we hit this when importing RuleTester from eslint). I could map node:fs/promises to something like fs-extra using jest's moduleNameMapper? So the project is never going higher than jest 24?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at some point we'll have a breaking change that drops older eslints/nodes, but i'm more likely to bail on jest entirely and use something less frictiony regardless.

can you map node:fs/promises to fs/promises, instead? the node: prefix is pretty useless.

Copy link
Contributor Author

@michaelfaith michaelfaith Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a few iterations, I got it working. I ended up having to map several built in node modules, as well as a couple of esm entry points of eslint packages, I also had to add a polyfill for structuredClone, which eslint uses as part of RuleTester and was added in node 17.

This comment was marked as off-topic.

Copy link
Contributor Author

@michaelfaith michaelfaith Aug 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything's green now, if you want to take another look when you have the time. It may be worth considering dynamically installing a newer jest for v9 and removing all of those workarounds (in the same way each eslint version is being installed), but I'll leave that to you.

@michaelfaith michaelfaith force-pushed the feat/eslint-v9-support branch 8 times, most recently from 3db1f8c to 4f21b85 Compare August 31, 2024 12:46
Copy link

socket-security bot commented Aug 31, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@eslint/[email protected] None 0 14.2 kB eslintbot
npm/[email protected] None 0 1.24 MB zloirock
npm/[email protected] environment Transitive: eval, filesystem, shell, unsafe +88 9.91 MB eslintbot
npm/[email protected] None 0 174 kB sindresorhus

View full report↗︎

@michaelfaith michaelfaith force-pushed the feat/eslint-v9-support branch 2 times, most recently from f99300c to 1231f61 Compare August 31, 2024 19:20
Copy link

codecov bot commented Aug 31, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.73%. Comparing base (a08fbcc) to head (1231f61).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
__tests__/__util__/parserOptionsMapper.js 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1009      +/-   ##
==========================================
- Coverage   99.03%   98.73%   -0.30%     
==========================================
  Files         107      107              
  Lines        1660     1666       +6     
  Branches      588      591       +3     
==========================================
+ Hits         1644     1645       +1     
- Misses         16       21       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

__tests__/__util__/nodeReexports/assert.js Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
@michaelfaith michaelfaith force-pushed the feat/eslint-v9-support branch 3 times, most recently from f8e70cd to 903bca2 Compare September 1, 2024 17:13
@ljharb ljharb changed the title build: update to eslint v9 [New] add eslint 9 support Sep 1, 2024
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good!

@ljharb ljharb mentioned this pull request Sep 1, 2024
14 tasks
@ljharb ljharb merged commit deac4fd into jsx-eslint:main Sep 1, 2024
105 checks passed
@michaelfaith michaelfaith deleted the feat/eslint-v9-support branch September 1, 2024 22:42
@ljharb
Copy link
Member

ljharb commented Sep 4, 2024

it's now released; v6.10.0.

@ruiaraujo012
Copy link

ruiaraujo012 commented Sep 12, 2024

@ljharb I think something is missing, there's no v6.10.0 release, there is a tag but not a release.

@ljharb
Copy link
Member

ljharb commented Sep 12, 2024

oh thanks, i always forget github releases (which don't matter; only npm matters)

@ruiaraujo012
Copy link

Oh, you're right, I didn't check npm 🙈 sorry.

devjiwonchoi added a commit to vercel/next.js that referenced this pull request Oct 14, 2024
> [!WARNING]
> **Breaking Change:** Now uses `[email protected]` which
has a new violation disallowing Component names starting with anything
but an uppercase letter. See
https://github.com/facebook/react/releases/tag/eslint-plugin-react-hooks%405.0.0
for more details.

Adds support of ESLint v9 to `eslint-plugin-next`, `eslint-config-next`
and `next lint`.

Does not require using the new flat config format. `next lint` will
automatically ensure the old config format can be used.

### Why?

As `eslint-plugin-react-hooks` has been updated for ESLint v9 support
and is a helpful package for Next v15 upgrade, unblock the restrictions
to upgrade to ESLint v9.

Also, ESLint v8 is [End of
Life](https://eslint.org/blog/2024/09/eslint-v8-eol-version-support/#:~:text=ESLint%20v8.-,x%20end%20of%20life%20is%20October%205%2C%202024,x%20on%20October%205%2C%202024.)
support since Oct 5th, so is good to unblock v9 now.

Plugins bumped:
- [x]
[@rushstack/eslint-patch](microsoft/rushstack#4719)
([v1.10.3](https://www.npmjs.com/package/@rushstack/eslint-patch/v/1.10.3?activeTab=versions)
no release post, confirmed on NPM)
- [x]
[@typescript-eslint/eslint-plugin](typescript-eslint/typescript-eslint#9002)
([v8.0.0](typescript-eslint/typescript-eslint#9002 (comment)))
- [x]
[eslint-plugin-import](import-js/eslint-plugin-import#2996)
([v2.31.0](https://github.com/import-js/eslint-plugin-import/releases/tag/v2.31.0))
- [x]
[eslint-plugin-jsx-a11y](jsx-eslint/eslint-plugin-jsx-a11y#1009)
([v6.10.0](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/releases/tag/v6.10.0))
- [x]
[eslint-plugin-react](jsx-eslint/eslint-plugin-react#3759)
([v7.35.0](https://github.com/jsx-eslint/eslint-plugin-react/releases/tag/v7.35.0))
- [x]
[eslint-plugin-react-hooks](facebook/react#28773)
([v5.0.0](https://github.com/facebook/react/releases/tag/eslint-plugin-react-hooks%405.0.0))

We have to switch to ESLint v9 in our repo due to a pnpm bug where it
automatically uses ESLint v9 even though we only installed it via
`eslint-v9: npm:[email protected]`. This is a pnpm bug that wouldn't happen
with Yarn v1, v4 nor NPM.

Closes #64409
Closes #64114
Closes #64453

Closes NEXT-3293

---------

Co-authored-by: Sebastian "Sebbie" Silbermann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for ESLint 9
5 participants