-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
chore: update eslint-plugin-react-hooks #9737
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
import { tanstackConfig } from '@tanstack/config/eslint' | ||
import pluginQuery from '@tanstack/eslint-plugin-query' | ||
import pluginReact from '@eslint-react/eslint-plugin' | ||
import * as reactHooks from 'eslint-plugin-react-hooks' | ||
|
||
export default [ | ||
...tanstackConfig, | ||
...pluginQuery.configs['flat/recommended'], | ||
pluginReact.configs.recommended, | ||
reactHooks.configs.recommended, | ||
{ | ||
rules: { | ||
'react-hooks/exhaustive-deps': 'error', | ||
'react-hooks/rules-of-hooks': 'error', | ||
}, | ||
}, | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
import { tanstackConfig } from '@tanstack/config/eslint' | ||
import pluginQuery from '@tanstack/eslint-plugin-query' | ||
import pluginReact from '@eslint-react/eslint-plugin' | ||
import * as reactHooks from 'eslint-plugin-react-hooks' | ||
|
||
export default [ | ||
...tanstackConfig, | ||
...pluginQuery.configs['flat/recommended'], | ||
pluginReact.configs.recommended, | ||
reactHooks.configs.recommended, | ||
{ | ||
rules: { | ||
'react-hooks/exhaustive-deps': 'error', | ||
'react-hooks/rules-of-hooks': 'error', | ||
}, | ||
}, | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
import { tanstackConfig } from '@tanstack/config/eslint' | ||
import pluginQuery from '@tanstack/eslint-plugin-query' | ||
import pluginReact from '@eslint-react/eslint-plugin' | ||
import * as reactHooks from 'eslint-plugin-react-hooks' | ||
|
||
export default [ | ||
...tanstackConfig, | ||
...pluginQuery.configs['flat/recommended'], | ||
pluginReact.configs.recommended, | ||
reactHooks.configs.recommended, | ||
{ | ||
rules: { | ||
'react-hooks/exhaustive-deps': 'error', | ||
'react-hooks/rules-of-hooks': 'error', | ||
}, | ||
}, | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
import { tanstackConfig } from '@tanstack/config/eslint' | ||
import pluginQuery from '@tanstack/eslint-plugin-query' | ||
import pluginReact from '@eslint-react/eslint-plugin' | ||
import * as reactHooks from 'eslint-plugin-react-hooks' | ||
|
||
export default [ | ||
...tanstackConfig, | ||
...pluginQuery.configs['flat/recommended'], | ||
pluginReact.configs.recommended, | ||
reactHooks.configs.recommended, | ||
{ | ||
rules: { | ||
'react-hooks/exhaustive-deps': 'error', | ||
'react-hooks/rules-of-hooks': 'error', | ||
}, | ||
}, | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
// @ts-check | ||
|
||
import pluginReact from '@eslint-react/eslint-plugin' | ||
import * as reactHooks from 'eslint-plugin-react-hooks' | ||
import reactHooks from 'eslint-plugin-react-hooks' | ||
import rootConfig from './root.eslint.config.js' | ||
|
||
export default [ | ||
...rootConfig, | ||
reactHooks.configs.recommended, | ||
// @ts-expect-error wtf | ||
...reactHooks.configs['recommended-latest'], | ||
{ | ||
files: ['**/*.{ts,tsx}'], | ||
...pluginReact.configs.recommended, | ||
rules: { | ||
'@eslint-react/no-context-provider': 'off', // We need to be React 18 compatible | ||
}, | ||
}, | ||
{ | ||
rules: { | ||
'react-hooks/exhaustive-deps': 'error', | ||
'react-hooks/rules-of-hooks': 'error', | ||
'react-hooks/react-compiler': 'error', | ||
'react-hooks/unsupported-syntax': 'error', | ||
'react-hooks/incompatible-library': 'error', | ||
}, | ||
}, | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,22 @@ | ||
// @ts-check | ||
|
||
import pluginReact from '@eslint-react/eslint-plugin' | ||
import * as reactHooks from 'eslint-plugin-react-hooks' | ||
import reactHooks from 'eslint-plugin-react-hooks' | ||
import rootConfig from './root.eslint.config.js' | ||
|
||
export default [ | ||
...rootConfig, | ||
reactHooks.configs.recommended, | ||
// @ts-expect-error wtf | ||
...reactHooks.configs['recommended-latest'], | ||
{ | ||
files: ['**/*.{ts,tsx}'], | ||
...pluginReact.configs.recommended, | ||
rules: { | ||
'@eslint-react/no-context-provider': 'off', // We need to be React 18 compatible | ||
}, | ||
}, | ||
{ | ||
rules: { | ||
'@eslint-react/no-unstable-context-value': 'off', | ||
'react-hooks/exhaustive-deps': 'error', | ||
'react-hooks/rules-of-hooks': 'error', | ||
'react-hooks/react-compiler': 'error', | ||
'react-hooks/unsupported-syntax': 'error', | ||
'react-hooks/incompatible-library': 'error', | ||
}, | ||
}, | ||
] |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,24 +1,22 @@ | ||||||||||
// @ts-check | ||||||||||
|
||||||||||
import pluginReact from '@eslint-react/eslint-plugin' | ||||||||||
import * as reactHooks from 'eslint-plugin-react-hooks' | ||||||||||
import reactHooks from 'eslint-plugin-react-hooks' | ||||||||||
import rootConfig from './root.eslint.config.js' | ||||||||||
|
||||||||||
export default [ | ||||||||||
...rootConfig, | ||||||||||
reactHooks.configs.recommended, | ||||||||||
// @ts-expect-error wtf | ||||||||||
...reactHooks.configs['recommended-latest'], | ||||||||||
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace unprofessional comment with a clear explanation. The comment "wtf" is unprofessional and doesn't explain why the type error is being suppressed. Replace it with a clear explanation of the type issue. - // @ts-expect-error wtf
+ // @ts-expect-error - recommended-latest config has incomplete type definitions
...reactHooks.configs['recommended-latest'], 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||
{ | ||||||||||
files: ['**/*.{ts,tsx}'], | ||||||||||
...pluginReact.configs.recommended, | ||||||||||
rules: { | ||||||||||
'@eslint-react/no-context-provider': 'off', // We need to be React 18 compatible | ||||||||||
}, | ||||||||||
}, | ||||||||||
{ | ||||||||||
rules: { | ||||||||||
'react-hooks/exhaustive-deps': 'error', | ||||||||||
'react-hooks/rules-of-hooks': 'error', | ||||||||||
'react-hooks/react-compiler': 'error', | ||||||||||
'react-hooks/unsupported-syntax': 'error', | ||||||||||
'react-hooks/incompatible-library': 'error', | ||||||||||
}, | ||||||||||
}, | ||||||||||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,29 @@ | ||
// @ts-check | ||
|
||
import pluginReact from '@eslint-react/eslint-plugin' | ||
import * as reactHooks from 'eslint-plugin-react-hooks' | ||
import reactHooks from 'eslint-plugin-react-hooks' | ||
import rootConfig from './root.eslint.config.js' | ||
|
||
export default [ | ||
...rootConfig, | ||
reactHooks.configs.recommended, | ||
// @ts-expect-error wtf | ||
...reactHooks.configs['recommended-latest'], | ||
{ | ||
files: ['**/*.{ts,tsx}'], | ||
...pluginReact.configs.recommended, | ||
rules: { | ||
'@eslint-react/no-context-provider': 'off', // We need to be React 18 compatible | ||
}, | ||
}, | ||
{ | ||
rules: { | ||
'@eslint-react/dom/no-missing-button-type': 'off', | ||
'react-hooks/react-compiler': 'error', | ||
'react-hooks/exhaustive-deps': 'error', | ||
'react-hooks/rules-of-hooks': 'error', | ||
'react-hooks/unsupported-syntax': 'error', | ||
'react-hooks/incompatible-library': 'error', | ||
}, | ||
}, | ||
{ | ||
files: ['**/__tests__/**'], | ||
rules: { | ||
'@eslint-react/dom/no-missing-button-type': 'off', | ||
'@typescript-eslint/no-unnecessary-condition': 'off', | ||
'react-hooks/react-compiler': 'off', | ||
}, | ||
}, | ||
] |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4684,6 +4684,7 @@ describe('useQuery', () => { | |||||||||||||||||||
|
||||||||||||||||||||
function Page(props: { limit: number }) { | ||||||||||||||||||||
const state = useQuery({ queryKey: [key, props.limit], queryFn }) | ||||||||||||||||||||
// eslint-disable-next-line react-hooks/immutability | ||||||||||||||||||||
states[props.limit] = state | ||||||||||||||||||||
return ( | ||||||||||||||||||||
<div> | ||||||||||||||||||||
|
@@ -6152,7 +6153,6 @@ describe('useQuery', () => { | |||||||||||||||||||
const key = queryKey() | ||||||||||||||||||||
|
||||||||||||||||||||
function Page() { | ||||||||||||||||||||
const mounted = React.useRef<boolean>(false) | ||||||||||||||||||||
const { data, status } = useQuery({ | ||||||||||||||||||||
enabled: false, | ||||||||||||||||||||
queryKey: key, | ||||||||||||||||||||
|
@@ -6162,9 +6162,10 @@ describe('useQuery', () => { | |||||||||||||||||||
}, | ||||||||||||||||||||
}) | ||||||||||||||||||||
|
||||||||||||||||||||
const mounted = React.useRef<boolean>(null) | ||||||||||||||||||||
// this simulates a synchronous update between the time the query is created | ||||||||||||||||||||
// and the time it is subscribed to that could be missed otherwise | ||||||||||||||||||||
if (!mounted.current) { | ||||||||||||||||||||
if (mounted.current === null) { | ||||||||||||||||||||
Comment on lines
+6165
to
+6168
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix type annotation for null initialization. The ref is typed as Apply this diff to correct the type: - const mounted = React.useRef<boolean>(null)
+ const mounted = React.useRef<boolean | null>(null) The usage pattern (initialize with 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||
mounted.current = true | ||||||||||||||||||||
queryClient.setQueryData(key, 1) | ||||||||||||||||||||
} | ||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drive-by comment as I saw your posts on Bluesky...
if you hadn't already come across it, thought it'd be helpful to point to facebook/react#34745, which explains (some of?) the type issues with integrating the plugin's config (and the expect error overrides you needed).
Issue was closed but the fix hasn't been published yet. You may have a better time with integration once it is 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ts-expect-error should go away if the types become correct