Skip to content

Commit

Permalink
ESLint manual fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arnautov-anton committed Jan 29, 2025
1 parent bc29ecc commit 2b07024
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 17 deletions.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/components/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ const ChannelInner = <
});

thread?.upsertReplyLocally({
// @ts-expect-error
// @ts-expect-error message type mismatch
message: {
...message,
error: parsedError,
Expand Down Expand Up @@ -1049,7 +1049,7 @@ const ChannelInner = <
};

thread?.upsertReplyLocally({
// @ts-expect-error
// @ts-expect-error message type mismatch
message: messagePreview,
});

Expand Down Expand Up @@ -1226,7 +1226,7 @@ const ChannelInner = <
],
);

// @ts-expect-error
// @ts-expect-error message type mismatch
const componentContextValue: Partial<ComponentContextValue> = useMemo(
() => ({
Attachment: props.Attachment,
Expand Down
3 changes: 3 additions & 0 deletions src/components/Channel/__tests__/Channel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ describe('Channel', () => {
it('should render empty channel container if channel does not have cid', async () => {
const { channel } = await initClient();
const childrenContent = 'Channel children';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { cid, ...channelWithoutCID } = channel;
const { asFragment } = render(
<ChatProvider
Expand Down Expand Up @@ -1482,6 +1483,7 @@ describe('Channel', () => {
});
describe('delete message', () => {
it('should throw error instead of calling default client.deleteMessage() function', async () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { id, ...message } = generateMessage();
const { channel, chatClient } = await initClient();
const clientDeleteMessageSpy = jest.spyOn(chatClient, 'deleteMessage');
Expand Down Expand Up @@ -1509,6 +1511,7 @@ describe('Channel', () => {
});

it('should throw error instead of calling custom doDeleteMessageRequest function', async () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { id, ...message } = generateMessage();
const { channel, chatClient } = await initClient();
const clientDeleteMessageSpy = jest
Expand Down
4 changes: 2 additions & 2 deletions src/components/ChatView/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import type { PropsWithChildren } from 'react';
import type { Thread, ThreadManagerState } from 'stream-chat';
import clsx from 'clsx';

const availableChatViews = ['channels', 'threads'] as const;
type ChatView = 'channels' | 'threads';

type ChatViewContextValue = {
activeChatView: typeof availableChatViews[number];
activeChatView: ChatView;
setActiveChatView: (cv: ChatViewContextValue['activeChatView']) => void;
};

Expand Down
1 change: 1 addition & 0 deletions src/components/MML/MML.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useChatContext } from '../../context/ChatContext';
import type { ActionHandlerReturnType } from '../Message/hooks/useActionHandler';

const MMLReact = React.lazy(async () => {
// eslint-disable-next-line import/no-extraneous-dependencies
const mml = await import('mml-react');
return { default: mml.MML };
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ describe('MessageInput', () => {
});

expect(doFileUploadRequest).toHaveBeenCalledTimes(1);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { localMetadata, ...uploadedRecordingAtt } = recording;
expect(sendMessage.mock.calls[0][0]).toStrictEqual({
attachments: [uploadedRecordingAtt],
Expand Down
4 changes: 2 additions & 2 deletions src/components/Message/hooks/useReactionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const useReactionHandler = <

try {
updateMessage(tempMessage);
// @ts-expect-error
// @ts-expect-error message type mismatch
thread?.upsertReplyLocally({ message: tempMessage });

const messageResponse = add
Expand All @@ -106,7 +106,7 @@ export const useReactionHandler = <
} catch (error) {
// revert to the original message if the API call fails
updateMessage(message);
// @ts-expect-error
// @ts-expect-error message type mismatch
thread?.upsertReplyLocally({ message });
}
}, 1000);
Expand Down
5 changes: 3 additions & 2 deletions src/components/Message/renderText/renderText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ export const markDownRenderers: RenderTextOptions['customMarkDownRenderers'] = {
export type RenderTextOptions<
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
> = {
// eslint-disable-next-line @typescript-eslint/ban-types
allowedTagNames?: Array<keyof JSX.IntrinsicElements | 'emoji' | 'mention' | (string & {})>;
allowedTagNames?: Array<
keyof JSX.IntrinsicElements | 'emoji' | 'mention' | (string & {})
>;
customMarkDownRenderers?: Options['components'] &
Partial<{
emoji: ComponentType;
Expand Down
5 changes: 2 additions & 3 deletions src/components/Message/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ export const validateAndGetMessage = <T extends unknown[]>(

// below is due to tests passing a single argument
// rather than an array.
if (!(args instanceof Array)) {
// @ts-expect-error
args = [args];
if (!Array.isArray(args)) {
args = [args] as unknown as T;
}

const returnValue = func(...args);
Expand Down
1 change: 1 addition & 0 deletions src/components/MessageActions/MessageActionsBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const UnMemoizedMessageActionsBox = <
handleMute,
handlePin,
isUserMuted,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
mine,
open,
...restDivProps
Expand Down
1 change: 0 additions & 1 deletion src/components/MessageInput/AttachmentSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export type AttachmentSelectorActionProps = {

export type AttachmentSelectorAction = {
ActionButton: React.ComponentType<AttachmentSelectorActionProps>;
// eslint-disable-next-line @typescript-eslint/ban-types
type: 'uploadFile' | 'createPoll' | (string & {});
ModalContent?: React.ComponentType<AttachmentSelectorModalContentProps>;
};
Expand Down
2 changes: 2 additions & 0 deletions src/components/MessageInput/__tests__/LinkPreviewList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@ describe('Link preview', () => {
it('submit new message with skip_url_enrich:false if no link previews managed to get loaded', async () => {
const channel = chatClient.channel('messaging', mockedChannelData.channel.id);
const sendMessageSpy = jest.spyOn(channel, 'sendMessage').mockImplementation();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let resolveEnrichURLPromise;
jest
.spyOn(chatClient, 'enrichURL')
Expand Down Expand Up @@ -987,6 +988,7 @@ describe('Link preview', () => {

const sendMessageSpy = jest.spyOn(channel, 'sendMessage').mockImplementation();

// eslint-disable-next-line @typescript-eslint/no-unused-vars
let resolveEnrichURLPromise;
jest
.spyOn(chatClient, 'enrichURL')
Expand Down
4 changes: 2 additions & 2 deletions src/components/MessageInput/hooks/useUserTrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const useUserTrigger = <
throttle(
async (query: string, onReady: (users: UserResponse<StreamChatGenerics>[]) => void) => {
try {
// @ts-expect-error
// @ts-expect-error valid query
const response = await channel.queryMembers({
name: { $autocomplete: query },
});
Expand Down Expand Up @@ -100,7 +100,7 @@ export const useUserTrigger = <

try {
const { users } = await client.queryUsers(
// @ts-expect-error
// @ts-expect-error valid query
{
$or: [{ id: { $autocomplete: query } }, { name: { $autocomplete: query } }],
...(typeof mentionQueryParams.filters === 'function'
Expand Down
1 change: 1 addition & 0 deletions src/components/MessageInput/hooks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const searchLocalUsers = <

if (useMentionsTransliteration) {
(async () => {
// eslint-disable-next-line import/no-extraneous-dependencies
const { default: transliterate } = await import('@stream-io/transliterate');
updatedName = transliterate(user.name || '').toLowerCase();
updatedQuery = transliterate(query).toLowerCase();
Expand Down
1 change: 1 addition & 0 deletions src/components/Reactions/ReactionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const UnMemoizedReactionsList = <
) => {
const {
handleFetchReactions,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
reactionDetailsSort,
reverse = false,
sortReactionDetails,
Expand Down
1 change: 1 addition & 0 deletions src/mock-builders/browser/AudioContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Connectable {
}

export class AudioContextMock {
// eslint-disable-next-line @typescript-eslint/no-empty-function
constructor() {}

createAnalyser = jest.fn(() => new Connectable());
Expand Down
1 change: 1 addition & 0 deletions src/mock-builders/generator/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const generateChannel = (options = { channel: {} }) => {
const { channel: optionsChannel, config, ...optionsBesidesChannel } = options;
const id = optionsChannel?.id ?? nanoid();
const type = optionsChannel?.type ?? 'messaging';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { id: _, type: __, ...restOptionsChannel } = optionsChannel ?? {};

return {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/Emojis/EmojiPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable typescript-sort-keys/interface */
import React, { useEffect, useState } from 'react';
import { usePopper } from 'react-popper';
import Picker from '@emoji-mart/react';
Expand Down
1 change: 0 additions & 1 deletion src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ export type UpdateMessageOptions = {

export type Readable<T> = {
[key in keyof T]: T[key];
// eslint-disable-next-line @typescript-eslint/ban-types
} & {};

export type ValuesType<T> = T[keyof T];
Expand Down

0 comments on commit 2b07024

Please sign in to comment.