Skip to content

Commit 616e877

Browse files
Prettier + ESLint fixes (and some manual fixes)
1 parent 2966f25 commit 616e877

File tree

385 files changed

+5770
-3331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

385 files changed

+5770
-3331
lines changed

e2e/fixtures/data/attachment.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable sort-keys */
1+
22
const smallImageAttachment = [
33
{
44
type: 'image',

eslint.config.mjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ export default tseslint.config(
5757
'object-shorthand': 'warn',
5858
'prefer-const': 'warn',
5959
'require-await': 'error',
60-
"sort-destructure-keys/sort-destructure-keys": [
61-
"error",
62-
{ caseSensitive: false },
63-
],
60+
'sort-destructure-keys/sort-destructure-keys': ['error', { caseSensitive: false }],
6461
'sort-imports': [
6562
'error',
6663
{

src/components/AIStateIndicator/AIStateIndicator.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ import { useChannelStateContext, useTranslationContext } from '../../context';
88
import type { DefaultStreamChatGenerics } from '../../types/types';
99

1010
export type AIStateIndicatorProps<
11-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
11+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
1212
> = {
1313
channel?: Channel<StreamChatGenerics>;
1414
};
1515

1616
export const AIStateIndicator = <
17-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
17+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
1818
>({
1919
channel: channelFromProps,
2020
}: AIStateIndicatorProps<StreamChatGenerics>) => {
2121
const { t } = useTranslationContext();
22-
const { channel: channelFromContext } = useChannelStateContext<StreamChatGenerics>(
23-
'AIStateIndicator',
24-
);
22+
const { channel: channelFromContext } =
23+
useChannelStateContext<StreamChatGenerics>('AIStateIndicator');
2524
const channel = channelFromProps || channelFromContext;
2625
const { aiState } = useAIState(channel);
2726
const allowedStates = {

src/components/AIStateIndicator/hooks/useAIState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const AIStates = {
1818
* @returns {{ aiState: AIState }} The current AI state for the given channel.
1919
*/
2020
export const useAIState = <
21-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
21+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
2222
>(
2323
channel?: Channel<StreamChatGenerics>,
2424
): { aiState: AIState } => {

src/components/Attachment/Attachment.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const ATTACHMENT_GROUPS_ORDER = [
5555
] as const;
5656

5757
export type AttachmentProps<
58-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
58+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
5959
> = {
6060
/** The message attachments to render, see [attachment structure](https://getstream.io/chat/docs/javascript/message_format/?language=javascript) **/
6161
attachments: StreamAttachment<StreamChatGenerics>[];
@@ -87,14 +87,17 @@ export type AttachmentProps<
8787
* A component used for rendering message attachments. By default, the component supports: AttachmentActions, Audio, Card, File, Gallery, Image, and Video
8888
*/
8989
export const Attachment = <
90-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
90+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
9191
>(
9292
props: AttachmentProps<StreamChatGenerics>,
9393
) => {
9494
const { attachments } = props;
9595

96-
// eslint-disable-next-line react-hooks/exhaustive-deps
97-
const groupedAttachments = useMemo(() => renderGroupedAttachments(props), [attachments]);
96+
const groupedAttachments = useMemo(
97+
() => renderGroupedAttachments(props),
98+
// eslint-disable-next-line react-hooks/exhaustive-deps
99+
[attachments],
100+
);
98101

99102
return (
100103
<div className='str-chat__attachment-list'>
@@ -107,13 +110,13 @@ export const Attachment = <
107110
};
108111

109112
const renderGroupedAttachments = <
110-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
113+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
111114
>({
112115
attachments,
113116
...rest
114117
}: AttachmentProps<StreamChatGenerics>): GroupedRenderedAttachment => {
115-
const uploadedImages: StreamAttachment<StreamChatGenerics>[] = attachments.filter((attachment) =>
116-
isUploadedImage(attachment),
118+
const uploadedImages: StreamAttachment<StreamChatGenerics>[] = attachments.filter(
119+
(attachment) => isUploadedImage(attachment),
117120
);
118121

119122
const containers = attachments
@@ -169,7 +172,7 @@ const renderGroupedAttachments = <
169172
};
170173

171174
const getAttachmentType = <
172-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
175+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
173176
>(
174177
attachment: AttachmentProps<StreamChatGenerics>['attachments'][number],
175178
): keyof typeof CONTAINER_MAP => {

src/components/Attachment/AttachmentActions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { ActionHandlerReturnType } from '../Message/hooks/useActionHandler'
77
import type { DefaultStreamChatGenerics } from '../../types/types';
88

99
export type AttachmentActionsProps<
10-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
10+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
1111
> = Attachment<StreamChatGenerics> & {
1212
/** A list of actions */
1313
actions: Action[];
@@ -20,7 +20,7 @@ export type AttachmentActionsProps<
2020
};
2121

2222
const UnMemoizedAttachmentActions = <
23-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
23+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
2424
>(
2525
props: AttachmentActionsProps<StreamChatGenerics>,
2626
) => {

src/components/Attachment/AttachmentContainer.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ import type {
3030
import type { Attachment } from 'stream-chat';
3131

3232
export type AttachmentContainerProps<
33-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
33+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
3434
> = {
3535
attachment: Attachment<StreamChatGenerics> | GalleryAttachment<StreamChatGenerics>;
3636
componentType: AttachmentComponentType;
3737
};
3838
export const AttachmentWithinContainer = <
39-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
39+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
4040
>({
4141
attachment,
4242
children,
@@ -50,16 +50,17 @@ export const AttachmentWithinContainer = <
5050
componentType === 'card' && !attachment?.image_url && !attachment?.thumb_url
5151
? 'no-image'
5252
: attachment?.actions?.length
53-
? 'actions'
54-
: '';
53+
? 'actions'
54+
: '';
5555
}
5656

5757
const classNames = clsx(
5858
'str-chat__message-attachment str-chat__message-attachment-dynamic-size',
5959
{
6060
[`str-chat__message-attachment--${componentType}`]: componentType,
6161
[`str-chat__message-attachment--${attachment?.type}`]: attachment?.type,
62-
[`str-chat__message-attachment--${componentType}--${extra}`]: componentType && extra,
62+
[`str-chat__message-attachment--${componentType}--${extra}`]:
63+
componentType && extra,
6364
'str-chat__message-attachment--svg-image': isSvgAttachment(attachment),
6465
'str-chat__message-attachment-with-actions': extra === 'actions',
6566
},
@@ -69,7 +70,7 @@ export const AttachmentWithinContainer = <
6970
};
7071

7172
export const AttachmentActionsContainer = <
72-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
73+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
7374
>({
7475
actionHandler,
7576
attachment,
@@ -108,7 +109,7 @@ function getCssDimensionsVariables(url: string) {
108109
}
109110

110111
export const GalleryContainer = <
111-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
112+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
112113
>({
113114
attachment,
114115
Gallery = DefaultGallery,
@@ -150,7 +151,7 @@ export const GalleryContainer = <
150151
};
151152

152153
export const ImageContainer = <
153-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
154+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
154155
>(
155156
props: RenderAttachmentProps<StreamChatGenerics>,
156157
) => {
@@ -194,7 +195,7 @@ export const ImageContainer = <
194195
};
195196

196197
export const CardContainer = <
197-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
198+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
198199
>(
199200
props: RenderAttachmentProps<StreamChatGenerics>,
200201
) => {
@@ -220,7 +221,7 @@ export const CardContainer = <
220221
};
221222

222223
export const FileContainer = <
223-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
224+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
224225
>({
225226
attachment,
226227
File = DefaultFile,
@@ -234,7 +235,7 @@ export const FileContainer = <
234235
);
235236
};
236237
export const AudioContainer = <
237-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
238+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
238239
>({
239240
attachment,
240241
Audio = DefaultAudio,
@@ -247,11 +248,11 @@ export const AudioContainer = <
247248
);
248249

249250
export const VoiceRecordingContainer = <
250-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
251+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
251252
>({
252253
attachment,
253-
VoiceRecording = DefaultVoiceRecording,
254254
isQuoted,
255+
VoiceRecording = DefaultVoiceRecording,
255256
}: RenderAttachmentProps<StreamChatGenerics>) => (
256257
<AttachmentWithinContainer attachment={attachment} componentType='voiceRecording'>
257258
<div className='str-chat__attachment'>
@@ -261,18 +262,17 @@ export const VoiceRecordingContainer = <
261262
);
262263

263264
export const MediaContainer = <
264-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
265+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
265266
>(
266267
props: RenderAttachmentProps<StreamChatGenerics>,
267268
) => {
268269
const { attachment, Media = ReactPlayer } = props;
269270
const componentType = 'media';
270-
const { shouldGenerateVideoThumbnail, videoAttachmentSizeHandler } = useChannelStateContext();
271+
const { shouldGenerateVideoThumbnail, videoAttachmentSizeHandler } =
272+
useChannelStateContext();
271273
const videoElement = useRef<HTMLDivElement>(null);
272-
const [
273-
attachmentConfiguration,
274-
setAttachmentConfiguration,
275-
] = useState<VideoAttachmentConfiguration>();
274+
const [attachmentConfiguration, setAttachmentConfiguration] =
275+
useState<VideoAttachmentConfiguration>();
276276

277277
useLayoutEffect(() => {
278278
if (videoElement.current && videoAttachmentSizeHandler) {
@@ -319,7 +319,7 @@ export const MediaContainer = <
319319
};
320320

321321
export const UnsupportedAttachmentContainer = <
322-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
322+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
323323
>({
324324
attachment,
325325
UnsupportedAttachment = DefaultUnsupportedAttachment,

src/components/Attachment/Audio.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import { useAudioController } from './hooks/useAudioController';
88
import type { DefaultStreamChatGenerics } from '../../types/types';
99

1010
export type AudioProps<
11-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
11+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
1212
> = {
1313
// fixme: rename og to attachment
1414
og: Attachment<StreamChatGenerics>;
1515
};
1616

1717
const UnMemoizedAudio = <
18-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
18+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
1919
>(
2020
props: AudioProps<StreamChatGenerics>,
2121
) => {

src/components/Attachment/Card.tsx

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ const UnableToRenderCard = ({ type }: { type?: CardProps['type'] }) => {
4141
);
4242
};
4343

44-
const SourceLink = ({ author_name, url }: Pick<CardProps, 'author_name'> & { url: string }) => (
45-
<div className='str-chat__message-attachment-card--source-link' data-testid='card-source-link'>
44+
const SourceLink = ({
45+
author_name,
46+
url,
47+
}: Pick<CardProps, 'author_name'> & { url: string }) => (
48+
<div
49+
className='str-chat__message-attachment-card--source-link'
50+
data-testid='card-source-link'
51+
>
4652
<SafeAnchor
4753
className='str-chat__message-attachment-card--url'
4854
href={url}
@@ -68,7 +74,13 @@ const CardHeader = (props: CardHeaderProps) => {
6874
let visual = null;
6975
if (asset_url && type === 'video') {
7076
visual = (
71-
<ReactPlayer className='react-player' controls height='100%' url={asset_url} width='100%' />
77+
<ReactPlayer
78+
className='react-player'
79+
controls
80+
height='100%'
81+
url={asset_url}
82+
width='100%'
83+
/>
7284
);
7385
} else if (image) {
7486
visual = (
@@ -104,7 +116,9 @@ const CardContent = (props: CardContentProps) => {
104116
) : (
105117
<div className='str-chat__message-attachment-card--flex'>
106118
{url && <SourceLink author_name={author_name} url={url} />}
107-
{title && <div className='str-chat__message-attachment-card--title'>{title}</div>}
119+
{title && (
120+
<div className='str-chat__message-attachment-card--title'>{title}</div>
121+
)}
108122
{text && <div className='str-chat__message-attachment-card--text'>{text}</div>}
109123
</div>
110124
)}
@@ -139,9 +153,13 @@ export const CardAudio = ({
139153
)}
140154
<div className='str-chat__message-attachment-audio-widget--second-row'>
141155
{url && <SourceLink author_name={author_name} url={url} />}
142-
{title && <div className='str-chat__message-attachment-audio-widget--title'>{title}</div>}
156+
{title && (
157+
<div className='str-chat__message-attachment-audio-widget--title'>{title}</div>
158+
)}
143159
{text && (
144-
<div className='str-chat__message-attachment-audio-widget--description'>{text}</div>
160+
<div className='str-chat__message-attachment-audio-widget--description'>
161+
{text}
162+
</div>
145163
)}
146164
</div>
147165
</div>
@@ -158,7 +176,8 @@ const UnMemoizedCard = (props: CardProps) => {
158176
const dimensions: { height?: string; width?: string } = {};
159177

160178
if (type === 'giphy' && typeof giphy !== 'undefined') {
161-
const giphyVersion = giphy[giphyVersionName as keyof NonNullable<Attachment['giphy']>];
179+
const giphyVersion =
180+
giphy[giphyVersionName as keyof NonNullable<Attachment['giphy']>];
162181
image = giphyVersion.url;
163182
dimensions.height = giphyVersion.height;
164183
dimensions.width = giphyVersion.width;
@@ -169,7 +188,9 @@ const UnMemoizedCard = (props: CardProps) => {
169188
}
170189

171190
return (
172-
<div className={`str-chat__message-attachment-card str-chat__message-attachment-card--${type}`}>
191+
<div
192+
className={`str-chat__message-attachment-card str-chat__message-attachment-card--${type}`}
193+
>
173194
<CardHeader {...props} dimensions={dimensions} image={image} />
174195
<CardContent {...props} />
175196
</div>

src/components/Attachment/FileAttachment.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@ import { DownloadButton, FileSizeIndicator } from './components';
77
import type { DefaultStreamChatGenerics } from '../../types/types';
88

99
export type FileAttachmentProps<
10-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
10+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
1111
> = {
1212
attachment: Attachment<StreamChatGenerics>;
1313
};
1414

1515
const UnMemoizedFileAttachment = <
16-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
16+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
1717
>({
1818
attachment,
1919
}: FileAttachmentProps<StreamChatGenerics>) => (
2020
<div className='str-chat__message-attachment-file--item' data-testid='attachment-file'>
2121
<FileIcon className='str-chat__file-icon' mimeType={attachment.mime_type} />
2222
<div className='str-chat__message-attachment-file--item-text'>
2323
<div className='str-chat__message-attachment-file--item-first-row'>
24-
<div className='str-chat__message-attachment-file--item-name' data-testid='file-title'>
24+
<div
25+
className='str-chat__message-attachment-file--item-name'
26+
data-testid='file-title'
27+
>
2528
{attachment.title}
2629
</div>
2730
<DownloadButton assetUrl={attachment.asset_url} />

0 commit comments

Comments
 (0)