Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

chore: fix code style issues (#4857)

EYHNb7edaab3872f
diff --git a/packages/common/infra/src/__internal__/react.ts b/packages/common/infra/src/__internal__/react.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/common/infra/vite.config.ts b/packages/common/infra/vite.config.ts
index a59c8ed098..ca5dc954e7 100644
--- a/packages/common/infra/vite.config.ts
+++ b/packages/common/infra/vite.config.ts
@@ -22,7 +22,6 @@ export default defineConfig({
root,
'src/__internal__/workspace.ts'
),
- '__internal__/react': resolve(root, 'src/__internal__/react.ts'),
'__internal__/plugin': resolve(root, 'src/__internal__/plugin.ts'),
},
formats: ['es', 'cjs'],
diff --git a/packages/frontend/component/src/components/notification-center/index.jotai.ts b/packages/frontend/component/src/components/notification-center/index.jotai.ts
index 89dfb934ca..c793112cdc 100644
--- a/packages/frontend/component/src/components/notification-center/index.jotai.ts
+++ b/packages/frontend/component/src/components/notification-center/index.jotai.ts
@@ -9,7 +9,7 @@ export type Notification = {
theme?: 'light' | 'dark' | 'default';
timeout?: number;
progressingBar?: boolean;
- multimedia?: React.ReactNode | JSX.Element | HTMLElement;
+ multimedia?: React.ReactNode | JSX.Element;
// actions
undo?: () => Promise<void>;
};
diff --git a/packages/frontend/component/src/components/notification-center/index.tsx b/packages/frontend/component/src/components/notification-center/index.tsx
index b83903c02c..5574b82a80 100644
--- a/packages/frontend/component/src/components/notification-center/index.tsx
+++ b/packages/frontend/component/src/components/notification-center/index.tsx
@@ -7,7 +7,7 @@ import * as Toast from '@radix-ui/react-toast';
import { IconButton } from '@toeverything/components/button';
import clsx from 'clsx';
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
-import type { ReactElement } from 'react';
+import type { ReactNode } from 'react';
import {
useCallback,
useEffect,
@@ -70,7 +70,7 @@ const typeColorMap = {
},
};
-function NotificationCard(props: NotificationCardProps): ReactElement {
+function NotificationCard(props: NotificationCardProps): ReactNode {
const removeNotification = useSetAtom(removeNotificationAtom);
const { notification, notifications, setHeights, heights, index } = props;
@@ -270,7 +270,7 @@ function NotificationCard(props: NotificationCardProps): ReactElement {
>
{notification.multimedia ? (
<div className={styles.notificationMultimediaStyle}>
- <>{notification.multimedia}</>
+ {notification.multimedia}
<IconButton className={styles.closeButtonWithMediaStyle}>
<CloseIcon onClick={onClickRemove} />
</IconButton>
@@ -373,7 +373,7 @@ function NotificationCard(props: NotificationCardProps): ReactElement {
);
}
-export function NotificationCenter(): ReactElement {
+export function NotificationCenter(): ReactNode {
const notifications = useAtomValue(notificationsAtom);
const [expand, setExpand] = useAtom(expandNotificationCenterAtom);
@@ -390,7 +390,7 @@ export function NotificationCenter(): ReactElement {
}
}, [notifications, setExpand]);
- if (!notifications.length) return <></>;
+ if (!notifications.length) return null;
return (
<Toast.Provider swipeDirection="right">
{notifications.map((notification, index) =>
diff --git a/packages/frontend/component/src/components/page-list/operation-menu-items/export.tsx b/packages/frontend/component/src/components/page-list/operation-menu-items/export.tsx
index 998ee77382..a924f71e58 100644
--- a/packages/frontend/component/src/components/page-list/operation-menu-items/export.tsx
+++ b/packages/frontend/component/src/components/page-list/operation-menu-items/export.tsx
@@ -97,7 +97,7 @@ export const ExportMenuItems = ({
const items = itemMap.map(({ component: Component, props }) => (
<Component key={props.label} {...props} />
));
- return <>{items}</>;
+ return items;
};
export const Export = ({ exportHandler, className }: ExportProps) => {
diff --git a/packages/frontend/component/src/components/provider-composer/__tests__/provider-composer.spec.tsx b/packages/frontend/component/src/components/provider-composer/__tests__/provider-composer.spec.tsx
index 9e91843d26..d20a27400e 100644
--- a/packages/frontend/component/src/components/provider-composer/__tests__/provider-composer.spec.tsx
+++ b/packages/frontend/component/src/components/provider-composer/__tests__/provider-composer.spec.tsx
@@ -15,7 +15,7 @@ test('ProviderComposer', async () => {
};
const ConsumerComponent = () => {
const value = useContext(Context);
- return <>{value}</>;
+ return value;
};
const Component = () => {
return (
diff --git a/packages/frontend/component/src/components/share-menu/share-page.tsx b/packages/frontend/component/src/components/share-menu/share-page.tsx
index 5b17c1a030..f16f6938f7 100644
--- a/packages/frontend/component/src/components/share-menu/share-page.tsx
+++ b/packages/frontend/component/src/components/share-menu/share-page.tsx
@@ -38,30 +38,25 @@ export const LocalSharePage = (props: ShareMenuProps) => {
const t = useAFFiNEI18N();
return (
- <>
- <div className={styles.localSharePage}>
- <div className={styles.columnContainerStyle} style={{ gap: '12px' }}>
- <div
- className={styles.descriptionStyle}
- style={{ maxWidth: '230px' }}
- >
- {t['com.affine.share-menu.EnableCloudDescription']()}
- </div>
- <div>
- <Button
- onClick={props.onEnableAffineCloud}
- type="primary"
- data-testid="share-menu-enable-affine-cloud-button"
- >
- {t['Enable AFFiNE Cloud']()}
- </Button>
- </div>
+ <div className={styles.localSharePage}>
+ <div className={styles.columnContainerStyle} style={{ gap: '12px' }}>
+ <div className={styles.descriptionStyle} style={{ maxWidth: '230px' }}>
+ {t['com.affine.share-menu.EnableCloudDescription']()}
</div>
- <div className={styles.cloudSvgContainer}>
- <CloudSvg />
+ <div>
+ <Button
+ onClick={props.onEnableAffineCloud}
+ type="primary"
+ data-testid="share-menu-enable-affine-cloud-button"
+ >
+ {t['Enable AFFiNE Cloud']()}
+ </Button>
</div>
</div>
- </>
+ <div className={styles.cloudSvgContainer}>
+ <CloudSvg />
+ </div>
+ </div>
);
};
@@ -218,11 +213,7 @@ export const SharePage = (props: ShareMenuProps) => {
if (props.workspace.flavour === WorkspaceFlavour.LOCAL) {
return <LocalSharePage {...props} />;
} else if (props.workspace.flavour === WorkspaceFlavour.AFFINE_CLOUD) {
- return (
- <>
- <AffineSharePage {...props} />
- </>
- );
+ return <AffineSharePage {...props} />;
}
throw new Error('Unreachable');
};
diff --git a/packages/frontend/component/src/components/workspace-list/index.tsx b/packages/frontend/component/src/components/workspace-list/index.tsx
index 3ec35c8674..5557616370 100644
--- a/packages/frontend/component/src/components/workspace-list/index.tsx
+++ b/packages/frontend/component/src/components/workspace-list/index.tsx
@@ -121,7 +121,7 @@ export const WorkspaceList = (props: WorkspaceListProps) => {
<SortableContext items={optimisticList}>
{optimisticList.map(item => (
<Suspense fallback={<WorkspaceCardSkeleton />} key={item.id}>
- <SortableWorkspaceItem {...props} item={item} key={item.id} />
+ <SortableWorkspaceItem key={item.id} {...props} item={item} />
</Suspense>
))}
</SortableContext>
diff --git a/packages/frontend/component/src/ui/popper/popper.tsx b/packages/frontend/component/src/ui/popper/popper.tsx
index 2d69365ff0..f54f1aae71 100644
--- a/packages/frontend/component/src/ui/popper/popper.tsx
+++ b/packages/frontend/component/src/ui/popper/popper.tsx
@@ -171,109 +171,107 @@ export const Popper = ({
}}
>
{showArrow ? (
- <>
- {placement.indexOf('bottom') === 0 ? (
- <div
- style={{
- display: 'flex',
- flexDirection: 'column',
- alignItems: 'center',
- }}
+ placement.indexOf('bottom') === 0 ? (
+ <div
+ style={{
+ display: 'flex',
+ flexDirection: 'column',
+ alignItems: 'center',
+ }}
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="11"
+ height="6"
+ viewBox="0 0 11 6"
+ fill="none"
>
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="11"
- height="6"
- viewBox="0 0 11 6"
- fill="none"
- >
- <path
- d="M6.38889 0.45C5.94444 -0.15 5.05555 -0.150001 4.61111 0.449999L0.499999 6L10.5 6L6.38889 0.45Z"
- style={{ fill: 'var(--affine-tooltip)' }}
- />
- </svg>
- {content}
- </div>
- ) : placement.indexOf('top') === 0 ? (
- <div
- style={{
- display: 'flex',
- flexDirection: 'column',
- alignItems: 'center',
- }}
+ <path
+ d="M6.38889 0.45C5.94444 -0.15 5.05555 -0.150001 4.61111 0.449999L0.499999 6L10.5 6L6.38889 0.45Z"
+ style={{ fill: 'var(--affine-tooltip)' }}
+ />
+ </svg>
+ {content}
+ </div>
+ ) : placement.indexOf('top') === 0 ? (
+ <div
+ style={{
+ display: 'flex',
+ flexDirection: 'column',
+ alignItems: 'center',
+ }}
+ >
+ {content}
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="11"
+ height="6"
+ viewBox="0 0 11 6"
+ fill="none"
+ >
+ <path
+ d="M4.61111 5.55C5.05556 6.15 5.94445 6.15 6.38889 5.55L10.5 -4.76837e-07H0.5L4.61111 5.55Z"
+ style={{ fill: 'var(--affine-tooltip)' }}
+ />
+ </svg>
+ </div>
+ ) : placement.indexOf('left') === 0 ? (
+ <>
+ {content}
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="6"
+ height="10"
+ viewBox="0 0 6 10"
+ fill="none"
>
- {content}
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="11"
- height="6"
- viewBox="0 0 11 6"
- fill="none"
- >
- <path
- d="M4.61111 5.55C5.05556 6.15 5.94445 6.15 6.38889 5.55L10.5 -4.76837e-07H0.5L4.61111 5.55Z"
- style={{ fill: 'var(--affine-tooltip)' }}
- />
- </svg>
- </div>
- ) : placement.indexOf('left') === 0 ? (
- <>
- {content}
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="6"
- height="10"
- viewBox="0 0 6 10"
- fill="none"
- >
- <path
- d="M5.55 5.88889C6.15 5.44444 6.15 4.55555 5.55 4.11111L-4.76837e-07 0L-4.76837e-07 10L5.55 5.88889Z"
- style={{ fill: 'var(--affine-tooltip)' }}
- />
- </svg>
- </>
- ) : placement.indexOf('right') === 0 ? (
- <>
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="6"
- height="10"
- viewBox="0 0 6 10"
+ <path
+ d="M5.55 5.88889C6.15 5.44444 6.15 4.55555 5.55 4.11111L-4.76837e-07 0L-4.76837e-07 10L5.55 5.88889Z"
style={{ fill: 'var(--affine-tooltip)' }}
- >
- <path
- d="M0.45 4.11111C-0.15 4.55556 -0.15 5.44445 0.45 5.88889L6 10V0L0.45 4.11111Z"
- style={{ fill: 'var(--affine-tooltip)' }}
- />
- </svg>
- {content}
- </>
- ) : (
- <div
- style={{
- display: 'flex',
- flexDirection: 'column',
- alignItems: 'center',
- }}
+ />
+ </svg>
+ </>
+ ) : placement.indexOf('right') === 0 ? (
+ <>
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="6"
+ height="10"
+ viewBox="0 0 6 10"
+ style={{ fill: 'var(--affine-tooltip)' }}
>
- {content}
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="11"
- height="6"
- viewBox="0 0 11 6"
- fill="none"
- >
- <path
- d="M4.61111 5.55C5.05556 6.15 5.94445 6.15 6.38889 5.55L10.5 -4.76837e-07H0.5L4.61111 5.55Z"
- style={{ fill: 'var(--affine-tooltip)' }}
- />
- </svg>
- </div>
- )}
- </>
+ <path
+ d="M0.45 4.11111C-0.15 4.55556 -0.15 5.44445 0.45 5.88889L6 10V0L0.45 4.11111Z"
+ style={{ fill: 'var(--affine-tooltip)' }}
+ />
+ </svg>
+ {content}
+ </>
+ ) : (
+ <div
+ style={{
+ display: 'flex',
+ flexDirection: 'column',
+ alignItems: 'center',
+ }}
+ >
+ {content}
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="11"
+ height="6"
+ viewBox="0 0 11 6"
+ fill="none"
+ >
+ <path
+ d="M4.61111 5.55C5.05556 6.15 5.94445 6.15 6.38889 5.55L10.5 -4.76837e-07H0.5L4.61111 5.55Z"
+ style={{ fill: 'var(--affine-tooltip)' }}
+ />
+ </svg>
+ </div>
+ )
) : (
- <>{content}</>
+ content
)}
</div>
</Grow>
diff --git a/packages/frontend/component/src/ui/tree-view/tree-node-inner.tsx b/packages/frontend/component/src/ui/tree-view/tree-node-inner.tsx
index e3797956ec..ef24330083 100644
--- a/packages/frontend/component/src/ui/tree-view/tree-node-inner.tsx
+++ b/packages/frontend/component/src/ui/tree-view/tree-node-inner.tsx
@@ -76,17 +76,13 @@ export const TreeNodeItem = <RenderProps,>({
disableCollapse,
allowDrop = true,
}: TreeNodeItemProps<RenderProps>) => {
- return (
- <>
- {node.render?.(node, {
- isOver: isOver && allowDrop,
- onAdd: () => onAdd?.(node.id),
- onDelete: () => onDelete?.(node.id),
- collapsed,
- setCollapsed,
- isSelected: selectedId === node.id,
- disableCollapse,
- })}
- </>
- );
+ return node.render?.(node, {
+ isOver: isOver && allowDrop,
+ onAdd: () => onAdd?.(node.id),
+ onDelete: () => onDelete?.(node.id),
+ collapsed,
+ setCollapsed,
+ isSelected: selectedId === node.id,
+ disableCollapse,
+ });
};
diff --git a/packages/frontend/core/src/adapters/cloud/ui.tsx b/packages/frontend/core/src/adapters/cloud/ui.tsx
index 7c4f60dd59..f129c020eb 100644
--- a/packages/frontend/core/src/adapters/cloud/ui.tsx
+++ b/packages/frontend/core/src/adapters/cloud/ui.tsx
@@ -48,14 +48,12 @@ export const UI = {
);
return (
- <>
- <PageDetailEditor
- pageId={currentPageId}
- onInit={useCallback(async page => initEmptyPage(page), [])}
- onLoad={onLoad}
- workspace={workspace.blockSuiteWorkspace}
- />
- </>
+ <PageDetailEditor
+ pageId={currentPageId}
+ onInit={useCallback(async page => initEmptyPage(page), [])}
+ onLoad={onLoad}
+ workspace={workspace.blockSuiteWorkspace}
+ />
);
},
NewSettingsDetail: ({
diff --git a/packages/frontend/core/src/adapters/local/index.tsx b/packages/frontend/core/src/adapters/local/index.tsx
index ab334e57ed..ca87fb7ff8 100644
--- a/packages/frontend/core/src/adapters/local/index.tsx
+++ b/packages/frontend/core/src/adapters/local/index.tsx
@@ -92,14 +92,12 @@ export const LocalAdapter: WorkspaceAdapter<WorkspaceFlavour.LOCAL> = {
throw new PageNotFoundError(workspace, currentPageId);
}
return (
- <>
- <PageDetailEditor
- pageId={currentPageId}
- onInit={useCallback(async page => initEmptyPage(page), [])}
- onLoad={onLoadEditor}
- workspace={workspace}
- />
- </>
+ <PageDetailEditor
+ pageId={currentPageId}
+ onInit={useCallback(async page => initEmptyPage(page), [])}
+ onLoad={onLoadEditor}
+ workspace={workspace}
+ />
);
},
NewSettingsDetail: ({
diff --git a/packages/frontend/core/src/adapters/public-cloud/ui.tsx b/packages/frontend/core/src/adapters/public-cloud/ui.tsx
index f8d6b9b459..4d32298cec 100644
--- a/packages/frontend/core/src/adapters/public-cloud/ui.tsx
+++ b/packages/frontend/core/src/adapters/public-cloud/ui.tsx
@@ -16,14 +16,12 @@ export const UI = {
throw new PageNotFoundError(workspace.blockSuiteWorkspace, currentPageId);
}
return (
- <>
- <PageDetailEditor
- pageId={currentPageId}
- onInit={useCallback(async page => initEmptyPage(page), [])}
- onLoad={onLoadEditor}
- workspace={workspace.blockSuiteWorkspace}
- />
- </>
+ <PageDetailEditor
+ pageId={currentPageId}
+ onInit={useCallback(async page => initEmptyPage(page), [])}
+ onLoad={onLoadEditor}
+ workspace={workspace.blockSuiteWorkspace}
+ />
);
},
NewSettingsDetail: () => {
diff --git a/packages/frontend/core/src/components/affine/auth/use-captcha.tsx b/packages/frontend/core/src/components/affine/auth/use-captcha.tsx
index e00ce53259..28a7649015 100644
--- a/packages/frontend/core/src/components/affine/auth/use-captcha.tsx
+++ b/packages/frontend/core/src/components/affine/auth/use-captcha.tsx
@@ -43,7 +43,7 @@ export const Captcha = () => {
const [response] = useAtom(responseAtom);
if (!runtimeConfig.enableCaptcha) {
- return <></>;
+ return null;
}
if (environment.isDesktop) {
diff --git a/packages/frontend/core/src/components/affine/auth/user-plan-button.tsx b/packages/frontend/core/src/components/affine/auth/user-plan-button.tsx
index b9b9ab1f16..aa0b417c6f 100644
--- a/packages/frontend/core/src/components/affine/auth/user-plan-button.tsx
+++ b/packages/frontend/core/src/components/affine/auth/user-plan-button.tsx
@@ -2,7 +2,7 @@ import { SubscriptionPlan } from '@affine/graphql';
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import Tooltip from '@toeverything/components/tooltip';
import { useSetAtom } from 'jotai';
-import React, { useCallback } from 'react';
+import { useCallback } from 'react';
import { withErrorBoundary } from 'react-error-boundary';
import { openSettingModalAtom } from '../../../atoms';
@@ -39,5 +39,5 @@ const UserPlanButtonWithData = () => {
// If fetch user data failed, just render empty.
export const UserPlanButton = withErrorBoundary(UserPlanButtonWithData, {
- fallbackRender: () => <React.Fragment />,
+ fallbackRender: () => null,
});
diff --git a/packages/frontend/core/src/components/affine/new-workspace-setting-detail/export.tsx b/packages/frontend/core/src/components/affine/new-workspace-setting-detail/export.tsx
index 0a659d7c44..79e92c9047 100644
--- a/packages/frontend/core/src/components/affine/new-workspace-setting-detail/export.tsx
+++ b/packages/frontend/core/src/components/affine/new-workspace-setting-detail/export.tsx
@@ -86,16 +86,14 @@ export const ExportPanel = ({ workspace }: ExportPanelProps) => {
}, [pushNotification, syncing, t, workspace, workspaceId]);
return (
- <>
- <SettingRow name={t['Export']()} desc={t['Export Description']()}>
- <Button
- data-testid="export-affine-backup"
- onClick={onExport}
- disabled={syncing}
- >
- {t['Export']()}
- </Button>
- </SettingRow>
- </>
+ <SettingRow name={t['Export']()} desc={t['Export Description']()}>
+ <Button
+ data-testid="export-affine-backup"
+ onClick={onExport}
+ disabled={syncing}
+ >
+ {t['Export']()}
+ </Button>
+ </SettingRow>
);
};
diff --git a/packages/frontend/core/src/components/affine/setting-modal/account-setting/index.tsx b/packages/frontend/core/src/components/affine/setting-modal/account-setting/index.tsx
index ed4321a27e..3f887cdefb 100644
--- a/packages/frontend/core/src/components/affine/setting-modal/account-setting/index.tsx
+++ b/packages/frontend/core/src/components/affine/setting-modal/account-setting/index.tsx
@@ -121,48 +121,46 @@ export const AvatarAndName = () => {
}, [allowUpdate, input, user]);
return (
- <>
- <SettingRow
- name={t['com.affine.settings.profile']()}
- desc={t['com.affine.settings.profile.message']()}
- spreadCol={false}
- >
- <FlexWrapper style={{ margin: '12px 0 24px 0' }} alignItems="center">
- <Suspense>
- <UserAvatar />
- </Suspense>
+ <SettingRow
+ name={t['com.affine.settings.profile']()}
+ desc={t['com.affine.settings.profile.message']()}
+ spreadCol={false}
+ >
+ <FlexWrapper style={{ margin: '12px 0 24px 0' }} alignItems="center">
+ <Suspense>
+ <UserAvatar />
+ </Suspense>
- <div className={style.profileInputWrapper}>
- <label>{t['com.affine.settings.profile.name']()}</label>
- <FlexWrapper alignItems="center">
- <Input
- defaultValue={input}
- data-testid="user-name-input"
- placeholder={t['com.affine.settings.profile.placeholder']()}
- maxLength={64}
- minLength={0}
- width={280}
- height={28}
- onChange={setInput}
- onEnter={handleUpdateUserName}
- />
- {allowUpdate ? (
- <Button
- data-testid="save-user-name"
- onClick={handleUpdateUserName}
- className={style.button}
- style={{
- marginLeft: '12px',
- }}
- >
- {t['com.affine.editCollection.save']()}
- </Button>
- ) : null}
- </FlexWrapper>
- </div>
- </FlexWrapper>
- </SettingRow>
- </>
+ <div className={style.profileInputWrapper}>
+ <label>{t['com.affine.settings.profile.name']()}</label>
+ <FlexWrapper alignItems="center">
+ <Input
+ defaultValue={input}
+ data-testid="user-name-input"
+ placeholder={t['com.affine.settings.profile.placeholder']()}
+ maxLength={64}
+ minLength={0}
+ width={280}
+ height={28}
+ onChange={setInput}
+ onEnter={handleUpdateUserName}
+ />
+ {allowUpdate ? (
+ <Button
+ data-testid="save-user-name"
+ onClick={handleUpdateUserName}
+ className={style.button}
+ style={{
+ marginLeft: '12px',
+ }}
+ >
+ {t['com.affine.editCollection.save']()}
+ </Button>
+ ) : null}
+ </FlexWrapper>
+ </div>
+ </FlexWrapper>
+ </SettingRow>
);
};
diff --git a/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/index.tsx b/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/index.tsx
index 724d4f0fbd..c7cda5e661 100644
--- a/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/index.tsx
+++ b/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/index.tsx
@@ -9,7 +9,7 @@ import { Trans } from '@affine/i18n';
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { useQuery } from '@affine/workspace/affine/gql';
import { useSetAtom } from 'jotai';
-import React, { Suspense, useEffect, useRef, useState } from 'react';
+import { Suspense, useEffect, useRef, useState } from 'react';
import type { FallbackProps } from 'react-error-boundary';
import { SWRErrorBoundary } from '../../../../../components/pure/swr-error-bundary';
@@ -205,9 +205,9 @@ const PlansErrorBoundary = ({ resetErrorBoundary }: FallbackProps) => {
const t = useAFFiNEI18N();
const title = t['com.affine.payment.title']();
- const subtitle = <React.Fragment />;
- const tabs = <React.Fragment />;
- const footer = <React.Fragment />;
+ const subtitle = '';
+ const tabs = '';
+ const footer = '';
const scroll = (
<div className={styles.errorTip}>
diff --git a/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/plan-card.tsx b/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/plan-card.tsx
index 359aeb3da5..98dbc7ced6 100644
--- a/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/plan-card.tsx
+++ b/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/plan-card.tsx
@@ -406,17 +406,15 @@ const Upgrade = ({
}, [onClose]);
return (
- <>
- <Button
- className={styles.planAction}
- type="primary"
- onClick={upgrade}
- disabled={isMutating}
- loading={isMutating}
- >
- {t['com.affine.payment.upgrade']()}
- </Button>
- </>
+ <Button
+ className={styles.planAction}
+ type="primary"
+ onClick={upgrade}
+ disabled={isMutating}
+ loading={isMutating}
+ >
+ {t['com.affine.payment.upgrade']()}
+ </Button>
);
};
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-header-title/operation-menu.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-header-title/operation-menu.tsx
index 1cd2e671ad..4a5976724f 100644
--- a/packages/frontend/core/src/components/blocksuite/block-suite-header-title/operation-menu.tsx
+++ b/packages/frontend/core/src/components/blocksuite/block-suite-header-title/operation-menu.tsx
@@ -218,17 +218,15 @@ export const PageMenu = ({ rename, pageId }: PageMenuProps) => {
return null;
}
return (
- <>
- <FlexWrapper alignItems="center" justifyContent="center" ref={ref}>
- <Menu
- items={EditMenu}
- contentOptions={{
- align: 'center',
- }}
- >
- <HeaderDropDownButton />
- </Menu>
- </FlexWrapper>
- </>
+ <FlexWrapper alignItems="center" justifyContent="center" ref={ref}>
+ <Menu
+ items={EditMenu}
+ contentOptions={{
+ align: 'center',
+ }}
+ >
+ <HeaderDropDownButton />
+ </Menu>
+ </FlexWrapper>
);
};
diff --git a/packages/frontend/core/src/components/cloud/provider.tsx b/packages/frontend/core/src/components/cloud/provider.tsx
index fe01c9ac36..6b9daf4d24 100644
--- a/packages/frontend/core/src/components/cloud/provider.tsx
+++ b/packages/frontend/core/src/components/cloud/provider.tsx
@@ -2,7 +2,7 @@ import { pushNotificationAtom } from '@affine/component/notification-center';
import { assertExists } from '@blocksuite/global/utils';
import { GraphQLError } from 'graphql';
import { useSetAtom } from 'jotai';
-import type { PropsWithChildren, ReactElement } from 'react';
+import type { PropsWithChildren, ReactNode } from 'react';
import { useCallback } from 'react';
import type { SWRConfiguration } from 'swr';
import { SWRConfig } from 'swr';
@@ -49,9 +49,9 @@ const cloudConfig: SWRConfiguration = {
],
};
-export const Provider = (props: PropsWithChildren): ReactElement => {
+export const Provider = (props: PropsWithChildren): ReactNode => {
if (!runtimeConfig.enableCloud) {
- return <>{props.children}</>;
+ return props.children;
}
return <SWRConfig value={cloudConfig}>{props.children}</SWRConfig>;
diff --git a/packages/frontend/core/src/components/page-detail-editor.tsx b/packages/frontend/core/src/components/page-detail-editor.tsx
index 4102327d6f..8050890d11 100644
--- a/packages/frontend/core/src/components/page-detail-editor.tsx
+++ b/packages/frontend/core/src/components/page-detail-editor.tsx
@@ -328,10 +328,8 @@ export const PageDetailEditor = (props: PageDetailEditorProps) => {
}
return (
- <>
- <Suspense>
- <LayoutPanel node={layout} editorProps={props} depth={0} />
- </Suspense>
- </>
+ <Suspense>
+ <LayoutPanel node={layout} editorProps={props} depth={0} />
+ </Suspense>
);
};
diff --git a/packages/frontend/core/src/components/pure/footer/index.tsx b/packages/frontend/core/src/components/pure/footer/index.tsx
index 83b0a84a5c..a8a0af8d0f 100644
--- a/packages/frontend/core/src/components/pure/footer/index.tsx
+++ b/packages/frontend/core/src/components/pure/footer/index.tsx
@@ -49,53 +49,49 @@ export const WorkspaceAvatar = forwardRef<HTMLDivElement, WorkspaceAvatarProps>(
const size = props.size || 20;
const sizeStr = size + 'px';
- return (
- <>
- {props.avatar ? (
- <div
- style={{
- ...props.style,
- width: sizeStr,
- height: sizeStr,
- color: '#fff',
- borderRadius: '50%',
- overflow: 'hidden',
- display: 'inline-block',
- verticalAlign: 'middle',
- }}
- ref={ref}
- >
- <picture>
- <img
- style={{ width: sizeStr, height: sizeStr }}
- src={props.avatar}
- alt=""
- referrerPolicy="no-referrer"
- />
- </picture>
- </div>
- ) : (
- <div
- style={{
- ...props.style,
- width: sizeStr,
- height: sizeStr,
- border: '1px solid #fff',
- color: '#fff',
- fontSize: Math.ceil(0.5 * size) + 'px',
- background: stringToColour(props.name || 'AFFiNE'),
- borderRadius: '50%',
- textAlign: 'center',
- lineHeight: size + 'px',
- display: 'inline-block',
- verticalAlign: 'middle',
- }}
- ref={ref}
- >
- {(props.name || 'AFFiNE').substring(0, 1)}
- </div>
- )}
- </>
+ return props.avatar ? (
+ <div
+ style={{
+ ...props.style,
+ width: sizeStr,
+ height: sizeStr,
+ color: '#fff',
+ borderRadius: '50%',
+ overflow: 'hidden',
+ display: 'inline-block',
+ verticalAlign: 'middle',
+ }}
+ ref={ref}
+ >
+ <picture>
+ <img
+ style={{ width: sizeStr, height: sizeStr }}
+ src={props.avatar}
+ alt=""
+ referrerPolicy="no-referrer"
+ />
+ </picture>
+ </div>
+ ) : (
+ <div
+ style={{
+ ...props.style,
+ width: sizeStr,
+ height: sizeStr,
+ border: '1px solid #fff',
+ color: '#fff',
+ fontSize: Math.ceil(0.5 * size) + 'px',
+ background: stringToColour(props.name || 'AFFiNE'),
+ borderRadius: '50%',
+ textAlign: 'center',
+ lineHeight: size + 'px',
+ display: 'inline-block',
+ verticalAlign: 'middle',
+ }}
+ ref={ref}
+ >
+ {(props.name || 'AFFiNE').substring(0, 1)}
+ </div>
);
}
);
diff --git a/packages/frontend/core/src/components/root-app-sidebar/index.tsx b/packages/frontend/core/src/components/root-app-sidebar/index.tsx
index a31c3a8899..1fd0d46d64 100644
--- a/packages/frontend/core/src/components/root-app-sidebar/index.tsx
+++ b/packages/frontend/core/src/components/root-app-sidebar/index.tsx
@@ -170,109 +170,105 @@ export const RootAppSidebar = ({
useRegisterBlocksuiteEditorCommands(router.back, router.forward);
const userInfo = useDeleteCollectionInfo();
return (
- <>
- <AppSidebar
- router={router}
- hasBackground={
- !(
- appSettings.enableBlurBackground &&
- environment.isDesktop &&
- environment.isMacOs
- )
- }
- generalShortcutsInfo={generalShortcutsInfo}
- >
- <MoveToTrash.ConfirmModal
- open={trashConfirmOpen}
- onConfirm={handleOnConfirm}
- onOpenChange={onTrashConfirmOpenChange}
- titles={deletePageTitles}
- />
- <SidebarContainer>
- <Menu
- rootOptions={{
- open: openUserWorkspaceList,
- }}
- items={
- <UserWithWorkspaceList onEventEnd={closeUserWorkspaceList} />
- }
- contentOptions={{
- // hide trigger
- sideOffset: -58,
- onInteractOutside: closeUserWorkspaceList,
- onEscapeKeyDown: closeUserWorkspaceList,
- style: {
- width: '300px',
- },
- }}
- >
- <WorkspaceCard
- currentWorkspace={currentWorkspace}
- onClick={useCallback(() => {
- setOpenUserWorkspaceList(true);
- }, [setOpenUserWorkspaceList])}
- />
- </Menu>
- <QuickSearchInput
- data-testid="slider-bar-quick-search-button"
- onClick={onOpenQuickSearchModal}
+ <AppSidebar
+ router={router}
+ hasBackground={
+ !(
+ appSettings.enableBlurBackground &&
+ environment.isDesktop &&
+ environment.isMacOs
+ )
+ }
+ generalShortcutsInfo={generalShortcutsInfo}
+ >
+ <MoveToTrash.ConfirmModal
+ open={trashConfirmOpen}
+ onConfirm={handleOnConfirm}
+ onOpenChange={onTrashConfirmOpenChange}
+ titles={deletePageTitles}
+ />
+ <SidebarContainer>
+ <Menu
+ rootOptions={{
+ open: openUserWorkspaceList,
+ }}
+ items={<UserWithWorkspaceList onEventEnd={closeUserWorkspaceList} />}
+ contentOptions={{
+ // hide trigger
+ sideOffset: -58,
+ onInteractOutside: closeUserWorkspaceList,
+ onEscapeKeyDown: closeUserWorkspaceList,
+ style: {
+ width: '300px',
+ },
+ }}
+ >
+ <WorkspaceCard
+ currentWorkspace={currentWorkspace}
+ onClick={useCallback(() => {
+ setOpenUserWorkspaceList(true);
+ }, [setOpenUserWorkspaceList])}
/>
- <RouteMenuLinkItem
- icon={<FolderIcon />}
- currentPath={currentPath}
- path={paths.all(currentWorkspaceId)}
- onClick={backToAll}
+ </Menu>
+ <QuickSearchInput
+ data-testid="slider-bar-quick-search-button"
+ onClick={onOpenQuickSearchModal}
+ />
+ <RouteMenuLinkItem
+ icon={<FolderIcon />}
+ currentPath={currentPath}
+ path={paths.all(currentWorkspaceId)}
+ onClick={backToAll}
+ >
+ <span data-testid="all-pages">
+ {t['com.affine.workspaceSubPath.all']()}
+ </span>
+ </RouteMenuLinkItem>
+ {runtimeConfig.enableNewSettingModal ? (
+ <MenuItem
+ data-testid="slider-bar-workspace-setting-button"
+ icon={<SettingsIcon />}
+ onClick={onOpenSettingModal}
>
- <span data-testid="all-pages">
- {t['com.affine.workspaceSubPath.all']()}
+ <span data-testid="settings-modal-trigger">
+ {t['com.affine.settingSidebar.title']()}
</span>
- </RouteMenuLinkItem>
- {runtimeConfig.enableNewSettingModal ? (
- <MenuItem
- data-testid="slider-bar-workspace-setting-button"
- icon={<SettingsIcon />}
- onClick={onOpenSettingModal}
- >
- <span data-testid="settings-modal-trigger">
- {t['com.affine.settingSidebar.title']()}
- </span>
- </MenuItem>
- ) : null}
- </SidebarContainer>
+ </MenuItem>
+ ) : null}
+ </SidebarContainer>
- <SidebarScrollableContainer>
- <CategoryDivider label={t['com.affine.rootAppSidebar.favorites']()}>
- <AddFavouriteButton workspace={blockSuiteWorkspace} />
- </CategoryDivider>
- <FavoriteList workspace={blockSuiteWorkspace} />
- <CategoryDivider label={t['com.affine.rootAppSidebar.collections']()}>
- <AddCollectionButton />
- </CategoryDivider>
- <CollectionsList workspace={blockSuiteWorkspace} info={userInfo} />
- <CategoryDivider label={t['com.affine.rootAppSidebar.others']()} />
- {/* fixme: remove the following spacer */}
- <div style={{ height: '4px' }} />
- <RouteMenuLinkItem
- ref={trashDroppable.setNodeRef}
- isDraggedOver={trashDroppable.isOver}
- icon={<AnimatedDeleteIcon closed={trashDroppable.isOver} />}
- currentPath={currentPath}
- path={paths.trash(currentWorkspaceId)}
- >
- <span data-testid="trash-page">
- {t['com.affine.workspaceSubPath.trash']()}
- </span>
- </RouteMenuLinkItem>
- {blockSuiteWorkspace && (
- <ImportPage blocksuiteWorkspace={blockSuiteWorkspace} />
- )}
- </SidebarScrollableContainer>
- <SidebarContainer>
- {environment.isDesktop && <AppUpdaterButton />}
- <div style={{ height: '4px' }} />
- <AddPageButton onClick={onClickNewPage} />
- </SidebarContainer>
- </AppSidebar>
- </>
+ <SidebarScrollableContainer>
+ <CategoryDivider label={t['com.affine.rootAppSidebar.favorites']()}>
+ <AddFavouriteButton workspace={blockSuiteWorkspace} />
+ </CategoryDivider>
+ <FavoriteList workspace={blockSuiteWorkspace} />
+ <CategoryDivider label={t['com.affine.rootAppSidebar.collections']()}>
+ <AddCollectionButton />
+ </CategoryDivider>
+ <CollectionsList workspace={blockSuiteWorkspace} info={userInfo} />
+ <CategoryDivider label={t['com.affine.rootAppSidebar.others']()} />
+ {/* fixme: remove the following spacer */}
+ <div style={{ height: '4px' }} />
+ <RouteMenuLinkItem
+ ref={trashDroppable.setNodeRef}
+ isDraggedOver={trashDroppable.isOver}
+ icon={<AnimatedDeleteIcon closed={trashDroppable.isOver} />}
+ currentPath={currentPath}
+ path={paths.trash(currentWorkspaceId)}
+ >
+ <span data-testid="trash-page">
+ {t['com.affine.workspaceSubPath.trash']()}
+ </span>
+ </RouteMenuLinkItem>
+ {blockSuiteWorkspace && (
+ <ImportPage blocksuiteWorkspace={blockSuiteWorkspace} />
+ )}
+ </SidebarScrollableContainer>
+ <SidebarContainer>
+ {environment.isDesktop && <AppUpdaterButton />}
+ <div style={{ height: '4px' }} />
+ <AddPageButton onClick={onClickNewPage} />
+ </SidebarContainer>
+ </AppSidebar>
);
};
diff --git a/packages/frontend/core/src/layouts/workspace-layout.tsx b/packages/frontend/core/src/layouts/workspace-layout.tsx
index a1686f89f0..34a48057cd 100644
--- a/packages/frontend/core/src/layouts/workspace-layout.tsx
+++ b/packages/frontend/core/src/layouts/workspace-layout.tsx
@@ -34,7 +34,7 @@ import { loadPage } from '@toeverything/hooks/use-block-suite-workspace-page';
import { currentWorkspaceIdAtom } from '@toeverything/infra/atom';
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
import { nanoid } from 'nanoid';
-import type { PropsWithChildren, ReactElement } from 'react';
+import type { PropsWithChildren, ReactNode } from 'react';
import { lazy, Suspense, useCallback, useEffect } from 'react';
import { useLocation, useParams } from 'react-router-dom';
import { Map as YMap } from 'yjs';
@@ -101,7 +101,7 @@ const showList: IslandItemNames[] = environment.isDesktop
export const CurrentWorkspaceContext = ({
children,
-}: PropsWithChildren): ReactElement => {
+}: PropsWithChildren): ReactNode => {
const workspaceId = useAtomValue(currentWorkspaceIdAtom);
const metadata = useAtomValue(rootWorkspacesMetadataAtom);
const exist = metadata.find(m => m.id === workspaceId);
@@ -114,7 +114,7 @@ export const CurrentWorkspaceContext = ({
if (!exist) {
return <WorkspaceFallback key="workspace-not-found" />;
}
- return <>{children}</>;
+ return children;
};
type WorkspaceLayoutProps = {
diff --git a/packages/frontend/core/src/pages/workspace/all-page.tsx b/packages/frontend/core/src/pages/workspace/all-page.tsx
index 8daf9e6093..7679202613 100644
--- a/packages/frontend/core/src/pages/workspace/all-page.tsx
+++ b/packages/frontend/core/src/pages/workspace/all-page.tsx
@@ -108,30 +108,28 @@ const usePageOperationsRenderer = () => {
});
};
return (
- <>
- <OperationCell
- favorite={!!page.favorite}
- isPublic={!!page.isPublic}
- onDisablePublicSharing={onDisablePublicSharing}
- link={`/workspace/${currentWorkspace.id}/${page.id}`}
- onRemoveToTrash={() =>
- setTrashModal({
- open: true,
- pageIds: [page.id],
- pageTitles: [page.title],
- })
- }
- onToggleFavoritePage={() => {
- const status = page.favorite;
- toggleFavorite(page.id);
- toast(
- status
- ? t['com.affine.toastMessage.removedFavorites']()
- : t['com.affine.toastMessage.addedFavorites']()
- );
- }}
- />
- </>
+ <OperationCell
+ favorite={!!page.favorite}
+ isPublic={!!page.isPublic}
+ onDisablePublicSharing={onDisablePublicSharing}
+ link={`/workspace/${currentWorkspace.id}/${page.id}`}
+ onRemoveToTrash={() =>
+ setTrashModal({
+ open: true,
+ pageIds: [page.id],
+ pageTitles: [page.title],
+ })
+ }
+ onToggleFavoritePage={() => {
+ const status = page.favorite;
+ toggleFavorite(page.id);
+ toast(
+ status
+ ? t['com.affine.toastMessage.removedFavorites']()
+ : t['com.affine.toastMessage.addedFavorites']()
+ );
+ }}
+ />
);
},
[currentWorkspace.id, setTrashModal, t, toggleFavorite]
diff --git a/packages/frontend/core/src/pages/workspace/trash-page.tsx b/packages/frontend/core/src/pages/workspace/trash-page.tsx
index 7e66cc7cd9..26345cc5aa 100644
--- a/packages/frontend/core/src/pages/workspace/trash-page.tsx
+++ b/packages/frontend/core/src/pages/workspace/trash-page.tsx
@@ -59,31 +59,29 @@ export const TrashPage = () => {
[permanentlyDeletePage, restoreFromTrash, t]
);
return (
- <>
- <div className={styles.root}>
- <WorkspaceHeader
- currentWorkspaceId={currentWorkspace.id}
- currentEntry={{
- subPath: WorkspaceSubPath.TRASH,
- }}
+ <div className={styles.root}>
+ <WorkspaceHeader
+ currentWorkspaceId={currentWorkspace.id}
+ currentEntry={{
+ subPath: WorkspaceSubPath.TRASH,
+ }}
+ />
+ {filteredPageMetas.length > 0 ? (
+ <VirtualizedPageList
+ pages={filteredPageMetas}
+ rowAsLink
+ groupBy={false}
+ isPreferredEdgeless={isPreferredEdgeless}
+ blockSuiteWorkspace={currentWorkspace.blockSuiteWorkspace}
+ pageOperationsRenderer={pageOperationsRenderer}
/>
- {filteredPageMetas.length > 0 ? (
- <VirtualizedPageList
- pages={filteredPageMetas}
- rowAsLink
- groupBy={false}
- isPreferredEdgeless={isPreferredEdgeless}
- blockSuiteWorkspace={currentWorkspace.blockSuiteWorkspace}
- pageOperationsRenderer={pageOperationsRenderer}
- />
- ) : (
- <EmptyPageList
- type="trash"
- blockSuiteWorkspace={currentWorkspace.blockSuiteWorkspace}
- />
- )}
- </div>
- </>
+ ) : (
+ <EmptyPageList
+ type="trash"
+ blockSuiteWorkspace={currentWorkspace.blockSuiteWorkspace}
+ />
+ )}
+ </div>
);
};
diff --git a/packages/frontend/workspace/src/affine/worker.ts b/packages/frontend/workspace/src/affine/worker.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/tests/storybook/src/stories/app-sidebar.stories.tsx b/tests/storybook/src/stories/app-sidebar.stories.tsx
index 88264b6195..c65e4e4218 100644
--- a/tests/storybook/src/stories/app-sidebar.stories.tsx
+++ b/tests/storybook/src/stories/app-sidebar.stories.tsx
@@ -53,12 +53,10 @@ const Main = () => {
export const Default: StoryFn = () => {
return (
- <>
- <Container>
- <AppSidebar />
- <Main />
- </Container>
- </>
+ <Container>
+ <AppSidebar />
+ <Main />
+ </Container>
);
};
diff --git a/tests/storybook/src/stories/quick-search/quick-search-modal.stories.tsx b/tests/storybook/src/stories/quick-search/quick-search-modal.stories.tsx
index 469760e95b..2b026b617d 100644
--- a/tests/storybook/src/stories/quick-search/quick-search-modal.stories.tsx
+++ b/tests/storybook/src/stories/quick-search/quick-search-modal.stories.tsx
@@ -28,10 +28,8 @@ export const CMDKModalStory: StoryFn = () => {
export const CMDKPanelStory: StoryFn = () => {
const [query, setQuery] = useState('');
return (
- <>
- <CMDKModal open>
- <CMDKContainer open query={query} onQueryChange={setQuery} />
- </CMDKModal>
- </>
+ <CMDKModal open>
+ <CMDKContainer open query={query} onQueryChange={setQuery} />
+ </CMDKModal>
);
};