Skip to content

chore: update to eslint-plugin-react-hooks v6 #9071

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
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@types/node",
"@types/react",
"@types/react-dom",
"eslint-plugin-react-compiler",
"node",
"react",
"react-dom",
Expand Down
6 changes: 2 additions & 4 deletions examples/react/algolia/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { tanstackConfig } from '@tanstack/config/eslint'
import pluginQuery from '@tanstack/eslint-plugin-query'
import pluginReact from '@eslint-react/eslint-plugin'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import * as reactHooks from 'eslint-plugin-react-hooks'

export default [
...tanstackConfig,
...pluginQuery.configs['flat/recommended'],
pluginReact.configs.recommended,
reactHooks.configs.recommended,
{
plugins: {
'react-hooks': pluginReactHooks,
},
rules: {
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
Expand Down
6 changes: 2 additions & 4 deletions examples/react/basic-graphql-request/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { tanstackConfig } from '@tanstack/config/eslint'
import pluginQuery from '@tanstack/eslint-plugin-query'
import pluginReact from '@eslint-react/eslint-plugin'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import * as reactHooks from 'eslint-plugin-react-hooks'

export default [
...tanstackConfig,
...pluginQuery.configs['flat/recommended'],
pluginReact.configs.recommended,
reactHooks.configs.recommended,
{
plugins: {
'react-hooks': pluginReactHooks,
},
rules: {
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
Expand Down
6 changes: 2 additions & 4 deletions examples/react/basic/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { tanstackConfig } from '@tanstack/config/eslint'
import pluginQuery from '@tanstack/eslint-plugin-query'
import pluginReact from '@eslint-react/eslint-plugin'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import * as reactHooks from 'eslint-plugin-react-hooks'

export default [
...tanstackConfig,
...pluginQuery.configs['flat/recommended'],
pluginReact.configs.recommended,
reactHooks.configs.recommended,
{
plugins: {
'react-hooks': pluginReactHooks,
},
rules: {
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
Expand Down
6 changes: 2 additions & 4 deletions examples/react/shadow-dom/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { tanstackConfig } from '@tanstack/config/eslint'
import pluginQuery from '@tanstack/eslint-plugin-query'
import pluginReact from '@eslint-react/eslint-plugin'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import * as reactHooks from 'eslint-plugin-react-hooks'

export default [
...tanstackConfig,
...pluginQuery.configs['flat/recommended'],
pluginReact.configs.recommended,
reactHooks.configs.recommended,
{
plugins: {
'react-hooks': pluginReactHooks,
},
rules: {
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"cpy-cli": "^5.0.0",
"esbuild-plugin-file-path-extensions": "^2.1.4",
"eslint": "^9.15.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-hooks": "^6.0.0-rc.1",
"fast-glob": "^3.3.3",
"jsdom": "^25.0.1",
"knip": "^5.50.2",
Expand Down
10 changes: 6 additions & 4 deletions packages/react-query-devtools/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
// @ts-check

import pluginReact from '@eslint-react/eslint-plugin'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import * as reactHooks from 'eslint-plugin-react-hooks'
import rootConfig from './root.eslint.config.js'

export default [
...rootConfig,
reactHooks.configs.recommended,
{
files: ['**/*.{ts,tsx}'],
...pluginReact.configs.recommended,
rules: {
'@eslint-react/no-context-provider': 'off', // We need to be React 18 compatible
},
},
{
plugins: {
'react-hooks': pluginReactHooks,
},
rules: {
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/react-compiler': 'error',
},
},
]
10 changes: 6 additions & 4 deletions packages/react-query-next-experimental/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
// @ts-check

import pluginReact from '@eslint-react/eslint-plugin'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import * as reactHooks from 'eslint-plugin-react-hooks'
import rootConfig from './root.eslint.config.js'

export default [
...rootConfig,
reactHooks.configs.recommended,
{
files: ['**/*.{ts,tsx}'],
...pluginReact.configs.recommended,
rules: {
'@eslint-react/no-context-provider': 'off', // We need to be React 18 compatible
},
},
{
plugins: {
'react-hooks': pluginReactHooks,
},
rules: {
'@eslint-react/no-unstable-context-value': 'off',
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/react-compiler': 'error',
},
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export function createHydrationStreamProvider<TShape>() {
.join(',')

// Flush stream
// eslint-disable-next-line react-hooks/react-compiler
stream.length = 0

const html: Array<string> = [
Expand Down
10 changes: 6 additions & 4 deletions packages/react-query-persist-client/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
// @ts-check

import pluginReact from '@eslint-react/eslint-plugin'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import * as reactHooks from 'eslint-plugin-react-hooks'
import rootConfig from './root.eslint.config.js'

export default [
...rootConfig,
reactHooks.configs.recommended,
{
files: ['**/*.{ts,tsx}'],
...pluginReact.configs.recommended,
rules: {
'@eslint-react/no-context-provider': 'off', // We need to be React 18 compatible
},
},
{
plugins: {
'react-hooks': pluginReactHooks,
},
rules: {
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/react-compiler': 'error',
},
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ describe('PersistQueryClientProvider', () => {
const state = useQuery({
queryKey: key,
queryFn: async () => {
// eslint-disable-next-line react-hooks/react-compiler
fetched = true
await sleep(10)
return 'fetched'
Expand Down
15 changes: 5 additions & 10 deletions packages/react-query/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
// @ts-check

import pluginReact from '@eslint-react/eslint-plugin'
// @ts-expect-error
import pluginReactCompiler from 'eslint-plugin-react-compiler'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import * as reactHooks from 'eslint-plugin-react-hooks'
import rootConfig from './root.eslint.config.js'

export default [
...rootConfig,
reactHooks.configs.recommended,
{
files: ['**/*.{ts,tsx}'],
...pluginReact.configs.recommended,
rules: {
'@eslint-react/no-context-provider': 'off',
'@eslint-react/no-context-provider': 'off', // We need to be React 18 compatible
},
},
{
plugins: {
'react-hooks': pluginReactHooks,
'react-compiler': pluginReactCompiler,
},
rules: {
'@eslint-react/dom/no-missing-button-type': 'off',
'react-compiler/react-compiler': 'error',
'react-hooks/react-compiler': 'error',
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
},
Expand All @@ -31,7 +26,7 @@ export default [
files: ['**/__tests__/**'],
rules: {
'@typescript-eslint/no-unnecessary-condition': 'off',
'react-compiler/react-compiler': 'off',
'react-hooks/react-compiler': 'off',
},
},
]
1 change: 0 additions & 1 deletion packages/react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.2",
"@vitejs/plugin-react": "^4.3.4",
"eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
"npm-run-all2": "^5.0.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/react-query/src/HydrationBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable react-compiler/react-compiler */

'use client'
import * as React from 'react'

Expand Down Expand Up @@ -101,6 +99,7 @@ export const HydrationBoundary = ({
hydrate(client, { queries: newQueries }, optionsRef.current)
}
if (existingQueries.length > 0) {
// eslint-disable-next-line react-hooks/react-compiler
setHydrationQueue((prev) =>
prev ? [...prev, ...existingQueries] : existingQueries,
)
Expand Down
2 changes: 0 additions & 2 deletions packages/react-query/src/useMutationState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable react-compiler/react-compiler */

'use client'
import * as React from 'react'

Expand Down
Loading