diff --git a/.oxlintrc.json b/.oxlintrc.json index acd586a254..9ec1cbe2be 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -94,7 +94,8 @@ "args": "after-used", "ignoreRestSiblings": true } - ] + ], + "react/rules-of-hooks": "error" }, "plugins": ["eslint", "oxc", "react", "typescript", "import"] } diff --git a/app/components/ActionButton.tsx b/app/components/ActionButton.tsx index 382497cf38..4c1a82ff93 100644 --- a/app/components/ActionButton.tsx +++ b/app/components/ActionButton.tsx @@ -21,7 +21,7 @@ export type Props = React.HTMLAttributes & { * Button that can be used to trigger an action definition. */ const ActionButton = React.forwardRef( - function _ActionButton( + function ActionButton_( { action, tooltip, hideOnActionDisabled, ...rest }: Props, ref: React.Ref ) { diff --git a/app/components/ContentEditable.tsx b/app/components/ContentEditable.tsx index 03b05c4913..3a53b87218 100644 --- a/app/components/ContentEditable.tsx +++ b/app/components/ContentEditable.tsx @@ -31,7 +31,7 @@ export type RefHandle = { * Defines a content editable component with the same interface as a native * HTMLInputElement (or, as close as we can get). */ -const ContentEditable = React.forwardRef(function _ContentEditable( +const ContentEditable = React.forwardRef(function ContentEditable_( { disabled, onChange, diff --git a/app/components/HoverPreview/HoverPreviewDocument.tsx b/app/components/HoverPreview/HoverPreviewDocument.tsx index 1688eb629f..732d00b32a 100644 --- a/app/components/HoverPreview/HoverPreviewDocument.tsx +++ b/app/components/HoverPreview/HoverPreviewDocument.tsx @@ -15,7 +15,7 @@ import { type Props = Omit; -const HoverPreviewDocument = React.forwardRef(function _HoverPreviewDocument( +const HoverPreviewDocument = React.forwardRef(function HoverPreviewDocument_( { url, id, title, summary, lastActivityByViewer }: Props, ref: React.Ref ) { diff --git a/app/components/HoverPreview/HoverPreviewGroup.tsx b/app/components/HoverPreview/HoverPreviewGroup.tsx index 7ebfcaecdf..89b4f52fd4 100644 --- a/app/components/HoverPreview/HoverPreviewGroup.tsx +++ b/app/components/HoverPreview/HoverPreviewGroup.tsx @@ -17,7 +17,7 @@ import ErrorBoundary from "../ErrorBoundary"; type Props = Omit; -const HoverPreviewGroup = React.forwardRef(function _HoverPreviewGroup( +const HoverPreviewGroup = React.forwardRef(function HoverPreviewGroup_( { name, description, memberCount, users }: Props, ref: React.Ref ) { diff --git a/app/components/HoverPreview/HoverPreviewIssue.tsx b/app/components/HoverPreview/HoverPreviewIssue.tsx index 4ee1dbf904..46bedcdd46 100644 --- a/app/components/HoverPreview/HoverPreviewIssue.tsx +++ b/app/components/HoverPreview/HoverPreviewIssue.tsx @@ -24,7 +24,7 @@ import { type Props = Omit; -const HoverPreviewIssue = React.forwardRef(function _HoverPreviewIssue( +const HoverPreviewIssue = React.forwardRef(function HoverPreviewIssue_( { url, id, title, description, author, labels, state, createdAt }: Props, ref: React.Ref ) { diff --git a/app/components/HoverPreview/HoverPreviewLink.tsx b/app/components/HoverPreview/HoverPreviewLink.tsx index c687952de9..b5ef796948 100644 --- a/app/components/HoverPreview/HoverPreviewLink.tsx +++ b/app/components/HoverPreview/HoverPreviewLink.tsx @@ -20,7 +20,7 @@ type Props = { description: string; }; -const HoverPreviewLink = React.forwardRef(function _HoverPreviewLink( +const HoverPreviewLink = React.forwardRef(function HoverPreviewLink_( { url, thumbnailUrl, title, description }: Props, ref: React.Ref ) { diff --git a/app/components/HoverPreview/HoverPreviewMention.tsx b/app/components/HoverPreview/HoverPreviewMention.tsx index 322d50ccea..4c4088ab3b 100644 --- a/app/components/HoverPreview/HoverPreviewMention.tsx +++ b/app/components/HoverPreview/HoverPreviewMention.tsx @@ -6,7 +6,7 @@ import { Preview, Title, Info, Card, CardContent } from "./Components"; type Props = Omit; -const HoverPreviewMention = React.forwardRef(function _HoverPreviewMention( +const HoverPreviewMention = React.forwardRef(function HoverPreviewMention_( { avatarUrl, name, lastActive, color }: Props, ref: React.Ref ) { diff --git a/app/components/HoverPreview/HoverPreviewPullRequest.tsx b/app/components/HoverPreview/HoverPreviewPullRequest.tsx index ff830953ea..2cda5f810c 100644 --- a/app/components/HoverPreview/HoverPreviewPullRequest.tsx +++ b/app/components/HoverPreview/HoverPreviewPullRequest.tsx @@ -20,7 +20,7 @@ import { type Props = Omit; const HoverPreviewPullRequest = React.forwardRef( - function _HoverPreviewPullRequest( + function HoverPreviewPullRequest_( { url, title, id, description, author, state, createdAt }: Props, ref: React.Ref ) { diff --git a/app/components/Lightbox.tsx b/app/components/Lightbox.tsx index 9fa6341ee5..0add1d8341 100644 --- a/app/components/Lightbox.tsx +++ b/app/components/Lightbox.tsx @@ -904,7 +904,7 @@ type ImageProps = { onMaxZoom: () => void; }; -const Image = forwardRef(function _Image( +const Image = forwardRef(function Image_( { src, alt, diff --git a/app/components/OneTimePasswordInput.tsx b/app/components/OneTimePasswordInput.tsx index 6ebfdc99cd..ab9a7506e9 100644 --- a/app/components/OneTimePasswordInput.tsx +++ b/app/components/OneTimePasswordInput.tsx @@ -9,7 +9,7 @@ type Props = React.ComponentProps & { }; export const OneTimePasswordInput = React.forwardRef( - function _OneTimePasswordInput( + function OneTimePasswordInput_( { length = 6, ...rest }: Props, ref: React.RefObject ) { diff --git a/app/components/Sharing/components/SearchInput.tsx b/app/components/Sharing/components/SearchInput.tsx index 3bcf3c63c2..c3b5f746ae 100644 --- a/app/components/Sharing/components/SearchInput.tsx +++ b/app/components/Sharing/components/SearchInput.tsx @@ -16,7 +16,7 @@ type Props = { action: React.ReactNode; }; -export const SearchInput = React.forwardRef(function _SearchInput( +export const SearchInput = React.forwardRef(function SearchInput_( { onChange, onClick, onKeyDown, query, back, action }: Props, ref: React.Ref ) { diff --git a/app/components/Sharing/components/Suggestions.tsx b/app/components/Sharing/components/Suggestions.tsx index e252a2bca4..1b76a4185a 100644 --- a/app/components/Sharing/components/Suggestions.tsx +++ b/app/components/Sharing/components/Suggestions.tsx @@ -44,7 +44,7 @@ type Props = { }; export const Suggestions = observer( - React.forwardRef(function _Suggestions( + React.forwardRef(function Suggestions_( { document, collection, diff --git a/app/components/Sidebar/Sidebar.tsx b/app/components/Sidebar/Sidebar.tsx index b005ad3b5f..d7e042d6b8 100644 --- a/app/components/Sidebar/Sidebar.tsx +++ b/app/components/Sidebar/Sidebar.tsx @@ -37,7 +37,7 @@ type Props = { children: React.ReactNode; }; -const Sidebar = React.forwardRef(function _Sidebar( +const Sidebar = React.forwardRef(function Sidebar_( { children, hidden = false, canCollapse = true, className }: Props, ref: React.RefObject ) { diff --git a/app/components/Sidebar/components/SidebarButton.tsx b/app/components/Sidebar/components/SidebarButton.tsx index 3c3e185fc9..aa6557d972 100644 --- a/app/components/Sidebar/components/SidebarButton.tsx +++ b/app/components/Sidebar/components/SidebarButton.tsx @@ -18,7 +18,7 @@ export type SidebarButtonProps = React.ComponentProps & { }; const SidebarButton = React.forwardRef( - function _SidebarButton( + function SidebarButton_( { position = "top", showMoreMenu, diff --git a/app/editor/index.tsx b/app/editor/index.tsx index 8341c66110..14c4466a10 100644 --- a/app/editor/index.tsx +++ b/app/editor/index.tsx @@ -914,7 +914,7 @@ const EditorContainer = styled(Styles)<{ `; const LazyLoadedEditor = React.forwardRef( - function _LazyLoadedEditor(props: Props, ref) { + function LazyLoadedEditor_(props: Props, ref) { return ( {(theme) => } diff --git a/app/scenes/Collection/index.tsx b/app/scenes/Collection/index.tsx index 53fc39add3..0e21f724cc 100644 --- a/app/scenes/Collection/index.tsx +++ b/app/scenes/Collection/index.tsx @@ -50,7 +50,7 @@ import { Header } from "./components/Header"; import usePersistedState from "~/hooks/usePersistedState"; import useCurrentUser from "~/hooks/useCurrentUser"; -const CollectionScene = observer(function _CollectionScene() { +const CollectionScene = observer(function CollectionScene_() { const params = useParams<{ collectionSlug?: string }>(); const history = useHistory(); const match = useRouteMatch(); diff --git a/app/scenes/Document/components/DocumentTitle.tsx b/app/scenes/Document/components/DocumentTitle.tsx index 18f76aec32..5b53bc061b 100644 --- a/app/scenes/Document/components/DocumentTitle.tsx +++ b/app/scenes/Document/components/DocumentTitle.tsx @@ -56,7 +56,7 @@ type Props = { const lineHeight = "1.25"; const fontSize = "2.25em"; -const DocumentTitle = React.forwardRef(function _DocumentTitle( +const DocumentTitle = React.forwardRef(function DocumentTitle_( { documentId, title, diff --git a/server/utils/fetch.ts b/server/utils/fetch.ts index aef2ca9bdb..3513f98418 100644 --- a/server/utils/fetch.ts +++ b/server/utils/fetch.ts @@ -1,4 +1,4 @@ -/* oxlint-disable no-restricted-imports */ +/* oxlint-disable no-restricted-imports, react/rules-of-hooks */ import http from "http"; import https from "https"; import nodeFetch, { type RequestInit, type Response } from "node-fetch";