Skip to content

Commit 1797588

Browse files
authored
Merge pull request #831 from GetStream/update-prettier-width
Update prettier print width
2 parents 87aa638 + 473f950 commit 1797588

File tree

179 files changed

+1215
-3700
lines changed

Some content is hidden

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

179 files changed

+1215
-3700
lines changed

.eslintrc.json

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@
5252
"react/prop-types": 0,
5353
"require-await": 2,
5454
"semi": [1, "always"],
55-
"sort-destructure-keys/sort-destructure-keys": [
56-
2,
57-
{ "caseSensitive": false }
58-
],
55+
"sort-destructure-keys/sort-destructure-keys": [2, { "caseSensitive": false }],
5956
"sort-imports": [
6057
"error",
6158
{
@@ -66,11 +63,7 @@
6663
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
6764
}
6865
],
69-
"sort-keys": [
70-
"error",
71-
"asc",
72-
{ "caseSensitive": false, "minKeys": 2, "natural": false }
73-
],
66+
"sort-keys": ["error", "asc", { "caseSensitive": false, "minKeys": 2, "natural": false }],
7467
"valid-typeof": 2,
7568
"import/prefer-default-export": 0,
7669
"import/extensions": [0],
@@ -198,10 +191,7 @@
198191
"react/prop-types": 0,
199192
"require-await": 2,
200193
"semi": [1, "always"],
201-
"sort-destructure-keys/sort-destructure-keys": [
202-
2,
203-
{ "caseSensitive": false }
204-
],
194+
"sort-destructure-keys/sort-destructure-keys": [2, { "caseSensitive": false }],
205195
"sort-imports": [
206196
"error",
207197
{
@@ -212,11 +202,7 @@
212202
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
213203
}
214204
],
215-
"sort-keys": [
216-
"error",
217-
"asc",
218-
{ "caseSensitive": false, "minKeys": 2, "natural": false }
219-
],
205+
"sort-keys": ["error", "asc", { "caseSensitive": false, "minKeys": 2, "natural": false }],
220206
"typescript-sort-keys/interface": [
221207
"error",
222208
"asc",

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"arrowParens": "always",
33
"jsxSingleQuote": true,
4+
"printWidth": 100,
45
"singleQuote": true,
56
"tabWidth": 2,
67
"trailingComma": "all"

emojiMartDataParser.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@ Object.keys(dataSet.emojis).map(removeSkinTonesInfo);
2424

2525
const newDataSetJson = JSON.stringify(dataSet);
2626

27-
fs.writeFileSync(
28-
path.join(__dirname, 'src', 'stream-emoji.json'),
29-
newDataSetJson,
30-
);
27+
fs.writeFileSync(path.join(__dirname, 'src', 'stream-emoji.json'), newDataSetJson);

examples/typescript-app/src/serviceWorker.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ const isLocalhost = Boolean(
1515
// [::1] is the IPv6 localhost address.
1616
window.location.hostname === '[::1]' ||
1717
// 127.0.0.0/8 are considered localhost for IPv4.
18-
window.location.hostname.match(
19-
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,
20-
),
18+
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/),
2119
);
2220

2321
type Config = {
@@ -127,9 +125,7 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {
127125
}
128126
})
129127
.catch(() => {
130-
console.log(
131-
'No internet connection found. App is running in offline mode.',
132-
);
128+
console.log('No internet connection found. App is running in offline mode.');
133129
});
134130
}
135131

scripts/validate-translations.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ fs.readdir(directoryPath, function (err, files) {
1717
keys.forEach((key) => {
1818
if (!data[key] || data[key] === '') {
1919
countMissingTranslations = countMissingTranslations + 1;
20-
console.error(
21-
'\\033[91m',
22-
'Missing translation for key "' + key + '" in "' + file + '"',
23-
);
20+
console.error('\\033[91m', 'Missing translation for key "' + key + '" in "' + file + '"');
2421
}
2522
});
2623
});

