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

ESLint 9 #34

Closed
wants to merge 8 commits into from
Closed

ESLint 9 #34

wants to merge 8 commits into from

Conversation

loucyx
Copy link
Contributor

@loucyx loucyx commented Apr 19, 2024

Description (What)

Bare minimum changes to have ESLint 9 support. Ideally tests should be updated to test flat config and a lot of types should be added, but this is the minimum changes to support ESLint 9.

Justification (Why)

To give support to folks upgrading to ESLint 9.

How Can This Be Tested?

  • yarn to install the new dependencies.
  • yarn test to run the tests.

@@ -492,14 +495,6 @@ const invalidAndHasBlockStatement = [
code: 'async function foo(a) { console.log(3); }',
output: 'const foo = async (a) => { console.log(3); };',
},
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new RuleTester by ESLint fails if you have duplicated tests, so I had to remove a bunch of duplicated tests.

ecmaFeatures: { jsx: false },
ecmaVersion: 8,
sourceType: 'module',
// TODO: Remove this `languageOptions` once the tests are updated for flat config:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once the tests are updated to support flat config, this can go back to the original values. The new default for RuleTester expects flat config tests.

@@ -7,6 +7,9 @@ import {
} from './config';
import rule from './prefer-arrow-functions';

// TODO: Remove this once Jest starts supporting modern JavaScript
globalThis.structuredClone ??= obj => JSON.parse(JSON.stringify(obj));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like ESLint now uses structuredClone so we need to "mock" it for Jest because Jest doesn't support that yet.

@@ -193,8 +193,8 @@ export default {
};

const isPrototypeAssignment = (node) => {
return context
.getAncestors()
return sourceCode
Copy link
Contributor Author

@loucyx loucyx Apr 19, 2024

Choose a reason for hiding this comment

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

These are the "key" changes, made following the official documentation.

@loucyx loucyx mentioned this pull request Apr 19, 2024
@simonwst
Copy link

simonwst commented Aug 9, 2024

Is there any update on this? We want to migrate to v9 and would love to continue using this plugin :)

@nbouvrette
Copy link

Same issue as @simonwst - I finally managed to get eslint-plugin-import-x working (I think) and the latest errors I am getting is the one related to the issue fixed by this PR.

@JamieMason @loucyx is there anything missing from this PR before it can be merged?

@loucyx
Copy link
Contributor Author

loucyx commented Aug 10, 2024

Not that I'm aware of. This is my first PR here, so maybe I missed something 😅

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.

3 participants