Unverified Commit 75f33f0e authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

Include `eslint-plugin-react-hooks` in React sync (#82294)

`eslint-plugin-react-hooks` is also published in React's nightly release cycle. I want to start dog fooding it in Next.js so that we can spot issues as early as possible.

It also includes some new heuristics that are important to flag React Compiler incompatibilities. Compat with the React Compiler of the Next.js codebase is especially relevant for Next DevTools which uses the React Compiler.

I'll follow-up on these violations. Each need different treatment.
parent c86a07db
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
"eslint-plugin-jsdoc": "48.0.4", "eslint-plugin-jsdoc": "48.0.4",
"eslint-plugin-mdx": "3.1.5", "eslint-plugin-mdx": "3.1.5",
"eslint-plugin-react": "7.35.0", "eslint-plugin-react": "7.35.0",
"eslint-plugin-react-hooks": "6.0.0-rc.1", "eslint-plugin-react-hooks": "0.0.0-experimental-c260b38d-20250731",
"eslint-v8": "npm:eslint@^8.57.0", "eslint-v8": "npm:eslint@^8.57.0",
"event-stream": "4.0.1", "event-stream": "4.0.1",
"execa": "2.0.3", "execa": "2.0.3",
......
...@@ -31,6 +31,7 @@ export function useMinimumLoadingTimeMultiple( ...@@ -31,6 +31,7 @@ export function useMinimumLoadingTimeMultiple(
if (loadStartTimeRef.current === null) { if (loadStartTimeRef.current === null) {
loadStartTimeRef.current = Date.now() loadStartTimeRef.current = Date.now()
} }
// eslint-disable-next-line react-hooks/react-compiler -- TODO
setIsLoading(true) setIsLoading(true)
} else { } else {
// If we're exiting the "loading" state: // If we're exiting the "loading" state:
......
...@@ -19,6 +19,7 @@ export function useUpdateAnimation( ...@@ -19,6 +19,7 @@ export function useUpdateAnimation(
return return
} }
// eslint-disable-next-line react-hooks/react-compiler -- TODO
setAnimate(true) setAnimate(true)
// It is important to use a CSS transitioned state, not a CSS keyframed animation // It is important to use a CSS transitioned state, not a CSS keyframed animation
// because if the issue count increases faster than the animation duration, it // because if the issue count increases faster than the animation duration, it
......
...@@ -44,6 +44,7 @@ export function NextLogo({ ...@@ -44,6 +44,7 @@ export function NextLogo({
const width = measuredWidth === 0 ? 'auto' : measuredWidth const width = measuredWidth === 0 ? 'auto' : measuredWidth
useEffect(() => { useEffect(() => {
// eslint-disable-next-line react-hooks/react-compiler -- TODO
setIsErrorExpanded(hasError) setIsErrorExpanded(hasError)
}, [hasError]) }, [hasError])
......
...@@ -76,6 +76,7 @@ export const ResizeHandle = ({ ...@@ -76,6 +76,7 @@ export const ResizeHandle = ({
const borderBottom = parseFloat(computedStyle.borderBottomWidth) || 0 const borderBottom = parseFloat(computedStyle.borderBottomWidth) || 0
const borderLeft = parseFloat(computedStyle.borderLeftWidth) || 0 const borderLeft = parseFloat(computedStyle.borderLeftWidth) || 0
// eslint-disable-next-line react-hooks/react-compiler -- TODO
setBorderWidths({ setBorderWidths({
top: borderTop, top: borderTop,
right: borderRight, right: borderRight,
......
...@@ -36,6 +36,7 @@ const Dialog: React.FC<DialogProps> = function Dialog({ ...@@ -36,6 +36,7 @@ const Dialog: React.FC<DialogProps> = function Dialog({
) )
useOnClickOutside( useOnClickOutside(
// eslint-disable-next-line react-hooks/react-compiler -- TODO
dialogRef.current, dialogRef.current,
CSS_SELECTORS_TO_EXCLUDE_ON_CLICK_OUTSIDE, CSS_SELECTORS_TO_EXCLUDE_ON_CLICK_OUTSIDE,
(e) => { (e) => {
......
...@@ -316,6 +316,7 @@ function MetaKey() { ...@@ -316,6 +316,7 @@ function MetaKey() {
useEffect(() => { useEffect(() => {
// Meta is Command on Apple devices, otherwise Control // Meta is Command on Apple devices, otherwise Control
if (apple === true) { if (apple === true) {
// eslint-disable-next-line react-hooks/react-compiler -- TODO
setLabel('⌘') setLabel('⌘')
} }
......
...@@ -36,6 +36,7 @@ export function DragProvider({ ...@@ -36,6 +36,7 @@ export function DragProvider({
}, []) }, [])
const value = useMemo<DragContextValue>( const value = useMemo<DragContextValue>(
// eslint-disable-next-line react-hooks/react-compiler -- TODO
() => ({ register, unregister, handles: handlesRef.current, disabled }), () => ({ register, unregister, handles: handlesRef.current, disabled }),
[register, unregister, disabled] [register, unregister, disabled]
) )
......
...@@ -13,6 +13,7 @@ export function ErrorMessage({ errorMessage }: ErrorMessageProps) { ...@@ -13,6 +13,7 @@ export function ErrorMessage({ errorMessage }: ErrorMessageProps) {
useLayoutEffect(() => { useLayoutEffect(() => {
if (messageRef.current) { if (messageRef.current) {
// eslint-disable-next-line react-hooks/react-compiler -- TODO
setShouldTruncate(messageRef.current.scrollHeight > 200) setShouldTruncate(messageRef.current.scrollHeight > 200)
} }
}, [errorMessage]) }, [errorMessage])
......
...@@ -48,6 +48,7 @@ export function SegmentBoundaryTrigger({ ...@@ -48,6 +48,7 @@ export function SegmentBoundaryTrigger({
() => { () => {
setIsOpen(false) setIsOpen(false)
}, },
// eslint-disable-next-line react-hooks/react-compiler -- TODO
triggerRef.current?.ownerDocument triggerRef.current?.ownerDocument
) )
......
...@@ -38,7 +38,7 @@ export function ShadowPortal({ children }: { children: React.ReactNode }) { ...@@ -38,7 +38,7 @@ export function ShadowPortal({ children }: { children: React.ReactNode }) {
forceUpdate({}) forceUpdate({})
}, [state.theme]) }, [state.theme])
return shadowNode.current // eslint-disable-next-line react-hooks/react-compiler -- TODO
? createPortal(children, shadowNode.current as any) const shadowRoot = shadowNode.current
: null return shadowRoot ? createPortal(children, shadowRoot as any) : null
} }
...@@ -43,6 +43,7 @@ export function useDelayedRender(active = false, options: Options = {}) { ...@@ -43,6 +43,7 @@ export function useDelayedRender(active = false, options: Options = {}) {
let unmountTimeout: Timeout | undefined let unmountTimeout: Timeout | undefined
if (active) { if (active) {
// eslint-disable-next-line react-hooks/react-compiler -- intentional cascading update
setMounted(true) setMounted(true)
if (enterDelay <= 0) { if (enterDelay <= 0) {
setRendered(true) setRendered(true)
......
...@@ -308,8 +308,8 @@ importers: ...@@ -308,8 +308,8 @@ importers:
specifier: 7.35.0 specifier: 7.35.0
version: 7.35.0(eslint@9.12.0) version: 7.35.0(eslint@9.12.0)
eslint-plugin-react-hooks: eslint-plugin-react-hooks:
specifier: 6.0.0-rc.1 specifier: 0.0.0-experimental-c260b38d-20250731
version: 6.0.0-rc.1(eslint@9.12.0) version: 0.0.0-experimental-c260b38d-20250731(eslint@9.12.0)
eslint-v8: eslint-v8:
specifier: npm:eslint@^8.57.0 specifier: npm:eslint@^8.57.0
version: eslint@8.57.1 version: eslint@8.57.1
...@@ -8885,15 +8885,15 @@ packages: ...@@ -8885,15 +8885,15 @@ packages:
peerDependencies: peerDependencies:
eslint: '>=8.0.0' eslint: '>=8.0.0'
eslint-plugin-react-hooks@5.0.0: eslint-plugin-react-hooks@0.0.0-experimental-c260b38d-20250731:
resolution: {integrity: sha512-hIOwI+5hYGpJEc4uPRmz2ulCjAGD/N13Lukkh8cLV0i2IRk/bdZDYjgLVHj+U9Z704kLIdIO6iueGvxNur0sgw==} resolution: {integrity: sha512-pDvUu0gLJQHFDh9Wq+M1Kh002RdacFTD5xHnOY4uLCwhKo3gerFrJSe09e+ZwdwN15E1vY0ZF+3Ymj6HFtAfGw==}
engines: {node: '>=10'} engines: {node: '>=18'}
peerDependencies: peerDependencies:
eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0
eslint-plugin-react-hooks@6.0.0-rc.1: eslint-plugin-react-hooks@5.0.0:
resolution: {integrity: sha512-7C4c7bdtd/B7Q+HruZxYhGjwZVvJawvQpilEYlRG1Jncuk1ZNqrFy9bO8SJNieyj3iDh8WPQA7BzzPO7sNAyEA==} resolution: {integrity: sha512-hIOwI+5hYGpJEc4uPRmz2ulCjAGD/N13Lukkh8cLV0i2IRk/bdZDYjgLVHj+U9Z704kLIdIO6iueGvxNur0sgw==}
engines: {node: '>=18'} engines: {node: '>=10'}
peerDependencies: peerDependencies:
eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0
...@@ -25658,11 +25658,7 @@ snapshots: ...@@ -25658,11 +25658,7 @@ snapshots:
- bluebird - bluebird
- supports-color - supports-color
eslint-plugin-react-hooks@5.0.0(eslint@9.12.0): eslint-plugin-react-hooks@0.0.0-experimental-c260b38d-20250731(eslint@9.12.0):
dependencies:
eslint: 9.12.0
eslint-plugin-react-hooks@6.0.0-rc.1(eslint@9.12.0):
dependencies: dependencies:
'@babel/core': 7.26.10 '@babel/core': 7.26.10
'@babel/parser': 7.27.0 '@babel/parser': 7.27.0
...@@ -25674,6 +25670,10 @@ snapshots: ...@@ -25674,6 +25670,10 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
eslint-plugin-react-hooks@5.0.0(eslint@9.12.0):
dependencies:
eslint: 9.12.0
eslint-plugin-react@7.35.0(eslint@9.12.0): eslint-plugin-react@7.35.0(eslint@9.12.0):
dependencies: dependencies:
array-includes: 3.1.8 array-includes: 3.1.8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment