You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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! 💜
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 context.getSource which don't exist any more (eslint/eslint#17520), so there'll need to be some upgrade work.
Reacted by Benjamin Staneck, Rocky Wu, Benoît Jeaurond, Emmanuel Chucks 🇬🇭, Salman Mehmood, Michał Grzegorzewski, Alex Gorbatchev, Hao Du, Francisco Blanco, Bryn Dyment and 6 more
Eslint officially released v9.0.0 today. However, the eslint-plugin-react-hooks plugin still restricts eslint to v8 in the peerDependencies list, so nobody who uses the plugin can download v9 without breaking dependency resolution.
Hope you'll add support for v9 soon!
Reacted by Dieter Oberkofler, Denis Evgrafov, oschwede, Jayden Seric, Luke Deen Taylor, dominictobias-bullish, Vasilii A, Adrian Ziemkowski, Eivind Szalay, Alexander Mukhin and 36 more
Reacted by Peter Briggs, Ëüclïdës DRY, Marko Kosir, Simon Schick and Eleonora
Reacted by Royston Shufflebotham, Justin McBride, Aelita, Marc Agbanchenou, Pierre Bertet, RedBeard, Lucas Teles , Csibike661, Son Nguyen, matijs and 31 more
Reacted by Jayden Seric, Son Nguyen, Sukka, Lucas Teles , Lucas Genzelis, Median, Avi Nerenberg and Ëüclïdës DRY
I just wanted to ask, is #28773 part of the 4.6.0 release that was published on npm 3 days ago or it's planned for a future release?
I am currently in the process of migrating to flat config, and the plugin is giving me an error.
Oops! Something went wrong! :(
ESLint: 9.1.0
TypeError: context.getSource is not a function
Occurred while linting /home/user/projects/eslint-flat-config-migration/src/index.tsx:8
Rule: "react-hooks/exhaustive-deps"
at visitFunctionWithDependencies (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint-plugin-react-hooks@4.6.0_eslint@9.1.0/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:1704:42)
at visitCallExpression (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint-plugin-react-hooks@4.6.0_eslint@9.1.0/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:1759:11)
at ruleErrorHandler (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/linter.js:1115:48)
at /home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
at NodeEventGenerator.applySelectors (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
at NodeEventGenerator.enterNode (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
at runRules (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/linter.js:1154:40)
If needed, here is a my repository where the issue can be reproduced by running npx eslint src/index.tsx
I just wanted to ask, is #28773 part of the 4.6.0 release that was published on npm 3 days ago or it's planned for a future release?
I am currently in the process of migrating to flat config, and the plugin is giving me an error.
Oops! Something went wrong! :(
ESLint: 9.1.0
TypeError: context.getSource is not a function
Occurred while linting /home/user/projects/eslint-flat-config-migration/src/index.tsx:8
Rule: "react-hooks/exhaustive-deps"
at visitFunctionWithDependencies (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint-plugin-react-hooks@4.6.0_eslint@9.1.0/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:1704:42)
at visitCallExpression (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint-plugin-react-hooks@4.6.0_eslint@9.1.0/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:1759:11)
at ruleErrorHandler (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/linter.js:1115:48)
at /home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
at NodeEventGenerator.applySelectors (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
at NodeEventGenerator.enterNode (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
at runRules (/home/user/projects/eslint-flat-config-migration/node_modules/.pnpm/eslint@9.1.0/node_modules/eslint/lib/linter/linter.js:1154:40)
If needed, here is a my repository where the issue can be reproduced by running npx eslint src/index.tsx
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.
Reacted by Jordan Harband, Milosz Frejnik, Kwan Jun Wen, REL1CX, Azeezat Raheem, Tomas Vancoillie and Son Sumin
Reacted by YuriyStepanovSber, Björn Heiß and Ben Hauch
Reacted by virtuallyunknown, Humberto Barrientos González and Simon Schick
I'm getting this error using v4.6.2 with ESLint 9.1.1 and React 18.2.0:
ESLint: 9.1.1
TypeError: context.getScope is not a function
Occurred while linting /Users/me/Documents/frontend/src/components/CTable/CTable.tsx:1013
Rule: "react-hooks/exhaustive-deps"
at visitCallExpression (/Users/me/Documents/frontend/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:1780:34)
at ruleErrorHandler (/Users/me/Documents/frontend/node_modules/eslint/lib/linter/linter.js:1115:48)
at /Users/me/Documents/frontend/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/Users/me/Documents/frontend/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/Users/me/Documents/frontend/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
at NodeEventGenerator.applySelectors (/Users/me/Documents/frontend/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
at NodeEventGenerator.enterNode (/Users/me/Documents/frontend/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
at runRules (/Users/me/Documents/frontend/node_modules/eslint/lib/linter/linter.js:1154:40)
at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (/Users/me/Documents/frontend/node_modules/eslint/lib/linter/linter.js:1880:31)
FWIW, for anyone already using FlatCompat for other plugins that don't yet have a flat config (e.g. the workaround some people seem to be suggesting for prettier), it also seems to work for react-hooks:
I'm happy to raise a PR for both if the team managing this repo want a hand?
I already have a PR open for hooks, and would gladly do the other, but there are unresolved decisions that the team needs to provide input on the hooks PR, which would apply to the compiler change too. So, no need to create yet another PR, until that's resolved.
Reacted by Brody McKee, Mykhaylo Ryechkin and Adonis Kakoulidis
I’m trying to integrate eslint-plugin-react-hooks into my ESLint configuration using tseslint.config([]) but haven’t had any success so far. I’ve tried all the suggested solutions mentioned above, but still can’t get it to work.
I’m currently using ESLint v9. Could you provide guidance or an example to help me set up this plugin properly with tseslint?
Thank you!
FWIW, for anyone already using FlatCompat for other plugins that don't yet have a flat config (e.g. the workaround some people seem to be suggesting for prettier), it also seems to work for react-hooks:
import { FlatCompat } from '@eslint/eslintrc';
import pluginJs from '@eslint/js';
import pluginReact from 'eslint-plugin-react';
import tseslint from 'typescript-eslint';
Activity
eps1lon commentedon Feb 13, 2024
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.
JoshuaKGoldberg commentedon Feb 13, 2024
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
configs,meta, andrules. https://eslint.org/docs/latest/extend/plugin-migration-flat-config#adding-plugin-meta-information shows a very minimal object.👍
Yeah it feels like it'd probably be cleanest to upgrade to ESLint 8 first, just in case any breaking changes impact the plugin.
RoystonS commentedon Apr 5, 2024
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
context.getSourcewhich don't exist any more (eslint/eslint#17520), so there'll need to be some upgrade work.e.g. https://github.com/facebook/react/blob/2acfb7b60922bdc8376dd144ca7bc532df78254b/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js#L529
JstnMcBrd commentedon Apr 6, 2024
Eslint officially released v9.0.0 today. However, the
eslint-plugin-react-hooksplugin still restricts eslint to v8 in thepeerDependencieslist, so nobody who uses the plugin can download v9 without breaking dependency resolution.Hope you'll add support for v9 soon!
RoystonS commentedon Apr 6, 2024
Should we raise a separate issue for v9 API support?
yhx-12243 commentedon Apr 6, 2024
Currently under discussion in jsx-eslint/eslint-plugin-react#3699.
eps1lon commentedon Apr 6, 2024
ESLint v9 support will be done in #28773
josiahgallen commentedon Apr 18, 2024
@eps1lon how far away from merge/release is this update to support eslint v9?
virtuallyunknown commentedon Apr 22, 2024
Hey @eps1lon, greetings!
I just wanted to ask, is #28773 part of the
4.6.0release that was published on npm 3 days ago or it's planned for a future release?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
npx eslint src/index.tsxhttps://github.com/virtuallyunknown/eslint-flat-config-migration
Relevant files:
https://github.com/virtuallyunknown/eslint-flat-config-migration/blob/master/eslint.config.js
https://github.com/virtuallyunknown/eslint-flat-config-migration/blob/master/configs/react.js
Cheers!
JacobZyy commentedon Apr 22, 2024
got the same error and I turn off the rules about react-hooks...
smaven commentedon Apr 25, 2024
The issue seems to have been resolved in the canary release.
If you are using
eslint-plugin-react, some rules such asreact/display-nameor other recommended ones don't work: jsx-eslint/eslint-plugin-react#3699.eps1lon commentedon Apr 25, 2024
eslint-plugin-reactis not authored by the React team. Please file an issue for this plugin in https://github.com/jsx-eslint/eslint-plugin-react instead.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.
virtuallyunknown commentedon Apr 25, 2024
I am not sure if this feedback is of any value, but it looks like the types from
eslintandtypescript-eslintare signaling about potential issues.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!
movestill commentedon May 8, 2024
I'm getting this error using v4.6.2 with ESLint 9.1.1 and React 18.2.0:
92 remaining items
alex-r-bigelow commentedon Dec 20, 2024
FWIW, for anyone already using
FlatCompatfor other plugins that don't yet have a flat config (e.g. the workaround some people seem to be suggesting forprettier), it also seems to work forreact-hooks:mrmckeb commentedon Dec 24, 2024
Just a quick note that the new
eslint-plugin-react-compilerpackage also doesn't support ESLint 9 / FlatConfig.virtuallyunknown commentedon Dec 24, 2024
If you are certain about this, then it's definitely worth opening a separate issue about it.
mrmckeb commentedon Dec 28, 2024
My thought was that it would make sense to address both at once, as they're both published from within this repository.
https://github.com/facebook/react/tree/main/compiler/packages/eslint-plugin-react-compiler
I'm happy to raise a PR for both if the team managing this repo want a hand?
michaelfaith commentedon Dec 28, 2024
I already have a PR open for hooks, and would gladly do the other, but there are unresolved decisions that the team needs to provide input on the hooks PR, which would apply to the compiler change too. So, no need to create yet another PR, until that's resolved.
Flaysh commentedon Jan 9, 2025
Hi, is there any update on this issue?
I’m trying to integrate
eslint-plugin-react-hooksinto my ESLint configuration usingtseslint.config([])but haven’t had any success so far. I’ve tried all the suggested solutions mentioned above, but still can’t get it to work.I’m currently using ESLint v9. Could you provide guidance or an example to help me set up this plugin properly with tseslint?
Thank you!
laug commentedon Jan 9, 2025
@Flaysh here is how I do it:
At the top of eslint.config.js:
import reactHooks from 'eslint-plugin-react-hooks'Under
extends: nothing, as this requires the flat configUnder
plugins:Under
rules:kachkaev commentedon Jan 9, 2025
@Flaysh this worked for me:
eslint.config.jsdeclarations/eslint-plugin-react-hooks.d.tsbrasillero commentedon Feb 5, 2025
This worked for me, but I got the solution from eslint docs here.
My code:
Neoxs commentedon Mar 23, 2025
🚀 Just completed an ESLint v9 migration, and wow… what a ride! 😵💫
I ran into breaking changes, weird errors, and unexpected surprises—but I documented everything so you don’t have to suffer the same way.
If you’re upgrading (or still hesitating), this guide might save you some headaches:
📖 neoxs.me/blog/migration-to-eslint-v9
Upgrade to eslint-plugin-react-hooks RC, remove fixupPluginRules
Upgrade to eslint-plugin-react-hooks RC, remove fixupPluginRules
Ignore eslint v10 in dependabot until react-hooks plugin supports it
Ignore eslint v10 in dependabot until react-hooks plugin supports it