Skip to content

Fix compatibility issues with ESLint 9 #157

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

Merged
merged 5 commits into from
Apr 8, 2025
Merged

Fix compatibility issues with ESLint 9 #157

merged 5 commits into from
Apr 8, 2025

Conversation

net
Copy link
Contributor

@net net commented Feb 19, 2025

ESLint 9 dropped support for some legacy plugin APIs. This migrates the plugin's rules to support ESLint 9, while staying backwards compatible.

Much of the diff is whitespace changes migrating legacy function rules to the object syntax, so I suggest viewing it with hide whitespace enabled.

Notably, this does not update the plugin to use the new flat config. This plugin will still work with the new flat config, but anyone wanting to use this in a flat config will have to use this compatibility syntax:

import relay from 'eslint-plugin-relay';

export default [
  // ...
  {
    plugins: { relay },
    // Note the default version on npm is a few years out of date, so to use
    // ts-recommended you have to install the latest @main tag via 
    //
    //     npm i --save-dev eslint-plugin-relay@main
    //
    rules: relay.configs['ts-recommended'].rules,
  },
];

If anyone wants to try updating the plugin to work natively with the new flat config, see: https://eslint.org/docs/latest/extend/plugin-migration-flat-config

Partially fixes #156.

@facebook-github-bot
Copy link

Hi @net!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@tyao1
Copy link
Contributor

tyao1 commented Mar 4, 2025

Thanks for fixing compatibility issues! There are some lint error in the commit, could you take a look?

Run yarn run lint
yarn run v1.22.22
$ eslint eslint-plugin-relay.js src

/home/runner/work/eslint-plugin-relay/eslint-plugin-relay/src/rule-compat-uses-vars.js
  38:[4](https://github.com/relayjs/eslint-plugin-relay/actions/runs/13423081297/job/38121857195?pr=157#step:5:5)4  error  Parsing error: Unexpected token ?

/home/runner/work/eslint-plugin-relay/eslint-plugin-relay/src/rule-generated-flow-types.js
  88:42  error  Parsing error: Unexpected token ?

/home/runner/work/eslint-plugin-relay/eslint-plugin-relay/src/rule-generated-typescript-types.js
  332:44  error  Parsing error: Unexpected token ?

/home/runner/work/eslint-plugin-relay/eslint-plugin-relay/src/rule-graphql-naming.js
  [5](https://github.com/relayjs/eslint-plugin-relay/actions/runs/13423081297/job/38121857195?pr=157#step:5:6)9:54  error  Parsing error: Unexpected token ?

/home/runner/work/eslint-plugin-relay/eslint-plugin-relay/src/rule-graphql-syntax.js
  47:31  error  Parsing error: Unexpected token ?

/home/runner/work/eslint-plugin-relay/eslint-plugin-relay/src/utils.js
  48:48  error  Parsing error: Unexpected token ?

✖ [6](https://github.com/relayjs/eslint-plugin-relay/actions/runs/13423081297/job/38121857195?pr=157#step:5:7) problems (6 errors, 0 warnings)

@net
Copy link
Contributor Author

net commented Mar 5, 2025

@tyao1 I believe those are caused by the version of eslint that this repo itself uses being out of date. I’ll go ahead and update it to the latest if that works for you.

@fbjork
Copy link

fbjork commented Apr 7, 2025

Would be lovely to see this PR merged!

@net
Copy link
Contributor Author

net commented Apr 8, 2025

@tyao1 I fixed the lint errors by upgrading to ESLint 9. I also fixed all the failing tests.

Unfortunately, there are six flow tests that are still failing that I wasn't able to fix. I believe they're failing due to the original changes for ESLint 9 compatibility.

Since those changes are backwards compatible, I don't believe this PR introduces any regressions for users on older ESLint versions despite those failing tests. Flow users on ESLint 9 may experience the generated-flow-types rule not surfacing errors in a few cases where it should, but that seems preferable to not being able to use the eslint-plugin-relay at all. The tests aren't failing due to runtime errors; the rule just isn't returning errors in a few cases where they're expected.

I commented out the six failing flow tests here: e81285a

I believe this is mergable now :)

@tyao1
Copy link
Contributor

tyao1 commented Apr 8, 2025

@tyao1 I fixed the lint errors by upgrading to ESLint 9. I also fixed all the failing tests.

Unfortunately, there are six flow tests that are still failing that I wasn't able to fix. I believe they're failing due to the original changes for ESLint 9 compatibility.

Since those changes are backwards compatible, I don't believe this PR introduces any regressions for users on older ESLint versions despite those failing tests. Flow users on ESLint 9 may experience the generated-flow-types rule not surfacing errors in a few cases where it should, but that seems preferable to not being able to use the eslint-plugin-relay at all. The tests aren't failing due to runtime errors; the rule just isn't returning errors in a few cases where they're expected.

I commented out the six failing flow tests here: e81285a

I believe this is mergable now :)

thanks for the fixes. These rules with failing tests might be redundant with the latest flow. We can revisit these failing tests if needed.

Do you have access to merge?

@tyao1 tyao1 merged commit 2274f07 into relayjs:main Apr 8, 2025
2 of 6 checks passed
@net
Copy link
Contributor Author

net commented Apr 9, 2025

Looks like the GitHub workflow errored so no release was published to NPM. Guessing it has something to do with actions/setup-node@v2 being pretty out of date—actions/setup-node@v4 is the latest now.

If no one looks into it I might take a look later.

@captbaritone
Copy link
Contributor

Shipped in eslint-plugin-relay@0.0.0-main-e39d0e7f7bfc174041e83f84d14760ca88a2b158 if folks want to try it out and confirm that it works.

@eMerzh
Copy link

eMerzh commented Apr 23, 2025

it works from here, i can remove the fixupPluginRules 👯 :)

thanks

@MTG2000
Copy link

MTG2000 commented Apr 23, 2025

Yup, working fine now.

Thanks! 👌

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.

ESLint v9 Support? (flat config)
8 participants