-
Notifications
You must be signed in to change notification settings - Fork 46.4k
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-plugin-react-hooks & "Flat Config" (ESLint 9) #28313
Comments
Thank you for reaching out. What would be involved in creating such a wrapper? Does it make more sense to file a PR and then see how it'll look? We're only on ESLint 7 though so I guess we need to upgrade that first to test. |
It's not too much work (famous last words, I know). In theory the plugin should be able to get away with exporting an object containing
👍
Yeah it feels like it'd probably be cleanest to upgrade to ESLint 8 first, just in case any breaking changes impact the plugin. |
Note that even wiring up the plugin manually doesn't enable it to work with the now-released ESLint 9: the plugin currently uses APIs like e.g.
|
Eslint officially released v9.0.0 today. However, the Hope you'll add support for v9 soon! |
Should we raise a separate issue for v9 API support? |
Currently under discussion in jsx-eslint/eslint-plugin-react#3699. |
ESLint v9 support will be done in #28773 |
@eps1lon how far away from merge/release is this update to support eslint v9? |
Hey @eps1lon, greetings! I just wanted to ask, is #28773 part of the I am currently in the process of migrating to flat config, and the plugin is giving me an error.
If needed, here is a my repository where the issue can be reproduced by running https://github.com/virtuallyunknown/eslint-flat-config-migration Relevant files: Cheers! |
got the same error and I turn off the rules about react-hooks... |
The issue seems to have been resolved in the canary release. If you are using |
ESLint v9 support is available in the Canary release channel (earliest version 5.1.0-canary-cb151849e1-20240424) and will be released as stable with the stable release of React 19. |
I am not sure if this feedback is of any value, but it looks like the types from // @ts-check
// @typescript-eslint/utils: 7.7.1
// eslint-plugin-react-hooks: 5.1.0-canary-cb151849e1-20240424
import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
/** @type {import('eslint').Linter.FlatConfig[]} */
export const configuration1 = [
{
plugins: {
'react-hooks': eslintPluginReactHooks
}
}
];
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
export const configuration2 = [
{
plugins: {
'react-hooks': eslintPluginReactHooks
}
}
]; I don't want to paste the error message because it's a giant wall of text, but feel free to try it on your own. This appears to be a type error only, and as far as I can tell the plugin is working as expected, so thanks for the updates, much appreciated! |
I just submitted a PR that adds support for flat config, if anyone wants to take a look / provide feedback |
Perfect compatibility and resolve const react = require('eslint-plugin-react')
const { FlatCompat } = require('@eslint/eslintrc')
const eslintConfigs = require('../../eslint.config')
const compat = new FlatCompat()
/**
* @type {Array<import('eslint').Linter.FlatConfig>}
*/
module.exports = [
...eslintConfigs,
react.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
...compat.config({
extends: ['plugin:react-hooks/recommended'],
rules: {
'react-hooks/exhaustive-deps': 'error'
}
})
] Then apply this patch with patch-package |
ESLint v9 has been available for some time now and it is unclear when React 19 will be released. Can the dev team please consider releasing just this the |
Pretty please 🙏 |
The amount of time ⏳ it takes to solve this problem 👾 is already beyond ridiculous 🫠 |
|
We cannot blame the React team for the fact that ESLint provides support for the previous version 8 for only 6 months since release of the new version 9 although including big breaking changes not so easy to adapt by all parties. Seems like they want to sell their ESLint LTS Support service to me tbh. I would really appreciate a new official release though for this package so let's hope we soon get some updates. |
While ESLint v9 provides some major breaking changes, they have been really good about community outreach, so most of all v8 plugins can safely and easily update to v9 at this point. |
The heck is going on here? |
Word 👍 |
Can I fix this Issue? I am a Full-Stack Software Developer and work with various Tech Stack like MERN , NEXT , REACT , FLUTTER, C#. |
There're multiple PRs already opened (including mine here: #30774). They just need to be reviewed by the team. Rather than opening another PR, I'd suggest reviewing one of the existing ones and providing feedback there. |
@caribou-code 3rd, and 6 months is not unreasonable for a very disruptive breaking change - historically it takes 4-6 months for the eslint ecosystem to entirely adapt to an eslint major, and eslint 9 will likely take much longer. |
FWIW this works for me in the interim (wanted to reshare in case anyone didnt read the full thread) |
Can you not switch to the new version of eslint with the beta release of react-hooks? @controversial kindly pointed out to me that you don't need to patch 4.6.2. The beta release (5.1.0) has support. I might be confused again as I didn't read the whole issue. However, I can tell you that my setup is now working fine without any patches on v5.1.0. |
Surprisingly, new major already supported by vast majority of ecosystem: Tracking: ESLint v9 support ✨ And those who for any reason don't want to migrate to the new major, simply should not bump the version 🚫 |
@bricss that's still missing a lot of entries, unfortunately. |
The release candidate works!
make sure to have a flat-config mine looks like that
|
👋 Coming over from eslint/eslint#18093: ESLint is migrating to a new "flat config" format that will be the default in ESLint v9.
It doesn't look like
eslint-plugin-react-hooks
has documented support yet. But, based on searching around (e.g. vercel/next.js#49337), ESLint v9 is basically supported if you wire it up manually in your config:Most community plugins provide a more convenient wrapper. For example,
eslint-plugin-jsdoc
provides ajsdoc.configs['flat/recommended']
object:Would the React team be open to a PR adding in a preset object like that? And either way, updating the docs on https://www.npmjs.com/package/eslint-plugin-react-hooks?
Note: this was also filed as reactjs/react.dev#6430.
I'm posting this issue here as a reference & cross-linking it to the table in eslint/eslint#18093. If there's anything technical blocking the extension from working with flat configs, please let us know - we'd be happy to try to help! 💜
Additional resources:
(sorry for not using the issue templates - I wasn't sure whether this would count as a bug)
The text was updated successfully, but these errors were encountered: