Skip to content

Commit 34eedd6

Browse files
authored
chore: update to eslint-plugin-react-hooks v6 (#9071)
* chore: update to eslint-plugin-react-hooks v6 and remove the separate compiler linter plugin, as those rules are now integrated * chore: disable compiler-linter in tests * chore: bypass lint violations * chore: Disable '@eslint-react/no-context-provider' to be react 18 compatible
1 parent 9e30aaf commit 34eedd6

File tree

16 files changed

+127
-155
lines changed

16 files changed

+127
-155
lines changed

.github/renovate.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"@types/node",
2121
"@types/react",
2222
"@types/react-dom",
23-
"eslint-plugin-react-compiler",
2423
"node",
2524
"react",
2625
"react-dom",

examples/react/algolia/eslint.config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { tanstackConfig } from '@tanstack/config/eslint'
22
import pluginQuery from '@tanstack/eslint-plugin-query'
33
import pluginReact from '@eslint-react/eslint-plugin'
4-
import pluginReactHooks from 'eslint-plugin-react-hooks'
4+
import * as reactHooks from 'eslint-plugin-react-hooks'
55

66
export default [
77
...tanstackConfig,
88
...pluginQuery.configs['flat/recommended'],
99
pluginReact.configs.recommended,
10+
reactHooks.configs.recommended,
1011
{
11-
plugins: {
12-
'react-hooks': pluginReactHooks,
13-
},
1412
rules: {
1513
'react-hooks/exhaustive-deps': 'error',
1614
'react-hooks/rules-of-hooks': 'error',

examples/react/basic-graphql-request/eslint.config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { tanstackConfig } from '@tanstack/config/eslint'
22
import pluginQuery from '@tanstack/eslint-plugin-query'
33
import pluginReact from '@eslint-react/eslint-plugin'
4-
import pluginReactHooks from 'eslint-plugin-react-hooks'
4+
import * as reactHooks from 'eslint-plugin-react-hooks'
55

66
export default [
77
...tanstackConfig,
88
...pluginQuery.configs['flat/recommended'],
99
pluginReact.configs.recommended,
10+
reactHooks.configs.recommended,
1011
{
11-
plugins: {
12-
'react-hooks': pluginReactHooks,
13-
},
1412
rules: {
1513
'react-hooks/exhaustive-deps': 'error',
1614
'react-hooks/rules-of-hooks': 'error',

examples/react/basic/eslint.config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { tanstackConfig } from '@tanstack/config/eslint'
22
import pluginQuery from '@tanstack/eslint-plugin-query'
33
import pluginReact from '@eslint-react/eslint-plugin'
4-
import pluginReactHooks from 'eslint-plugin-react-hooks'
4+
import * as reactHooks from 'eslint-plugin-react-hooks'
55

66
export default [
77
...tanstackConfig,
88
...pluginQuery.configs['flat/recommended'],
99
pluginReact.configs.recommended,
10+
reactHooks.configs.recommended,
1011
{
11-
plugins: {
12-
'react-hooks': pluginReactHooks,
13-
},
1412
rules: {
1513
'react-hooks/exhaustive-deps': 'error',
1614
'react-hooks/rules-of-hooks': 'error',

examples/react/shadow-dom/eslint.config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { tanstackConfig } from '@tanstack/config/eslint'
22
import pluginQuery from '@tanstack/eslint-plugin-query'
33
import pluginReact from '@eslint-react/eslint-plugin'
4-
import pluginReactHooks from 'eslint-plugin-react-hooks'
4+
import * as reactHooks from 'eslint-plugin-react-hooks'
55

66
export default [
77
...tanstackConfig,
88
...pluginQuery.configs['flat/recommended'],
99
pluginReact.configs.recommended,
10+
reactHooks.configs.recommended,
1011
{
11-
plugins: {
12-
'react-hooks': pluginReactHooks,
13-
},
1412
rules: {
1513
'react-hooks/exhaustive-deps': 'error',
1614
'react-hooks/rules-of-hooks': 'error',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"cpy-cli": "^5.0.0",
5252
"esbuild-plugin-file-path-extensions": "^2.1.4",
5353
"eslint": "^9.15.0",
54-
"eslint-plugin-react-hooks": "^5.2.0",
54+
"eslint-plugin-react-hooks": "^6.0.0-rc.1",
5555
"fast-glob": "^3.3.3",
5656
"jsdom": "^25.0.1",
5757
"knip": "^5.50.2",
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
// @ts-check
22

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

77
export default [
88
...rootConfig,
9+
reactHooks.configs.recommended,
910
{
1011
files: ['**/*.{ts,tsx}'],
1112
...pluginReact.configs.recommended,
13+
rules: {
14+
'@eslint-react/no-context-provider': 'off', // We need to be React 18 compatible
15+
},
1216
},
1317
{
14-
plugins: {
15-
'react-hooks': pluginReactHooks,
16-
},
1718
rules: {
1819
'react-hooks/exhaustive-deps': 'error',
1920
'react-hooks/rules-of-hooks': 'error',
21+
'react-hooks/react-compiler': 'error',
2022
},
2123
},
2224
]
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
// @ts-check
22

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

77
export default [
88
...rootConfig,
9+
reactHooks.configs.recommended,
910
{
1011
files: ['**/*.{ts,tsx}'],
1112
...pluginReact.configs.recommended,
13+
rules: {
14+
'@eslint-react/no-context-provider': 'off', // We need to be React 18 compatible
15+
},
1216
},
1317
{
14-
plugins: {
15-
'react-hooks': pluginReactHooks,
16-
},
1718
rules: {
1819
'@eslint-react/no-unstable-context-value': 'off',
1920
'react-hooks/exhaustive-deps': 'error',
2021
'react-hooks/rules-of-hooks': 'error',
22+
'react-hooks/react-compiler': 'error',
2123
},
2224
},
2325
]

packages/react-query-next-experimental/src/HydrationStreamProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export function createHydrationStreamProvider<TShape>() {
130130
.join(',')
131131

132132
// Flush stream
133+
// eslint-disable-next-line react-hooks/react-compiler
133134
stream.length = 0
134135

135136
const html: Array<string> = [
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
// @ts-check
22

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

77
export default [
88
...rootConfig,
9+
reactHooks.configs.recommended,
910
{
1011
files: ['**/*.{ts,tsx}'],
1112
...pluginReact.configs.recommended,
13+
rules: {
14+
'@eslint-react/no-context-provider': 'off', // We need to be React 18 compatible
15+
},
1216
},
1317
{
14-
plugins: {
15-
'react-hooks': pluginReactHooks,
16-
},
1718
rules: {
1819
'react-hooks/exhaustive-deps': 'error',
1920
'react-hooks/rules-of-hooks': 'error',
21+
'react-hooks/react-compiler': 'error',
2022
},
2123
},
2224
]

packages/react-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ describe('PersistQueryClientProvider', () => {
371371
const state = useQuery({
372372
queryKey: key,
373373
queryFn: async () => {
374+
// eslint-disable-next-line react-hooks/react-compiler
374375
fetched = true
375376
await sleep(10)
376377
return 'fetched'

packages/react-query/eslint.config.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
// @ts-check
22

33
import pluginReact from '@eslint-react/eslint-plugin'
4-
// @ts-expect-error
5-
import pluginReactCompiler from 'eslint-plugin-react-compiler'
6-
import pluginReactHooks from 'eslint-plugin-react-hooks'
4+
import * as reactHooks from 'eslint-plugin-react-hooks'
75
import rootConfig from './root.eslint.config.js'
86

97
export default [
108
...rootConfig,
9+
reactHooks.configs.recommended,
1110
{
1211
files: ['**/*.{ts,tsx}'],
1312
...pluginReact.configs.recommended,
1413
rules: {
15-
'@eslint-react/no-context-provider': 'off',
14+
'@eslint-react/no-context-provider': 'off', // We need to be React 18 compatible
1615
},
1716
},
1817
{
19-
plugins: {
20-
'react-hooks': pluginReactHooks,
21-
'react-compiler': pluginReactCompiler,
22-
},
2318
rules: {
2419
'@eslint-react/dom/no-missing-button-type': 'off',
25-
'react-compiler/react-compiler': 'error',
20+
'react-hooks/react-compiler': 'error',
2621
'react-hooks/exhaustive-deps': 'error',
2722
'react-hooks/rules-of-hooks': 'error',
2823
},
@@ -31,7 +26,7 @@ export default [
3126
files: ['**/__tests__/**'],
3227
rules: {
3328
'@typescript-eslint/no-unnecessary-condition': 'off',
34-
'react-compiler/react-compiler': 'off',
29+
'react-hooks/react-compiler': 'off',
3530
},
3631
},
3732
]

packages/react-query/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
"@types/react": "^19.0.1",
7676
"@types/react-dom": "^19.0.2",
7777
"@vitejs/plugin-react": "^4.3.4",
78-
"eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
7978
"npm-run-all2": "^5.0.0",
8079
"react": "^19.0.0",
8180
"react-dom": "^19.0.0",

packages/react-query/src/HydrationBoundary.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable react-compiler/react-compiler */
2-
31
'use client'
42
import * as React from 'react'
53

@@ -101,6 +99,7 @@ export const HydrationBoundary = ({
10199
hydrate(client, { queries: newQueries }, optionsRef.current)
102100
}
103101
if (existingQueries.length > 0) {
102+
// eslint-disable-next-line react-hooks/react-compiler
104103
setHydrationQueue((prev) =>
105104
prev ? [...prev, ...existingQueries] : existingQueries,
106105
)

packages/react-query/src/useMutationState.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable react-compiler/react-compiler */
2-
31
'use client'
42
import * as React from 'react'
53

0 commit comments

Comments
 (0)