src/components/Attachment/Attachment.tsx

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import {
77
} from './AttachmentActions';
88
import { AudioProps, Audio as DefaultAudio } from './Audio';
99
import { CardProps, Card as DefaultCard } from './Card';
10-
import {
11-
FileAttachment as DefaultFile,
12-
FileAttachmentProps,
13-
} from './FileAttachment';
10+
import { FileAttachment as DefaultFile, FileAttachmentProps } from './FileAttachment';
1411
import {
1512
isAudioAttachment,
1613
isFileAttachment,
@@ -38,9 +35,7 @@ import type { ActionHandlerReturnType } from '../Message';
3835

3936
import type { DefaultAttachmentType } from '../../../types/types';
4037

41-
export type AttachmentProps<
42-
At extends DefaultAttachmentType = DefaultAttachmentType
43-
> = {
38+
export type AttachmentProps<At extends DefaultAttachmentType = DefaultAttachmentType> = {
4439
/**
4540
* The attachment to render.
4641
* See [Attachment structure](https://getstream.io/chat/docs/javascript/message_format/?language=javascript)
@@ -93,13 +88,7 @@ export type DefaultAttachmentProps<
9388
> = Required<
9489
Pick<
9590
InnerAttachmentUIComponentProps,
96-
| 'AttachmentActions'
97-
| 'Audio'
98-
| 'Card'
99-
| 'File'
100-
| 'Gallery'
101-
| 'Image'
102-
| 'Media'
91+
'AttachmentActions' | 'Audio' | 'Card' | 'File' | 'Gallery' | 'Image' | 'Media'
10392
>
10493
> & {
10594
attachment: ExtendedAttachment<At>;
@@ -137,9 +126,7 @@ export type InnerAttachmentUIComponentProps<
137126
*
138127
* @example ./Attachment.md
139128
*/
140-
export const Attachment = <
141-
At extends DefaultAttachmentType = DefaultAttachmentType
142-
>(
129+
export const Attachment = <At extends DefaultAttachmentType = DefaultAttachmentType>(
143130
props: AttachmentProps<At>,
144131
) => {
145132
const {
@@ -157,8 +144,7 @@ export const Attachment = <
157144
const gallery = {
158145
images: attachments?.filter(
159146
(attachment) =>
160-
attachment.type === 'image' &&
161-
!(attachment.og_scrape_url || attachment.title_link),
147+
attachment.type === 'image' && !(attachment.og_scrape_url || attachment.title_link),
162148
),
163149
type: 'gallery',
164150
};
@@ -169,10 +155,7 @@ export const Attachment = <
169155
newAttachments = [
170156
...attachments.filter(
171157
(attachment) =>
172-
!(
173-
attachment.type === 'image' &&
174-
!(attachment.og_scrape_url || attachment.title_link)
175-
),
158+
!(attachment.type === 'image' && !(attachment.og_scrape_url || attachment.title_link)),
176159
),
177160
gallery,
178161
];

src/components/Attachment/AttachmentActions.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ export type AttachmentActionsProps = {
1717
) => void;
1818
};
1919

20-
const UnMemoizedAttachmentActions: React.FC<AttachmentActionsProps> = (
21-
props,
22-
) => {
20+
const UnMemoizedAttachmentActions: React.FC<AttachmentActionsProps> = (props) => {
2321
const { actionHandler, actions, id, text } = props;
2422

2523
const handleActionClick = (
@@ -42,9 +40,7 @@ const UnMemoizedAttachmentActions: React.FC<AttachmentActionsProps> = (
4240
data-testid={`${action.name}`}
4341
data-value={action.value}
4442
key={`${id}-${action.value}`}
45-
onClick={(event) =>
46-
handleActionClick(event, action.name, action.value)
47-
}
43+
onClick={(event) => handleActionClick(event, action.name, action.value)}
4844
>
4945
{action.text}
5046
</button>

src/components/Attachment/Audio.tsx

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@ const progressUpdateInterval = 500;
88
/**
99
* Audio attachment with play/pause button and progress bar
1010
*/
11-
export type AudioProps<
12-
At extends DefaultAttachmentType = DefaultAttachmentType
13-
> = {
11+
export type AudioProps<At extends DefaultAttachmentType = DefaultAttachmentType> = {
1412
og: Attachment<At>;
1513
};
1614

17-
const UnMemoizedAudio = <
18-
At extends DefaultAttachmentType = DefaultAttachmentType
19-
>(
15+
const UnMemoizedAudio = <At extends DefaultAttachmentType = DefaultAttachmentType>(
2016
props: AudioProps<At>,
2117
) => {
2218
const { og } = props;
@@ -66,12 +62,7 @@ const UnMemoizedAudio = <
6662
data-testid='play-audio'
6763
onClick={() => setIsPlaying(true)}
6864
>
69-
<svg
70-
height='40'
71-
viewBox='0 0 64 64'
72-
width='40'
73-
xmlns='http://www.w3.org/2000/svg'
74-
>
65+
<svg height='40' viewBox='0 0 64 64' width='40' xmlns='http://www.w3.org/2000/svg'>
7566
<path
7667
d='M32 58c14.36 0 26-11.64 26-26S46.36 6 32 6 6 17.64 6 32s11.64 26 26 26zm0 6C14.327 64 0 49.673 0 32 0 14.327 14.327 0 32 0c17.673 0 32 14.327 32 32 0 17.673-14.327 32-32 32zm13.237-28.412L26.135 45.625a3.27 3.27 0 0 1-4.426-1.4 3.319 3.319 0 0 1-.372-1.47L21 23.36c-.032-1.823 1.41-3.327 3.222-3.358a3.263 3.263 0 0 1 1.473.322l19.438 9.36a3.311 3.311 0 0 1 .103 5.905z'
7768
fillRule='nonzero'
@@ -84,12 +75,7 @@ const UnMemoizedAudio = <
8475
data-testid='pause-audio'
8576
onClick={() => setIsPlaying(false)}
8677
>
87-
<svg
88-
height='40'
89-
viewBox='0 0 64 64'
90-
width='40'
91-
xmlns='http://www.w3.org/2000/svg'
92-
>
78+
<svg height='40' viewBox='0 0 64 64' width='40' xmlns='http://www.w3.org/2000/svg'>
9379
<path
9480
d='M32 58.215c14.478 0 26.215-11.737 26.215-26.215S46.478 5.785 32 5.785 5.785 17.522 5.785 32 17.522 58.215 32 58.215zM32 64C14.327 64 0 49.673 0 32 0 14.327 14.327 0 32 0c17.673 0 32 14.327 32 32 0 17.673-14.327 32-32 32zm-7.412-45.56h2.892a2.17 2.17 0 0 1 2.17 2.17v23.865a2.17 2.17 0 0 1-2.17 2.17h-2.892a2.17 2.17 0 0 1-2.17-2.17V20.61a2.17 2.17 0 0 1 2.17-2.17zm12.293 0h2.893a2.17 2.17 0 0 1 2.17 2.17v23.865a2.17 2.17 0 0 1-2.17 2.17h-2.893a2.17 2.17 0 0 1-2.17-2.17V20.61a2.17 2.17 0 0 1 2.17-2.17z'
9581
fillRule='nonzero'
@@ -106,10 +92,7 @@ const UnMemoizedAudio = <
10692
</span>
10793
<span className='str-chat__audio__content--subtitle'>{text}</span>
10894
<div className='str-chat__audio__content--progress'>
109-
<div
110-
data-testid='audio-progress'
111-
style={{ width: `${progress}%` }}
112-
/>
95+
<div data-testid='audio-progress' style={{ width: `${progress}%` }} />
11396
</div>
11497
</div>
11598
</div>

src/components/Attachment/Card.tsx

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,15 @@ export type CardProps = {
2424
};
2525

2626
const UnMemoizedCard: React.FC<CardProps> = (props) => {
27-
const {
28-
image_url,
29-
og_scrape_url,
30-
text,
31-
thumb_url,
32-
title,
33-
title_link,
34-
type,
35-
} = props;
27+
const { image_url, og_scrape_url, text, thumb_url, title, title_link, type } = props;
3628

3729
const { t } = useTranslationContext();
3830

3931
const image = thumb_url || image_url;
4032

4133
const trimUrl = (url?: string | null) => {
4234
if (url !== undefined && url !== null) {
43-
const [trimmedUrl] = url
44-
.replace(/^(?:https?:\/\/)?(?:www\.)?/i, '')
45-
.split('/');
35+
const [trimmedUrl] = url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, '').split('/');
4636

4737
return trimmedUrl;
4838
}
@@ -68,26 +58,16 @@ const UnMemoizedCard: React.FC<CardProps> = (props) => {
6858
}
6959

7060
return (
71-
<div
72-
className={`str-chat__message-attachment-card str-chat__message-attachment-card--${type}`}
73-
>
61+
<div className={`str-chat__message-attachment-card str-chat__message-attachment-card--${type}`}>
7462
{image && (
7563
<div className='str-chat__message-attachment-card--header'>
7664
<img alt={image} src={image} />
7765
</div>
7866
)}
7967
<div className='str-chat__message-attachment-card--content'>
8068
<div className='str-chat__message-attachment-card--flex'>
81-
{title && (
82-
<div className='str-chat__message-attachment-card--title'>
83-
{title}
84-
</div>
85-
)}
86-
{text && (
87-
<div className='str-chat__message-attachment-card--text'>
88-
{text}
89-
</div>
90-
)}
69+
{title && <div className='str-chat__message-attachment-card--title'>{title}</div>}
70+
{text && <div className='str-chat__message-attachment-card--text'>{text}</div>}
9171
{(title_link || og_scrape_url) && (
9272
<SafeAnchor
9373
className='str-chat__message-attachment-card--url'

src/components/Attachment/FileAttachment.tsx

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,25 @@ import type { Attachment } from 'stream-chat';
88

99
import type { DefaultAttachmentType } from '../../../types/types';
1010

11-
export type FileAttachmentProps<
12-
At extends DefaultAttachmentType = DefaultAttachmentType
13-
> = {
11+
export type FileAttachmentProps<At extends DefaultAttachmentType = DefaultAttachmentType> = {
1412
attachment: Attachment<At>;
1513
};
1614

17-
const UnMemoizedFileAttachment = <
18-
At extends DefaultAttachmentType = DefaultAttachmentType
19-
>(
15+
const UnMemoizedFileAttachment = <At extends DefaultAttachmentType = DefaultAttachmentType>(
2016
props: FileAttachmentProps<At>,
2117
) => {
2218
const { attachment } = props;
2319

2420
return (
25-
<div
26-
className='str-chat__message-attachment-file--item'
27-
data-testid='attachment-file'
28-
>
29-
<FileIcon
30-
big={true}
31-
filename={attachment.title}
32-
mimeType={attachment.mime_type}
33-
size={30}
34-
/>
21+
<div className='str-chat__message-attachment-file--item' data-testid='attachment-file'>
22+
<FileIcon big={true} filename={attachment.title} mimeType={attachment.mime_type} size={30} />
3523
<div className='str-chat__message-attachment-file--item-text'>
3624
<SafeAnchor download href={attachment.asset_url} target='_blank'>
3725
{attachment.title}
3826
</SafeAnchor>
39-
{attachment.file_size &&
40-
Number.isFinite(Number(attachment.file_size)) && (
41-
<span>{prettybytes(attachment.file_size)}</span>
42-
)}
27+
{attachment.file_size && Number.isFinite(Number(attachment.file_size)) && (
28+
<span>{prettybytes(attachment.file_size)}</span>
29+
)}
4330
</div>
4431
</div>
4532
);

0 commit comments

Comments
 (0)