From 6fbc5c7fe41841e066eb756b35df7743303b0c3c Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Tue, 2 Jun 2026 21:40:47 -0300 Subject: [PATCH] refactor(gazzodown): remove ReactElement type annotations from functional components - Removed explicit return type annotations of ReactElement from multiple functional components across the codebase. - Updated components in Markup, PreviewMarkup, HeadingBlock, OrderedListBlock, ParagraphBlock, QuoteBlock, SpoilerBlock, TaskListBlock, UnorderedListBlock, CodeBlock, CodeElement, PreviewCodeBlock, PreviewCodeElement, ColorElement, PreviewColorElement, BoldSpan, ImageElement, InlineElements, ItalicSpan, LinkSpan, PlainSpan, PreviewInlineElements, SpoilerSpan, StrikeSpan, BigEmojiBlock, BigEmojiElement, Emoji, EmojiElement, EmojiRenderer, PreviewBigEmojiBlock, PreviewEmojiElement, KatexBlock, KatexElement, KatexErrorBoundary, PreviewKatexBlock, PreviewKatexElement, ChannelMentionElement, PreviewChannelMentionElement, PreviewUserMentionElement, UserMentionElement. --- packages/gazzodown/src/Markup.tsx | 3 +-- packages/gazzodown/src/PreviewMarkup.tsx | 3 +-- packages/gazzodown/src/blocks/HeadingBlock.tsx | 3 +-- packages/gazzodown/src/blocks/OrderedListBlock.tsx | 3 +-- packages/gazzodown/src/blocks/ParagraphBlock.tsx | 3 +-- packages/gazzodown/src/blocks/QuoteBlock.tsx | 3 +-- packages/gazzodown/src/blocks/SpoilerBlock.tsx | 4 ++-- packages/gazzodown/src/blocks/TaskListBlock.tsx | 5 ++--- packages/gazzodown/src/blocks/UnorderedListBlock.tsx | 3 +-- packages/gazzodown/src/code/CodeBlock.tsx | 3 +-- packages/gazzodown/src/code/CodeElement.tsx | 4 +--- packages/gazzodown/src/code/PreviewCodeBlock.tsx | 3 +-- packages/gazzodown/src/code/PreviewCodeElement.tsx | 4 +--- packages/gazzodown/src/colors/ColorElement.tsx | 3 +-- packages/gazzodown/src/colors/PreviewColorElement.tsx | 3 +-- packages/gazzodown/src/elements/BoldSpan.tsx | 5 ++--- packages/gazzodown/src/elements/ImageElement.tsx | 3 +-- packages/gazzodown/src/elements/InlineElements.tsx | 3 +-- packages/gazzodown/src/elements/ItalicSpan.tsx | 5 ++--- packages/gazzodown/src/elements/LinkSpan.tsx | 3 +-- packages/gazzodown/src/elements/PlainSpan.tsx | 3 +-- packages/gazzodown/src/elements/PreviewInlineElements.tsx | 3 +-- packages/gazzodown/src/elements/SpoilerSpan.tsx | 6 +++--- packages/gazzodown/src/elements/StrikeSpan.tsx | 5 ++--- packages/gazzodown/src/emoji/BigEmojiBlock.tsx | 3 +-- packages/gazzodown/src/emoji/BigEmojiElement.tsx | 3 +-- packages/gazzodown/src/emoji/Emoji.tsx | 3 +-- packages/gazzodown/src/emoji/EmojiElement.tsx | 3 +-- packages/gazzodown/src/emoji/EmojiRenderer.tsx | 3 +-- packages/gazzodown/src/emoji/PreviewBigEmojiBlock.tsx | 3 +-- packages/gazzodown/src/emoji/PreviewEmojiElement.tsx | 3 +-- packages/gazzodown/src/katex/KatexBlock.tsx | 3 +-- packages/gazzodown/src/katex/KatexElement.tsx | 3 +-- packages/gazzodown/src/katex/KatexErrorBoundary.tsx | 4 ++-- packages/gazzodown/src/katex/PreviewKatexBlock.tsx | 4 +--- packages/gazzodown/src/katex/PreviewKatexElement.tsx | 4 +--- packages/gazzodown/src/mentions/ChannelMentionElement.tsx | 3 +-- .../gazzodown/src/mentions/PreviewChannelMentionElement.tsx | 3 +-- .../gazzodown/src/mentions/PreviewUserMentionElement.tsx | 3 +-- packages/gazzodown/src/mentions/UserMentionElement.tsx | 3 +-- 40 files changed, 48 insertions(+), 89 deletions(-) diff --git a/packages/gazzodown/src/Markup.tsx b/packages/gazzodown/src/Markup.tsx index c4d3b82c4c997..a789c4beb136d 100644 --- a/packages/gazzodown/src/Markup.tsx +++ b/packages/gazzodown/src/Markup.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import { lazy, memo } from 'react'; import HeadingBlock from './blocks/HeadingBlock'; @@ -19,7 +18,7 @@ type MarkupProps = { tokens: MessageParser.Root; }; -const Markup = ({ tokens }: MarkupProps): ReactElement => ( +const Markup = ({ tokens }: MarkupProps) => ( <> {tokens.map((block, index) => { switch (block.type) { diff --git a/packages/gazzodown/src/PreviewMarkup.tsx b/packages/gazzodown/src/PreviewMarkup.tsx index 5a0805c9d9146..9ec62bfcbfa3f 100644 --- a/packages/gazzodown/src/PreviewMarkup.tsx +++ b/packages/gazzodown/src/PreviewMarkup.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import { memo } from 'react'; import PreviewCodeBlock from './code/PreviewCodeBlock'; @@ -15,7 +14,7 @@ type PreviewMarkupProps = { tokens: MessageParser.Root; }; -const PreviewMarkup = ({ tokens }: PreviewMarkupProps): ReactElement | null => { +const PreviewMarkup = ({ tokens }: PreviewMarkupProps) => { if (isOnlyBigEmojiBlock(tokens)) { return ; } diff --git a/packages/gazzodown/src/blocks/HeadingBlock.tsx b/packages/gazzodown/src/blocks/HeadingBlock.tsx index c507a01d83ba6..e6459c349385b 100644 --- a/packages/gazzodown/src/blocks/HeadingBlock.tsx +++ b/packages/gazzodown/src/blocks/HeadingBlock.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import InlineElements from '../elements/InlineElements'; @@ -8,7 +7,7 @@ type HeadingBlockProps = { level?: 1 | 2 | 3 | 4; }; -const HeadingBlock = ({ children = [], level = 1 }: HeadingBlockProps): ReactElement => { +const HeadingBlock = ({ children = [], level = 1 }: HeadingBlockProps) => { const HeadingTag = `h${level}` as const; return ( diff --git a/packages/gazzodown/src/blocks/OrderedListBlock.tsx b/packages/gazzodown/src/blocks/OrderedListBlock.tsx index 6c6fc2734e34b..5f616da0515a2 100644 --- a/packages/gazzodown/src/blocks/OrderedListBlock.tsx +++ b/packages/gazzodown/src/blocks/OrderedListBlock.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import InlineElements from '../elements/InlineElements'; @@ -7,7 +6,7 @@ type OrderedListBlockProps = { items: MessageParser.ListItem[]; }; -const OrderedListBlock = ({ items }: OrderedListBlockProps): ReactElement => ( +const OrderedListBlock = ({ items }: OrderedListBlockProps) => (
    {items.map(({ value, number }, index) => (
  1. diff --git a/packages/gazzodown/src/blocks/ParagraphBlock.tsx b/packages/gazzodown/src/blocks/ParagraphBlock.tsx index c8e578d2e2653..94197b202032a 100644 --- a/packages/gazzodown/src/blocks/ParagraphBlock.tsx +++ b/packages/gazzodown/src/blocks/ParagraphBlock.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import InlineElements from '../elements/InlineElements'; @@ -7,7 +6,7 @@ type ParagraphBlockProps = { children: MessageParser.Inlines[]; }; -const ParagraphBlock = ({ children }: ParagraphBlockProps): ReactElement => ( +const ParagraphBlock = ({ children }: ParagraphBlockProps) => (
    {children}
    diff --git a/packages/gazzodown/src/blocks/QuoteBlock.tsx b/packages/gazzodown/src/blocks/QuoteBlock.tsx index 4e56bbfe21535..85f25d9176fbb 100644 --- a/packages/gazzodown/src/blocks/QuoteBlock.tsx +++ b/packages/gazzodown/src/blocks/QuoteBlock.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import ParagraphBlock from './ParagraphBlock'; @@ -7,7 +6,7 @@ type QuoteBlockProps = { children: MessageParser.Paragraph[]; }; -const QuoteBlock = ({ children }: QuoteBlockProps): ReactElement => ( +const QuoteBlock = ({ children }: QuoteBlockProps) => (
    {children.map((paragraph, index) => ( {paragraph.value} diff --git a/packages/gazzodown/src/blocks/SpoilerBlock.tsx b/packages/gazzodown/src/blocks/SpoilerBlock.tsx index ab629b71f9920..6d13ccfb7c04d 100644 --- a/packages/gazzodown/src/blocks/SpoilerBlock.tsx +++ b/packages/gazzodown/src/blocks/SpoilerBlock.tsx @@ -1,5 +1,5 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { KeyboardEvent, ReactElement } from 'react'; +import type { KeyboardEvent } from 'react'; import { useCallback, useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -35,7 +35,7 @@ const srOnlyStyle = { width: 1, } as const; -const SpoilerBlock = ({ children }: SpoilerBlockProps): ReactElement => { +const SpoilerBlock = ({ children }: SpoilerBlockProps) => { const { t } = useTranslation(); const [revealed, setRevealed] = useState(false); diff --git a/packages/gazzodown/src/blocks/TaskListBlock.tsx b/packages/gazzodown/src/blocks/TaskListBlock.tsx index 8e1e67596d0d5..7d27aaa3621d2 100644 --- a/packages/gazzodown/src/blocks/TaskListBlock.tsx +++ b/packages/gazzodown/src/blocks/TaskListBlock.tsx @@ -1,6 +1,5 @@ import { CheckBox } from '@rocket.chat/fuselage'; import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import { useContext } from 'react'; import { MarkupInteractionContext } from '../MarkupInteractionContext'; @@ -10,7 +9,7 @@ type TaskListBlockProps = { tasks: MessageParser.Task[]; }; -const TaksListBlock = ({ tasks }: TaskListBlockProps): ReactElement => { +const TaskListBlock = ({ tasks }: TaskListBlockProps) => { const { onTaskChecked } = useContext(MarkupInteractionContext); return ( @@ -24,4 +23,4 @@ const TaksListBlock = ({ tasks }: TaskListBlockProps): ReactElement => { ); }; -export default TaksListBlock; +export default TaskListBlock; diff --git a/packages/gazzodown/src/blocks/UnorderedListBlock.tsx b/packages/gazzodown/src/blocks/UnorderedListBlock.tsx index 500e525011107..618fc9d1c1ea7 100644 --- a/packages/gazzodown/src/blocks/UnorderedListBlock.tsx +++ b/packages/gazzodown/src/blocks/UnorderedListBlock.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import InlineElements from '../elements/InlineElements'; @@ -7,7 +6,7 @@ type UnorderedListBlockProps = { items: MessageParser.ListItem[]; }; -const UnorderedListBlock = ({ items }: UnorderedListBlockProps): ReactElement => ( +const UnorderedListBlock = ({ items }: UnorderedListBlockProps) => (
      {items.map((item, index) => (
    • diff --git a/packages/gazzodown/src/code/CodeBlock.tsx b/packages/gazzodown/src/code/CodeBlock.tsx index 2852d701c2cfe..08295cba3046e 100644 --- a/packages/gazzodown/src/code/CodeBlock.tsx +++ b/packages/gazzodown/src/code/CodeBlock.tsx @@ -3,7 +3,6 @@ import { IconButton, Box } from '@rocket.chat/fuselage'; import type * as MessageParser from '@rocket.chat/message-parser'; import { useToastMessageDispatch } from '@rocket.chat/ui-contexts'; import hljs from 'highlight.js'; -import type { ReactElement } from 'react'; import { Fragment, useContext, useLayoutEffect, useMemo, useRef, useCallback } from 'react'; import { useTranslation } from 'react-i18next'; @@ -24,7 +23,7 @@ const onHoverStyle = css` } `; -const CodeBlock = ({ lines = [], language }: CodeBlockProps): ReactElement => { +const CodeBlock = ({ lines = [], language }: CodeBlockProps) => { const ref = useRef(null); const { highlightRegex } = useContext(MarkupInteractionContext); diff --git a/packages/gazzodown/src/code/CodeElement.tsx b/packages/gazzodown/src/code/CodeElement.tsx index eeaa4b57cfa62..2c39b554acd4d 100644 --- a/packages/gazzodown/src/code/CodeElement.tsx +++ b/packages/gazzodown/src/code/CodeElement.tsx @@ -1,12 +1,10 @@ -import type { ReactElement } from 'react'; - import PlainSpan from '../elements/PlainSpan'; type CodeElementProps = { code: string; }; -const CodeElement = ({ code }: CodeElementProps): ReactElement => ( +const CodeElement = ({ code }: CodeElementProps) => ( diff --git a/packages/gazzodown/src/code/PreviewCodeBlock.tsx b/packages/gazzodown/src/code/PreviewCodeBlock.tsx index a3aae973f5bdd..513081117ae75 100644 --- a/packages/gazzodown/src/code/PreviewCodeBlock.tsx +++ b/packages/gazzodown/src/code/PreviewCodeBlock.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import { useMemo } from 'react'; type PreviewCodeBlockProps = { @@ -7,7 +6,7 @@ type PreviewCodeBlockProps = { lines: MessageParser.CodeLine[]; }; -export const PreviewCodeBlock = ({ lines }: PreviewCodeBlockProps): ReactElement | null => { +export const PreviewCodeBlock = ({ lines }: PreviewCodeBlockProps) => { const firstLine = useMemo(() => lines.find((line) => line.value.value.trim())?.value.value.trim(), [lines]); if (!firstLine) { diff --git a/packages/gazzodown/src/code/PreviewCodeElement.tsx b/packages/gazzodown/src/code/PreviewCodeElement.tsx index 84e6e460d27dd..4b0960e06dd38 100644 --- a/packages/gazzodown/src/code/PreviewCodeElement.tsx +++ b/packages/gazzodown/src/code/PreviewCodeElement.tsx @@ -1,9 +1,7 @@ -import type { ReactElement } from 'react'; - type PreviewCodeElementProps = { code: string; }; -const PreviewCodeElement = ({ code }: PreviewCodeElementProps): ReactElement => <>{code}; +const PreviewCodeElement = ({ code }: PreviewCodeElementProps) => <>{code}; export default PreviewCodeElement; diff --git a/packages/gazzodown/src/colors/ColorElement.tsx b/packages/gazzodown/src/colors/ColorElement.tsx index 6334ba208ae29..8119ca35901dd 100644 --- a/packages/gazzodown/src/colors/ColorElement.tsx +++ b/packages/gazzodown/src/colors/ColorElement.tsx @@ -1,4 +1,3 @@ -import type { ReactElement } from 'react'; import { memo } from 'react'; type ColorElementProps = { @@ -8,7 +7,7 @@ type ColorElementProps = { a: number; }; -const ColorElement = ({ r, g, b, a }: ColorElementProps): ReactElement => ( +const ColorElement = ({ r, g, b, a }: ColorElementProps) => ( value.toString(16).padStart(2, '0'); @@ -10,7 +9,7 @@ type PreviewColorElementProps = { a: number; }; -const PreviewColorElement = ({ r, g, b, a }: PreviewColorElementProps): ReactElement => { +const PreviewColorElement = ({ r, g, b, a }: PreviewColorElementProps) => { if (a === 255) { return ( <> diff --git a/packages/gazzodown/src/elements/BoldSpan.tsx b/packages/gazzodown/src/elements/BoldSpan.tsx index 00aa8743d0e84..cc7f2e886570b 100644 --- a/packages/gazzodown/src/elements/BoldSpan.tsx +++ b/packages/gazzodown/src/elements/BoldSpan.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import ItalicSpan from './ItalicSpan'; import LinkSpan from './LinkSpan'; @@ -22,7 +21,7 @@ type BoldSpanProps = { children: MessageBlock[]; }; -const BoldSpan = ({ children }: BoldSpanProps): ReactElement => ( +const BoldSpan = ({ children }: BoldSpanProps) => ( <> {children.map((block, index) => { if ( @@ -39,7 +38,7 @@ const BoldSpan = ({ children }: BoldSpanProps): ReactElement => ( ); -const renderBlockComponent = (block: MessageBlock, index: number): ReactElement | null => { +const renderBlockComponent = (block: MessageBlock, index: number) => { switch (block.type) { case 'EMOJI': return ; diff --git a/packages/gazzodown/src/elements/ImageElement.tsx b/packages/gazzodown/src/elements/ImageElement.tsx index 33d9b401e8fbd..59965747f2a53 100644 --- a/packages/gazzodown/src/elements/ImageElement.tsx +++ b/packages/gazzodown/src/elements/ImageElement.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import { useMemo } from 'react'; import { sanitizeUrl } from './sanitizeUrl'; @@ -47,7 +46,7 @@ type ImageElementProps = { alt: MessageParser.Markup; }; -const ImageElement = ({ src, alt }: ImageElementProps): ReactElement => { +const ImageElement = ({ src, alt }: ImageElementProps) => { const plainAlt = useMemo(() => flattenMarkup(alt), [alt]); const safeSrc = sanitizeUrl(src); diff --git a/packages/gazzodown/src/elements/InlineElements.tsx b/packages/gazzodown/src/elements/InlineElements.tsx index 2b3e57605e746..19aecfb7a01b1 100644 --- a/packages/gazzodown/src/elements/InlineElements.tsx +++ b/packages/gazzodown/src/elements/InlineElements.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import { lazy } from 'react'; import BoldSpan from './BoldSpan'; @@ -23,7 +22,7 @@ type InlineElementsProps = { children: (MessageParser.Inlines | { fallback: MessageParser.Plain; type: undefined })[]; }; -const InlineElements = ({ children }: InlineElementsProps): ReactElement => ( +const InlineElements = ({ children }: InlineElementsProps) => ( <> {children.map((child, index) => { switch (child.type) { diff --git a/packages/gazzodown/src/elements/ItalicSpan.tsx b/packages/gazzodown/src/elements/ItalicSpan.tsx index 0e683120f7d9d..08005f6a58e4b 100644 --- a/packages/gazzodown/src/elements/ItalicSpan.tsx +++ b/packages/gazzodown/src/elements/ItalicSpan.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import BoldSpan from './BoldSpan'; import LinkSpan from './LinkSpan'; @@ -22,7 +21,7 @@ type ItalicSpanProps = { children: MessageBlock[]; }; -const ItalicSpan = ({ children }: ItalicSpanProps): ReactElement => ( +const ItalicSpan = ({ children }: ItalicSpanProps) => ( <> {children.map((block, index) => { if ( @@ -39,7 +38,7 @@ const ItalicSpan = ({ children }: ItalicSpanProps): ReactElement => ( ); -const renderBlockComponent = (block: MessageBlock, index: number): ReactElement | null => { +const renderBlockComponent = (block: MessageBlock, index: number) => { switch (block.type) { case 'EMOJI': return ; diff --git a/packages/gazzodown/src/elements/LinkSpan.tsx b/packages/gazzodown/src/elements/LinkSpan.tsx index ba234e65d3c42..801f9695a5b39 100644 --- a/packages/gazzodown/src/elements/LinkSpan.tsx +++ b/packages/gazzodown/src/elements/LinkSpan.tsx @@ -1,6 +1,5 @@ import type * as MessageParser from '@rocket.chat/message-parser'; import { getBaseURI, isExternal } from '@rocket.chat/ui-client/dist/helpers/getBaseURI'; -import type { ReactElement } from 'react'; import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; @@ -15,7 +14,7 @@ type LinkSpanProps = { label: MessageParser.Markup | MessageParser.Markup[]; }; -const LinkSpan = ({ href, label }: LinkSpanProps): ReactElement => { +const LinkSpan = ({ href, label }: LinkSpanProps) => { // Should sanitize 'href' if any of the insecure prefixes are present - see DSK-34 on Jira const sanitizedHref = sanitizeUrl(href); diff --git a/packages/gazzodown/src/elements/PlainSpan.tsx b/packages/gazzodown/src/elements/PlainSpan.tsx index 82db9ec187d84..fa298600b04a9 100644 --- a/packages/gazzodown/src/elements/PlainSpan.tsx +++ b/packages/gazzodown/src/elements/PlainSpan.tsx @@ -1,4 +1,3 @@ -import type { ReactElement } from 'react'; import { Fragment, memo, useContext, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; @@ -8,7 +7,7 @@ type PlainSpanProps = { text: string; }; -const PlainSpan = ({ text }: PlainSpanProps): ReactElement => { +const PlainSpan = ({ text }: PlainSpanProps) => { const { t } = useTranslation(); const { highlightRegex, markRegex } = useContext(MarkupInteractionContext); diff --git a/packages/gazzodown/src/elements/PreviewInlineElements.tsx b/packages/gazzodown/src/elements/PreviewInlineElements.tsx index 5371e2e02febd..3e839d3784a67 100644 --- a/packages/gazzodown/src/elements/PreviewInlineElements.tsx +++ b/packages/gazzodown/src/elements/PreviewInlineElements.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import { Fragment } from 'react'; import BoldSpan from './BoldSpan'; @@ -17,7 +16,7 @@ type PreviewInlineElementsProps = { children: MessageParser.Inlines[]; }; -const PreviewInlineElements = ({ children }: PreviewInlineElementsProps): ReactElement => ( +const PreviewInlineElements = ({ children }: PreviewInlineElementsProps) => ( <> {children.map((child, index) => { switch (child.type) { diff --git a/packages/gazzodown/src/elements/SpoilerSpan.tsx b/packages/gazzodown/src/elements/SpoilerSpan.tsx index 86205cbad9f54..d14032df4f46a 100644 --- a/packages/gazzodown/src/elements/SpoilerSpan.tsx +++ b/packages/gazzodown/src/elements/SpoilerSpan.tsx @@ -1,5 +1,5 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { KeyboardEvent, ReactElement } from 'react'; +import type { KeyboardEvent } from 'react'; import { lazy, useCallback, useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -49,7 +49,7 @@ const srOnlyStyle = { width: 1, } as const; -const SpoilerSpan = ({ children }: SpoilerSpanProps): ReactElement => { +const SpoilerSpan = ({ children }: SpoilerSpanProps) => { const { t } = useTranslation(); const [revealed, setRevealed] = useState(false); @@ -81,7 +81,7 @@ const SpoilerSpan = ({ children }: SpoilerSpanProps): ReactElement => { ); }; -const renderBlockComponent = (block: MessageParser.Inlines, index: number): ReactElement | null => { +const renderBlockComponent = (block: MessageParser.Inlines, index: number) => { switch (block.type) { case 'EMOJI': return ; diff --git a/packages/gazzodown/src/elements/StrikeSpan.tsx b/packages/gazzodown/src/elements/StrikeSpan.tsx index ac2875559c879..add2af4011c4e 100644 --- a/packages/gazzodown/src/elements/StrikeSpan.tsx +++ b/packages/gazzodown/src/elements/StrikeSpan.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import BoldSpan from './BoldSpan'; import ItalicSpan from './ItalicSpan'; @@ -23,7 +22,7 @@ type StrikeSpanProps = { children: MessageBlock[]; }; -const StrikeSpan = ({ children }: StrikeSpanProps): ReactElement => ( +const StrikeSpan = ({ children }: StrikeSpanProps) => ( <> {children.map((block, index) => { if ( @@ -40,7 +39,7 @@ const StrikeSpan = ({ children }: StrikeSpanProps): ReactElement => ( ); -const renderBlockComponent = (block: MessageBlock, index: number): ReactElement | null => { +const renderBlockComponent = (block: MessageBlock, index: number) => { switch (block.type) { case 'EMOJI': return ; diff --git a/packages/gazzodown/src/emoji/BigEmojiBlock.tsx b/packages/gazzodown/src/emoji/BigEmojiBlock.tsx index d246d983a2c41..72a94729ca3f0 100644 --- a/packages/gazzodown/src/emoji/BigEmojiBlock.tsx +++ b/packages/gazzodown/src/emoji/BigEmojiBlock.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import BigEmojiElement from './BigEmojiElement'; @@ -7,7 +6,7 @@ type BigEmojiBlockProps = { emoji: MessageParser.Emoji[]; }; -const BigEmojiBlock = ({ emoji }: BigEmojiBlockProps): ReactElement => ( +const BigEmojiBlock = ({ emoji }: BigEmojiBlockProps) => (
      {emoji.map((emoji, index) => ( diff --git a/packages/gazzodown/src/emoji/BigEmojiElement.tsx b/packages/gazzodown/src/emoji/BigEmojiElement.tsx index d9ae87bbcb4d1..58a8b8858f9f4 100644 --- a/packages/gazzodown/src/emoji/BigEmojiElement.tsx +++ b/packages/gazzodown/src/emoji/BigEmojiElement.tsx @@ -1,10 +1,9 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import Emoji from './Emoji'; type BigEmojiElementProps = MessageParser.Emoji; -const BigEmojiElement = (emoji: BigEmojiElementProps): ReactElement => ; +const BigEmojiElement = (emoji: BigEmojiElementProps) => ; export default BigEmojiElement; diff --git a/packages/gazzodown/src/emoji/Emoji.tsx b/packages/gazzodown/src/emoji/Emoji.tsx index c4062ea470b86..b33b33c6f05c8 100644 --- a/packages/gazzodown/src/emoji/Emoji.tsx +++ b/packages/gazzodown/src/emoji/Emoji.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import { useMemo, useContext, memo } from 'react'; import { MarkupInteractionContext } from '../MarkupInteractionContext'; @@ -11,7 +10,7 @@ type EmojiProps = MessageParser.Emoji & { preview?: boolean; }; -const Emoji = ({ big = false, preview = false, ...emoji }: EmojiProps): ReactElement => { +const Emoji = ({ big = false, preview = false, ...emoji }: EmojiProps) => { const { convertAsciiToEmoji, useEmoji } = useContext(MarkupInteractionContext); const asciiEmoji = useMemo( diff --git a/packages/gazzodown/src/emoji/EmojiElement.tsx b/packages/gazzodown/src/emoji/EmojiElement.tsx index d3005376176d9..a0080c5af9874 100644 --- a/packages/gazzodown/src/emoji/EmojiElement.tsx +++ b/packages/gazzodown/src/emoji/EmojiElement.tsx @@ -1,11 +1,10 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import { memo } from 'react'; import Emoji from './Emoji'; type EmojiElementProps = MessageParser.Emoji; -const EmojiElement = (emoji: EmojiElementProps): ReactElement => ; +const EmojiElement = (emoji: EmojiElementProps) => ; export default memo(EmojiElement); diff --git a/packages/gazzodown/src/emoji/EmojiRenderer.tsx b/packages/gazzodown/src/emoji/EmojiRenderer.tsx index 3ef81ad6887c2..b66039a8bcb82 100644 --- a/packages/gazzodown/src/emoji/EmojiRenderer.tsx +++ b/packages/gazzodown/src/emoji/EmojiRenderer.tsx @@ -1,7 +1,6 @@ import { MessageEmoji, ThreadMessageEmoji } from '@rocket.chat/fuselage'; import type * as MessageParser from '@rocket.chat/message-parser'; import DOMPurify from 'dompurify'; -import type { ReactElement } from 'react'; import { useMemo, useContext, memo } from 'react'; import { MarkupInteractionContext } from '../MarkupInteractionContext'; @@ -11,7 +10,7 @@ type EmojiProps = MessageParser.Emoji & { preview?: boolean; }; -const EmojiRenderer = ({ big = false, preview = false, ...emoji }: EmojiProps): ReactElement => { +const EmojiRenderer = ({ big = false, preview = false, ...emoji }: EmojiProps) => { const { detectEmoji } = useContext(MarkupInteractionContext); const fallback = useMemo(() => ('unicode' in emoji ? emoji.unicode : `:${emoji.shortCode ?? emoji.value.value}:`), [emoji]); diff --git a/packages/gazzodown/src/emoji/PreviewBigEmojiBlock.tsx b/packages/gazzodown/src/emoji/PreviewBigEmojiBlock.tsx index 6a2c8a2358b80..cc4d8c92b84b8 100644 --- a/packages/gazzodown/src/emoji/PreviewBigEmojiBlock.tsx +++ b/packages/gazzodown/src/emoji/PreviewBigEmojiBlock.tsx @@ -1,5 +1,4 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import PreviewEmojiElement from './PreviewEmojiElement'; @@ -7,7 +6,7 @@ type PreviewBigEmojiBlockProps = { emoji: MessageParser.Emoji[]; }; -const PreviewBigEmojiBlock = ({ emoji }: PreviewBigEmojiBlockProps): ReactElement => ( +const PreviewBigEmojiBlock = ({ emoji }: PreviewBigEmojiBlockProps) => ( <> {emoji.map((emoji, index) => ( diff --git a/packages/gazzodown/src/emoji/PreviewEmojiElement.tsx b/packages/gazzodown/src/emoji/PreviewEmojiElement.tsx index 6da9d7b7e32cb..f8629efd16f5d 100644 --- a/packages/gazzodown/src/emoji/PreviewEmojiElement.tsx +++ b/packages/gazzodown/src/emoji/PreviewEmojiElement.tsx @@ -1,10 +1,9 @@ import type * as MessageParser from '@rocket.chat/message-parser'; -import type { ReactElement } from 'react'; import Emoji from './Emoji'; type PreviewEmojiElementProps = MessageParser.Emoji; -const PreviewEmojiElement = (emoji: PreviewEmojiElementProps): ReactElement => ; +const PreviewEmojiElement = (emoji: PreviewEmojiElementProps) => ; export default PreviewEmojiElement; diff --git a/packages/gazzodown/src/katex/KatexBlock.tsx b/packages/gazzodown/src/katex/KatexBlock.tsx index e4ac18e9e5acf..874007f47150e 100644 --- a/packages/gazzodown/src/katex/KatexBlock.tsx +++ b/packages/gazzodown/src/katex/KatexBlock.tsx @@ -1,5 +1,4 @@ import katex from 'katex'; -import type { ReactElement } from 'react'; import { useMemo } from 'react'; import 'katex/dist/katex.css'; @@ -8,7 +7,7 @@ type KatexBlockProps = { code: string; }; -const KatexBlock = ({ code }: KatexBlockProps): ReactElement => { +const KatexBlock = ({ code }: KatexBlockProps) => { const html = useMemo( () => katex.renderToString(code, { diff --git a/packages/gazzodown/src/katex/KatexElement.tsx b/packages/gazzodown/src/katex/KatexElement.tsx index 951e502b6e868..6b3fc1829f0e6 100644 --- a/packages/gazzodown/src/katex/KatexElement.tsx +++ b/packages/gazzodown/src/katex/KatexElement.tsx @@ -1,5 +1,4 @@ import katex from 'katex'; -import type { ReactElement } from 'react'; import { useMemo } from 'react'; import 'katex/dist/katex.css'; @@ -8,7 +7,7 @@ type KatexElementProps = { code: string; }; -const KatexElement = ({ code }: KatexElementProps): ReactElement => { +const KatexElement = ({ code }: KatexElementProps) => { const html = useMemo( () => katex.renderToString(code, { diff --git a/packages/gazzodown/src/katex/KatexErrorBoundary.tsx b/packages/gazzodown/src/katex/KatexErrorBoundary.tsx index a1bdeffdb9a35..073b2a7a44625 100644 --- a/packages/gazzodown/src/katex/KatexErrorBoundary.tsx +++ b/packages/gazzodown/src/katex/KatexErrorBoundary.tsx @@ -1,6 +1,6 @@ import colors from '@rocket.chat/fuselage-tokens/colors.json'; import styled from '@rocket.chat/styled'; -import type { PropsWithChildren, ReactElement } from 'react'; +import type { PropsWithChildren } from 'react'; import { useState } from 'react'; import { ErrorBoundary } from 'react-error-boundary'; @@ -11,7 +11,7 @@ const Fallback = styled('span')` text-decoration-color: ${colors.r400}; `; -const KatexErrorBoundary = ({ children, code }: KatexErrorBoundaryProps): ReactElement => { +const KatexErrorBoundary = ({ children, code }: KatexErrorBoundaryProps) => { const [error, setError] = useState(null); return ( {code}}> diff --git a/packages/gazzodown/src/katex/PreviewKatexBlock.tsx b/packages/gazzodown/src/katex/PreviewKatexBlock.tsx index 34caa3c73e8a4..8aae72a541b35 100644 --- a/packages/gazzodown/src/katex/PreviewKatexBlock.tsx +++ b/packages/gazzodown/src/katex/PreviewKatexBlock.tsx @@ -1,11 +1,9 @@ -import type { ReactElement } from 'react'; - import 'katex/dist/katex.css'; type PreviewKatexBlockProps = { code: string; }; -const PreviewKatexBlock = ({ code }: PreviewKatexBlockProps): ReactElement => <>{code}; +const PreviewKatexBlock = ({ code }: PreviewKatexBlockProps) => <>{code}; export default PreviewKatexBlock; diff --git a/packages/gazzodown/src/katex/PreviewKatexElement.tsx b/packages/gazzodown/src/katex/PreviewKatexElement.tsx index 863a768fb9070..7fd6ec7275a26 100644 --- a/packages/gazzodown/src/katex/PreviewKatexElement.tsx +++ b/packages/gazzodown/src/katex/PreviewKatexElement.tsx @@ -1,11 +1,9 @@ -import type { ReactElement } from 'react'; - import 'katex/dist/katex.css'; type PreviewKatexElementProps = { code: string; }; -const PreviewKatexElement = ({ code }: PreviewKatexElementProps): ReactElement => <>{code}; +const PreviewKatexElement = ({ code }: PreviewKatexElementProps) => <>{code}; export default PreviewKatexElement; diff --git a/packages/gazzodown/src/mentions/ChannelMentionElement.tsx b/packages/gazzodown/src/mentions/ChannelMentionElement.tsx index 5db9e68f6a845..d0b73de5ba283 100644 --- a/packages/gazzodown/src/mentions/ChannelMentionElement.tsx +++ b/packages/gazzodown/src/mentions/ChannelMentionElement.tsx @@ -1,6 +1,5 @@ import { MessageHighlight } from '@rocket.chat/fuselage'; import { useButtonPattern } from '@rocket.chat/fuselage-hooks'; -import type { ReactElement } from 'react'; import { memo, useContext, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; @@ -12,7 +11,7 @@ type ChannelMentionElementProps = { const handleChannelMention = (mention: string, withSymbol: boolean | undefined): string => (withSymbol ? `#${mention}` : mention); -const ChannelMentionElement = ({ mention }: ChannelMentionElementProps): ReactElement => { +const ChannelMentionElement = ({ mention }: ChannelMentionElementProps) => { const { t } = useTranslation(); const { resolveChannelMention, onChannelMentionClick, showMentionSymbol } = useContext(MarkupInteractionContext); diff --git a/packages/gazzodown/src/mentions/PreviewChannelMentionElement.tsx b/packages/gazzodown/src/mentions/PreviewChannelMentionElement.tsx index bf901f40e121a..075b9bd87a53e 100644 --- a/packages/gazzodown/src/mentions/PreviewChannelMentionElement.tsx +++ b/packages/gazzodown/src/mentions/PreviewChannelMentionElement.tsx @@ -1,10 +1,9 @@ -import type { ReactElement } from 'react'; import { memo } from 'react'; type PreviewChannelMentionElementProps = { mention: string; }; -const PreviewChannelMentionElement = ({ mention }: PreviewChannelMentionElementProps): ReactElement => <>#{mention}; +const PreviewChannelMentionElement = ({ mention }: PreviewChannelMentionElementProps) => <>#{mention}; export default memo(PreviewChannelMentionElement); diff --git a/packages/gazzodown/src/mentions/PreviewUserMentionElement.tsx b/packages/gazzodown/src/mentions/PreviewUserMentionElement.tsx index 772a429507b98..deb7f982bfc40 100644 --- a/packages/gazzodown/src/mentions/PreviewUserMentionElement.tsx +++ b/packages/gazzodown/src/mentions/PreviewUserMentionElement.tsx @@ -1,10 +1,9 @@ -import type { ReactElement } from 'react'; import { memo } from 'react'; type PreviewUserMentionElementProps = { mention: string; }; -const PreviewUserMentionElement = ({ mention }: PreviewUserMentionElementProps): ReactElement => <>@{mention}; +const PreviewUserMentionElement = ({ mention }: PreviewUserMentionElementProps) => <>@{mention}; export default memo(PreviewUserMentionElement); diff --git a/packages/gazzodown/src/mentions/UserMentionElement.tsx b/packages/gazzodown/src/mentions/UserMentionElement.tsx index 31094859885d7..5701c1af1bea5 100644 --- a/packages/gazzodown/src/mentions/UserMentionElement.tsx +++ b/packages/gazzodown/src/mentions/UserMentionElement.tsx @@ -1,6 +1,5 @@ import { MessageHighlight } from '@rocket.chat/fuselage'; import { useButtonPattern } from '@rocket.chat/fuselage-hooks'; -import type { ReactElement } from 'react'; import { memo, useContext, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; @@ -13,7 +12,7 @@ type UserMentionElementProps = { const handleUserMention = (mention: string | undefined, withSymbol: boolean | undefined): string | undefined => withSymbol ? `@${mention}` : mention; -const UserMentionElement = ({ mention }: UserMentionElementProps): ReactElement => { +const UserMentionElement = ({ mention }: UserMentionElementProps) => { const { t } = useTranslation(); const { resolveUserMention, onUserMentionClick, ownUserId, useRealName, showMentionSymbol, triggerProps } = useContext(MarkupInteractionContext);