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

upgrade the eslint lib to v9 #570

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

upgrade the eslint lib to v9 #570

wants to merge 5 commits into from

Conversation

ejahnGithub
Copy link

@ejahnGithub ejahnGithub commented Nov 6, 2024

ref #539

upgrade the eslint lib to v9 by following this doc https://eslint.org/docs/latest/use/migrate-to-9.0.0

also updated context.getScope() by this https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/#context.getscope() to resolve error

we have both .eslintrc.js to support eslint v8 and eslint.config.mjs to support eslint v9

@ejahnGithub ejahnGithub requested a review from a team as a code owner November 6, 2024 00:02
@ejahnGithub ejahnGithub changed the title update the eslint lib to v9 upgrade the eslint lib to v9 Nov 6, 2024
@gracepark
Copy link
Contributor

I want to preface this by saying I'm still new eslint plugin development (and eslint in general), so there are still some things I'm not 100% sure of. I've come to conclusion that there's 2 separate things here (definitely intertwined with each other still).:

  • Support flat config (eslint.config.js)
  • Upgrade to eslint v9

This PR upgrades us to eslint v9; however, I think more than upgrading to eslint v9, we want to support flat config. Flat config I believe is available from 8.57.0 and on. So, we don't necessarily need to upgrade to v9 to support flat config. But if we do, even better.

At the very least, we want to be backwards compatible, so we don't break things for folks who haven't updated to flat config (regardless of version). If we're fine with breaking changes for folks not on flat config, this is a different story, but even so I think we'd still have work to do since our exported configs are not flat config.

I think in order for us to be backwards compatible, we'll need to export both legacy and flat configs as mentioned here. In addition, I think we should update our plugin structure.

I found some examples of other plugins that have both configs:

I think that may be the reason for some of the issues I ran into. Bc I took clipboard-copy-element which is on v8.42.0 (no flat config). I npm link-ed with this PR and I ran into an error, and even if I do install the plugin as mentioned, I have to end up dl-ing every plugin that was referenced in the config file (which I think makes sense):

Oops! Something went wrong! :(

ESLint: 8.42.0

ESLint couldn't find the plugin "eslint-plugin-escompat".

(The package "eslint-plugin-escompat" was not found when loaded as a Node module from the directory "/Users/gracepark/github/clipboard-copy-element".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm install eslint-plugin-escompat@latest --save-dev

The plugin "eslint-plugin-escompat" was referenced from the config file in ".eslintrc.json » plugin:github/browser".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

And, when I ran it with the current eslint-plugin-github package, I did not run into these errors.

This is the section that I think affects us: https://eslint.org/docs/latest/extend/plugin-migration-flat-config#migrating-configs-for-flat-config since we do export configs, and those are not flat configs. We'll want both legacy and flat configs.

Let me know if I'm misunderstanding something here.

@ejahnGithub
Copy link
Author

I’m using FlatCompat to handle the transition to Flat Config. This allows to integrate legacy .eslintrc configurations and plugins without a complete refactor, maintaining compatibility while gradually updating to the Flat Config format.

ref: https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config

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.

2 participants