From 2aa56cbccd76685b6d09b57fcc53a1f92ade0f01 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 24 May 2026 06:47:17 +0800 Subject: [PATCH] chore: bump toolchain & fix lint --- .../embed-github-block/embed-github-block.ts | 4 +-- .../src/embed-loom-block/embed-loom-block.ts | 4 +-- .../embed-youtube-block.ts | 12 ++----- .../blocks/image/src/image-edgeless-block.ts | 3 +- .../affine/gfx/mindmap/src/view/view.ts | 22 ++++++------- .../model-crud/get-selected-models.ts | 3 +- .../src/plugins/copilot/embedding/job.ts | 4 +-- .../common/infra/src/livedata/livedata.ts | 4 +-- .../common/y-octo/core/src/doc/codec/item.rs | 2 ++ .../common/y-octo/core/src/doc/codec/refs.rs | 4 +-- .../common/y-octo/core/src/doc/common/somr.rs | 4 +-- .../common/y-octo/core/src/doc/history.rs | 4 +-- .../common/y-octo/core/src/doc/types/text.rs | 12 ++----- .../component/src/ui/avatar/avatar.tsx | 33 +++++++++++-------- .../frontend/component/src/ui/input/input.tsx | 6 ++-- .../component/src/ui/input/row-input.tsx | 4 ++- .../component/src/ui/menu/desktop/root.tsx | 26 +++++++-------- .../component/src/ui/menu/desktop/sub.tsx | 15 ++++++--- .../component/src/ui/menu/mobile/root.tsx | 15 +++++---- .../component/src/ui/menu/mobile/sub.tsx | 10 ++++-- .../component/src/ui/popover/popover.tsx | 12 ++++--- .../ai-chat-composer/ai-chat-composer.ts | 9 ++--- .../blocksuite/ai/widgets/ai-panel/type.ts | 2 +- .../blocksuite/attachment-viewer/error.tsx | 7 ++-- .../components/page-list/docs/select-page.tsx | 4 ++- .../components/navigation-panel/tree/node.tsx | 6 ++-- .../components/navigation-panel/tree/root.tsx | 4 ++- .../plans/icons/bulled-list.tsx | 2 +- .../layouts/add-item-placeholder.tsx | 4 ++- .../components/navigation/tree/node.tsx | 6 ++-- .../components/navigation/tree/root.tsx | 4 ++- .../dialogs/setting/dropdown-select.tsx | 6 ++-- .../doc-database-backlink-info.tsx | 2 +- .../src/modules/quicksearch/views/cmdk.tsx | 4 ++- .../quicksearch/views/highlight-text.tsx | 2 +- packages/frontend/i18n/src/resources/index.ts | 2 +- packages/frontend/i18n/src/resources/tr.json | 2 +- .../media-capture-playground/server/encode.ts | 4 +-- .../e2e/utils/chat-panel-utils.ts | 8 ++--- 39 files changed, 151 insertions(+), 130 deletions(-) diff --git a/blocksuite/affine/blocks/embed/src/embed-github-block/embed-github-block.ts b/blocksuite/affine/blocks/embed/src/embed-github-block/embed-github-block.ts index 432385bdae..f57e25606b 100644 --- a/blocksuite/affine/blocks/embed/src/embed-github-block/embed-github-block.ts +++ b/blocksuite/affine/blocks/embed/src/embed-github-block/embed-github-block.ts @@ -117,7 +117,7 @@ export class EmbedGithubBlockComponent extends EmbedBlockComponent< override renderBlock() { const { - title = 'GitHub', + title, githubType, status, statusReason, @@ -139,7 +139,7 @@ export class EmbedGithubBlockComponent extends EmbedBlockComponent< ? getGithubStatusIcon(githubType, status, statusReason) : nothing; const statusText = loading ? '' : status; - const titleText = loading ? 'Loading...' : title; + const titleText = loading ? 'Loading...' : title || 'GitHub'; const descriptionText = loading ? '' : description; const bannerImage = !loading && image diff --git a/blocksuite/affine/blocks/embed/src/embed-loom-block/embed-loom-block.ts b/blocksuite/affine/blocks/embed/src/embed-loom-block/embed-loom-block.ts index 5cd1cf85fd..05502138cc 100644 --- a/blocksuite/affine/blocks/embed/src/embed-loom-block/embed-loom-block.ts +++ b/blocksuite/affine/blocks/embed/src/embed-loom-block/embed-loom-block.ts @@ -89,14 +89,14 @@ export class EmbedLoomBlockComponent extends EmbedBlockComponent< } override renderBlock() { - const { image, title = 'Loom', description, videoId } = this.model.props; + const { image, title, description, videoId } = this.model.props; const loading = this.loading; const theme = this.std.get(ThemeProvider).theme; const imageProxyService = this.store.get(ImageProxyService); const { EmbedCardBannerIcon } = getEmbedCardIcons(theme); const titleIcon = loading ? LoadingIcon() : LoomIcon; - const titleText = loading ? 'Loading...' : title; + const titleText = loading ? 'Loading...' : title || 'Loom'; const descriptionText = loading ? '' : description; const bannerImage = !loading && image diff --git a/blocksuite/affine/blocks/embed/src/embed-youtube-block/embed-youtube-block.ts b/blocksuite/affine/blocks/embed/src/embed-youtube-block/embed-youtube-block.ts index f3bf9bfec7..27d9567891 100644 --- a/blocksuite/affine/blocks/embed/src/embed-youtube-block/embed-youtube-block.ts +++ b/blocksuite/affine/blocks/embed/src/embed-youtube-block/embed-youtube-block.ts @@ -96,21 +96,15 @@ export class EmbedYoutubeBlockComponent extends EmbedBlockComponent< } override renderBlock() { - const { - image, - title = 'YouTube', - description, - creator, - creatorImage, - videoId, - } = this.model.props; + const { image, title, description, creator, creatorImage, videoId } = + this.model.props; const loading = this.loading; const theme = this.std.get(ThemeProvider).theme; const imageProxyService = this.store.get(ImageProxyService); const { EmbedCardBannerIcon } = getEmbedCardIcons(theme); const titleIcon = loading ? LoadingIcon() : YoutubeIcon; - const titleText = loading ? 'Loading...' : title; + const titleText = loading ? 'Loading...' : title || 'YouTube'; const descriptionText = loading ? null : description; const bannerImage = !loading && image diff --git a/blocksuite/affine/blocks/image/src/image-edgeless-block.ts b/blocksuite/affine/blocks/image/src/image-edgeless-block.ts index 74cdfc0016..140121841a 100644 --- a/blocksuite/affine/blocks/image/src/image-edgeless-block.ts +++ b/blocksuite/affine/blocks/image/src/image-edgeless-block.ts @@ -276,7 +276,8 @@ export class ImageEdgelessBlockComponent extends GfxBlockComponent { private _setLayoutMethod() { this.model.setLayoutMethod(function ( this: MindmapElementModel, - tree: MindmapNode | MindmapRoot = this.tree, - options: { - applyStyle?: boolean; - layoutType?: LayoutType; - stashed?: boolean; - } = { - applyStyle: true, - stashed: true, - } + tree: MindmapNode | MindmapRoot | undefined, + options: + | { + applyStyle?: boolean; + layoutType?: LayoutType; + stashed?: boolean; + } + | undefined ) { const { stashed, applyStyle, layoutType } = Object.assign( { @@ -137,9 +136,10 @@ export class MindMapView extends GfxElementModelView { }, options ); + const targetTree = tree ?? this.tree; - const pop = stashed ? this.stashTree(tree) : null; - handleLayout(this, tree, applyStyle, layoutType); + const pop = stashed ? this.stashTree(targetTree) : null; + handleLayout(this, targetTree, applyStyle, layoutType); pop?.(); }); } diff --git a/blocksuite/affine/shared/src/commands/model-crud/get-selected-models.ts b/blocksuite/affine/shared/src/commands/model-crud/get-selected-models.ts index e54353fbce..ff9db818ac 100644 --- a/blocksuite/affine/shared/src/commands/model-crud/get-selected-models.ts +++ b/blocksuite/affine/shared/src/commands/model-crud/get-selected-models.ts @@ -58,8 +58,7 @@ export const getSelectedModelsCommand: Command< ]) .pipe(getSelectedBlocksCommand, { types, mode }) .pipe(ctx => { - const { selectedBlocks = [] } = ctx; - selectedModels.push(...selectedBlocks.map(el => el.model)); + selectedModels.push(...ctx.selectedBlocks.map(el => el.model)); }) .run(); diff --git a/packages/backend/server/src/plugins/copilot/embedding/job.ts b/packages/backend/server/src/plugins/copilot/embedding/job.ts index 02e243f53e..4c9e2c74a3 100644 --- a/packages/backend/server/src/plugins/copilot/embedding/job.ts +++ b/packages/backend/server/src/plugins/copilot/embedding/job.ts @@ -374,10 +374,10 @@ export class CopilotEmbeddingJob { const docContent = await this.doc.getFullDocContent(workspaceId, docId); const authors = await this.models.doc.getAuthors(workspaceId, docId); if (docContent && authors) { - const { title = 'Untitled', summary } = docContent; + const { title, summary } = docContent; const { createdAt, updatedAt, createdByUser, updatedByUser } = authors; return { - title, + title: title || 'Untitled', summary, createdAt: createdAt.toDateString(), updatedAt: updatedAt.toDateString(), diff --git a/packages/common/infra/src/livedata/livedata.ts b/packages/common/infra/src/livedata/livedata.ts index febf4968bf..1575e2f456 100644 --- a/packages/common/infra/src/livedata/livedata.ts +++ b/packages/common/infra/src/livedata/livedata.ts @@ -255,9 +255,7 @@ export class LiveData constructor( initialValue: T, - upstream: - | ((upstream: Observable) => Observable) - | undefined = undefined + upstream?: (upstream: Observable) => Observable ) { super(); this.raw$ = new BehaviorSubject(initialValue); diff --git a/packages/common/y-octo/core/src/doc/codec/item.rs b/packages/common/y-octo/core/src/doc/codec/item.rs index 260a77e86b..6d192d6065 100644 --- a/packages/common/y-octo/core/src/doc/codec/item.rs +++ b/packages/common/y-octo/core/src/doc/codec/item.rs @@ -37,6 +37,8 @@ impl PartialEq for Item { } } +impl Eq for Item {} + impl std::fmt::Debug for Item { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut dbg = f.debug_struct("Item"); diff --git a/packages/common/y-octo/core/src/doc/codec/refs.rs b/packages/common/y-octo/core/src/doc/codec/refs.rs index c15b6b4c96..1ecd189155 100644 --- a/packages/common/y-octo/core/src/doc/codec/refs.rs +++ b/packages/common/y-octo/core/src/doc/codec/refs.rs @@ -44,9 +44,7 @@ impl PartialEq for Node { } } -impl Eq for Node { - fn assert_receiver_is_total_eq(&self) {} -} +impl Eq for Node {} impl From for Node { fn from(value: Item) -> Self { diff --git a/packages/common/y-octo/core/src/doc/common/somr.rs b/packages/common/y-octo/core/src/doc/common/somr.rs index 9b22d60650..6c79a49c0f 100644 --- a/packages/common/y-octo/core/src/doc/common/somr.rs +++ b/packages/common/y-octo/core/src/doc/common/somr.rs @@ -299,9 +299,7 @@ impl PartialEq for SomrInner { } } -impl Eq for Somr { - fn assert_receiver_is_total_eq(&self) {} -} +impl Eq for Somr {} impl PartialOrd for Somr { fn partial_cmp(&self, other: &Self) -> Option { diff --git a/packages/common/y-octo/core/src/doc/history.rs b/packages/common/y-octo/core/src/doc/history.rs index 44f52b504b..38b3ec54cd 100644 --- a/packages/common/y-octo/core/src/doc/history.rs +++ b/packages/common/y-octo/core/src/doc/history.rs @@ -64,7 +64,7 @@ impl StoreHistory { // make items as reference let mut store_items = store_items.iter().collect::>(); - store_items.sort_by(|a, b| a.id.clock.cmp(&b.id.clock)); + store_items.sort_by_key(|item| item.id.clock); self.parse_items(store_items) } @@ -126,7 +126,7 @@ impl StoreHistory { // make items as reference let mut store_items = store_items.iter().collect::>(); - store_items.sort_by(|a, b| a.id.clock.cmp(&b.id.clock)); + store_items.sort_by_key(|item| item.id.clock); self.parse_items(store_items) } diff --git a/packages/common/y-octo/core/src/doc/types/text.rs b/packages/common/y-octo/core/src/doc/types/text.rs index bfe37caede..b268eb80a1 100644 --- a/packages/common/y-octo/core/src/doc/types/text.rs +++ b/packages/common/y-octo/core/src/doc/types/text.rs @@ -266,11 +266,7 @@ fn advance_text_position(store: &mut DocStore, pos: &mut TextPosition, mut remai } fn minimize_attribute_changes(pos: &mut TextPosition, attrs: &TextAttributes) { - loop { - let Some(item) = pos.right.get() else { - break; - }; - + while let Some(item) = pos.right.get() { if item.deleted() { pos.forward(); continue; @@ -345,11 +341,7 @@ fn insert_negated_attributes( pos: &mut TextPosition, mut negated: TextAttributes, ) -> JwstCodecResult { - loop { - let Some(item) = pos.right.get() else { - break; - }; - + while let Some(item) = pos.right.get() { if item.deleted() { pos.forward(); continue; diff --git a/packages/frontend/component/src/ui/avatar/avatar.tsx b/packages/frontend/component/src/ui/avatar/avatar.tsx index 008626bfa6..deb6c68cf6 100644 --- a/packages/frontend/component/src/ui/avatar/avatar.tsx +++ b/packages/frontend/component/src/ui/avatar/avatar.tsx @@ -61,6 +61,11 @@ export type AvatarProps = { removeButtonProps?: HTMLAttributes; } & HTMLAttributes; +const EMPTY_STYLE: CSSProperties = {}; +const EMPTY_FALLBACK_PROPS: AvatarFallbackProps = {}; +const EMPTY_HOVER_WRAPPER_PROPS: HTMLAttributes = {}; +const EMPTY_REMOVE_BUTTON_PROPS: HTMLAttributes = {}; + function drawImageFit( img: ImageBitmap, ctx: CanvasRenderingContext2D, @@ -88,32 +93,32 @@ export const Avatar = forwardRef( ( { size = 20, - style: propsStyles = {}, + style: propsStyles = EMPTY_STYLE, url, image, name, className, colorfulFallback = false, hoverIcon, - fallbackProps: { className: fallbackClassName, ...fallbackProps } = {}, + fallbackProps = EMPTY_FALLBACK_PROPS, imageProps, avatarProps, rounded = '50%', onRemove, - hoverWrapperProps: { - className: hoverWrapperClassName, - ...hoverWrapperProps - } = {}, + hoverWrapperProps = EMPTY_HOVER_WRAPPER_PROPS, avatarTooltipOptions, removeTooltipOptions, - removeButtonProps: { - className: removeButtonClassName, - ...removeButtonProps - } = {}, + removeButtonProps = EMPTY_REMOVE_BUTTON_PROPS, ...props }, ref ) => { + const { className: fallbackClassName, ...otherFallbackProps } = + fallbackProps; + const { className: hoverWrapperClassName, ...otherHoverWrapperProps } = + hoverWrapperProps; + const { className: removeButtonClassName, ...otherRemoveButtonProps } = + removeButtonProps; const firstCharOfName = useMemo(() => { return name?.slice(0, 1); }, [name]); @@ -180,7 +185,7 @@ export const Avatar = forwardRef( {colorfulFallback ? ( @@ -196,7 +201,7 @@ export const Avatar = forwardRef( fallbackClassName )} delayMs={url ? 600 : undefined} - {...fallbackProps} + {...otherFallbackProps} > @@ -204,7 +209,7 @@ export const Avatar = forwardRef( {hoverIcon ? (
{hoverIcon}
@@ -223,7 +228,7 @@ export const Avatar = forwardRef( className={clsx(style.removeButton, removeButtonClassName)} onClick={onRemove} ref={setRemoveButtonDom} - {...removeButtonProps} + {...otherRemoveButtonProps} > diff --git a/packages/frontend/component/src/ui/input/input.tsx b/packages/frontend/component/src/ui/input/input.tsx index d1af0ae38f..a1340d65fc 100644 --- a/packages/frontend/component/src/ui/input/input.tsx +++ b/packages/frontend/component/src/ui/input/input.tsx @@ -27,6 +27,8 @@ export type InputProps = { onEnter?: (value: string) => void; } & Omit, 'onChange' | 'size' | 'onBlur'>; +const EMPTY_STYLE: CSSProperties = {}; + export const Input = forwardRef(function Input( { disabled, @@ -34,8 +36,8 @@ export const Input = forwardRef(function Input( noBorder = false, className, status = 'default', - style = {}, - inputStyle = {}, + style = EMPTY_STYLE, + inputStyle = EMPTY_STYLE, size = 'default', preFix, endFix, diff --git a/packages/frontend/component/src/ui/input/row-input.tsx b/packages/frontend/component/src/ui/input/row-input.tsx index c73104ae37..9990fb28af 100644 --- a/packages/frontend/component/src/ui/input/row-input.tsx +++ b/packages/frontend/component/src/ui/input/row-input.tsx @@ -25,6 +25,8 @@ export type RowInputProps = { debounce?: number; } & Omit, 'onChange' | 'size' | 'onBlur'>; +const EMPTY_STYLE: CSSProperties = {}; + // RowInput component that is used in the selector layout for search input // handles composition events and enter key press export const RowInput = forwardRef( @@ -33,7 +35,7 @@ export const RowInput = forwardRef( disabled, onChange: propsOnChange, className, - style = {}, + style = EMPTY_STYLE, onEnter, onKeyDown, onBlur, diff --git a/packages/frontend/component/src/ui/menu/desktop/root.tsx b/packages/frontend/component/src/ui/menu/desktop/root.tsx index 5968e69c70..2d1721ea6a 100644 --- a/packages/frontend/component/src/ui/menu/desktop/root.tsx +++ b/packages/frontend/component/src/ui/menu/desktop/root.tsx @@ -11,26 +11,26 @@ const MenuContextValue = { type: 'dropdown-menu', } as const; +const EMPTY_ROOT_OPTIONS: NonNullable = {}; +const EMPTY_CONTENT_OPTIONS: NonNullable = {}; +const EMPTY_CONTENT_STYLE: React.CSSProperties = {}; + export const DesktopMenu = ({ children, items, noPortal, portalOptions, - rootOptions: { - defaultOpen, - modal, - open, - onOpenChange, - onClose, - ...rootOptions - } = {}, - contentOptions: { - className = '', - style: contentStyle = {}, - ...otherContentOptions - } = {}, + rootOptions: rawRootOptions, + contentOptions: rawContentOptions, ref, }: MenuProps) => { + const { defaultOpen, modal, open, onOpenChange, onClose, ...rootOptions } = + rawRootOptions ?? EMPTY_ROOT_OPTIONS; + const { + className = '', + style: contentStyle = EMPTY_CONTENT_STYLE, + ...otherContentOptions + } = rawContentOptions ?? EMPTY_CONTENT_OPTIONS; const [innerOpen, setInnerOpen] = useState(defaultOpen); const finalOpen = open ?? innerOpen; diff --git a/packages/frontend/component/src/ui/menu/desktop/sub.tsx b/packages/frontend/component/src/ui/menu/desktop/sub.tsx index 7a7dc0c8ed..c875d4c5ec 100644 --- a/packages/frontend/component/src/ui/menu/desktop/sub.tsx +++ b/packages/frontend/component/src/ui/menu/desktop/sub.tsx @@ -9,18 +9,25 @@ import * as styles from '../styles.css'; import { useMenuItem } from '../use-menu-item'; import { DesktopMenuContext } from './context'; +const EMPTY_SUB_OPTIONS: NonNullable = {}; +const EMPTY_SUB_CONTENT_OPTIONS: NonNullable< + MenuSubProps['subContentOptions'] +> = {}; + export const DesktopMenuSub = ({ children: propsChildren, items, portalOptions, - subOptions: { defaultOpen, ...otherSubOptions } = {}, + subOptions, triggerOptions, - subContentOptions: { + subContentOptions, +}: MenuSubProps) => { + const { defaultOpen, ...otherSubOptions } = subOptions ?? EMPTY_SUB_OPTIONS; + const { className: subContentClassName = '', style: contentStyle, ...otherSubContentOptions - } = {}, -}: MenuSubProps) => { + } = subContentOptions ?? EMPTY_SUB_CONTENT_OPTIONS; const { type } = useContext(DesktopMenuContext); const { className, children, otherProps } = useMenuItem({ children: propsChildren, diff --git a/packages/frontend/component/src/ui/menu/mobile/root.tsx b/packages/frontend/component/src/ui/menu/mobile/root.tsx index 6d86e6aa24..668e108731 100644 --- a/packages/frontend/component/src/ui/menu/mobile/root.tsx +++ b/packages/frontend/component/src/ui/menu/mobile/root.tsx @@ -24,11 +24,18 @@ import { import * as styles from './styles.css'; import { MobileMenuSubRaw } from './sub'; +const EMPTY_CONTENT_OPTIONS: NonNullable = {}; + export const MobileMenu = ({ children, items, title, - contentOptions: { + contentOptions, + contentWrapperStyle, + rootOptions, + ref, +}: MenuProps) => { + const { className, onPointerDownOutside, onInteractOutside, @@ -38,11 +45,7 @@ export const MobileMenu = ({ align: _align, ...otherContentOptions - } = {}, - contentWrapperStyle, - rootOptions, - ref, -}: MenuProps) => { + } = contentOptions ?? EMPTY_CONTENT_OPTIONS; const [subMenus, setSubMenus] = useState([]); const [open, setOpen] = useState(false); const mobileContextValue = useMemo( diff --git a/packages/frontend/component/src/ui/menu/mobile/sub.tsx b/packages/frontend/component/src/ui/menu/mobile/sub.tsx index 30c1a26485..792091ed63 100644 --- a/packages/frontend/component/src/ui/menu/mobile/sub.tsx +++ b/packages/frontend/component/src/ui/menu/mobile/sub.tsx @@ -6,13 +6,18 @@ import type { MenuSubProps } from '../menu.types'; import { useMenuItem } from '../use-menu-item'; import { useMobileSubMenuHelper } from './context'; +const EMPTY_SUB_CONTENT_OPTIONS: NonNullable< + MenuSubProps['subContentOptions'] +> = {}; + export const MobileMenuSub = ({ title, children: propsChildren, items, triggerOptions, - subContentOptions: contentOptions = {}, + subContentOptions, }: MenuSubProps & { title?: string }) => { + const contentOptions = subContentOptions ?? EMPTY_SUB_CONTENT_OPTIONS; const { className, children, @@ -43,11 +48,12 @@ export const MobileMenuSubRaw = ({ children, items, subOptions, - subContentOptions: contentOptions = {}, + subContentOptions, }: MenuSubProps & { onClick?: (e: MouseEvent) => void; title?: string; }) => { + const contentOptions = subContentOptions ?? EMPTY_SUB_CONTENT_OPTIONS; const id = useId(); const { addSubMenu } = useMobileSubMenuHelper(); diff --git a/packages/frontend/component/src/ui/popover/popover.tsx b/packages/frontend/component/src/ui/popover/popover.tsx index 1f5c794fa7..1370056aa2 100644 --- a/packages/frontend/component/src/ui/popover/popover.tsx +++ b/packages/frontend/component/src/ui/popover/popover.tsx @@ -15,17 +15,21 @@ export interface PopoverProps extends PopoverPrimitiveProps { portalOptions?: PopoverPortalProps; contentOptions?: PopoverContentProps; } + +const EMPTY_CONTENT_OPTIONS: NonNullable = {}; + export const Popover = ({ content, children, portalOptions, - contentOptions: { + contentOptions, + ...props +}: PopoverProps) => { + const { className: contentClassName, style: contentStyle, ...otherContentOptions - } = {}, - ...props -}: PopoverProps) => { + } = contentOptions ?? EMPTY_CONTENT_OPTIONS; return ( {children} diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts index 3508c9b09d..3680ac949c 100644 --- a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts +++ b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts @@ -428,13 +428,8 @@ export class AIChatComposer extends SignalWatcher( }; private readonly addSelectedContextChip = async () => { - const { - attachments = [], - snapshot, - combinedElementsMarkdown, - docs = [], - html, - } = this.chatContextValue; + const { attachments, snapshot, combinedElementsMarkdown, docs, html } = + this.chatContextValue; await this.removeSelectedContextChip(); const chip: SelectedContextChip = { uuid: uuidv4(), diff --git a/packages/frontend/core/src/blocksuite/ai/widgets/ai-panel/type.ts b/packages/frontend/core/src/blocksuite/ai/widgets/ai-panel/type.ts index 08d5a64cdf..0a7640ce57 100644 --- a/packages/frontend/core/src/blocksuite/ai/widgets/ai-panel/type.ts +++ b/packages/frontend/core/src/blocksuite/ai/widgets/ai-panel/type.ts @@ -23,7 +23,7 @@ export interface AIPanelErrorConfig { } export interface AIPanelGeneratingConfig { - generatingIcon: TemplateResult<1>; + generatingIcon?: TemplateResult<1>; height?: number; stages?: string[]; } diff --git a/packages/frontend/core/src/blocksuite/attachment-viewer/error.tsx b/packages/frontend/core/src/blocksuite/attachment-viewer/error.tsx index a50000fad2..7f3f25e2a3 100644 --- a/packages/frontend/core/src/blocksuite/attachment-viewer/error.tsx +++ b/packages/frontend/core/src/blocksuite/attachment-viewer/error.tsx @@ -67,11 +67,14 @@ interface ErrorBaseProps { buttons?: ReactElement[]; } +const DEFAULT_ICON = ; +const EMPTY_BUTTONS: ReactElement[] = []; + const ErrorBase = ({ title, subtitle, - icon = , - buttons = [], + icon = DEFAULT_ICON, + buttons = EMPTY_BUTTONS, }: ErrorBaseProps) => { return (
diff --git a/packages/frontend/core/src/components/page-list/docs/select-page.tsx b/packages/frontend/core/src/components/page-list/docs/select-page.tsx index 6478ba083e..4d4e857265 100644 --- a/packages/frontend/core/src/components/page-list/docs/select-page.tsx +++ b/packages/frontend/core/src/components/page-list/docs/select-page.tsx @@ -20,8 +20,10 @@ import { AffineShapeIcon } from '..'; import { SelectorLayout } from '../selector/selector-layout'; import * as styles from './select-page.css'; +const EMPTY_INIT: string[] = []; + export const SelectPage = memo(function SelectPage({ - init = [], + init = EMPTY_INIT, onConfirm, onCancel, onChange: propsOnChange, diff --git a/packages/frontend/core/src/desktop/components/navigation-panel/tree/node.tsx b/packages/frontend/core/src/desktop/components/navigation-panel/tree/node.tsx index fdd2731d2e..077b47d328 100644 --- a/packages/frontend/core/src/desktop/components/navigation-panel/tree/node.tsx +++ b/packages/frontend/core/src/desktop/components/navigation-panel/tree/node.tsx @@ -48,6 +48,8 @@ import { DropEffect } from './drop-effect'; import * as styles from './node.css'; import type { NodeOperation } from './types'; +const EMPTY_OPERATIONS: NodeOperation[] = []; + export type NavigationPanelTreeNodeDropEffectData = { source: { data: AffineDNDData['draggable'] }; treeInstruction: DropTargetTreeInstruction | null; @@ -190,9 +192,9 @@ export const NavigationPanelTreeNode = ({ collapsible = true, canDrop, reorderable = true, - operations = [], + operations = EMPTY_OPERATIONS, postfix, - childrenOperations = [], + childrenOperations = EMPTY_OPERATIONS, childrenPlaceholder, linkComponent: LinkComponent = WorkbenchLink, dndData, diff --git a/packages/frontend/core/src/desktop/components/navigation-panel/tree/root.tsx b/packages/frontend/core/src/desktop/components/navigation-panel/tree/root.tsx index 7dadabe2aa..c651293c55 100644 --- a/packages/frontend/core/src/desktop/components/navigation-panel/tree/root.tsx +++ b/packages/frontend/core/src/desktop/components/navigation-panel/tree/root.tsx @@ -4,9 +4,11 @@ import { NavigationPanelTreeContext } from './context'; import * as styles from './root.css'; import type { NodeOperation } from './types'; +const EMPTY_OPERATIONS: NodeOperation[] = []; + export const NavigationPanelTreeRoot = ({ children, - childrenOperations = [], + childrenOperations = EMPTY_OPERATIONS, placeholder, }: { children?: React.ReactNode; diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/plans/icons/bulled-list.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/plans/icons/bulled-list.tsx index edd3db03e9..c37f959a67 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/plans/icons/bulled-list.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/plans/icons/bulled-list.tsx @@ -1,4 +1,4 @@ -export function BulledListIcon({ color = 'currentColor' }: { color: string }) { +export function BulledListIcon({ color = 'currentColor' }: { color?: string }) { return ( icon?: React.ReactNode; } +const DEFAULT_ICON = ; + export const AddItemPlaceholder = ({ onClick, label = 'Add Item', - icon = , + icon = DEFAULT_ICON, className, ...attrs }: AddItemPlaceholderProps) => { diff --git a/packages/frontend/core/src/mobile/components/navigation/tree/node.tsx b/packages/frontend/core/src/mobile/components/navigation/tree/node.tsx index 24a85b7d42..c60e91504e 100644 --- a/packages/frontend/core/src/mobile/components/navigation/tree/node.tsx +++ b/packages/frontend/core/src/mobile/components/navigation/tree/node.tsx @@ -22,6 +22,8 @@ import * as styles from './node.css'; interface NavigationPanelTreeNodeProps extends BaseNavigationPanelTreeNodeProps {} +const EMPTY_OPERATIONS: BaseNavigationPanelTreeNodeProps['operations'] = []; + export const NavigationPanelTreeNode = ({ children, icon: Icon, @@ -33,9 +35,9 @@ export const NavigationPanelTreeNode = ({ collapsed, extractEmojiAsIcon, setCollapsed, - operations = [], + operations = EMPTY_OPERATIONS, postfix, - childrenOperations = [], + childrenOperations = EMPTY_OPERATIONS, childrenPlaceholder, linkComponent: LinkComponent = WorkbenchLink, ...otherProps diff --git a/packages/frontend/core/src/mobile/components/navigation/tree/root.tsx b/packages/frontend/core/src/mobile/components/navigation/tree/root.tsx index 4fe0020789..4838f37c6e 100644 --- a/packages/frontend/core/src/mobile/components/navigation/tree/root.tsx +++ b/packages/frontend/core/src/mobile/components/navigation/tree/root.tsx @@ -6,9 +6,11 @@ import { useMemo, useState } from 'react'; import * as styles from './root.css'; +const EMPTY_OPERATIONS: NodeOperation[] = []; + export const NavigationPanelTreeRoot = ({ children, - childrenOperations = [], + childrenOperations = EMPTY_OPERATIONS, placeholder, }: { children?: React.ReactNode; diff --git a/packages/frontend/core/src/mobile/dialogs/setting/dropdown-select.tsx b/packages/frontend/core/src/mobile/dialogs/setting/dropdown-select.tsx index d94ea530ad..c910557ff6 100644 --- a/packages/frontend/core/src/mobile/dialogs/setting/dropdown-select.tsx +++ b/packages/frontend/core/src/mobile/dialogs/setting/dropdown-select.tsx @@ -33,11 +33,13 @@ export interface SettingDropdownSelectProps< native?: boolean; } +const EMPTY_OPTIONS: DropdownItem[] = []; + export const SettingDropdownSelect = < V extends string = string, E extends boolean | undefined = true, >({ - options = [], + options = EMPTY_OPTIONS as DropdownItem[], value, emitValue = true, onChange, @@ -98,7 +100,7 @@ export const NativeSettingDropdownSelect = < V extends string = string, E extends boolean | undefined = true, >({ - options = [], + options = EMPTY_OPTIONS as DropdownItem[], value, emitValue = true, onChange, diff --git a/packages/frontend/core/src/modules/doc-info/views/database-properties/doc-database-backlink-info.tsx b/packages/frontend/core/src/modules/doc-info/views/database-properties/doc-database-backlink-info.tsx index 0972b59510..54eeebb8fb 100644 --- a/packages/frontend/core/src/modules/doc-info/views/database-properties/doc-database-backlink-info.tsx +++ b/packages/frontend/core/src/modules/doc-info/views/database-properties/doc-database-backlink-info.tsx @@ -85,7 +85,7 @@ const DatabaseBacklinkRow = ({ row$, onChange, }: { - defaultOpen: boolean; + defaultOpen?: boolean; row$: Observable; onChange?: ( row: DatabaseRow, diff --git a/packages/frontend/core/src/modules/quicksearch/views/cmdk.tsx b/packages/frontend/core/src/modules/quicksearch/views/cmdk.tsx index 57a5e037ce..fe448b0375 100644 --- a/packages/frontend/core/src/modules/quicksearch/views/cmdk.tsx +++ b/packages/frontend/core/src/modules/quicksearch/views/cmdk.tsx @@ -20,10 +20,12 @@ import { HighlightText } from './highlight-text'; type Groups = { group?: QuickSearchGroup; items: QuickSearchItem[] }[]; +const EMPTY_GROUPS: Groups = []; + export const CMDK = ({ className, query, - groups: newGroups = [], + groups: newGroups = EMPTY_GROUPS, error, inputLabel, placeholder, diff --git a/packages/frontend/core/src/modules/quicksearch/views/highlight-text.tsx b/packages/frontend/core/src/modules/quicksearch/views/highlight-text.tsx index e927162858..91a54f6ada 100644 --- a/packages/frontend/core/src/modules/quicksearch/views/highlight-text.tsx +++ b/packages/frontend/core/src/modules/quicksearch/views/highlight-text.tsx @@ -3,7 +3,7 @@ import { Fragment, useMemo } from 'react'; import * as styles from './highlight-text.css'; type HighlightProps = { - text: string; + text?: string; start: string; end: string; }; diff --git a/packages/frontend/i18n/src/resources/index.ts b/packages/frontend/i18n/src/resources/index.ts index 4380550acb..a5bd96e731 100644 --- a/packages/frontend/i18n/src/resources/index.ts +++ b/packages/frontend/i18n/src/resources/index.ts @@ -192,5 +192,5 @@ export const SUPPORTED_LANGUAGES: Record< originalName: 'Türkçe', flagEmoji: '🇹🇷', resource: () => import('./tr.json'), - } + }, }; diff --git a/packages/frontend/i18n/src/resources/tr.json b/packages/frontend/i18n/src/resources/tr.json index 36c4f07b80..0d709c54c4 100644 --- a/packages/frontend/i18n/src/resources/tr.json +++ b/packages/frontend/i18n/src/resources/tr.json @@ -1584,7 +1584,7 @@ "com.affine.settings.workspace.experimental-features.enable-mind-map-import.name": "Zihin Haritası İçe Aktarımı", "com.affine.settings.workspace.experimental-features.enable-mind-map-import.description": "Zihin haritasının içe aktarılmasını etkinleştirir.", "com.affine.settings.workspace.experimental-features.enable-block-meta.name": "Blok Metaverisi", - "com.affine.settings.workspace.experimental-features.enable-block-meta.description": "Etkinleştirildiğinde, tüm bloklar için oluşturulma zamanı, güncellenme zamanı ile oluşturan ve güncelleyen bilgileri gösterilir.", + "com.affine.settings.workspace.experimental-features.enable-block-meta.description": "Etkinleştirildiğinde, tüm bloklar için oluşturulma zamanı, güncellenme zamanı ile oluşturan ve güncelleyen bilgileri gösterilir.", "com.affine.settings.workspace.experimental-features.enable-callout.name": "Belirtme çizgisi", "com.affine.settings.workspace.experimental-features.enable-callout.description": "Sözleriniz öne çıksın. Bu aynı zamanda transkripsiyon bloğundaki belirtme çizgisini de içerir.", "com.affine.settings.workspace.experimental-features.enable-embed-iframe-block.name": "Iframe Bloğunu Göm", diff --git a/packages/frontend/media-capture-playground/server/encode.ts b/packages/frontend/media-capture-playground/server/encode.ts index 2fe401b4b0..00bc4f89c1 100644 --- a/packages/frontend/media-capture-playground/server/encode.ts +++ b/packages/frontend/media-capture-playground/server/encode.ts @@ -1,8 +1,8 @@ export function createWavBuffer( samples: Float32Array, options: { - sampleRate: number; - numChannels: number; + sampleRate?: number; + numChannels?: number; } ) { const { sampleRate = 44100, numChannels = 1 } = options; diff --git a/tests/affine-cloud-copilot/e2e/utils/chat-panel-utils.ts b/tests/affine-cloud-copilot/e2e/utils/chat-panel-utils.ts index f2f38f9bee..ed9aef8cb7 100644 --- a/tests/affine-cloud-copilot/e2e/utils/chat-panel-utils.ts +++ b/tests/affine-cloud-copilot/e2e/utils/chat-panel-utils.ts @@ -273,9 +273,7 @@ export class ChatPanelUtils { await expect(async () => { const states = await page .getByTestId('chat-panel-chip') - .evaluateAll(elements => - elements.map(el => el.getAttribute('data-state')) - ); + .evaluateAll(elements => elements.map(el => el.dataset.state)); expect(states.every(state => state === 'finished')).toBe(true); }).toPass({ timeout: 20000 }); @@ -283,9 +281,7 @@ export class ChatPanelUtils { await expect(async () => { const states = await page .getByTestId('chat-panel-chip') - .evaluateAll(elements => - elements.map(el => el.getAttribute('data-state')) - ); + .evaluateAll(elements => elements.map(el => el.dataset.state)); expect(states).toHaveLength(attachments.length); expect(states.every(state => state === 'finished')).toBe(true); }).toPass({ timeout: 20000 });