Skip to content

Commit 809a8fb

Browse files
authored
chore: update eslint-plugin-react-hooks plugin (#8405)
* chore(eslint): bump eslint-plugin-react-hooks * chore(eslint): update react hooks config * refactor: fix lint problems
1 parent d53301c commit 809a8fb

File tree

7 files changed

+25
-29
lines changed

7 files changed

+25
-29
lines changed

apps/site/eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import next from '@next/eslint-plugin-next';
22
import * as mdx from 'eslint-plugin-mdx';
33
import react from 'eslint-plugin-react';
4-
import * as hooks from 'eslint-plugin-react-hooks';
4+
import reactHooks from 'eslint-plugin-react-hooks';
55

66
import baseConfig from '../../eslint.config.js';
77

@@ -11,7 +11,7 @@ export default baseConfig.concat([
1111
},
1212

1313
react.configs.flat['jsx-runtime'],
14-
hooks.configs['recommended-latest'],
14+
reactHooks.configs.flat['recommended-latest'],
1515
next.configs['core-web-vitals'],
1616
mdx.flatCodeBlocks,
1717

apps/site/hooks/react-client/useMediaQuery.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
import { useState, useEffect } from 'react';
44

55
const useMediaQuery = (query: string) => {
6-
const [matches, setMatches] = useState(false);
6+
const [matches, setMatches] = useState(() => {
7+
if (typeof window === 'undefined') {
8+
return false;
9+
}
10+
11+
return window.matchMedia?.(query)?.matches ?? false;
12+
});
713

814
useEffect(() => {
9-
const { matches, addEventListener, removeEventListener } =
10-
window.matchMedia?.(query) ?? {
11-
matches: false,
12-
addEventListener: () => {},
13-
removeEventListener: () => {},
14-
};
15-
16-
setMatches(matches);
15+
const { addEventListener, removeEventListener } = window.matchMedia?.(
16+
query
17+
) ?? {
18+
matches: false,
19+
addEventListener: () => {},
20+
removeEventListener: () => {},
21+
};
1722

1823
const handler = (event: MediaQueryListEvent) => setMatches(event.matches);
1924

apps/site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"eslint-config-next": "16.0.7",
9494
"eslint-plugin-mdx": "~3.6.2",
9595
"eslint-plugin-react": "~7.37.5",
96-
"eslint-plugin-react-hooks": "^5.2.0",
96+
"eslint-plugin-react-hooks": "^7.0.1",
9797
"global-jsdom": "^27.0.0",
9898
"handlebars": "4.7.8",
9999
"jsdom": "^27.2.0",

apps/site/providers/navigationStateProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const NavigationStateProvider: FC<PropsWithChildren> = ({
1616
const navigationState = useRef<NavigationStateContextType>({});
1717

1818
return (
19+
// eslint-disable-next-line react-hooks/refs
1920
<NavigationStateContext.Provider value={navigationState.current}>
2021
{children}
2122
</NavigationStateContext.Provider>

packages/ui-components/eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import react from 'eslint-plugin-react';
2-
import * as hooks from 'eslint-plugin-react-hooks';
2+
import reactHooks from 'eslint-plugin-react-hooks';
33
import storybook from 'eslint-plugin-storybook';
44

55
import baseConfig from '../../eslint.config.js';
66

77
export default baseConfig.concat([
88
react.configs.flat['jsx-runtime'],
9-
hooks.configs['recommended-latest'],
9+
reactHooks.configs.flat['recommended-latest'],
1010
...storybook.configs['flat/recommended'],
1111

1212
// Type-checking

packages/ui-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"cross-env": "catalog:",
6565
"css-loader": "~7.1.2",
6666
"eslint-plugin-react": "~7.37.5",
67-
"eslint-plugin-react-hooks": "^5.2.0",
67+
"eslint-plugin-react-hooks": "^7.0.1",
6868
"eslint-plugin-storybook": "~10.0.2",
6969
"global-jsdom": "^27.0.0",
7070
"postcss-cli": "^11.0.1",

pnpm-lock.yaml

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)