Skip to content

Commit 6e5333b

Browse files
committed
chore: enable eslint-plugin-react-hooks
1 parent ccdd3c2 commit 6e5333b

File tree

16 files changed

+192
-141
lines changed

16 files changed

+192
-141
lines changed

eslint.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import eslint from '@eslint/js'
44
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
5-
import importX from 'eslint-plugin-import-x'
5+
import { importX } from 'eslint-plugin-import-x'
6+
import * as reactHooks from 'eslint-plugin-react-hooks'
67
import { config, configs } from 'typescript-eslint'
78

89
export default config(
@@ -12,6 +13,7 @@ export default config(
1213
eslint.configs.recommended,
1314
importX.flatConfigs.recommended,
1415
importX.flatConfigs.typescript,
16+
reactHooks.configs['recommended-latest'],
1517
{
1618
files: ['**/*.{ts,tsx}'],
1719
extends: [configs.eslintRecommended, configs.strictTypeChecked],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
"clean-pkg-json": "^1.3.0",
119119
"eslint-import-resolver-typescript": "^4.4.1",
120120
"eslint-plugin-import-x": "^4.13.3",
121+
"eslint-plugin-react-hooks": "^5.2.0",
121122
"nano-staged": "^0.8.0",
122123
"npm-run-all2": "^7.0.2",
123124
"prettier": "^3.5.3",

src/global/SiteOverrides/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,14 @@ export const SiteOverrides = () => {
7171
requestAnimationFrame(() => {
7272
document.title = newTitle
7373
})
74-
}, [title])
74+
}, [
75+
articleTitle,
76+
frontmatter.title,
77+
frontmatter.titleSuffix,
78+
pageType,
79+
siteData,
80+
title,
81+
])
7582

7683
useEffect(() => {
7784
if (!logoText) {

src/global/VersionsNav/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const VersionsNav_ = () => {
106106
}
107107

108108
void fetchVersions().catch(noop)
109-
}, [])
109+
}, [version, versionsBase])
110110

111111
// hack way to detect nav menu recreation on theme change
112112
useEffect(() => {

src/runtime/components/ExternalSiteLink.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ const ExternalSiteLink_ = ({
3131
}: ExternalSiteLinkProps) => {
3232
const isPrint = useIsPrint()
3333

34-
const site = useMemo(() => virtual.sites?.find((s) => s.name === name), [])
34+
const site = useMemo(
35+
() => virtual.sites?.find((s) => s.name === name),
36+
[name],
37+
)
3538
const lang = useLang()
3639

3740
if (!site) {

src/runtime/components/K8sCrd.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,18 @@ export const K8sCrdSchemaPart = ({
7272
title={
7373
<>
7474
{name}
75-
{type && <code>{type}</code>}
76-
{required && <Badge>required</Badge>}
75+
{type && (
76+
<>
77+
{' '}
78+
<code>{type}</code>
79+
</>
80+
)}
81+
{required && (
82+
<>
83+
{' '}
84+
<Badge>required</Badge>
85+
</>
86+
)}
7787
</>
7888
}
7989
open={open}
@@ -121,8 +131,7 @@ export const K8sCrdSchema = ({
121131
<Markdown>{description}</Markdown>
122132
<div className="flex items-center">
123133
<span>
124-
<code>{version}</code>
125-
<Badge>version</Badge>
134+
<code>{version}</code> <Badge>version</Badge>
126135
</span>
127136
{!isPrint && properties != null && (
128137
<Button
@@ -172,7 +181,7 @@ export const K8sCrd = ({ name, crdPath }: K8sCrdProps) => {
172181
}
173182
return crd.metadata.name === name
174183
}) || [],
175-
[],
184+
[crdPath, name],
176185
)
177186

178187
if (!crd) {
@@ -183,8 +192,7 @@ export const K8sCrd = ({ name, crdPath }: K8sCrdProps) => {
183192
return (
184193
<>
185194
<X.p>
186-
<code>{crd.spec.group}</code>
187-
<Badge>group</Badge>
195+
<code>{crd.spec.group}</code> <Badge>group</Badge>
188196
</X.p>
189197
{crd.spec.versions.map((version) => (
190198
<K8sCrdSchema

src/runtime/components/K8sPermissionTable.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export const K8sPermissionTable = ({ functions }: K8sPermissionTableProps) => {
111111
}
112112
return matched
113113
})
114+
// eslint-disable-next-line react-hooks/exhaustive-deps
114115
}, [...functions])
115116

116117
const roleTemplates = useMemo(

src/runtime/components/Mermaid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const Mermaid = ({ className, children }: MermaidProps) => {
3232
}
3333

3434
void render()
35-
}, [children, isDark])
35+
}, [children, id, isDark])
3636

3737
return (
3838
<div

src/runtime/components/OpenAPIPath.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export const OpenAPIPath = ({
197197
}
198198
}
199199
return []
200-
}, [])
200+
}, [openapiPath_, page.routePath, path])
201201

202202
if (!pathItem || !openapi) {
203203
console.error(`No OpenAPI path definition found for ${path}`)

src/runtime/components/OpenAPIRef.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,10 @@ export const OpenAPIRef = ({
173173
}
174174
}
175175
return []
176-
}, [])
177-
178-
if (!schemaItem || !openapi) {
179-
console.error(`No OpenAPI schema definition found for ${schema}\n`)
180-
return null
181-
}
176+
}, [openapiPath_, schema])
182177

183178
const refs = useMemo(() => {
184-
if (collectRefs) {
179+
if (collectRefs && openapi) {
185180
return getRefsForSchema(
186181
openapi,
187182
schema,
@@ -190,6 +185,11 @@ export const OpenAPIRef = ({
190185
}
191186
}, [collectRefs, openapi, page.routePath, schema])
192187

188+
if (!schemaItem || !openapi) {
189+
console.error(`No OpenAPI schema definition found for ${schema}\n`)
190+
return null
191+
}
192+
193193
return (
194194
<>
195195
<HeadingTitle uid={uid} slug={schema} level={2}>

0 commit comments

Comments
 (0)