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

Add support for ESLint 9 to @emotion/eslint-plugin #3248

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

soren121
Copy link

@soren121 soren121 commented Aug 27, 2024

What:

Adds support for ESLint 9 to @emotion/eslint-plugin.

Closes #3211
Closes #3251

Why:

ESLint 9 contains breaking changes for plugins. We need to apply those changes, so that end-users may smoothly upgrade their projects to ESLint 9.

How:

I followed the upgrade guides for ESLint and TypeScript ESLint.

The plugin exports a plugin object for ESLint 9; the existing rules export is also maintained. The plugin doesn't export configurations, so no changes were needed for flat config support.

Some context methods were deprecated/removed in ESLint 9. The plugin uses the new methods when available, and falls back to the old methods when an older version of ESLint is in use.

I had to migrate the base project's ESLint setup to v9, because Yarn was unhappy with two different ESLint versions in the monorepo.

The Node version in CI was bumped from 16.x to 20.x, to meet ESLint's minimum Node version requirement (it's 18.18.0+, but might as well use 20.x.) The Parcel bundler used for the benchmark script needed a minor version bump to fix Node 18+ compatibility.

Checklist:

  • Documentation N/A
  • Tests
  • Code complete
  • Changeset

Copy link

changeset-bot bot commented Aug 27, 2024

🦋 Changeset detected

Latest commit: 940ed5d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@emotion/eslint-plugin Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines 234 to -247
/** @jsx jsx */
import * as emotion from '@emotion/react'
let ele = <div css={\`color:hotpink;\`} />
let ele = <div css={{}} />
`.trim(),
errors: [
{
messageId: 'cssPropWithPragma'
}
],
output: `
/** @jsx jsx */
/** @jsx emotion.jsx */
import * as emotion from '@emotion/react'
let ele = <div css={\`color:hotpink;\`} />
Copy link
Author

@soren121 soren121 Aug 27, 2024

Choose a reason for hiding this comment

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

With TypeScript-ESLint 8's RuleTester, this causes an error due to overlapping fixes for cssPropWithPragma and templateLiterals. The new RuleTester tries to apply fixes for all errors, not just the first encountered.

To fix this, I split it into two tests, one for each fix.

Copy link

codesandbox-ci bot commented Aug 27, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@soren121 soren121 changed the title Support ESLint 9 for eslint-plugin Support ESLint 9 for @emotion/eslint-plugin Aug 27, 2024
@soren121 soren121 changed the title Support ESLint 9 for @emotion/eslint-plugin Add support for ESLint 9 to @emotion/eslint-plugin Aug 28, 2024
Copy link

codecov bot commented Sep 12, 2024

Codecov Report

Attention: Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 94.81%. Comparing base (ad630e3) to head (940ed5d).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
packages/eslint-plugin/src/rules/jsx-import.ts 88.23% 2 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
...kages/eslint-plugin/src/rules/syntax-preference.ts 91.96% <100.00%> (+0.14%) ⬆️
packages/eslint-plugin/src/utils.ts 100.00% <100.00%> (ø)
packages/eslint-plugin/test/test-utils.ts 100.00% <100.00%> (ø)
packages/eslint-plugin/src/rules/jsx-import.ts 97.29% <88.23%> (-0.73%) ⬇️
---- 🚨 Try these New Features:

@shunxing
Copy link

shunxing commented Oct 25, 2024

Hi @soren121, do you have any update on this PR ?

@soren121
Copy link
Author

@shunxing Still waiting on the maintainers to take a look.

@yunseyeong
Copy link

💯

runs:
using: 'composite'
steps:
- name: Setup Node.js 16.x
uses: actions/setup-node@v3
- name: Setup Node.js 20.x

Choose a reason for hiding this comment

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

yesterday, Node LTS Version is updated to 22, is it ok?
https://nodejs.org/en/about/previous-releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@typescript-eslint/utils is outdate @emotion/eslint-plugin should support eslint 9
3 participants