mirror of
https://github.com/outline/outline.git
synced 2025-12-21 10:39:41 -06:00
fix: apply react/rules-of-hooks (#10840)
This commit is contained in:
@@ -94,7 +94,8 @@
|
|||||||
"args": "after-used",
|
"args": "after-used",
|
||||||
"ignoreRestSiblings": true
|
"ignoreRestSiblings": true
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"react/rules-of-hooks": "error"
|
||||||
},
|
},
|
||||||
"plugins": ["eslint", "oxc", "react", "typescript", "import"]
|
"plugins": ["eslint", "oxc", "react", "typescript", "import"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export type Props = React.HTMLAttributes<HTMLButtonElement> & {
|
|||||||
* Button that can be used to trigger an action definition.
|
* Button that can be used to trigger an action definition.
|
||||||
*/
|
*/
|
||||||
const ActionButton = React.forwardRef<HTMLButtonElement, Props>(
|
const ActionButton = React.forwardRef<HTMLButtonElement, Props>(
|
||||||
function _ActionButton(
|
function ActionButton_(
|
||||||
{ action, tooltip, hideOnActionDisabled, ...rest }: Props,
|
{ action, tooltip, hideOnActionDisabled, ...rest }: Props,
|
||||||
ref: React.Ref<HTMLButtonElement>
|
ref: React.Ref<HTMLButtonElement>
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export type RefHandle = {
|
|||||||
* Defines a content editable component with the same interface as a native
|
* Defines a content editable component with the same interface as a native
|
||||||
* HTMLInputElement (or, as close as we can get).
|
* HTMLInputElement (or, as close as we can get).
|
||||||
*/
|
*/
|
||||||
const ContentEditable = React.forwardRef(function _ContentEditable(
|
const ContentEditable = React.forwardRef(function ContentEditable_(
|
||||||
{
|
{
|
||||||
disabled,
|
disabled,
|
||||||
onChange,
|
onChange,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
|
|
||||||
type Props = Omit<UnfurlResponse[UnfurlResourceType.Document], "type">;
|
type Props = Omit<UnfurlResponse[UnfurlResourceType.Document], "type">;
|
||||||
|
|
||||||
const HoverPreviewDocument = React.forwardRef(function _HoverPreviewDocument(
|
const HoverPreviewDocument = React.forwardRef(function HoverPreviewDocument_(
|
||||||
{ url, id, title, summary, lastActivityByViewer }: Props,
|
{ url, id, title, summary, lastActivityByViewer }: Props,
|
||||||
ref: React.Ref<HTMLDivElement>
|
ref: React.Ref<HTMLDivElement>
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import ErrorBoundary from "../ErrorBoundary";
|
|||||||
|
|
||||||
type Props = Omit<UnfurlResponse[UnfurlResourceType.Group], "type">;
|
type Props = Omit<UnfurlResponse[UnfurlResourceType.Group], "type">;
|
||||||
|
|
||||||
const HoverPreviewGroup = React.forwardRef(function _HoverPreviewGroup(
|
const HoverPreviewGroup = React.forwardRef(function HoverPreviewGroup_(
|
||||||
{ name, description, memberCount, users }: Props,
|
{ name, description, memberCount, users }: Props,
|
||||||
ref: React.Ref<HTMLDivElement>
|
ref: React.Ref<HTMLDivElement>
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import {
|
|||||||
|
|
||||||
type Props = Omit<UnfurlResponse[UnfurlResourceType.Issue], "type">;
|
type Props = Omit<UnfurlResponse[UnfurlResourceType.Issue], "type">;
|
||||||
|
|
||||||
const HoverPreviewIssue = React.forwardRef(function _HoverPreviewIssue(
|
const HoverPreviewIssue = React.forwardRef(function HoverPreviewIssue_(
|
||||||
{ url, id, title, description, author, labels, state, createdAt }: Props,
|
{ url, id, title, description, author, labels, state, createdAt }: Props,
|
||||||
ref: React.Ref<HTMLDivElement>
|
ref: React.Ref<HTMLDivElement>
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type Props = {
|
|||||||
description: string;
|
description: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const HoverPreviewLink = React.forwardRef(function _HoverPreviewLink(
|
const HoverPreviewLink = React.forwardRef(function HoverPreviewLink_(
|
||||||
{ url, thumbnailUrl, title, description }: Props,
|
{ url, thumbnailUrl, title, description }: Props,
|
||||||
ref: React.Ref<HTMLDivElement>
|
ref: React.Ref<HTMLDivElement>
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Preview, Title, Info, Card, CardContent } from "./Components";
|
|||||||
|
|
||||||
type Props = Omit<UnfurlResponse[UnfurlResourceType.Mention], "type">;
|
type Props = Omit<UnfurlResponse[UnfurlResourceType.Mention], "type">;
|
||||||
|
|
||||||
const HoverPreviewMention = React.forwardRef(function _HoverPreviewMention(
|
const HoverPreviewMention = React.forwardRef(function HoverPreviewMention_(
|
||||||
{ avatarUrl, name, lastActive, color }: Props,
|
{ avatarUrl, name, lastActive, color }: Props,
|
||||||
ref: React.Ref<HTMLDivElement>
|
ref: React.Ref<HTMLDivElement>
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
type Props = Omit<UnfurlResponse[UnfurlResourceType.PR], "type">;
|
type Props = Omit<UnfurlResponse[UnfurlResourceType.PR], "type">;
|
||||||
|
|
||||||
const HoverPreviewPullRequest = React.forwardRef(
|
const HoverPreviewPullRequest = React.forwardRef(
|
||||||
function _HoverPreviewPullRequest(
|
function HoverPreviewPullRequest_(
|
||||||
{ url, title, id, description, author, state, createdAt }: Props,
|
{ url, title, id, description, author, state, createdAt }: Props,
|
||||||
ref: React.Ref<HTMLDivElement>
|
ref: React.Ref<HTMLDivElement>
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -904,7 +904,7 @@ type ImageProps = {
|
|||||||
onMaxZoom: () => void;
|
onMaxZoom: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Image = forwardRef<HTMLImageElement, ImageProps>(function _Image(
|
const Image = forwardRef<HTMLImageElement, ImageProps>(function Image_(
|
||||||
{
|
{
|
||||||
src,
|
src,
|
||||||
alt,
|
alt,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ type Props = React.ComponentProps<typeof OneTimePasswordRoot> & {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const OneTimePasswordInput = React.forwardRef(
|
export const OneTimePasswordInput = React.forwardRef(
|
||||||
function _OneTimePasswordInput(
|
function OneTimePasswordInput_(
|
||||||
{ length = 6, ...rest }: Props,
|
{ length = 6, ...rest }: Props,
|
||||||
ref: React.RefObject<HTMLInputElement>
|
ref: React.RefObject<HTMLInputElement>
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type Props = {
|
|||||||
action: React.ReactNode;
|
action: React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SearchInput = React.forwardRef(function _SearchInput(
|
export const SearchInput = React.forwardRef(function SearchInput_(
|
||||||
{ onChange, onClick, onKeyDown, query, back, action }: Props,
|
{ onChange, onClick, onKeyDown, query, back, action }: Props,
|
||||||
ref: React.Ref<HTMLInputElement>
|
ref: React.Ref<HTMLInputElement>
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const Suggestions = observer(
|
export const Suggestions = observer(
|
||||||
React.forwardRef(function _Suggestions(
|
React.forwardRef(function Suggestions_(
|
||||||
{
|
{
|
||||||
document,
|
document,
|
||||||
collection,
|
collection,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ type Props = {
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Sidebar = React.forwardRef<HTMLDivElement, Props>(function _Sidebar(
|
const Sidebar = React.forwardRef<HTMLDivElement, Props>(function Sidebar_(
|
||||||
{ children, hidden = false, canCollapse = true, className }: Props,
|
{ children, hidden = false, canCollapse = true, className }: Props,
|
||||||
ref: React.RefObject<HTMLDivElement>
|
ref: React.RefObject<HTMLDivElement>
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export type SidebarButtonProps = React.ComponentProps<typeof Button> & {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const SidebarButton = React.forwardRef<HTMLButtonElement, SidebarButtonProps>(
|
const SidebarButton = React.forwardRef<HTMLButtonElement, SidebarButtonProps>(
|
||||||
function _SidebarButton(
|
function SidebarButton_(
|
||||||
{
|
{
|
||||||
position = "top",
|
position = "top",
|
||||||
showMoreMenu,
|
showMoreMenu,
|
||||||
|
|||||||
@@ -914,7 +914,7 @@ const EditorContainer = styled(Styles)<{
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const LazyLoadedEditor = React.forwardRef<Editor, Props>(
|
const LazyLoadedEditor = React.forwardRef<Editor, Props>(
|
||||||
function _LazyLoadedEditor(props: Props, ref) {
|
function LazyLoadedEditor_(props: Props, ref) {
|
||||||
return (
|
return (
|
||||||
<WithTheme>
|
<WithTheme>
|
||||||
{(theme) => <Editor theme={theme} {...props} ref={ref} />}
|
{(theme) => <Editor theme={theme} {...props} ref={ref} />}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import { Header } from "./components/Header";
|
|||||||
import usePersistedState from "~/hooks/usePersistedState";
|
import usePersistedState from "~/hooks/usePersistedState";
|
||||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||||
|
|
||||||
const CollectionScene = observer(function _CollectionScene() {
|
const CollectionScene = observer(function CollectionScene_() {
|
||||||
const params = useParams<{ collectionSlug?: string }>();
|
const params = useParams<{ collectionSlug?: string }>();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const match = useRouteMatch();
|
const match = useRouteMatch();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ type Props = {
|
|||||||
const lineHeight = "1.25";
|
const lineHeight = "1.25";
|
||||||
const fontSize = "2.25em";
|
const fontSize = "2.25em";
|
||||||
|
|
||||||
const DocumentTitle = React.forwardRef(function _DocumentTitle(
|
const DocumentTitle = React.forwardRef(function DocumentTitle_(
|
||||||
{
|
{
|
||||||
documentId,
|
documentId,
|
||||||
title,
|
title,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* oxlint-disable no-restricted-imports */
|
/* oxlint-disable no-restricted-imports, react/rules-of-hooks */
|
||||||
import http from "http";
|
import http from "http";
|
||||||
import https from "https";
|
import https from "https";
|
||||||
import nodeFetch, { type RequestInit, type Response } from "node-fetch";
|
import nodeFetch, { type RequestInit, type Response } from "node-fetch";
|
||||||
|
|||||||
Reference in New Issue
Block a user