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

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

ESLint 9 #34

wants to merge 8 commits into from

Conversation

loucyx
Copy link

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

None yet

1 participant