From 6d531c149b66182bd9be3e6fe33cd0f3e19bd921 Mon Sep 17 00:00:00 2001 From: alchemycodess Date: Mon, 2 Mar 2026 03:43:37 +0530 Subject: [PATCH 1/5] chore: migrate chat.reportMessage endpoint to new OpenAPI pattern with AJV validation --- .../migrate-chat-reportMessage-to-openapi.md | 6 ++ apps/meteor/app/api/server/v1/chat.ts | 63 ++++++++++++------- packages/rest-typings/src/v1/chat.ts | 3 - 3 files changed, 47 insertions(+), 25 deletions(-) create mode 100644 .changeset/migrate-chat-reportMessage-to-openapi.md diff --git a/.changeset/migrate-chat-reportMessage-to-openapi.md b/.changeset/migrate-chat-reportMessage-to-openapi.md new file mode 100644 index 0000000000000..0fa9734b7e1d5 --- /dev/null +++ b/.changeset/migrate-chat-reportMessage-to-openapi.md @@ -0,0 +1,6 @@ +--- +'@rocket.chat/meteor': minor +'@rocket.chat/rest-typings': minor +--- + +Migrated chat.reportMessage endpoint to new OpenAPI pattern with AJV validation \ No newline at end of file diff --git a/apps/meteor/app/api/server/v1/chat.ts b/apps/meteor/app/api/server/v1/chat.ts index c9fc2ce6925ec..48b5a7f1155cf 100644 --- a/apps/meteor/app/api/server/v1/chat.ts +++ b/apps/meteor/app/api/server/v1/chat.ts @@ -4,7 +4,6 @@ import { MessageTypes } from '@rocket.chat/message-types'; import { Messages, Users, Rooms, Subscriptions } from '@rocket.chat/models'; import { ajv, - isChatReportMessageProps, isChatGetURLPreviewProps, isChatUpdateProps, isChatGetThreadsListProps, @@ -207,6 +206,23 @@ const isChatPinMessageProps = ajv.compile(ChatPinMessageSchema); const isChatUnpinMessageProps = ajv.compile(ChatUnpinMessageSchema); +type ChatReportMessage = { + messageId: string; + description: string; +}; + +const ChatReportMessageSchema = { + type: 'object', + properties: { + messageId: { type: 'string' }, + description: { type: 'string' }, + }, + required: ['messageId', 'description'], + additionalProperties: false, +}; + +const isChatReportMessageLocalProps = ajv.compile(ChatReportMessageSchema); + const chatEndpoints = API.v1 .post( 'chat.pinMessage', @@ -350,6 +366,30 @@ const chatEndpoints = API.v1 message, }); }, + ) + .post( + 'chat.reportMessage', + { + authRequired: true, + body: isChatReportMessageLocalProps, + response: { + 200: ajv.compile({ + type: 'object', + properties: { + success: { type: 'boolean', enum: [true] } + }, + required: ['success'], + additionalProperties: false + }), + 400: validateBadRequestErrorResponse, + 401: validateUnauthorizedErrorResponse, + }, + }, + async function action() { + const { messageId, description } = this.bodyParams; + await reportMessage(messageId, description, this.userId); + return API.v1.success(); + }, ); API.v1.addRoute( @@ -513,27 +553,6 @@ API.v1.addRoute( }, ); -API.v1.addRoute( - 'chat.reportMessage', - { authRequired: true, validateParams: isChatReportMessageProps }, - { - async post() { - const { messageId, description } = this.bodyParams; - if (!messageId) { - return API.v1.failure('The required "messageId" param is missing.'); - } - - if (!description) { - return API.v1.failure('The required "description" param is missing.'); - } - - await reportMessage(messageId, description, this.userId); - - return API.v1.success(); - }, - }, -); - API.v1.addRoute( 'chat.ignoreUser', { authRequired: true, validateParams: isChatIgnoreUserProps }, diff --git a/packages/rest-typings/src/v1/chat.ts b/packages/rest-typings/src/v1/chat.ts index 71fd745d7f95c..549ff9e2abc1d 100644 --- a/packages/rest-typings/src/v1/chat.ts +++ b/packages/rest-typings/src/v1/chat.ts @@ -979,9 +979,6 @@ export type ChatEndpoints = { '/v1/chat.unStarMessage': { POST: (params: ChatUnstarMessage) => void; }; - '/v1/chat.reportMessage': { - POST: (params: ChatReportMessage) => void; - }; '/v1/chat.getDiscussions': { GET: (params: ChatGetDiscussions) => { messages: IMessage[]; From f2c43fd840fe04bcb5b63a386c69a466429a7cc5 Mon Sep 17 00:00:00 2001 From: alchemycodess Date: Mon, 2 Mar 2026 16:13:58 +0530 Subject: [PATCH 2/5] fix: add minLength validation for messageId and description --- apps/meteor/app/api/server/v1/chat.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/meteor/app/api/server/v1/chat.ts b/apps/meteor/app/api/server/v1/chat.ts index 48b5a7f1155cf..c0aa830ccb523 100644 --- a/apps/meteor/app/api/server/v1/chat.ts +++ b/apps/meteor/app/api/server/v1/chat.ts @@ -214,8 +214,8 @@ type ChatReportMessage = { const ChatReportMessageSchema = { type: 'object', properties: { - messageId: { type: 'string' }, - description: { type: 'string' }, + messageId: { type: 'string', minLength: 1 }, + description: { type: 'string', minLength: 1 }, }, required: ['messageId', 'description'], additionalProperties: false, From 4c4ed70f0b562ac9107a645318035d4179f5f234 Mon Sep 17 00:00:00 2001 From: alchemycodess Date: Wed, 4 Mar 2026 02:25:38 +0530 Subject: [PATCH 3/5] fix: apply eslint fixes --- apps/meteor/.scripts/run-ha.ts | 2 +- apps/meteor/app/2fa/server/code/EmailCheck.ts | 4 +-- apps/meteor/app/2fa/server/code/index.ts | 2 +- apps/meteor/app/api/server/ApiClass.ts | 6 ++-- .../app/api/server/helpers/parseJsonQuery.ts | 2 +- .../meteor/app/api/server/lib/isValidQuery.ts | 1 - apps/meteor/app/api/server/v1/calendar.ts | 6 ++-- apps/meteor/app/api/server/v1/channels.ts | 2 +- apps/meteor/app/api/server/v1/chat.ts | 22 +++++++-------- .../meteor/app/api/server/v1/custom-sounds.ts | 2 +- .../app/api/server/v1/custom-user-status.ts | 2 +- apps/meteor/app/api/server/v1/e2e.ts | 1 - apps/meteor/app/api/server/v1/groups.ts | 6 ++-- apps/meteor/app/api/server/v1/im.ts | 2 +- apps/meteor/app/api/server/v1/integrations.ts | 2 +- apps/meteor/app/api/server/v1/roles.ts | 4 +-- apps/meteor/app/api/server/v1/rooms.ts | 13 ++++----- .../meteor/app/api/server/v1/subscriptions.ts | 4 +-- .../app/api/server/v1/videoConference.ts | 2 +- apps/meteor/app/apple/server/loginHandler.ts | 2 +- .../app/apps/server/bridges/activation.ts | 1 - .../app/apps/server/bridges/livechat.ts | 15 +++++----- apps/meteor/app/apps/server/bridges/roles.ts | 2 +- .../app/apps/server/bridges/scheduler.ts | 2 +- .../app/apps/server/converters/threads.ts | 4 +-- .../server/functions/getUsersInRole.ts | 8 ++---- .../authorization/server/functions/hasRole.ts | 8 ++---- .../autotranslate/server/googleTranslate.ts | 6 ++-- apps/meteor/app/crowd/server/crowd.ts | 2 +- .../server/methods/createDiscussion.ts | 2 +- apps/meteor/app/emoji/client/emojiParser.ts | 2 +- .../server/lib/RocketChat.ErrorHandler.ts | 1 - .../app/file-upload/server/lib/FileUpload.ts | 13 ++++----- .../classes/converters/RoomConverter.ts | 4 +-- .../meteor/app/integrations/server/api/api.ts | 3 +- .../server/lib/isolated-vm/buildSandbox.ts | 2 +- .../integrations/server/lib/triggerHandler.ts | 7 ++--- .../incoming/updateIncomingIntegration.ts | 1 - .../app/lib/server/functions/createRoom.ts | 1 - .../app/lib/server/functions/deleteMessage.ts | 2 +- .../lib/server/functions/isTheLastMessage.ts | 1 - .../server/functions/saveUser/saveNewUser.ts | 2 +- .../app/lib/server/functions/setEmail.ts | 2 +- .../app/lib/server/functions/setRealName.ts | 2 +- .../app/lib/server/functions/setUsername.ts | 2 +- .../server/functions/updateGroupDMsName.ts | 1 - .../app/lib/server/lib/processDirectEmail.ts | 2 +- .../server/lib/sendNotificationsOnMessage.ts | 2 +- .../app/lib/server/methods/saveSettings.ts | 4 +-- .../meteor/app/lib/server/methods/setEmail.ts | 2 +- .../meteor/app/livechat/server/api/v1/room.ts | 8 +++--- .../app/livechat/server/api/v1/visitor.ts | 2 +- ...ilterBusinessHoursThatMustBeOpened.spec.ts | 4 +-- apps/meteor/app/livechat/server/lib/Helper.ts | 4 +-- .../app/livechat/server/lib/RoutingManager.ts | 4 +-- .../app/livechat/server/lib/closeRoom.ts | 2 +- .../lib/contacts/resolveContactConflicts.ts | 2 +- .../app/livechat/server/lib/departmentsLib.ts | 2 +- .../roomAccessValidator.compatibility.ts | 2 +- .../LivechatAgentActivityMonitor.ts | 4 +-- .../app/message-pin/server/pinMessage.ts | 2 +- .../meteor-accounts-saml/server/lib/SAML.ts | 2 +- .../meteor-accounts-saml/server/lib/Utils.ts | 2 +- .../server/lib/settings.ts | 2 +- .../app/settings/server/SettingsRegistry.ts | 1 - .../server/functions/settings.mocks.ts | 8 +++--- apps/meteor/app/settings/server/startup.ts | 1 - .../app/slackbridge/server/RocketAdapter.ts | 14 +++++----- .../meteor/app/slackbridge/server/SlackAPI.ts | 6 ++-- .../app/slackbridge/server/SlackAdapter.ts | 28 +++++++++---------- .../app/slashcommands-create/server/server.ts | 2 +- .../app/slashcommands-invite/server/server.ts | 2 +- .../app/slashcommands-open/client/client.ts | 2 +- .../server/functions/sendUsageReport.ts | 2 +- .../app/ui-message/client/ActionManager.ts | 2 +- apps/meteor/app/ui/client/lib/UserAction.ts | 2 +- apps/meteor/app/utils/client/getURL.ts | 2 +- apps/meteor/app/utils/lib/getURL.ts | 4 +-- apps/meteor/app/utils/server/getURL.ts | 2 +- .../server/getUserNotificationPreference.ts | 6 +--- apps/meteor/client/apps/orchestrator.ts | 2 +- .../GenericUpsellModal.spec.tsx | 1 - .../Sidebar/SidebarNavigationItem.tsx | 2 +- apps/meteor/client/definitions/global.d.ts | 2 -- .../hooks/notification/useNotification.ts | 2 +- .../meteor/client/lib/2fa/process2faReturn.ts | 4 +-- apps/meteor/client/lib/chats/data.ts | 8 +++--- .../client/lib/customOAuth/CustomOAuth.ts | 2 +- apps/meteor/client/lib/e2ee/crypto/shared.ts | 4 +-- .../client/lib/e2ee/rocketchat.e2e.room.ts | 6 ++-- apps/meteor/client/lib/getDirtyFields.ts | 2 +- apps/meteor/client/lib/streamer/streamer.ts | 2 +- apps/meteor/client/lib/userData.ts | 1 - apps/meteor/client/lib/userStatuses.ts | 2 +- .../client/lib/utils/getUidDirectMessage.ts | 2 +- .../hooks/useAdministrationMenu.spec.tsx | 2 +- .../AuthenticationProvider.tsx | 2 +- apps/meteor/client/router/index.tsx | 2 +- .../RoomList/SidebarItemTemplateWithData.tsx | 1 - .../ABACAttributesTab/AttributesForm.spec.tsx | 1 - .../views/admin/EditableSettingsContext.ts | 2 +- .../views/admin/customEmoji/CustomEmoji.tsx | 2 +- .../customEmoji/EditCustomEmojiWithData.tsx | 2 +- .../channels/useChannelsList.ts | 1 - .../messages/useMessageOrigins.ts | 1 - .../messages/useMessagesSent.ts | 1 - .../messages/useTopFivePopularChannels.ts | 1 - .../users/useActiveUsers.ts | 1 - .../users/useHourlyChatActivity.ts | 1 - .../users/useUsersByTimeOfTheDay.ts | 1 - .../users/useWeeklyChatActivity.ts | 1 - .../admin/integrations/IntegrationsTable.tsx | 2 +- .../outgoing/OutgoingWebhookForm.tsx | 5 +--- .../views/admin/invites/InvitesPage.tsx | 2 +- .../client/views/audit/hooks/useAuditTab.ts | 2 +- .../EnterE2EPasswordModal.spec.tsx | 1 - .../AppDetailsPage/AppDetailsPage.tsx | 2 +- .../client/views/marketplace/helpers.ts | 2 +- .../views/marketplace/hooks/useAppInfo.ts | 4 +-- .../client/views/modal/uikit/ModalBlock.tsx | 4 +-- .../sidebar/RoomList/SidebarItemWithData.tsx | 1 - .../sidepanel/SidePanelInternal.tsx | 2 +- .../views/omnichannel/components/Tags.tsx | 2 +- .../OutboundMessageWizard.stories.tsx | 1 - .../forms/RecipientForm/RecipientForm.tsx | 4 +-- .../forms/RepliesForm/RepliesForm.spec.tsx | 4 +-- .../steps/MessageStep.spec.tsx | 1 - .../steps/MessageStep.stories.tsx | 1 - .../steps/RecipientStep.spec.tsx | 1 - .../steps/RecipientStep.stories.tsx | 1 - .../steps/RepliesStep.spec.tsx | 1 - .../steps/RepliesStep.stories.tsx | 1 - .../outboundMessage/utils/template.spec.ts | 2 +- .../directory/hooks/useDisplayFilters.ts | 2 +- .../composer/hooks/useComposerBoxPopup.ts | 10 +++---- .../hooks/useComposerBoxPopupQueries.ts | 6 ++-- .../hooks/useMessageComposerIsArchived.ts | 2 +- .../MessageBoxActionsToolbar.tsx | 2 +- .../UserInfo/UserInfoActions.tsx | 1 - .../hooks/useVideoConfOpenCall.tsx | 2 +- .../MainLayout/LayoutWithSidebar.spec.tsx | 2 +- .../views/root/hooks/loggedIn/useUnread.ts | 2 +- .../ChannelDesertionTable.tsx | 5 +--- .../externals/meteor/accounts-base.d.ts | 1 - .../server/api/lib/inquiries.ts | 2 +- .../server/hooks/afterOnHold.ts | 2 +- .../server/lib/LivechatEnterprise.ts | 2 +- .../server/lib/QueueInactivityMonitor.ts | 2 +- .../server/lib/VisitorInactivityMonitor.ts | 2 +- .../server/lib/debounceByParams.ts | 5 +--- apps/meteor/ee/server/api/audit.ts | 8 +++--- .../api/engagementDashboard/channels.ts | 2 +- .../api/engagementDashboard/messages.ts | 2 +- apps/meteor/ee/server/api/sessions.ts | 2 +- .../endpoints/appsCountHandler.ts | 2 +- .../ee/server/apps/communication/uikit.ts | 2 +- apps/meteor/ee/server/configuration/saml.ts | 4 +-- .../lib/engagementDashboard/channels.ts | 2 +- .../lib/engagementDashboard/messages.ts | 2 +- apps/meteor/ee/server/lib/ldap/Manager.ts | 4 +-- .../dataExport/exportRoomMessagesToFile.ts | 4 +-- .../meteor/server/lib/dataExport/sendEmail.ts | 2 +- apps/meteor/server/lib/http/call.ts | 2 +- apps/meteor/server/lib/i18n.ts | 2 +- apps/meteor/server/lib/ldap/Manager.ts | 4 +-- .../server/lib/rooms/roomTypes/private.ts | 2 +- .../server/lib/rooms/roomTypes/public.ts | 2 +- .../server/services/analytics/service.ts | 2 +- apps/meteor/server/services/image/service.ts | 4 +-- .../server/services/meteor/userReactivity.ts | 2 +- .../omnichannel-analytics/AgentData.ts | 10 +++---- .../services/omnichannel-analytics/service.ts | 1 - apps/meteor/server/services/team/service.ts | 10 +++---- apps/meteor/server/startup/migrations/v294.ts | 2 +- apps/meteor/server/startup/migrations/v304.ts | 6 +--- apps/meteor/server/startup/migrations/v307.ts | 2 +- apps/meteor/server/ufs/ufs-server.ts | 1 - apps/meteor/server/ufs/ufs-store.ts | 1 - apps/meteor/tests/data/rooms.helper.ts | 1 - .../e2e-encryption/e2ee-legacy-format.spec.ts | 2 +- apps/meteor/tests/e2e/page-objects/login.ts | 2 +- .../app/license/server/canEnableApp.spec.ts | 1 - .../omnichannel-analytics/AgentData.tests.ts | 2 +- 183 files changed, 251 insertions(+), 325 deletions(-) diff --git a/apps/meteor/.scripts/run-ha.ts b/apps/meteor/.scripts/run-ha.ts index a1a3775000690..2b53a960d7c06 100644 --- a/apps/meteor/.scripts/run-ha.ts +++ b/apps/meteor/.scripts/run-ha.ts @@ -56,7 +56,7 @@ async function runMain(config: IConfig): Promise { async function runInstance(config: IConfig): Promise { // Desctructuring the unused variables allows us to omit them in the `mainConfig` - // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { customEnv, parentEnv, ...mainConfig } = config; const env = { diff --git a/apps/meteor/app/2fa/server/code/EmailCheck.ts b/apps/meteor/app/2fa/server/code/EmailCheck.ts index 8c9865c0b0042..4f98e2c5abef8 100644 --- a/apps/meteor/app/2fa/server/code/EmailCheck.ts +++ b/apps/meteor/app/2fa/server/code/EmailCheck.ts @@ -101,7 +101,7 @@ ${t('If_you_didnt_try_to_login_in_your_account_please_ignore_this_email')} const random = Random._randomString(6, '0123456789'); const encryptedRandom = await bcrypt.hash(random, Accounts._bcryptRounds()); const expire = new Date(); - const expirationInSeconds = parseInt(settings.get('Accounts_TwoFactorAuthentication_By_Email_Code_Expiration') as string, 10); + const expirationInSeconds = parseInt(settings.get('Accounts_TwoFactorAuthentication_By_Email_Code_Expiration'), 10); expire.setSeconds(expire.getSeconds() + expirationInSeconds); @@ -145,6 +145,6 @@ ${t('If_you_didnt_try_to_login_in_your_account_please_ignore_this_email')} public async maxFaildedAttemtpsReached(user: IUser) { const maxAttempts = settings.get('Accounts_TwoFactorAuthentication_Max_Invalid_Email_Code_Attempts'); - return (await Users.maxInvalidEmailCodeAttemptsReached(user._id, maxAttempts)) as boolean; + return await Users.maxInvalidEmailCodeAttemptsReached(user._id, maxAttempts); } } diff --git a/apps/meteor/app/2fa/server/code/index.ts b/apps/meteor/app/2fa/server/code/index.ts index cfe7b8ab7d4d4..1a3050e480834 100644 --- a/apps/meteor/app/2fa/server/code/index.ts +++ b/apps/meteor/app/2fa/server/code/index.ts @@ -64,7 +64,7 @@ function getFingerprintFromConnection(connection: IMethodConnection): string { } function getRememberDate(from: Date = new Date()): Date | undefined { - const rememberFor = parseInt(settings.get('Accounts_TwoFactorAuthentication_RememberFor') as string, 10); + const rememberFor = parseInt(settings.get('Accounts_TwoFactorAuthentication_RememberFor'), 10); if (rememberFor <= 0) { return; diff --git a/apps/meteor/app/api/server/ApiClass.ts b/apps/meteor/app/api/server/ApiClass.ts index 8d44fb85941ad..7ed7e2fe6b282 100644 --- a/apps/meteor/app/api/server/ApiClass.ts +++ b/apps/meteor/app/api/server/ApiClass.ts @@ -276,7 +276,7 @@ export class APIClass; - return finalResult as SuccessResult; + return finalResult; } public redirect(code: C, result: T): RedirectResult { @@ -799,7 +799,7 @@ export class APIClass; if (typeof operations[method as keyof Operations] === 'function') { - (operations as Record)[method as string] = { + (operations as Record)[method] = { action: operations[method as keyof Operations], }; } else { @@ -953,7 +953,7 @@ export class APIClass] as Record).action as any, + (operations[method as keyof Operations] as Record).action, ); this._routes.push({ path: route, diff --git a/apps/meteor/app/api/server/helpers/parseJsonQuery.ts b/apps/meteor/app/api/server/helpers/parseJsonQuery.ts index fafaebcf59c94..33b51cbfb1d4a 100644 --- a/apps/meteor/app/api/server/helpers/parseJsonQuery.ts +++ b/apps/meteor/app/api/server/helpers/parseJsonQuery.ts @@ -94,7 +94,7 @@ export async function parseJsonQuery(api: GenericRouteExecutionContext): Promise Object.keys(fields).forEach((k) => { if (nonSelectableFields.includes(k) || nonSelectableFields.includes(k.split(API.v1.fieldSeparator)[0])) { - fields && delete fields[k as keyof typeof fields]; + fields && delete fields[k]; } }); } diff --git a/apps/meteor/app/api/server/lib/isValidQuery.ts b/apps/meteor/app/api/server/lib/isValidQuery.ts index ef8a0716505cb..912c14c7ae595 100644 --- a/apps/meteor/app/api/server/lib/isValidQuery.ts +++ b/apps/meteor/app/api/server/lib/isValidQuery.ts @@ -15,7 +15,6 @@ export const isValidQuery: { throw new Error('query must be an object'); } - // eslint-disable-next-line @typescript-eslint/no-use-before-define return verifyQuery(query, allowedAttributes, allowedOperations); }, { diff --git a/apps/meteor/app/api/server/v1/calendar.ts b/apps/meteor/app/api/server/v1/calendar.ts index 5eff639a80f5e..4318037fbd379 100644 --- a/apps/meteor/app/api/server/v1/calendar.ts +++ b/apps/meteor/app/api/server/v1/calendar.ts @@ -35,7 +35,7 @@ API.v1.addRoute( const event = await Calendar.get(id); - if (!event || event.uid !== userId) { + if (event?.uid !== userId) { return API.v1.failure(); } @@ -104,7 +104,7 @@ API.v1.addRoute( const event = await Calendar.get(eventId); - if (!event || event.uid !== userId) { + if (event?.uid !== userId) { throw new Error('invalid-calendar-event'); } @@ -133,7 +133,7 @@ API.v1.addRoute( const event = await Calendar.get(eventId); - if (!event || event.uid !== userId) { + if (event?.uid !== userId) { throw new Error('invalid-calendar-event'); } diff --git a/apps/meteor/app/api/server/v1/channels.ts b/apps/meteor/app/api/server/v1/channels.ts index 5dfdc22c237ee..c141d02747912 100644 --- a/apps/meteor/app/api/server/v1/channels.ts +++ b/apps/meteor/app/api/server/v1/channels.ts @@ -309,7 +309,7 @@ API.v1.addRoute( rid: findResult._id, ...parseIds(mentionIds, 'mentions._id'), ...parseIds(starredIds, 'starred._id'), - ...(pinned && pinned.toLowerCase() === 'true' ? { pinned: true } : {}), + ...(pinned?.toLowerCase() === 'true' ? { pinned: true } : {}), _hidden: { $ne: true }, }; diff --git a/apps/meteor/app/api/server/v1/chat.ts b/apps/meteor/app/api/server/v1/chat.ts index 50fc5165f7387..1aae3fe767a29 100644 --- a/apps/meteor/app/api/server/v1/chat.ts +++ b/apps/meteor/app/api/server/v1/chat.ts @@ -410,17 +410,17 @@ const chatEndpoints = API.v1 this.userId, hasContent ? { - _id: msg._id, - rid: msg.rid, - content: bodyParams.content, - ...(bodyParams.e2eMentions && { e2eMentions: bodyParams.e2eMentions }), - } + _id: msg._id, + rid: msg.rid, + content: bodyParams.content, + ...(bodyParams.e2eMentions && { e2eMentions: bodyParams.e2eMentions }), + } : { - _id: msg._id, - rid: msg.rid, - msg: bodyParams.text, - ...(bodyParams.customFields && { customFields: bodyParams.customFields }), - }, + _id: msg._id, + rid: msg.rid, + msg: bodyParams.text, + ...(bodyParams.customFields && { customFields: bodyParams.customFields }), + }, 'previewUrls' in bodyParams ? bodyParams.previewUrls : undefined, ]; @@ -1072,5 +1072,5 @@ export type ChatEndpoints = ExtractRoutesFromAPI; declare module '@rocket.chat/rest-typings' { // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface - interface Endpoints extends ChatEndpoints { } + interface Endpoints extends ChatEndpoints {} } diff --git a/apps/meteor/app/api/server/v1/custom-sounds.ts b/apps/meteor/app/api/server/v1/custom-sounds.ts index a2fa2b675f07f..1fb4e384d1b22 100644 --- a/apps/meteor/app/api/server/v1/custom-sounds.ts +++ b/apps/meteor/app/api/server/v1/custom-sounds.ts @@ -100,7 +100,7 @@ const customSoundsEndpoints = API.v1 const filter = { ...query, - ...(name ? { name: { $regex: escapeRegExp(name as string), $options: 'i' } } : {}), + ...(name ? { name: { $regex: escapeRegExp(name), $options: 'i' } } : {}), }; const { cursor, totalCount } = CustomSounds.findPaginated(filter, { diff --git a/apps/meteor/app/api/server/v1/custom-user-status.ts b/apps/meteor/app/api/server/v1/custom-user-status.ts index 4d4297cfe001c..1e9b2f2210bb7 100644 --- a/apps/meteor/app/api/server/v1/custom-user-status.ts +++ b/apps/meteor/app/api/server/v1/custom-user-status.ts @@ -100,7 +100,7 @@ const customUserStatusEndpoints = API.v1.get( const filter = { ...query, - ...(name ? { name: { $regex: escapeRegExp(name as string), $options: 'i' } } : {}), + ...(name ? { name: { $regex: escapeRegExp(name), $options: 'i' } } : {}), ...(_id ? { _id } : {}), }; diff --git a/apps/meteor/app/api/server/v1/e2e.ts b/apps/meteor/app/api/server/v1/e2e.ts index aba7e3a0db952..827006f68c9d0 100644 --- a/apps/meteor/app/api/server/v1/e2e.ts +++ b/apps/meteor/app/api/server/v1/e2e.ts @@ -510,7 +510,6 @@ API.v1.addRoute( }, { async post() { - // eslint-disable-next-line @typescript-eslint/naming-convention const { public_key, private_key, force } = this.bodyParams; await setUserPublicAndPrivateKeysMethod(this.userId, { diff --git a/apps/meteor/app/api/server/v1/groups.ts b/apps/meteor/app/api/server/v1/groups.ts index 2437813860836..93f6210c981ac 100644 --- a/apps/meteor/app/api/server/v1/groups.ts +++ b/apps/meteor/app/api/server/v1/groups.ts @@ -67,7 +67,7 @@ async function getRoomFromParams(params: { roomId?: string } | { roomName?: stri } })(); - if (!room || room.t !== 'p') { + if (room?.t !== 'p') { throw new Meteor.Error('error-room-not-found', 'The required "roomId" or "roomName" param provided does not match any group'); } @@ -273,7 +273,7 @@ API.v1.addRoute( room = await Rooms.findOneByName(params.roomName || ''); } - if (!room || room.t !== 'p') { + if (room?.t !== 'p') { throw new Meteor.Error('error-room-not-found', 'The required "roomId" or "roomName" param provided does not match any group'); } @@ -791,7 +791,7 @@ API.v1.addRoute( rid: findResult.rid, ...parseIds(mentionIds, 'mentions._id'), ...parseIds(starredIds, 'starred._id'), - ...(pinned && pinned.toLowerCase() === 'true' ? { pinned: true } : {}), + ...(pinned?.toLowerCase() === 'true' ? { pinned: true } : {}), _hidden: { $ne: true }, }; diff --git a/apps/meteor/app/api/server/v1/im.ts b/apps/meteor/app/api/server/v1/im.ts index f97bd6e7e9161..55d6c4c2a5eb1 100644 --- a/apps/meteor/app/api/server/v1/im.ts +++ b/apps/meteor/app/api/server/v1/im.ts @@ -510,7 +510,7 @@ API.v1.addRoute( ...query, ...parseIds(mentionIds, 'mentions._id'), ...parseIds(starredIds, 'starred._id'), - ...(pinned && pinned.toLowerCase() === 'true' ? { pinned: true } : {}), + ...(pinned?.toLowerCase() === 'true' ? { pinned: true } : {}), _hidden: { $ne: true }, }; const sortObj = sort || { ts: -1 }; diff --git a/apps/meteor/app/api/server/v1/integrations.ts b/apps/meteor/app/api/server/v1/integrations.ts index 78d77fe007f39..6457666882729 100644 --- a/apps/meteor/app/api/server/v1/integrations.ts +++ b/apps/meteor/app/api/server/v1/integrations.ts @@ -110,7 +110,7 @@ API.v1.addRoute( const filter = { ...query, - ...(name ? { name: { $regex: escapeRegExp(name as string), $options: 'i' } } : {}), + ...(name ? { name: { $regex: escapeRegExp(name), $options: 'i' } } : {}), ...(type ? { type } : {}), }; diff --git a/apps/meteor/app/api/server/v1/roles.ts b/apps/meteor/app/api/server/v1/roles.ts index 8985e48c0aff5..931ab7d3cba4a 100644 --- a/apps/meteor/app/api/server/v1/roles.ts +++ b/apps/meteor/app/api/server/v1/roles.ts @@ -119,9 +119,9 @@ API.v1.addRoute( } const { cursor, totalCount } = await getUsersInRolePaginated(roleData._id, roomId, { - limit: count as number, + limit: count, sort: { username: 1 }, - skip: offset as number, + skip: offset, projection, }); diff --git a/apps/meteor/app/api/server/v1/rooms.ts b/apps/meteor/app/api/server/v1/rooms.ts index 930e9cd8168cb..08bb8f9979bb5 100644 --- a/apps/meteor/app/api/server/v1/rooms.ts +++ b/apps/meteor/app/api/server/v1/rooms.ts @@ -322,7 +322,7 @@ API.v1.addRoute( } await Promise.all( - Object.entries(notifications as Notifications).map(async ([notificationKey, notificationValue]) => + Object.entries(notifications).map(async ([notificationKey, notificationValue]) => saveNotificationSettingsMethod(this.userId, roomId, notificationKey as NotificationFieldType, notificationValue), ), ); @@ -421,7 +421,6 @@ API.v1.addRoute( { authRequired: true /* , validateParams: isRoomsCreateDiscussionProps */ }, { async post() { - // eslint-disable-next-line @typescript-eslint/naming-convention const { prid, pmid, reply, t_name, users, encrypted, topic } = this.bodyParams; if (!prid) { return API.v1.failure('Body parameter "prid" is required.'); @@ -516,7 +515,7 @@ API.v1.addRoute( const [files, total] = await Promise.all([cursor.toArray(), totalCount]); // If the initial image was not returned in the query, insert it as the first element of the list - if (initialImage && !files.find(({ _id }) => _id === (initialImage as IUpload)._id)) { + if (initialImage && !files.find(({ _id }) => _id === initialImage._id)) { files.splice(0, 0, initialImage); } @@ -733,7 +732,7 @@ API.v1.addRoute( void dataExport.sendFile( { rid, - format: format as 'html' | 'json', + format, dateFrom: convertedDateFrom, dateTo: convertedDateTo, }, @@ -781,7 +780,7 @@ API.v1.addRoute( const [room, user] = await Promise.all([ findRoomByIdOrName({ params: { roomId }, - }) as Promise, + }), Users.findOneByIdOrUsername(userId || username), ]); @@ -1211,9 +1210,7 @@ export const roomEndpoints = API.v1 }, ); -type RoomEndpoints = ExtractRoutesFromAPI & - ExtractRoutesFromAPI & - ExtractRoutesFromAPI; +type RoomEndpoints = ExtractRoutesFromAPI & ExtractRoutesFromAPI; declare module '@rocket.chat/rest-typings' { // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface diff --git a/apps/meteor/app/api/server/v1/subscriptions.ts b/apps/meteor/app/api/server/v1/subscriptions.ts index b6e406bbfc969..b36fa4f4aff40 100644 --- a/apps/meteor/app/api/server/v1/subscriptions.ts +++ b/apps/meteor/app/api/server/v1/subscriptions.ts @@ -24,10 +24,10 @@ API.v1.addRoute( let updatedSinceDate: Date | undefined; if (updatedSince) { - if (isNaN(Date.parse(updatedSince as string))) { + if (isNaN(Date.parse(updatedSince))) { throw new Meteor.Error('error-roomId-param-invalid', 'The "lastUpdate" query parameter must be a valid date.'); } - updatedSinceDate = new Date(updatedSince as string); + updatedSinceDate = new Date(updatedSince); } const result = await getSubscriptions(this.userId, updatedSinceDate); diff --git a/apps/meteor/app/api/server/v1/videoConference.ts b/apps/meteor/app/api/server/v1/videoConference.ts index 5036eed09cc2d..16226d149e8c9 100644 --- a/apps/meteor/app/api/server/v1/videoConference.ts +++ b/apps/meteor/app/api/server/v1/videoConference.ts @@ -29,7 +29,7 @@ API.v1.addRoute( } try { - await canSendMessageAsync(roomId, { uid: userId, username: this.user.username!, type: this.user.type! }); + await canSendMessageAsync(roomId, { uid: userId, username: this.user.username!, type: this.user.type }); } catch (error) { return API.v1.forbidden(); } diff --git a/apps/meteor/app/apple/server/loginHandler.ts b/apps/meteor/app/apple/server/loginHandler.ts index 18ac7ddd75268..c9b335fcba5de 100644 --- a/apps/meteor/app/apple/server/loginHandler.ts +++ b/apps/meteor/app/apple/server/loginHandler.ts @@ -32,7 +32,7 @@ Accounts.registerLoginHandler('apple', async (loginRequest) => { const result = Accounts.updateOrCreateUserFromExternalService('apple', serviceData, { profile }); // Ensure processing succeeded - if (result === undefined || result.userId === undefined) { + if (result?.userId === undefined) { return { type: 'apple', error: new Meteor.Error(Accounts.LoginCancelledError.numericError, 'User creation failed from Apple response token'), diff --git a/apps/meteor/app/apps/server/bridges/activation.ts b/apps/meteor/app/apps/server/bridges/activation.ts index 399dfd285e65e..13feb717663d1 100644 --- a/apps/meteor/app/apps/server/bridges/activation.ts +++ b/apps/meteor/app/apps/server/bridges/activation.ts @@ -5,7 +5,6 @@ import { UserStatus } from '@rocket.chat/core-typings'; import { Users } from '@rocket.chat/models'; export class AppActivationBridge extends ActivationBridge { - // eslint-disable-next-line no-empty-function constructor(private readonly orch: IAppServerOrchestrator) { super(); } diff --git a/apps/meteor/app/apps/server/bridges/livechat.ts b/apps/meteor/app/apps/server/bridges/livechat.ts index 6952ac6f5457c..05b61f2bf9ab9 100644 --- a/apps/meteor/app/apps/server/bridges/livechat.ts +++ b/apps/meteor/app/apps/server/bridges/livechat.ts @@ -57,7 +57,7 @@ export class AppLivechatBridge extends LivechatBridge { // #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed. const guest = this.orch.getConverters().get('visitors').convertAppVisitor(message.visitor); - const appMessage = (await this.orch.getConverters().get('messages').convertAppMessage(message)) as IMessage | undefined; + const appMessage = await this.orch.getConverters().get('messages').convertAppMessage(message); const livechatMessage = appMessage as ILivechatMessage | undefined; const msg = await sendMessage({ @@ -121,13 +121,12 @@ export class AppLivechatBridge extends LivechatBridge { type: OmnichannelSourceType.APP, id: appId, alias: this.orch.getManager()?.getOneById(appId)?.getName(), - ...(source && - source.type === 'app' && { - sidebarIcon: source.sidebarIcon, - defaultIcon: source.defaultIcon, - label: source.label, - destination: source.destination, - }), + ...(source?.type === 'app' && { + sidebarIcon: source.sidebarIcon, + defaultIcon: source.defaultIcon, + label: source.label, + destination: source.destination, + }), }, }, agent: agentRoom, diff --git a/apps/meteor/app/apps/server/bridges/roles.ts b/apps/meteor/app/apps/server/bridges/roles.ts index aa0fcdc7b80b7..25dadf8471213 100644 --- a/apps/meteor/app/apps/server/bridges/roles.ts +++ b/apps/meteor/app/apps/server/bridges/roles.ts @@ -8,7 +8,7 @@ export class AppRoleBridge extends RoleBridge { super(); } - protected async getOneByIdOrName(idOrName: IAppsRole['id'] | IAppsRole['name'], appId: string): Promise { + protected async getOneByIdOrName(idOrName: IAppsRole['id'], appId: string): Promise { this.orch.debugLog(`The App ${appId} is getting the roleByIdOrName: "${idOrName}"`); // #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed. diff --git a/apps/meteor/app/apps/server/bridges/scheduler.ts b/apps/meteor/app/apps/server/bridges/scheduler.ts index b08d49182c9bc..088f0e49e1604 100644 --- a/apps/meteor/app/apps/server/bridges/scheduler.ts +++ b/apps/meteor/app/apps/server/bridges/scheduler.ts @@ -90,7 +90,7 @@ export class AppSchedulerBridge extends SchedulerBridge { }); if (runAfterRegister.length) { - return Promise.all(runAfterRegister) as Promise>; + return Promise.all(runAfterRegister); } } diff --git a/apps/meteor/app/apps/server/converters/threads.ts b/apps/meteor/app/apps/server/converters/threads.ts index 376488f3ec3ca..72f794763c07b 100644 --- a/apps/meteor/app/apps/server/converters/threads.ts +++ b/apps/meteor/app/apps/server/converters/threads.ts @@ -51,7 +51,7 @@ export class AppThreadsConverter implements IAppThreadsConverter { const replies = await Messages.find(query).toArray(); - const room = (await this.orch.getConverters().get('rooms').convertById(mainMessage.rid)) as IRoom | undefined; + const room = await this.orch.getConverters().get('rooms').convertById(mainMessage.rid); if (!room) { return []; @@ -120,7 +120,7 @@ export class AppThreadsConverter implements IAppThreadsConverter { user = await convertToApp(message.u as unknown as IUser); } - return user as IAppsUser; + return user; }, files: async (message: IMessage) => convertMessageFiles(message.files, attachments), } as const; diff --git a/apps/meteor/app/authorization/server/functions/getUsersInRole.ts b/apps/meteor/app/authorization/server/functions/getUsersInRole.ts index 3b3af203221a6..d4cb49abfa349 100644 --- a/apps/meteor/app/authorization/server/functions/getUsersInRole.ts +++ b/apps/meteor/app/authorization/server/functions/getUsersInRole.ts @@ -14,11 +14,7 @@ export function getUsersInRole

( options: FindOptions

, ): Promise>; -export function getUsersInRole

( - roleId: IRole['_id'], - scope: string | undefined, - options?: any | undefined, -): Promise> { +export function getUsersInRole

(roleId: IRole['_id'], scope: string | undefined, options?: any): Promise> { // TODO move the code from Roles.findUsersInRole to here and change all places to use this function return Roles.findUsersInRole(roleId, scope, options); } @@ -26,7 +22,7 @@ export function getUsersInRole

( export async function getUsersInRolePaginated( roleId: IRole['_id'], scope: string | undefined, - options?: any | undefined, + options?: any, ): Promise>> { if (process.env.NODE_ENV === 'development' && (scope === 'Users' || scope === 'Subscriptions')) { throw new Error('Roles.findUsersInRole method received a role scope instead of a scope value.'); diff --git a/apps/meteor/app/authorization/server/functions/hasRole.ts b/apps/meteor/app/authorization/server/functions/hasRole.ts index 00f781725c55c..6326d76800802 100644 --- a/apps/meteor/app/authorization/server/functions/hasRole.ts +++ b/apps/meteor/app/authorization/server/functions/hasRole.ts @@ -4,11 +4,7 @@ import { Roles } from '@rocket.chat/models'; /** * @deprecated use `Authorization.hasAnyRole` instead */ -export const hasAnyRoleAsync = async ( - userId: IUser['_id'], - roleIds: IRole['_id'][], - scope?: IRoom['_id'] | undefined, -): Promise => { +export const hasAnyRoleAsync = async (userId: IUser['_id'], roleIds: IRole['_id'][], scope?: IRoom['_id']): Promise => { if (!Array.isArray(roleIds)) { throw new Error('error-invalid-arguments'); } @@ -20,7 +16,7 @@ export const hasAnyRoleAsync = async ( return Roles.isUserInRoles(userId, roleIds, scope); }; -export const hasRoleAsync = async (userId: IUser['_id'], roleId: IRole['_id'], scope?: IRoom['_id'] | undefined): Promise => { +export const hasRoleAsync = async (userId: IUser['_id'], roleId: IRole['_id'], scope?: IRoom['_id']): Promise => { if (Array.isArray(roleId)) { throw new Error('error-invalid-arguments'); } diff --git a/apps/meteor/app/autotranslate/server/googleTranslate.ts b/apps/meteor/app/autotranslate/server/googleTranslate.ts index 4ffa557406154..ae73abce93d16 100644 --- a/apps/meteor/app/autotranslate/server/googleTranslate.ts +++ b/apps/meteor/app/autotranslate/server/googleTranslate.ts @@ -157,8 +157,7 @@ class GoogleAutoTranslate extends AutoTranslate { if ( result.status === 200 && - body.data && - body.data.translations && + body.data?.translations && Array.isArray(body.data.translations) && body.data.translations.length > 0 ) { @@ -206,8 +205,7 @@ class GoogleAutoTranslate extends AutoTranslate { if ( result.status === 200 && - body.data && - body.data.translations && + body.data?.translations && Array.isArray(body.data.translations) && body.data.translations.length > 0 ) { diff --git a/apps/meteor/app/crowd/server/crowd.ts b/apps/meteor/app/crowd/server/crowd.ts index 54cefce69ad48..0fd045caa4f3b 100644 --- a/apps/meteor/app/crowd/server/crowd.ts +++ b/apps/meteor/app/crowd/server/crowd.ts @@ -378,7 +378,7 @@ Accounts.registerLoginHandler('crowd', async function (this: typeof Accounts, lo const crowd = new CROWD(); const user = await crowd.authenticate(loginRequest.username, loginRequest.crowdPassword); - if (user && user.crowd === false) { + if (user?.crowd === false) { logger.debug({ msg: 'User is not a valid crowd user, falling back', username: loginRequest.username }); return fallbackDefaultAccountSystem(this, loginRequest.username, loginRequest.crowdPassword); } diff --git a/apps/meteor/app/discussion/server/methods/createDiscussion.ts b/apps/meteor/app/discussion/server/methods/createDiscussion.ts index 65804410c405a..36712024b63a2 100644 --- a/apps/meteor/app/discussion/server/methods/createDiscussion.ts +++ b/apps/meteor/app/discussion/server/methods/createDiscussion.ts @@ -85,7 +85,7 @@ const create = async ({ } if (prid) { const parentRoom = await getParentRoom(message.rid); - if (!parentRoom || prid !== parentRoom._id) { + if (prid !== parentRoom?._id) { throw new Meteor.Error('error-invalid-arguments', 'Root message room ID does not match parent room ID ', { method: 'DiscussionCreation', }); diff --git a/apps/meteor/app/emoji/client/emojiParser.ts b/apps/meteor/app/emoji/client/emojiParser.ts index c919642d28345..e7455b8416a1d 100644 --- a/apps/meteor/app/emoji/client/emojiParser.ts +++ b/apps/meteor/app/emoji/client/emojiParser.ts @@ -26,7 +26,7 @@ export const emojiParser = (html: string) => { emojis.forEach((emojiElement) => { const htmlElement = emojiElement.parentElement; - if (htmlElement && htmlElement.nodeName === 'CODE') { + if (htmlElement?.nodeName === 'CODE') { emojiElement.replaceWith(emojiElement.getAttribute('title') ?? ''); } }); diff --git a/apps/meteor/app/error-handler/server/lib/RocketChat.ErrorHandler.ts b/apps/meteor/app/error-handler/server/lib/RocketChat.ErrorHandler.ts index 68300cb24e59c..de20cc8f43aed 100644 --- a/apps/meteor/app/error-handler/server/lib/RocketChat.ErrorHandler.ts +++ b/apps/meteor/app/error-handler/server/lib/RocketChat.ErrorHandler.ts @@ -68,7 +68,6 @@ Meteor.startup(async () => { }); }); -// eslint-disable-next-line @typescript-eslint/no-this-alias const originalMeteorDebug = Meteor._debug; Meteor._debug = function (message, stack, ...args) { diff --git a/apps/meteor/app/file-upload/server/lib/FileUpload.ts b/apps/meteor/app/file-upload/server/lib/FileUpload.ts index 89878e783a413..3cddf565aebaf 100644 --- a/apps/meteor/app/file-upload/server/lib/FileUpload.ts +++ b/apps/meteor/app/file-upload/server/lib/FileUpload.ts @@ -238,8 +238,8 @@ export const FileUpload = { const tempFilePath = UploadFS.getTempFilePath(file._id); - const height = settings.get('Accounts_AvatarSize') as number; - const width = height as number; + const height = settings.get('Accounts_AvatarSize'); + const width = height; const s = sharp(tempFilePath); if (settings.get('FileUpload_RotateImages') === true) { @@ -307,8 +307,8 @@ export const FileUpload = { return; } - const width = settings.get('Message_Attachments_Thumbnails_Width') as number; - const height = settings.get('Message_Attachments_Thumbnails_Height') as number; + const width = settings.get('Message_Attachments_Thumbnails_Width'); + const height = settings.get('Message_Attachments_Thumbnails_Height'); if (fileParam.identify?.size && fileParam.identify.size.height < height && fileParam.identify?.size.width < width) { return; @@ -334,7 +334,7 @@ export const FileUpload = { height, thumbFileType: (mime.lookup(format) as string) || '', thumbFileName: file?.name as string, - originalFileId: file?._id as string, + originalFileId: file?._id, })); image.pipe(transformer); @@ -454,7 +454,7 @@ export const FileUpload = { } const { query } = URL.parse(url, true); - // eslint-disable-next-line @typescript-eslint/naming-convention + let { rc_uid, rc_token, rc_rid, rc_room_type } = query as Record; const { token } = query; @@ -671,7 +671,6 @@ export const FileUpload = { return; } - // eslint-disable-next-line prettier/prettier const headersToProxy = ['age', 'cache-control', 'content-length', 'content-type', 'date', 'expired', 'last-modified']; headersToProxy.forEach((header) => { diff --git a/apps/meteor/app/importer/server/classes/converters/RoomConverter.ts b/apps/meteor/app/importer/server/classes/converters/RoomConverter.ts index 97ed061ec8377..3db5e4a21b56b 100644 --- a/apps/meteor/app/importer/server/classes/converters/RoomConverter.ts +++ b/apps/meteor/app/importer/server/classes/converters/RoomConverter.ts @@ -53,7 +53,7 @@ export class RoomConverter extends RecordConverter { } async findExistingRoom(data: IImportChannel): Promise { - if (data._id && data._id.toUpperCase() === 'GENERAL') { + if (data._id?.toUpperCase() === 'GENERAL') { const room = await Rooms.findOneById('GENERAL', {}); // Prevent the importer from trying to create a new general if (!room) { @@ -84,7 +84,7 @@ export class RoomConverter extends RecordConverter { async updateRoom(room: IRoom, roomData: IImportChannel, startedByUserId: string): Promise { roomData._id = room._id; - if ((roomData._id as string).toUpperCase() === 'GENERAL' && roomData.name !== room.name) { + if (roomData._id.toUpperCase() === 'GENERAL' && roomData.name !== room.name) { await saveRoomSettings(startedByUserId, 'GENERAL', 'roomName', roomData.name); } diff --git a/apps/meteor/app/integrations/server/api/api.ts b/apps/meteor/app/integrations/server/api/api.ts index 511b22f3f97d0..8759079cb9d9e 100644 --- a/apps/meteor/app/integrations/server/api/api.ts +++ b/apps/meteor/app/integrations/server/api/api.ts @@ -27,7 +27,6 @@ import { deleteOutgoingIntegration } from '../methods/outgoing/deleteOutgoingInt const ivmEngine = new IsolatedVMScriptEngine(true); -// eslint-disable-next-line no-unused-vars function getEngine(_integration: IIntegration): IsolatedVMScriptEngine { return ivmEngine; } @@ -59,7 +58,7 @@ async function createIntegration(options: IntegrationOptions, user: IUser): Prom if (options.data == null) { options.data = {}; } - if (options.data.channel_name != null && options.data.channel_name.indexOf('#') === -1) { + if (options.data.channel_name?.indexOf('#') === -1) { options.data.channel_name = `#${options.data.channel_name}`; } return addOutgoingIntegration(user._id, { diff --git a/apps/meteor/app/integrations/server/lib/isolated-vm/buildSandbox.ts b/apps/meteor/app/integrations/server/lib/isolated-vm/buildSandbox.ts index 1bbefb6a2ee7a..3c57740fc7bd7 100644 --- a/apps/meteor/app/integrations/server/lib/isolated-vm/buildSandbox.ts +++ b/apps/meteor/app/integrations/server/lib/isolated-vm/buildSandbox.ts @@ -17,7 +17,7 @@ const proxyObject = (obj: Record, forbiddenKeys: string[] = []): Re if (typeof value === 'function') { return new ivm.Reference(async (...args: any[]) => { - const result = (obj[key] as any)(...args); + const result = obj[key](...args); if (result && result instanceof Promise) { return new Promise(async (resolve, reject) => { diff --git a/apps/meteor/app/integrations/server/lib/triggerHandler.ts b/apps/meteor/app/integrations/server/lib/triggerHandler.ts index 135c88bdde228..7ed8811b7193e 100644 --- a/apps/meteor/app/integrations/server/lib/triggerHandler.ts +++ b/apps/meteor/app/integrations/server/lib/triggerHandler.ts @@ -92,7 +92,6 @@ class RocketChatIntegrationHandler { } } - // eslint-disable-next-line no-unused-vars getEngine(_integration: any): IsolatedVMScriptEngine { return this.ivmEngine; } @@ -797,11 +796,11 @@ class RocketChatIntegrationHandler { } async replay(integration: IOutgoingIntegration, history: IIntegrationHistory) { - if (!integration || integration.type !== 'webhook-outgoing') { + if (integration?.type !== 'webhook-outgoing') { throw new Meteor.Error('integration-type-must-be-outgoing', 'The integration type to replay must be an outgoing webhook.'); } - if (!history || !history.data) { + if (!history?.data) { throw new Meteor.Error('history-data-must-be-defined', 'The history data must be defined to replay an integration.'); } @@ -811,7 +810,7 @@ class RocketChatIntegrationHandler { let room; let user; - if (history.data.owner && history.data.owner._id) { + if (history.data.owner?._id) { owner = await Users.findOneById(history.data.owner._id); } if (history.data.message_id) { diff --git a/apps/meteor/app/integrations/server/methods/incoming/updateIncomingIntegration.ts b/apps/meteor/app/integrations/server/methods/incoming/updateIncomingIntegration.ts index 774d7a0d597a0..be370184e1bab 100644 --- a/apps/meteor/app/integrations/server/methods/incoming/updateIncomingIntegration.ts +++ b/apps/meteor/app/integrations/server/methods/incoming/updateIncomingIntegration.ts @@ -206,7 +206,6 @@ export const updateIncomingIntegration = async ( }; Meteor.methods({ - // eslint-disable-next-line complexity async updateIncomingIntegration(integrationId, integration) { if (!this.userId) { throw new Meteor.Error('error-invalid-user', 'Invalid user', { diff --git a/apps/meteor/app/lib/server/functions/createRoom.ts b/apps/meteor/app/lib/server/functions/createRoom.ts index a9cd1330d6148..1297af8839f6e 100644 --- a/apps/meteor/app/lib/server/functions/createRoom.ts +++ b/apps/meteor/app/lib/server/functions/createRoom.ts @@ -139,7 +139,6 @@ async function createUsersSubscriptions({ await Rooms.incUsersCountById(room._id, subs.length); } -// eslint-disable-next-line complexity export const createRoom = async ( type: T, name: T extends 'd' ? undefined : string, diff --git a/apps/meteor/app/lib/server/functions/deleteMessage.ts b/apps/meteor/app/lib/server/functions/deleteMessage.ts index f00e7edb98e7b..65193c59c4753 100644 --- a/apps/meteor/app/lib/server/functions/deleteMessage.ts +++ b/apps/meteor/app/lib/server/functions/deleteMessage.ts @@ -120,7 +120,7 @@ async function deleteThreadMessage(message: IThreadMessage, user: IUser, room: I } } - if (updatedParentMessage && updatedParentMessage.tcount === 0) { + if (updatedParentMessage?.tcount === 0) { void notifyOnMessageChange({ id: message.tmid, }); diff --git a/apps/meteor/app/lib/server/functions/isTheLastMessage.ts b/apps/meteor/app/lib/server/functions/isTheLastMessage.ts index f1f1fb4c1497d..1680cfc13a6fa 100644 --- a/apps/meteor/app/lib/server/functions/isTheLastMessage.ts +++ b/apps/meteor/app/lib/server/functions/isTheLastMessage.ts @@ -2,6 +2,5 @@ import type { IMessage, IRoom, AtLeast } from '@rocket.chat/core-typings'; import { settings } from '../../../settings/server'; -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const isTheLastMessage = (room: AtLeast, message: Pick) => settings.get('Store_Last_Message') && (!room.lastMessage || room.lastMessage._id === message._id); diff --git a/apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts b/apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts index 35fb39b5336f6..1a72ffffc741b 100644 --- a/apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts +++ b/apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts @@ -16,7 +16,7 @@ export const saveNewUser = async function (userData: SaveUserData, sendPassword: await validateEmailDomain(userData.email); const roles = (!!userData.roles && userData.roles.length > 0 && userData.roles) || getNewUserRoles(); - const isGuest = roles && roles.length === 1 && roles.includes('guest'); + const isGuest = roles?.length === 1 && roles.includes('guest'); // insert user const createUser: Record = { diff --git a/apps/meteor/app/lib/server/functions/setEmail.ts b/apps/meteor/app/lib/server/functions/setEmail.ts index f9a911e85b3c3..14a08be7ec04f 100644 --- a/apps/meteor/app/lib/server/functions/setEmail.ts +++ b/apps/meteor/app/lib/server/functions/setEmail.ts @@ -66,7 +66,7 @@ export const setEmail = async function ( } // User already has desired username, return - if (user?.emails?.[0] && user.emails[0].address === email) { + if (user?.emails?.[0]?.address === email) { return user; } diff --git a/apps/meteor/app/lib/server/functions/setRealName.ts b/apps/meteor/app/lib/server/functions/setRealName.ts index d33aa01406230..7689973f69519 100644 --- a/apps/meteor/app/lib/server/functions/setRealName.ts +++ b/apps/meteor/app/lib/server/functions/setRealName.ts @@ -27,7 +27,7 @@ export const setRealName = async function ( } // User already has desired name, return - if (user.name && user.name.trim() === name) { + if (user.name?.trim() === name) { return user; } diff --git a/apps/meteor/app/lib/server/functions/setUsername.ts b/apps/meteor/app/lib/server/functions/setUsername.ts index 9eeff3a14a0e3..c7e8f318a6c28 100644 --- a/apps/meteor/app/lib/server/functions/setUsername.ts +++ b/apps/meteor/app/lib/server/functions/setUsername.ts @@ -49,7 +49,7 @@ export const setUsernameWithValidation = async (userId: string, username: string throw new Meteor.Error('error-not-allowed', 'Not allowed'); } - if (user.username === username || (user.username && user.username.toLowerCase() === username.toLowerCase())) { + if (user.username === username || user.username?.toLowerCase() === username.toLowerCase()) { return; } diff --git a/apps/meteor/app/lib/server/functions/updateGroupDMsName.ts b/apps/meteor/app/lib/server/functions/updateGroupDMsName.ts index 6e0eb970b9bc5..ba7427ee4d42c 100644 --- a/apps/meteor/app/lib/server/functions/updateGroupDMsName.ts +++ b/apps/meteor/app/lib/server/functions/updateGroupDMsName.ts @@ -57,7 +57,6 @@ export const updateGroupDMsName = async ( const rooms = Rooms.findGroupDMsByUids([userThatChangedName._id], { projection: { uids: 1 }, session }); - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type const getMembers = (uids: string[]) => uids.map((uid) => users.get(uid)).filter(isNotUndefined); // loop rooms to update the subscriptions from them all diff --git a/apps/meteor/app/lib/server/lib/processDirectEmail.ts b/apps/meteor/app/lib/server/lib/processDirectEmail.ts index e88b7d58468e4..61c786730de32 100644 --- a/apps/meteor/app/lib/server/lib/processDirectEmail.ts +++ b/apps/meteor/app/lib/server/lib/processDirectEmail.ts @@ -29,7 +29,7 @@ export const processDirectEmail = async function (email: ParsedMail): Promise (settings.get('Message_MaxAllowedSize') as number)) { + if (msg && msg.length > settings.get('Message_MaxAllowedSize')) { return; } const emailAdress = email.from.value[0].address; diff --git a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts index 0a347c7526abc..5a4e553346b0a 100644 --- a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts +++ b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts @@ -401,7 +401,7 @@ export async function sendAllNotifications(message: IMessage, room: IRoom) { return message; } - if (!room || room.t == null) { + if (room?.t == null) { return message; } diff --git a/apps/meteor/app/lib/server/methods/saveSettings.ts b/apps/meteor/app/lib/server/methods/saveSettings.ts index 11458f2f0be78..e8efa3be6ebd1 100644 --- a/apps/meteor/app/lib/server/methods/saveSettings.ts +++ b/apps/meteor/app/lib/server/methods/saveSettings.ts @@ -130,8 +130,8 @@ Meteor.methods({ const auditSettingOperation = updateAuditedByUser({ _id: uid, username: (await Meteor.userAsync())!.username!, - ip: this.connection!.clientAddress || '', - useragent: this.connection!.httpHeaders['user-agent'] || '', + ip: this.connection.clientAddress || '', + useragent: this.connection.httpHeaders['user-agent'] || '', }); const promises = params.map(({ _id, value }) => auditSettingOperation(Settings.updateValueById, _id, value)); diff --git a/apps/meteor/app/lib/server/methods/setEmail.ts b/apps/meteor/app/lib/server/methods/setEmail.ts index e1faece1e9919..fd78b077a1b06 100644 --- a/apps/meteor/app/lib/server/methods/setEmail.ts +++ b/apps/meteor/app/lib/server/methods/setEmail.ts @@ -24,7 +24,7 @@ export const setEmailFunction = async (email: string, user: Meteor.User | IUser) }); } - if (user.emails?.[0] && user.emails[0].address === email) { + if (user.emails?.[0]?.address === email) { return email; } diff --git a/apps/meteor/app/livechat/server/api/v1/room.ts b/apps/meteor/app/livechat/server/api/v1/room.ts index a06c8c2743753..add9393af786c 100644 --- a/apps/meteor/app/livechat/server/api/v1/room.ts +++ b/apps/meteor/app/livechat/server/api/v1/room.ts @@ -67,7 +67,7 @@ API.v1.addRoute( agentId: Match.Maybe(String), }); - check(this.queryParams, extraCheckParams as any); + check(this.queryParams, extraCheckParams); const { token, rid, agentId, ...extraParams } = this.queryParams; @@ -291,7 +291,7 @@ API.v1.addRoute( }; const room = await LivechatRooms.findOneById(this.bodyParams.roomId); - if (!room || room.t !== 'l') { + if (room?.t !== 'l') { throw new Error('error-invalid-room'); } @@ -358,7 +358,7 @@ const livechatVisitorDepartmentTransfer = API.v1.post( } const room = await LivechatRooms.findOneById(rid); - if (!room || room.t !== 'l') { + if (room?.t !== 'l') { return API.v1.failure('error-invalid-room'); } @@ -463,7 +463,7 @@ API.v1.addRoute( const firstError = result.find((item) => item.status === 'rejected'); if (firstError) { - throw new Error((firstError as PromiseRejectedResult).reason.error); + throw new Error(firstError.reason.error); } await callbacks.run('livechat.saveInfo', await LivechatRooms.findOneById(roomData._id), { diff --git a/apps/meteor/app/livechat/server/api/v1/visitor.ts b/apps/meteor/app/livechat/server/api/v1/visitor.ts index 706260f80afba..c0ced64e56312 100644 --- a/apps/meteor/app/livechat/server/api/v1/visitor.ts +++ b/apps/meteor/app/livechat/server/api/v1/visitor.ts @@ -55,7 +55,7 @@ API.v1.addRoute( ...(department && { department }), ...(username && { username }), ...(connectionData && { connectionData }), - ...(phone && typeof phone === 'string' && { phone: { number: phone as string } }), + ...(phone && typeof phone === 'string' && { phone: { number: phone } }), connectionData: normalizeHttpHeaderData(this.request.headers), }; diff --git a/apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.spec.ts b/apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.spec.ts index 6fe3c1e2c9bf7..a308191b5fcef 100644 --- a/apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.spec.ts +++ b/apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.spec.ts @@ -2,7 +2,7 @@ import { LivechatBusinessHourTypes } from '@rocket.chat/core-typings'; import { filterBusinessHoursThatMustBeOpened } from './filterBusinessHoursThatMustBeOpened'; -describe('different timezones between server and business hours saturday ', () => { +describe('different timezones between server and business hours saturday', () => { beforeEach(() => jest.useFakeTimers().setSystemTime(new Date('2024-04-20T20:10:11Z'))); afterEach(() => jest.useRealTimers()); it('should return a bh when the finish time resolves to a different day on server', async () => { @@ -53,7 +53,7 @@ describe('different timezones between server and business hours saturday ', () = }); }); -describe('different timezones between server and business hours sunday ', () => { +describe('different timezones between server and business hours sunday', () => { beforeEach(() => jest.useFakeTimers().setSystemTime(new Date('2025-07-27T11:02:11Z'))); afterEach(() => jest.useRealTimers()); it('should return a bh when the finish time resolves to a different day on server', async () => { diff --git a/apps/meteor/app/livechat/server/lib/Helper.ts b/apps/meteor/app/livechat/server/lib/Helper.ts index 2ce0a3a66fe40..31a3d35bdf3fa 100644 --- a/apps/meteor/app/livechat/server/lib/Helper.ts +++ b/apps/meteor/app/livechat/server/lib/Helper.ts @@ -512,7 +512,7 @@ export const forwardRoomToAgent = async (room: IOmnichannelRoom, transferData: T throw new Error('error-invalid-inquiry'); } - if (oldServedBy && agentId === oldServedBy._id) { + if (agentId === oldServedBy?._id) { throw new Error('error-selected-agent-room-agent-are-same'); } @@ -724,7 +724,7 @@ export const forwardRoomToDepartment = async (room: IOmnichannelRoom, guest: ILi } const { servedBy, chatQueued } = roomTaken; - if (!chatQueued && oldServedBy && servedBy && oldServedBy._id === servedBy._id) { + if (!chatQueued && oldServedBy && oldServedBy._id === servedBy?._id) { if (!department?.fallbackForwardDepartment?.length) { logger.debug({ msg: 'Cannot forward room. Chat assigned to agent instead', diff --git a/apps/meteor/app/livechat/server/lib/RoutingManager.ts b/apps/meteor/app/livechat/server/lib/RoutingManager.ts index 8c6fb51c08b2d..3a371b7b1eb4d 100644 --- a/apps/meteor/app/livechat/server/lib/RoutingManager.ts +++ b/apps/meteor/app/livechat/server/lib/RoutingManager.ts @@ -253,7 +253,7 @@ export const RoutingManager: Routing = { return room; } - if (room.servedBy && room.servedBy._id === agent.agentId) { + if (room.servedBy?._id === agent.agentId) { logger.debug({ msg: 'Cannot take inquiry. Already taken by agent', inquiryId: inquiry._id, agentId: room.servedBy._id }); return room; } @@ -368,7 +368,7 @@ export const RoutingManager: Routing = { const subscriptions = await Subscriptions.findByRoomId(roomId).toArray(); subscriptions?.forEach(({ u }) => { - if (ignoreUser && ignoreUser._id === u._id) { + if (ignoreUser?._id === u._id) { return; } void removeAgentFromSubscription(roomId, u); diff --git a/apps/meteor/app/livechat/server/lib/closeRoom.ts b/apps/meteor/app/livechat/server/lib/closeRoom.ts index dbaa2ad5d4b54..50b90e0be1763 100644 --- a/apps/meteor/app/livechat/server/lib/closeRoom.ts +++ b/apps/meteor/app/livechat/server/lib/closeRoom.ts @@ -186,7 +186,7 @@ async function doCloseRoom( } const updatedRoom = await LivechatRooms.closeRoomById(rid, closeData, { session }); - if (!params.forceClose && (!updatedRoom || updatedRoom.modifiedCount !== 1)) { + if (!params.forceClose && updatedRoom?.modifiedCount !== 1) { throw new Error('Error closing room'); } diff --git a/apps/meteor/app/livechat/server/lib/contacts/resolveContactConflicts.ts b/apps/meteor/app/livechat/server/lib/contacts/resolveContactConflicts.ts index 84e36c5995b3e..a8c9efc02e3f1 100644 --- a/apps/meteor/app/livechat/server/lib/contacts/resolveContactConflicts.ts +++ b/apps/meteor/app/livechat/server/lib/contacts/resolveContactConflicts.ts @@ -54,7 +54,7 @@ export async function resolveContactConflicts(params: ResolveContactConflictsPar updatedConflictingFieldsArr = contact.conflictingFields.filter( (conflictingField: ILivechatContactConflictingField) => !fieldsToRemove.has(conflictingField.field), - ) as ILivechatContactConflictingField[]; + ); } const set = { diff --git a/apps/meteor/app/livechat/server/lib/departmentsLib.ts b/apps/meteor/app/livechat/server/lib/departmentsLib.ts index 3612ba48415a6..56f45cfc50343 100644 --- a/apps/meteor/app/livechat/server/lib/departmentsLib.ts +++ b/apps/meteor/app/livechat/server/lib/departmentsLib.ts @@ -42,7 +42,7 @@ export async function saveDepartment( }) : null; - if (departmentUnit && !departmentUnit._id && department && department.parentId) { + if (departmentUnit && !departmentUnit._id && department?.parentId) { const isLastDepartmentInUnit = (await LivechatDepartment.countDepartmentsInUnit(department.parentId)) === 1; if (isLastDepartmentInUnit) { throw new Meteor.Error('error-unit-cant-be-empty', "The last department in a unit can't be removed", { diff --git a/apps/meteor/app/livechat/server/roomAccessValidator.compatibility.ts b/apps/meteor/app/livechat/server/roomAccessValidator.compatibility.ts index be0c765dd7891..bbeebd5ef73b6 100644 --- a/apps/meteor/app/livechat/server/roomAccessValidator.compatibility.ts +++ b/apps/meteor/app/livechat/server/roomAccessValidator.compatibility.ts @@ -70,7 +70,7 @@ export const validators: OmnichannelRoomAccessValidator[] = [ // TODO: findone filtering if the inquiry is queued instead of checking here const inquiry = await LivechatInquiry.findOne(filter, { projection: { status: 1 } }); - return inquiry && inquiry.status === 'queued'; + return inquiry?.status === 'queued'; }, async function (room, user) { if (!room.departmentId || room.open || !user?._id) { diff --git a/apps/meteor/app/livechat/server/statistics/LivechatAgentActivityMonitor.ts b/apps/meteor/app/livechat/server/statistics/LivechatAgentActivityMonitor.ts index dc112b33c28ae..869d00170a2ba 100644 --- a/apps/meteor/app/livechat/server/statistics/LivechatAgentActivityMonitor.ts +++ b/apps/meteor/app/livechat/server/statistics/LivechatAgentActivityMonitor.ts @@ -109,7 +109,7 @@ export class LivechatAgentActivityMonitor { } const user = await Users.findOneById>(userId, { projection: { statusLivechat: 1 } }); - if (!user || user.statusLivechat !== 'available') { + if (user?.statusLivechat !== 'available') { return; } @@ -126,7 +126,7 @@ export class LivechatAgentActivityMonitor { } const user = await Users.findOneById>(userId, { projection: { status: 1 } }); - if (user && user.status === 'offline') { + if (user?.status === 'offline') { return; } diff --git a/apps/meteor/app/message-pin/server/pinMessage.ts b/apps/meteor/app/message-pin/server/pinMessage.ts index 204868d9dcda3..af6f3d6e43de6 100644 --- a/apps/meteor/app/message-pin/server/pinMessage.ts +++ b/apps/meteor/app/message-pin/server/pinMessage.ts @@ -136,7 +136,7 @@ export const unpinMessage = async (userId: string, message: IMessage) => { } let originalMessage = await Messages.findOneById(message._id); - if (originalMessage == null || originalMessage._id == null) { + if (originalMessage?._id == null) { throw new Meteor.Error('error-invalid-message', 'Message you are unpinning was not found', { method: 'unpinMessage', action: 'Message_pinning', diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts b/apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts index fdac8b0b77fa8..48273ee682862 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts +++ b/apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts @@ -295,7 +295,7 @@ export class SAML { } let timeoutHandler: NodeJS.Timeout | undefined = undefined; - const redirect = (url?: string | undefined): void => { + const redirect = (url?: string): void => { if (!timeoutHandler) { // If the handler is null, then we already ended the response; return; diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts b/apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts index ec8924c69a7f4..94a022a485393 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts +++ b/apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts @@ -367,7 +367,7 @@ export class SAMLUtils { } } - if (mapping.regex && mainValue && mainValue.match) { + if (mapping.regex && mainValue?.match) { let regexValue; const match = mainValue.match(new RegExp(mapping.regex)); if (match?.length) { diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts b/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts index dacdd014806e4..489a9c27085e5 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts +++ b/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts @@ -45,7 +45,7 @@ const getSamlConfigs = function (service: string): SAMLConfiguration { privateKey: settings.get(`${service}_private_key`), publicCert: settings.get(`${service}_public_cert`), // People often overlook the instruction to remove the header and footer of the certificate on this specific setting, so let's do it for them. - cert: SAMLUtils.normalizeCert((settings.get(`${service}_cert`) as string) || ''), + cert: SAMLUtils.normalizeCert(settings.get(`${service}_cert`) || ''), algorithm: settings.get(`${service}_signature_algorithm`) || 'SHA1', }, signatureValidationType: settings.get(`${service}_signature_validation_type`), diff --git a/apps/meteor/app/settings/server/SettingsRegistry.ts b/apps/meteor/app/settings/server/SettingsRegistry.ts index 3b93ca5c0bfb6..6b0eb83f2ad0b 100644 --- a/apps/meteor/app/settings/server/SettingsRegistry.ts +++ b/apps/meteor/app/settings/server/SettingsRegistry.ts @@ -208,7 +208,6 @@ export class SettingsRegistry { */ async addGroup(_id: string, cb?: addGroupCallback): Promise; - // eslint-disable-next-line no-dupe-class-members async addGroup(_id: string, groupOptions: ISettingAddGroupOptions | addGroupCallback = {}, cb?: addGroupCallback): Promise { if (!_id || (groupOptions instanceof Function && cb)) { throw new Error('Invalid arguments'); diff --git a/apps/meteor/app/settings/server/functions/settings.mocks.ts b/apps/meteor/app/settings/server/functions/settings.mocks.ts index fb31c3021b1b3..758f96a6904b6 100644 --- a/apps/meteor/app/settings/server/functions/settings.mocks.ts +++ b/apps/meteor/app/settings/server/functions/settings.mocks.ts @@ -41,7 +41,7 @@ class SettingsClass { insertOne(doc: any): void { this.data.set(doc._id, doc); - // eslint-disable-next-line @typescript-eslint/no-var-requires + this.settings.set(doc); this.insertCalls++; } @@ -77,13 +77,13 @@ class SettingsClass { this.data.set(query._id, data); // Can't import before the mock command on end of this file! - // eslint-disable-next-line @typescript-eslint/no-var-requires + this.settings.set(data); }, this.delay); } else { this.data.set(query._id, data); // Can't import before the mock command on end of this file! - // eslint-disable-next-line @typescript-eslint/no-var-requires + this.settings.set(data); } @@ -98,7 +98,7 @@ class SettingsClass { updateValueById(id: string, value: any): void { this.data.set(id, { ...this.data.get(id), value }); // Can't import before the mock command on end of this file! - // eslint-disable-next-line @typescript-eslint/no-var-requires + if (this.delay) { setTimeout(() => { this.settings.set(this.data.get(id) as ISetting); diff --git a/apps/meteor/app/settings/server/startup.ts b/apps/meteor/app/settings/server/startup.ts index 5c0f4cdee5fe6..450d46cc45599 100644 --- a/apps/meteor/app/settings/server/startup.ts +++ b/apps/meteor/app/settings/server/startup.ts @@ -3,7 +3,6 @@ import type { Settings } from '@rocket.chat/models'; import type { ICachedSettings } from './CachedSettings'; -// eslint-disable-next-line @typescript-eslint/naming-convention export async function initializeSettings({ model, settings }: { model: typeof Settings; settings: ICachedSettings }): Promise { await model.find().forEach((record: ISetting) => { settings.set(record); diff --git a/apps/meteor/app/slackbridge/server/RocketAdapter.ts b/apps/meteor/app/slackbridge/server/RocketAdapter.ts index 925bb4ef2dc4d..6bf34a2cb0ca7 100644 --- a/apps/meteor/app/slackbridge/server/RocketAdapter.ts +++ b/apps/meteor/app/slackbridge/server/RocketAdapter.ts @@ -188,7 +188,7 @@ export default class RocketAdapter { return; } - if (!rocketMessage.attachments || !rocketMessage.attachments.length) { + if (!rocketMessage.attachments?.length) { return; } @@ -252,7 +252,7 @@ export default class RocketAdapter { for await (const member of members) { if (member !== slackChannel.creator) { const rocketUser = (await this.findUser(member)) || (await this.addUser(member)); - if (rocketUser && rocketUser.username) { + if (rocketUser?.username) { rocketUsers.push(rocketUser.username); } } @@ -314,12 +314,12 @@ export default class RocketAdapter { }; let lastSetTopic = 0; - if (slackChannel.topic && slackChannel.topic.value) { + if (slackChannel.topic?.value) { roomUpdate.topic = slackChannel.topic.value; lastSetTopic = slackChannel.topic.last_set; } - if (slackChannel.purpose && slackChannel.purpose.value && slackChannel.purpose.last_set > lastSetTopic) { + if (slackChannel.purpose?.value && slackChannel.purpose.last_set > lastSetTopic) { roomUpdate.topic = slackChannel.purpose.value; } await Rooms.addImportIds(slackChannel.rocketId, slackChannel.id); @@ -359,7 +359,7 @@ export default class RocketAdapter { if (user) { const rocketUserData = user; const isBot = rocketUserData.is_bot === true; - const email = (rocketUserData.profile && rocketUserData.profile.email) || ''; + const email = rocketUserData.profile?.email || ''; let existingRocketUser; if (!isBot) { existingRocketUser = @@ -391,7 +391,7 @@ export default class RocketAdapter { roles: isBot ? ['bot'] : ['user'], }; - if (rocketUserData.profile && rocketUserData.profile.real_name) { + if (rocketUserData.profile?.real_name) { userUpdate.name = rocketUserData.profile.real_name; } @@ -422,7 +422,7 @@ export default class RocketAdapter { } const importIds = [rocketUserData.id]; - if (isBot && rocketUserData.profile && rocketUserData.profile.bot_id) { + if (isBot && rocketUserData.profile?.bot_id) { importIds.push(rocketUserData.profile.bot_id); } await Users.addImportIds(rocketUserData.rocketId, importIds); diff --git a/apps/meteor/app/slackbridge/server/SlackAPI.ts b/apps/meteor/app/slackbridge/server/SlackAPI.ts index a352537059c0c..1ba1d7a920479 100644 --- a/apps/meteor/app/slackbridge/server/SlackAPI.ts +++ b/apps/meteor/app/slackbridge/server/SlackAPI.ts @@ -28,7 +28,7 @@ export class SlackAPI { if (response && response && Array.isArray(response.channels) && response.channels.length > 0) { channels = channels.concat(response.channels); - if (response.response_metadata && response.response_metadata.next_cursor) { + if (response.response_metadata?.next_cursor) { const nextChannels = await this.getChannels(response.response_metadata.next_cursor); channels = channels.concat(nextChannels); } @@ -56,7 +56,7 @@ export class SlackAPI { if (response && response && Array.isArray(response.channels) && response.channels.length > 0) { groups = groups.concat(response.channels); - if (response.response_metadata && response.response_metadata.next_cursor) { + if (response.response_metadata?.next_cursor) { const nextGroups = await this.getGroups(response.response_metadata.next_cursor); groups = groups.concat(nextGroups); } @@ -104,7 +104,7 @@ export class SlackAPI { const response = await request.json(); if (response && response && request.status === 200 && request.ok && Array.isArray(response.members)) { members = members.concat(response.members); - const hasMoreItems = response.response_metadata && response.response_metadata.next_cursor; + const hasMoreItems = response.response_metadata?.next_cursor; if (hasMoreItems) { currentCursor = response.response_metadata.next_cursor; } diff --git a/apps/meteor/app/slackbridge/server/SlackAdapter.ts b/apps/meteor/app/slackbridge/server/SlackAdapter.ts index e62d0bcdcd932..3d4aeb66c7017 100644 --- a/apps/meteor/app/slackbridge/server/SlackAdapter.ts +++ b/apps/meteor/app/slackbridge/server/SlackAdapter.ts @@ -607,7 +607,7 @@ export default class SlackAdapter { * https://api.slack.com/events/message */ async onMessage(slackMessage, isImporting) { - const isAFileShare = slackMessage && slackMessage.files && Array.isArray(slackMessage.files) && slackMessage.files.length; + const isAFileShare = slackMessage?.files && Array.isArray(slackMessage.files) && slackMessage.files.length; if (isAFileShare) { await this.processFileShare(slackMessage); return; @@ -841,22 +841,22 @@ export default class SlackAdapter { } async postMessage(slackChannel, rocketMessage) { - if (slackChannel && slackChannel.id) { - let iconUrl = getUserAvatarURL(rocketMessage.u && rocketMessage.u.username); + if (slackChannel?.id) { + let iconUrl = getUserAvatarURL(rocketMessage.u?.username); if (iconUrl) { iconUrl = Meteor.absoluteUrl().replace(/\/$/, '') + iconUrl; } const data = { text: rocketMessage.msg, channel: slackChannel.id, - username: rocketMessage.u && rocketMessage.u.username, + username: rocketMessage.u?.username, icon_url: iconUrl, link_names: 1, }; if (rocketMessage.tmid) { const tmessage = await Messages.findOneById(rocketMessage.tmid); - if (tmessage && tmessage.slackTs) { + if (tmessage?.slackTs) { data.thread_ts = tmessage.slackTs; } } @@ -873,7 +873,7 @@ export default class SlackAdapter { this.removeMessageBeingSent(data); } - if (postResult && postResult.message && postResult.message.bot_id && postResult.message.ts) { + if (postResult?.message?.bot_id && postResult.message.ts) { this.slackBotId = postResult.message.bot_id; await Messages.setSlackBotIdAndSlackTs(rocketMessage._id, postResult.message.bot_id, postResult.message.ts); slackLogger.debug({ @@ -890,7 +890,7 @@ export default class SlackAdapter { https://api.slack.com/methods/chat.update */ async postMessageUpdate(slackChannel, rocketMessage) { - if (slackChannel && slackChannel.id) { + if (slackChannel?.id) { const data = { ts: this.getTimeStamp(rocketMessage), channel: slackChannel.id, @@ -931,7 +931,7 @@ export default class SlackAdapter { } const file = slackMessage.files[0]; - if (file && file.url_private_download !== undefined) { + if (file?.url_private_download !== undefined) { const rocketChannel = await this.rocket.getChannel(slackMessage); const rocketUser = await this.rocket.getUser(slackMessage.user); @@ -1158,7 +1158,7 @@ export default class SlackAdapter { } async processShareMessage(rocketChannel, rocketUser, slackMessage, isImporting) { - if (slackMessage.file && slackMessage.file.url_private_download !== undefined) { + if (slackMessage.file?.url_private_download !== undefined) { const details = { message_id: this.createSlackMessageId(slackMessage.ts), name: slackMessage.file.name, @@ -1178,7 +1178,7 @@ export default class SlackAdapter { } async processPinnedItemMessage(rocketChannel, rocketUser, slackMessage, isImporting) { - if (slackMessage.attachments && slackMessage.attachments[0] && slackMessage.attachments[0].text) { + if (slackMessage.attachments?.[0]?.text) { // TODO: refactor this logic to use the service to send this system message instead of using sendMessage const rocketMsgObj = { rid: rocketChannel._id, @@ -1288,7 +1288,7 @@ export default class SlackAdapter { attachment.image_url = url; attachment.image_type = file.type; attachment.image_size = file.size; - attachment.image_dimensions = file.identify && file.identify.size; + attachment.image_dimensions = file.identify?.size; } if (/^audio\/.+/.test(file.type)) { attachment.audio_url = url; @@ -1359,13 +1359,13 @@ export default class SlackAdapter { let topic = ''; let topic_last_set = 0; let topic_creator = null; - if (channel && channel.topic && channel.topic.value) { + if (channel?.topic?.value) { topic = channel.topic.value; topic_last_set = channel.topic.last_set; topic_creator = channel.topic.creator; } - if (channel && channel.purpose && channel.purpose.value) { + if (channel?.purpose?.value) { if (topic_last_set) { if (topic_last_set < channel.purpose.last_set) { topic = channel.purpose.topic; @@ -1433,7 +1433,7 @@ export default class SlackAdapter { channel: this.getSlackChannel(rid).id, oldest: 1, }); - while (results && results.has_more) { + while (results?.has_more) { // eslint-disable-next-line no-await-in-loop results = await this.importFromHistory({ channel: this.getSlackChannel(rid).id, diff --git a/apps/meteor/app/slashcommands-create/server/server.ts b/apps/meteor/app/slashcommands-create/server/server.ts index 6abee71c56fdd..4406c21ce3f7f 100644 --- a/apps/meteor/app/slashcommands-create/server/server.ts +++ b/apps/meteor/app/slashcommands-create/server/server.ts @@ -24,7 +24,7 @@ slashCommands.add({ return result; } - const regexp = new RegExp(settings.get('UTF8_Channel_Names_Validation') as string); + const regexp = new RegExp(settings.get('UTF8_Channel_Names_Validation')); const channel = regexp.exec(params.trim()); diff --git a/apps/meteor/app/slashcommands-invite/server/server.ts b/apps/meteor/app/slashcommands-invite/server/server.ts index 26ea1256c3c34..6f228d0845791 100644 --- a/apps/meteor/app/slashcommands-invite/server/server.ts +++ b/apps/meteor/app/slashcommands-invite/server/server.ts @@ -77,7 +77,7 @@ slashCommands.add({ projection: { _id: 1 }, }); if (subscription == null) { - usersFiltered.push(user as IUser); + usersFiltered.push(user); continue; } const usernameStr = user.username as string; diff --git a/apps/meteor/app/slashcommands-open/client/client.ts b/apps/meteor/app/slashcommands-open/client/client.ts index 88cee2fda319a..b4995db1a8bff 100644 --- a/apps/meteor/app/slashcommands-open/client/client.ts +++ b/apps/meteor/app/slashcommands-open/client/client.ts @@ -27,7 +27,7 @@ slashCommands.add({ roomCoordinator.openRouteLink(subscription.t, subscription, router.getSearchParameters()); } - if (type && type.indexOf('d') === -1) { + if (type?.indexOf('d') === -1) { return; } try { diff --git a/apps/meteor/app/statistics/server/functions/sendUsageReport.ts b/apps/meteor/app/statistics/server/functions/sendUsageReport.ts index b96c8177da17a..a8ee0920427ee 100644 --- a/apps/meteor/app/statistics/server/functions/sendUsageReport.ts +++ b/apps/meteor/app/statistics/server/functions/sendUsageReport.ts @@ -47,7 +47,7 @@ export async function sendUsageReport(logger: Logger): Promise>(); -const rooms = new Map void>(); +const rooms = new Map void>(); const performingUsers = new Map(); const performingUsersEmitter = new Emitter<{ changed: void }>(); diff --git a/apps/meteor/app/utils/client/getURL.ts b/apps/meteor/app/utils/client/getURL.ts index b427c7110ccef..0da322dad27f7 100644 --- a/apps/meteor/app/utils/client/getURL.ts +++ b/apps/meteor/app/utils/client/getURL.ts @@ -3,7 +3,7 @@ import { getURLWithoutSettings } from '../lib/getURL'; import { Info } from '../rocketchat.info'; export const getURL = function ( - path: string, // eslint-disable-next-line @typescript-eslint/naming-convention + path: string, params: { cdn?: boolean; full?: boolean; diff --git a/apps/meteor/app/utils/lib/getURL.ts b/apps/meteor/app/utils/lib/getURL.ts index 3d757abb6c83c..e45469b98f520 100644 --- a/apps/meteor/app/utils/lib/getURL.ts +++ b/apps/meteor/app/utils/lib/getURL.ts @@ -37,7 +37,7 @@ function getCloudUrl( export const _getURL = ( path: string, - // eslint-disable-next-line @typescript-eslint/naming-convention + { cdn, full, cloud, cloud_route, cloud_params, _cdn_prefix, _root_url_path_prefix, _site_url }: Record, deeplinkUrl?: string, ): string => { @@ -76,7 +76,7 @@ export const _getURL = ( export const getURLWithoutSettings = ( path: string, - // eslint-disable-next-line @typescript-eslint/naming-convention + { cdn = true, full = false, diff --git a/apps/meteor/app/utils/server/getURL.ts b/apps/meteor/app/utils/server/getURL.ts index 4703569736add..61f386ee14a8b 100644 --- a/apps/meteor/app/utils/server/getURL.ts +++ b/apps/meteor/app/utils/server/getURL.ts @@ -2,7 +2,7 @@ import { settings } from '../../settings/server'; import { getURLWithoutSettings } from '../lib/getURL'; export const getURL = function ( - path: string, // eslint-disable-next-line @typescript-eslint/naming-convention + path: string, params: { cdn?: boolean; full?: boolean; diff --git a/apps/meteor/app/utils/server/getUserNotificationPreference.ts b/apps/meteor/app/utils/server/getUserNotificationPreference.ts index 2c70a7a11a18c..9874a8a112eec 100644 --- a/apps/meteor/app/utils/server/getUserNotificationPreference.ts +++ b/apps/meteor/app/utils/server/getUserNotificationPreference.ts @@ -29,11 +29,7 @@ export const getUserNotificationPreference = async (user: IUser | string, pref: return null; } - if ( - user?.settings?.preferences && - typeof user.settings.preferences[preferenceKey] !== 'undefined' && - user.settings.preferences[preferenceKey] !== 'default' - ) { + if (typeof user?.settings?.preferences?.[preferenceKey] !== 'undefined' && user.settings.preferences[preferenceKey] !== 'default') { return { value: user.settings.preferences[preferenceKey], origin: 'user', diff --git a/apps/meteor/client/apps/orchestrator.ts b/apps/meteor/client/apps/orchestrator.ts index d08641da34d22..ba50259e1faab 100644 --- a/apps/meteor/client/apps/orchestrator.ts +++ b/apps/meteor/client/apps/orchestrator.ts @@ -74,7 +74,7 @@ class AppClientOrchestrator { return { apps: [], error: 'Invalid response from API' }; } - const apps = (result as App[]).map((app: App) => { + const apps = result.map((app: App) => { const { latest, appRequestStats, price, pricingPlans, purchaseType, isEnterpriseOnly, modifiedAt, bundledIn, requestedEndUser } = app; return { ...latest, diff --git a/apps/meteor/client/components/GenericUpsellModal/GenericUpsellModal.spec.tsx b/apps/meteor/client/components/GenericUpsellModal/GenericUpsellModal.spec.tsx index f9f944ce5bb39..431f092178153 100644 --- a/apps/meteor/client/components/GenericUpsellModal/GenericUpsellModal.spec.tsx +++ b/apps/meteor/client/components/GenericUpsellModal/GenericUpsellModal.spec.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { composeStories } from '@storybook/react'; import { render, screen } from '@testing-library/react'; diff --git a/apps/meteor/client/components/Sidebar/SidebarNavigationItem.tsx b/apps/meteor/client/components/Sidebar/SidebarNavigationItem.tsx index a5ea0be9492cb..6cb5488a7ba57 100644 --- a/apps/meteor/client/components/Sidebar/SidebarNavigationItem.tsx +++ b/apps/meteor/client/components/Sidebar/SidebarNavigationItem.tsx @@ -28,7 +28,7 @@ const SidebarNavigationItem = ({ badge: Badge, }: SidebarNavigationItemProps) => { const path = pathSection; - const isActive = !!path && currentPath?.includes(path as string); + const isActive = !!path && currentPath?.includes(path); if (permissionGranted === false || (typeof permissionGranted === 'function' && !permissionGranted())) { return null; diff --git a/apps/meteor/client/definitions/global.d.ts b/apps/meteor/client/definitions/global.d.ts index 3cefc38cc8362..1f1072ec6313b 100644 --- a/apps/meteor/client/definitions/global.d.ts +++ b/apps/meteor/client/definitions/global.d.ts @@ -1,7 +1,6 @@ import type { IRocketChatDesktop } from '@rocket.chat/desktop-api'; declare global { - // eslint-disable-next-line @typescript-eslint/naming-convention interface Window { RocketChatDesktop?: IRocketChatDesktop; @@ -70,7 +69,6 @@ declare global { addStream(stream: MediaStream): void; } - // eslint-disable-next-line @typescript-eslint/naming-convention interface MediaTrackConstraints { /** @deprecated */ mozMediaSource?: string; diff --git a/apps/meteor/client/hooks/notification/useNotification.ts b/apps/meteor/client/hooks/notification/useNotification.ts index cb6fe93077d34..5f2f9ea6891ab 100644 --- a/apps/meteor/client/hooks/notification/useNotification.ts +++ b/apps/meteor/client/hooks/notification/useNotification.ts @@ -33,7 +33,7 @@ export const useNotification = () => { } as any); const n = new Notification(notification.title, { - icon: notification.icon || getUserAvatarURL(notification.payload.sender?.username as string), + icon: notification.icon || getUserAvatarURL(notification.payload.sender?.username), body: stripTags(message?.msg), tag: msgId, canReply: true, diff --git a/apps/meteor/client/lib/2fa/process2faReturn.ts b/apps/meteor/client/lib/2fa/process2faReturn.ts index 4042370caae39..9669107bb3e2f 100644 --- a/apps/meteor/client/lib/2fa/process2faReturn.ts +++ b/apps/meteor/client/lib/2fa/process2faReturn.ts @@ -74,7 +74,7 @@ export async function process2faReturn({ const props = { ...getProps(error.details.method, emailOrUsername || error.details.emailOrUsername), - // eslint-disable-next-line no-nested-ternary + invalidAttempt: isTotpInvalidError(error), }; @@ -111,7 +111,7 @@ export async function process2faAsyncReturn({ const props = { method: error.details.method, emailOrUsername: emailOrUsername || error.details.emailOrUsername || getUser()?.username, - // eslint-disable-next-line no-nested-ternary + invalidAttempt: isTotpInvalidError(error), }; diff --git a/apps/meteor/client/lib/chats/data.ts b/apps/meteor/client/lib/chats/data.ts index 5206e802e7d0c..b72a7bcb0ee8e 100644 --- a/apps/meteor/client/lib/chats/data.ts +++ b/apps/meteor/client/lib/chats/data.ts @@ -67,14 +67,14 @@ export const createDataAPI = ({ rid, tmid }: { rid: IRoom['_id']; tmid: IMessage } const canEditMessage = hasAtLeastOnePermission('edit-message', message.rid); - const editAllowed = (settings.peek('Message_AllowEditing') as boolean | undefined) ?? false; + const editAllowed = settings.peek('Message_AllowEditing') ?? false; const editOwn = message?.u && message.u._id === getUserId(); if (!canEditMessage && (!editAllowed || !editOwn)) { return false; } - const blockEditInMinutes = settings.peek('Message_AllowEditing_BlockEditInMinutes') as number | undefined; + const blockEditInMinutes = settings.peek('Message_AllowEditing_BlockEditInMinutes'); const bypassBlockTimeLimit = hasPermission('bypass-time-limit-edit-and-delete', message.rid); const elapsedMinutes = moment().diff(message.ts, 'minutes'); @@ -200,7 +200,7 @@ export const createDataAPI = ({ rid, tmid }: { rid: IRoom['_id']; tmid: IMessage return true; } - const deletionEnabled = settings.peek('Message_AllowDeleting') as boolean | undefined; + const deletionEnabled = settings.peek('Message_AllowDeleting'); if (!deletionEnabled) { return false; } @@ -213,7 +213,7 @@ export const createDataAPI = ({ rid, tmid }: { rid: IRoom['_id']; tmid: IMessage return false; } - const blockDeleteInMinutes = settings.peek('Message_AllowDeleting_BlockDeleteInMinutes') as number | undefined; + const blockDeleteInMinutes = settings.peek('Message_AllowDeleting_BlockDeleteInMinutes'); const bypassBlockTimeLimit = hasPermission('bypass-time-limit-edit-and-delete', message.rid); const elapsedMinutes = moment().diff(message.ts, 'minutes'); const onTimeForDelete = bypassBlockTimeLimit || !blockDeleteInMinutes || !elapsedMinutes || elapsedMinutes <= blockDeleteInMinutes; diff --git a/apps/meteor/client/lib/customOAuth/CustomOAuth.ts b/apps/meteor/client/lib/customOAuth/CustomOAuth.ts index 8ac31adc0a5ce..57938577cf6b8 100644 --- a/apps/meteor/client/lib/customOAuth/CustomOAuth.ts +++ b/apps/meteor/client/lib/customOAuth/CustomOAuth.ts @@ -54,7 +54,7 @@ export class CustomOAuth implements IOAuth } configureLogin() { - const loginWithService = `loginWith${capitalize(this.name) as Capitalize}` as const; + const loginWithService = `loginWith${capitalize(this.name)}` as const; const loginWithOAuthTokenAndTOTP = createOAuthTotpLoginMethod(this); diff --git a/apps/meteor/client/lib/e2ee/crypto/shared.ts b/apps/meteor/client/lib/e2ee/crypto/shared.ts index 1605a106e53b3..2d298591ebbc4 100644 --- a/apps/meteor/client/lib/e2ee/crypto/shared.ts +++ b/apps/meteor/client/lib/e2ee/crypto/shared.ts @@ -34,12 +34,12 @@ export const encryptBuffer = > key: HasUsage, params: TParams, data: BufferSource, -): Promise => subtle.encrypt(params, key, data) as Promise; +): Promise => subtle.encrypt(params, key, data); export const decryptBuffer = ( key: HasUsage, params: ParamsOf, data: BufferSource, -): Promise => subtle.decrypt(params, key, data) as Promise; +): Promise => subtle.decrypt(params, key, data); export const deriveBits = (...args: Parameters) => subtle.deriveBits(...args); type AesParams = { diff --git a/apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts b/apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts index 625e305365af1..e2e22a89416d7 100644 --- a/apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts +++ b/apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts @@ -401,7 +401,7 @@ export class E2ERoom extends Emitter { // Import session key for use. try { - const key = await Aes.importKey(JSON.parse(this.sessionKeyExportedString!)); + const key = await Aes.importKey(JSON.parse(this.sessionKeyExportedString)); // Key has been obtained. E2E is now in session. this.groupSessionKey = key; span.info('Group key imported'); @@ -498,13 +498,13 @@ export class E2ERoom extends Emitter { }[] > = { [this.roomId]: [] }; for await (const user of users) { - const encryptedGroupKey = await this.encryptGroupKeyForParticipant(user.e2e!.public_key!); + const encryptedGroupKey = await this.encryptGroupKeyForParticipant(user.e2e!.public_key); if (!encryptedGroupKey) { span.warn(`Could not encrypt group key for user ${user._id}`); return; } if (decryptedOldGroupKeys) { - const oldKeys = await this.encryptOldKeysForParticipant(user.e2e!.public_key!, decryptedOldGroupKeys); + const oldKeys = await this.encryptOldKeysForParticipant(user.e2e!.public_key, decryptedOldGroupKeys); if (oldKeys) { usersSuggestedGroupKeys[this.roomId].push({ _id: user._id, key: encryptedGroupKey, oldKeys }); continue; diff --git a/apps/meteor/client/lib/getDirtyFields.ts b/apps/meteor/client/lib/getDirtyFields.ts index ede3197a23d57..5ef62b04dc627 100644 --- a/apps/meteor/client/lib/getDirtyFields.ts +++ b/apps/meteor/client/lib/getDirtyFields.ts @@ -12,7 +12,7 @@ export const getDirtyFields = ( ): Partial => { const dirtyFieldsObjValue = Object.keys(dirtyFields).reduce((acc, currentField) => { const isDirty = Array.isArray(dirtyFields[currentField]) - ? (dirtyFields[currentField] as boolean[]).some((value) => value === true) + ? dirtyFields[currentField].some((value) => value === true) : dirtyFields[currentField] === true; if (isDirty) { return { diff --git a/apps/meteor/client/lib/streamer/streamer.ts b/apps/meteor/client/lib/streamer/streamer.ts index 1eb31015acaf5..e1c60b16bc9b2 100644 --- a/apps/meteor/client/lib/streamer/streamer.ts +++ b/apps/meteor/client/lib/streamer/streamer.ts @@ -75,7 +75,7 @@ export class StreamerCentral extends EV { getStreamer(name: N, options: StreamerOptions): Streamer { const existingInstance = this.instances[name]; if (existingInstance) { - return existingInstance as Streamer; + return existingInstance; } const streamer = new Streamer(name, options); diff --git a/apps/meteor/client/lib/userData.ts b/apps/meteor/client/lib/userData.ts index 2b768bad7a597..ced79b7a00313 100644 --- a/apps/meteor/client/lib/userData.ts +++ b/apps/meteor/client/lib/userData.ts @@ -64,7 +64,6 @@ export const synchronizeUserData = async (uid: IUser['_id']): Promise { switch (data.type) { case 'inserted': { - // eslint-disable-next-line @typescript-eslint/no-unused-vars const { type, id, ...user } = data; Users.state.store(user.data); break; diff --git a/apps/meteor/client/lib/userStatuses.ts b/apps/meteor/client/lib/userStatuses.ts index 631c1d1ea0442..27a20f0275ae8 100644 --- a/apps/meteor/client/lib/userStatuses.ts +++ b/apps/meteor/client/lib/userStatuses.ts @@ -41,7 +41,7 @@ export class UserStatuses implements Iterable { return { name: customUserStatus.name, id: customUserStatus._id, - statusType: customUserStatus.statusType as UserStatus, + statusType: customUserStatus.statusType, localizeName: false, }; } diff --git a/apps/meteor/client/lib/utils/getUidDirectMessage.ts b/apps/meteor/client/lib/utils/getUidDirectMessage.ts index 6f56110629855..342aa31d01067 100644 --- a/apps/meteor/client/lib/utils/getUidDirectMessage.ts +++ b/apps/meteor/client/lib/utils/getUidDirectMessage.ts @@ -6,7 +6,7 @@ import { getUserId } from '../user'; export const getUidDirectMessage = (rid: IRoom['_id'], uid: IUser['_id'] | undefined = getUserId() ?? undefined): string | undefined => { const room = Rooms.state.get(rid); - if (!room || room.t !== 'd' || !room.uids || room.uids.length > 2) { + if (room?.t !== 'd' || !room.uids || room.uids.length > 2) { return undefined; } diff --git a/apps/meteor/client/navbar/NavBarSettingsToolbar/hooks/useAdministrationMenu.spec.tsx b/apps/meteor/client/navbar/NavBarSettingsToolbar/hooks/useAdministrationMenu.spec.tsx index 6eb991ca61afb..7ec820c09c1bd 100644 --- a/apps/meteor/client/navbar/NavBarSettingsToolbar/hooks/useAdministrationMenu.spec.tsx +++ b/apps/meteor/client/navbar/NavBarSettingsToolbar/hooks/useAdministrationMenu.spec.tsx @@ -3,7 +3,7 @@ import { renderHook, waitFor } from '@testing-library/react'; import { useAdministrationMenu } from './useAdministrationMenu'; -it('should return omnichannel item if has `view-livechat-manager` permission ', async () => { +it('should return omnichannel item if has `view-livechat-manager` permission', async () => { const { result } = renderHook(() => useAdministrationMenu(), { wrapper: mockAppRoot() .withEndpoint('GET', '/v1/licenses.info', () => ({ diff --git a/apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx b/apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx index d32e6ec52a411..47e7cdd4e8eda 100644 --- a/apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx +++ b/apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx @@ -73,7 +73,7 @@ const AuthenticationProvider = ({ children }: AuthenticationProviderProps): Reac const loginWithService = `loginWith${loginMethods[serviceName] || capitalize(String(serviceName || ''))}`; - const method: (config: unknown, cb: (error: any) => void) => Promise = (Meteor as any)[loginWithService] as any; + const method: (config: unknown, cb: (error: any) => void) => Promise = (Meteor as any)[loginWithService]; if (!method) { return () => Promise.reject(new Error('Login method not found')); diff --git a/apps/meteor/client/router/index.tsx b/apps/meteor/client/router/index.tsx index 04083e9f89834..297507ab70823 100644 --- a/apps/meteor/client/router/index.tsx +++ b/apps/meteor/client/router/index.tsx @@ -220,7 +220,7 @@ export class Router implements RouterContextValue { readonly getLocationPathname = () => this.current?.path.replace(/\?.*/, '') as LocationPathname; - readonly getLocationSearch = () => location.search as LocationSearch; + readonly getLocationSearch = () => location.search; readonly getRouteParameters = () => (this.current?.params ? (Object.fromEntries(this.current.params.entries()) as RouteParameters) : {}); diff --git a/apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx b/apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx index 445c5607c672e..c1ac9b141007f 100644 --- a/apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx +++ b/apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx @@ -161,7 +161,6 @@ const keys: (keyof RoomListRowProps)[] = [ 'videoConfActions', ]; -// eslint-disable-next-line react/no-multi-comp export default memo(SidebarItemTemplateWithData, (prevProps, nextProps) => { if (keys.some((key) => prevProps[key] !== nextProps[key])) { return false; diff --git a/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesForm.spec.tsx b/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesForm.spec.tsx index 84927e6427a5a..9b5f5de2f0573 100644 --- a/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesForm.spec.tsx +++ b/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesForm.spec.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { composeStories } from '@storybook/react'; import { render, screen, waitFor } from '@testing-library/react'; diff --git a/apps/meteor/client/views/admin/EditableSettingsContext.ts b/apps/meteor/client/views/admin/EditableSettingsContext.ts index 4b16e344db796..d0c65e841032b 100644 --- a/apps/meteor/client/views/admin/EditableSettingsContext.ts +++ b/apps/meteor/client/views/admin/EditableSettingsContext.ts @@ -149,7 +149,7 @@ export const useEditableSettingsDispatch = (): ((changes: Partial state.mutate); }; -export const useEditableSettingVisibilityQuery = (query?: ISetting['enableQuery'] | ISetting['displayQuery']): boolean => { +export const useEditableSettingVisibilityQuery = (query?: ISetting['enableQuery']): boolean => { const { useEditableSettingsStore } = useContext(EditableSettingsContext); return useEditableSettingsStore((state) => { diff --git a/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx b/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx index 326531a20e9c6..cb98cc60e0f61 100644 --- a/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx +++ b/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx @@ -114,7 +114,7 @@ const CustomEmoji = ({ onClick, reload }: CustomEmojiProps) => { /> )} - {isSuccess && data && data.emojis.length === 0 && } + {isSuccess && data?.emojis.length === 0 && } {isError && ( diff --git a/apps/meteor/client/views/admin/customEmoji/EditCustomEmojiWithData.tsx b/apps/meteor/client/views/admin/customEmoji/EditCustomEmojiWithData.tsx index a593e67333c7b..24e9d769eae9b 100644 --- a/apps/meteor/client/views/admin/customEmoji/EditCustomEmojiWithData.tsx +++ b/apps/meteor/client/views/admin/customEmoji/EditCustomEmojiWithData.tsx @@ -32,7 +32,7 @@ const EditCustomEmojiWithData = ({ _id, onChange, close, ...props }: EditCustomE return ; } - if (error || !data || !data.emojis || data.emojis.update.length < 1) { + if (error || !data?.emojis || data.emojis.update.length < 1) { return ; } diff --git a/apps/meteor/client/views/admin/engagementDashboard/channels/useChannelsList.ts b/apps/meteor/client/views/admin/engagementDashboard/channels/useChannelsList.ts index c8e9c82e74698..4ba36195551f9 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/channels/useChannelsList.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/channels/useChannelsList.ts @@ -10,7 +10,6 @@ type UseChannelsListOptions = { count: number; }; -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useChannelsList = ({ period, offset, count }: UseChannelsListOptions) => { const getChannelsList = useEndpoint('GET', '/v1/engagement-dashboard/channels/list'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/messages/useMessageOrigins.ts b/apps/meteor/client/views/admin/engagementDashboard/messages/useMessageOrigins.ts index b451840427cd8..33cc6327476c9 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/messages/useMessageOrigins.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/messages/useMessageOrigins.ts @@ -6,7 +6,6 @@ import { getPeriodRange } from '../../../../components/dashboards/periods'; type UseMessageOriginsOptions = { period: Period['key'] }; -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useMessageOrigins = ({ period }: UseMessageOriginsOptions) => { const getMessageOrigins = useEndpoint('GET', '/v1/engagement-dashboard/messages/origin'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/messages/useMessagesSent.ts b/apps/meteor/client/views/admin/engagementDashboard/messages/useMessagesSent.ts index a8e3bfe8bed1c..92c7c8911f4f8 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/messages/useMessagesSent.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/messages/useMessagesSent.ts @@ -6,7 +6,6 @@ import { getPeriodRange } from '../../../../components/dashboards/periods'; type UseMessagesSentOptions = { period: Period['key']; utc: boolean }; -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useMessagesSent = ({ period, utc }: UseMessagesSentOptions) => { const getMessagesSent = useEndpoint('GET', '/v1/engagement-dashboard/messages/messages-sent'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/messages/useTopFivePopularChannels.ts b/apps/meteor/client/views/admin/engagementDashboard/messages/useTopFivePopularChannels.ts index bc6780a3e1270..9e4f8828b63e5 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/messages/useTopFivePopularChannels.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/messages/useTopFivePopularChannels.ts @@ -6,7 +6,6 @@ import { getPeriodRange } from '../../../../components/dashboards/periods'; type UseTopFivePopularChannelsOptions = { period: Period['key'] }; -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useTopFivePopularChannels = ({ period }: UseTopFivePopularChannelsOptions) => { const getTopFivePopularChannels = useEndpoint('GET', '/v1/engagement-dashboard/messages/top-five-popular-channels'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/users/useActiveUsers.ts b/apps/meteor/client/views/admin/engagementDashboard/users/useActiveUsers.ts index cb5c7d6939047..2c92ffc7456dd 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/users/useActiveUsers.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/users/useActiveUsers.ts @@ -5,7 +5,6 @@ import { getPeriodRange } from '../../../../components/dashboards/periods'; type UseActiveUsersOptions = { utc: boolean }; -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useActiveUsers = ({ utc }: UseActiveUsersOptions) => { const getActiveUsers = useEndpoint('GET', '/v1/engagement-dashboard/users/active-users'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/users/useHourlyChatActivity.ts b/apps/meteor/client/views/admin/engagementDashboard/users/useHourlyChatActivity.ts index 7870cd8105c78..b314c949147c4 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/users/useHourlyChatActivity.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/users/useHourlyChatActivity.ts @@ -7,7 +7,6 @@ type UseHourlyChatActivityOptions = { utc: boolean; }; -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useHourlyChatActivity = ({ displacement, utc }: UseHourlyChatActivityOptions) => { const getHourlyChatActivity = useEndpoint('GET', '/v1/engagement-dashboard/users/chat-busier/hourly-data'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/users/useUsersByTimeOfTheDay.ts b/apps/meteor/client/views/admin/engagementDashboard/users/useUsersByTimeOfTheDay.ts index 4118edce0f1cd..cb5f1b78cd895 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/users/useUsersByTimeOfTheDay.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/users/useUsersByTimeOfTheDay.ts @@ -6,7 +6,6 @@ import { getPeriodRange } from '../../../../components/dashboards/periods'; type UseUsersByTimeOfTheDayOptions = { period: Period['key']; utc: boolean }; -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useUsersByTimeOfTheDay = ({ period, utc }: UseUsersByTimeOfTheDayOptions) => { const getUsersByTimeOfTheDay = useEndpoint('GET', '/v1/engagement-dashboard/users/users-by-time-of-the-day-in-a-week'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/users/useWeeklyChatActivity.ts b/apps/meteor/client/views/admin/engagementDashboard/users/useWeeklyChatActivity.ts index 6f9c0bde042df..b0b6c99add788 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/users/useWeeklyChatActivity.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/users/useWeeklyChatActivity.ts @@ -7,7 +7,6 @@ type UseWeeklyChatActivityOptions = { utc: boolean; }; -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useWeeklyChatActivity = ({ displacement, utc }: UseWeeklyChatActivityOptions) => { const getWeeklyChatActivity = useEndpoint('GET', '/v1/engagement-dashboard/users/chat-busier/weekly-data'); diff --git a/apps/meteor/client/views/admin/integrations/IntegrationsTable.tsx b/apps/meteor/client/views/admin/integrations/IntegrationsTable.tsx index f80ec353cc056..611dbc12e0371 100644 --- a/apps/meteor/client/views/admin/integrations/IntegrationsTable.tsx +++ b/apps/meteor/client/views/admin/integrations/IntegrationsTable.tsx @@ -131,7 +131,7 @@ const IntegrationsTable = ({ type }: { type?: string }) => { /> )} - {isSuccess && data && data.integrations.length === 0 && } + {isSuccess && data?.integrations.length === 0 && } {isError && ( diff --git a/apps/meteor/client/views/admin/integrations/outgoing/OutgoingWebhookForm.tsx b/apps/meteor/client/views/admin/integrations/outgoing/OutgoingWebhookForm.tsx index 00e8d6aea8e78..ab29f359a5129 100644 --- a/apps/meteor/client/views/admin/integrations/outgoing/OutgoingWebhookForm.tsx +++ b/apps/meteor/client/views/admin/integrations/outgoing/OutgoingWebhookForm.tsx @@ -71,10 +71,7 @@ const OutgoingWebhookForm = () => { [t], ); - const eventOptions: SelectOption[] = useMemo( - () => Object.entries(outgoingEvents).map(([key, val]) => [key, t(val.label as TranslationKey)]), - [t], - ); + const eventOptions: SelectOption[] = useMemo(() => Object.entries(outgoingEvents).map(([key, val]) => [key, t(val.label)]), [t]); const scriptEngineOptions: SelectOption[] = useMemo(() => [['isolated-vm', t('Script_Engine_isolated_vm')]], [t]); diff --git a/apps/meteor/client/views/admin/invites/InvitesPage.tsx b/apps/meteor/client/views/admin/invites/InvitesPage.tsx index efc94915cdf7a..6ab2eddd84866 100644 --- a/apps/meteor/client/views/admin/invites/InvitesPage.tsx +++ b/apps/meteor/client/views/admin/invites/InvitesPage.tsx @@ -111,7 +111,7 @@ const InvitesPage = (): ReactElement => { )} - {isSuccess && data && data.length === 0 && } + {isSuccess && data?.length === 0 && } {isError && ( diff --git a/apps/meteor/client/views/audit/hooks/useAuditTab.ts b/apps/meteor/client/views/audit/hooks/useAuditTab.ts index 42d24c5af3c00..20b0dfc151046 100644 --- a/apps/meteor/client/views/audit/hooks/useAuditTab.ts +++ b/apps/meteor/client/views/audit/hooks/useAuditTab.ts @@ -11,7 +11,7 @@ const typeToTabMap: Record = { 'l': 'omnichannel', }; -const tabToTabMap = new Map(Object.entries(typeToTabMap).map(([type, tab]) => [tab, type as IAuditLog['fields']['type']])); +const tabToTabMap = new Map(Object.entries(typeToTabMap).map(([type, tab]) => [tab, type])); export const useAuditTab = () => { const tab = useRouteParameter('tab'); diff --git a/apps/meteor/client/views/e2e/EnterE2EPasswordModal/EnterE2EPasswordModal.spec.tsx b/apps/meteor/client/views/e2e/EnterE2EPasswordModal/EnterE2EPasswordModal.spec.tsx index 0eb37d9037ad0..1130500962d78 100644 --- a/apps/meteor/client/views/e2e/EnterE2EPasswordModal/EnterE2EPasswordModal.spec.tsx +++ b/apps/meteor/client/views/e2e/EnterE2EPasswordModal/EnterE2EPasswordModal.spec.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { composeStories } from '@storybook/react'; import { render, screen } from '@testing-library/react'; diff --git a/apps/meteor/client/views/marketplace/AppDetailsPage/AppDetailsPage.tsx b/apps/meteor/client/views/marketplace/AppDetailsPage/AppDetailsPage.tsx index eed2e5003868d..58fea5f46cade 100644 --- a/apps/meteor/client/views/marketplace/AppDetailsPage/AppDetailsPage.tsx +++ b/apps/meteor/client/views/marketplace/AppDetailsPage/AppDetailsPage.tsx @@ -92,7 +92,7 @@ const AppDetailsPage = ({ id }: AppDetailsPageProps): ReactElement => { try { await AppClientOrchestratorInstance.setAppSettings( id, - (Object.values(settings || {}) as ISetting[]).map((setting) => ({ + Object.values(settings || {}).map((setting) => ({ ...setting, value: data[setting.id], })), diff --git a/apps/meteor/client/views/marketplace/helpers.ts b/apps/meteor/client/views/marketplace/helpers.ts index 7f40f8f32f177..ed2ce3ce8244f 100644 --- a/apps/meteor/client/views/marketplace/helpers.ts +++ b/apps/meteor/client/views/marketplace/helpers.ts @@ -225,7 +225,7 @@ export const appStatusSpanProps = ( }; } - const isOnTrialPeriod = subscriptionInfo && subscriptionInfo.status === 'trialing'; + const isOnTrialPeriod = subscriptionInfo?.status === 'trialing'; if (isOnTrialPeriod) { return { icon: 'checkmark-circled', diff --git a/apps/meteor/client/views/marketplace/hooks/useAppInfo.ts b/apps/meteor/client/views/marketplace/hooks/useAppInfo.ts index c562017ef1899..c6fc3fecebdc3 100644 --- a/apps/meteor/client/views/marketplace/hooks/useAppInfo.ts +++ b/apps/meteor/client/views/marketplace/hooks/useAppInfo.ts @@ -64,8 +64,8 @@ export const useAppInfo = (appId: string, context: string): AppInfo | undefined appVersion: appId, }) .then(({ app }: any) => { - (appResult as App).tosLink = app.tosLink; - (appResult as App).privacyLink = app.privacyLink; + appResult.tosLink = app.tosLink; + appResult.privacyLink = app.privacyLink; return getBundledInApp(app); }) .catch(() => ({ diff --git a/apps/meteor/client/views/modal/uikit/ModalBlock.tsx b/apps/meteor/client/views/modal/uikit/ModalBlock.tsx index ff102f00e773e..fbfb2be5746fb 100644 --- a/apps/meteor/client/views/modal/uikit/ModalBlock.tsx +++ b/apps/meteor/client/views/modal/uikit/ModalBlock.tsx @@ -113,7 +113,7 @@ const ModalBlock = ({ view, errors, onSubmit, onClose, onCancel }: ModalBlockPar if (!ref.current) { return; } - const elements = Array.from(ref.current.querySelectorAll(focusableElementsString)) as HTMLElement[]; + const elements = Array.from(ref.current.querySelectorAll(focusableElementsString)); const [first] = elements; const last = elements.pop(); @@ -161,7 +161,7 @@ const ModalBlock = ({ view, errors, onSubmit, onClose, onCancel }: ModalBlockPar if (!container.contains(e.target as HTMLElement)) { return; } - return handleKeyDown(e as KeyboardEvent); + return handleKeyDown(e); }; document.addEventListener('keydown', ignoreIfNotContains); diff --git a/apps/meteor/client/views/navigation/sidebar/RoomList/SidebarItemWithData.tsx b/apps/meteor/client/views/navigation/sidebar/RoomList/SidebarItemWithData.tsx index 79b933e59ca3d..3c6f0458a3d9d 100644 --- a/apps/meteor/client/views/navigation/sidebar/RoomList/SidebarItemWithData.tsx +++ b/apps/meteor/client/views/navigation/sidebar/RoomList/SidebarItemWithData.tsx @@ -89,7 +89,6 @@ function safeDateNotEqualCheck(a: Date | string | undefined, b: Date | string | const keys: (keyof RoomListRowProps)[] = ['id', 'style', 't', 'videoConfActions']; -// eslint-disable-next-line react/no-multi-comp export default memo(SidebarItemWithData, (prevProps, nextProps) => { if (keys.some((key) => prevProps[key] !== nextProps[key])) { return false; diff --git a/apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.tsx b/apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.tsx index 92e1e8475d433..1dd5ce480ad72 100644 --- a/apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.tsx +++ b/apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.tsx @@ -52,7 +52,7 @@ const SidePanelInternal = ({ title, currentTab, unreadOnly, toggleUnreadOnly, ro - {rooms && rooms.length === 0 && } + {rooms?.length === 0 && } - {tagsResult?.tags && tagsResult?.tags.length ? ( + {tagsResult?.tags?.length ? ( { const data = await getContact({ contactId }); // TODO: Can be safely removed once unknown contacts handling is added to the endpoint - if (data?.contact && data.contact.unknown) { + if (data?.contact?.unknown) { throw new ContactNotFoundError(); } @@ -149,7 +149,7 @@ const RecipientForm = (props: RecipientFormProps) => { }, [clearErrors, isErrorProvider, validateProviderField]); useEffect(() => { - isDirty && onDirty && onDirty(); + isDirty && onDirty?.(); }, [isDirty, onDirty]); const submit = useEffectEvent(async (values: RecipientFormData) => { diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/forms/RepliesForm/RepliesForm.spec.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/forms/RepliesForm/RepliesForm.spec.tsx index 886543e008ba3..f391bcf2e0c6c 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/forms/RepliesForm/RepliesForm.spec.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/forms/RepliesForm/RepliesForm.spec.tsx @@ -136,7 +136,7 @@ describe('RepliesForm', () => { expect(screen.getByLabelText('Agent (optional)')).toBeDisabled(); }); - xit('should render with default values', async () => { + it.skip('should render with default values', async () => { const defaultValues = { departmentId: 'department-1', agentId: 'agent-1', @@ -183,7 +183,7 @@ describe('RepliesForm', () => { await waitFor(() => expect(screen.queryByText('Error loading department information')).not.toBeInTheDocument()); }); - xit('should call submit with correct values when form is submitted', async () => { + it.skip('should call submit with correct values when form is submitted', async () => { const handleSubmit = jest.fn(); const defaultValues = { departmentId: 'department-1', diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.spec.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.spec.tsx index 95339ff897cfe..022ac3229dc04 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.spec.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.spec.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { WizardContext, StepsLinkedList } from '@rocket.chat/ui-client'; import { composeStories } from '@storybook/react'; diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.stories.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.stories.tsx index 4960d4ac70299..7b87753ca5ec7 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.stories.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.stories.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { Box } from '@rocket.chat/fuselage'; import { WizardContext, StepsLinkedList } from '@rocket.chat/ui-client'; import { action } from '@storybook/addon-actions'; diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.spec.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.spec.tsx index 448a0f96dfc45..54e65e93f21d1 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.spec.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.spec.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { WizardContext, StepsLinkedList } from '@rocket.chat/ui-client'; import { composeStories } from '@storybook/react'; diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.stories.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.stories.tsx index 003bf14150b13..e1e2643af82df 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.stories.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.stories.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { Box } from '@rocket.chat/fuselage'; import { mockAppRoot } from '@rocket.chat/mock-providers'; import { WizardContext, StepsLinkedList } from '@rocket.chat/ui-client'; diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.spec.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.spec.tsx index 382b766579ad1..f4b346c557c99 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.spec.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.spec.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { WizardContext, StepsLinkedList } from '@rocket.chat/ui-client'; import { composeStories } from '@storybook/react'; diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.stories.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.stories.tsx index 391ef96567ec4..c9c5396d7e640 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.stories.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.stories.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { faker } from '@faker-js/faker'; import { Box } from '@rocket.chat/fuselage'; import { mockAppRoot } from '@rocket.chat/mock-providers'; diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/utils/template.spec.ts b/apps/meteor/client/views/omnichannel/components/outboundMessage/utils/template.spec.ts index 99e1b06fcdc7b..a605e3ce15699 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/utils/template.spec.ts +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/utils/template.spec.ts @@ -55,7 +55,7 @@ describe('processTemplatePreviewText', () => { expect(text).toBe('Hello World'); }); - it('it should keep the placeholder in case the parameter is an empty string', () => { + it('should keep the placeholder in case the parameter is an empty string', () => { const text = processTemplatePreviewText('Hello {{1}}', [{ type: 'text', value: '', format: 'text' }]); expect(text).toBe('Hello {{1}}'); diff --git a/apps/meteor/client/views/omnichannel/directory/hooks/useDisplayFilters.ts b/apps/meteor/client/views/omnichannel/directory/hooks/useDisplayFilters.ts index 8a7b38b50ed64..c99de88ff0b93 100644 --- a/apps/meteor/client/views/omnichannel/directory/hooks/useDisplayFilters.ts +++ b/apps/meteor/client/views/omnichannel/directory/hooks/useDisplayFilters.ts @@ -41,5 +41,5 @@ export const useDisplayFilters = (filtersQuery: ChatsFiltersQuery) => { }; const parseMultiSelect = (data: PaginatedMultiSelectOption[]) => { - return data.map((a) => (a.label as string).split(' (')[0]).join(', '); + return data.map((a) => a.label.split(' (')[0]).join(', '); }; diff --git a/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts b/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts index b4e24c3fff608..9e0997dd5fcde 100644 --- a/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts +++ b/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts @@ -81,7 +81,7 @@ export const useComposerBoxPopup = ( setFocused((focused) => { const sortedItems = items .filter((item) => item.isSuccess) - .flatMap((item) => item.data as T[]) + .flatMap((item) => item.data) .sort((a, b) => (('sort' in a && a.sort) || 0) - (('sort' in b && b.sort) || 0)); return sortedItems.find((item) => item._id === focused?._id) ?? sortedItems[0]; }); @@ -194,7 +194,7 @@ export const useComposerBoxPopup = ( setFocused((focused) => { const list = items .filter((item) => item.isSuccess) - .flatMap((item) => item.data as T[]) + .flatMap((item) => item.data) .sort((a, b) => (('sort' in a && a.sort) || 0) - (('sort' in b && b.sort) || 0)); if (!list) { @@ -203,7 +203,7 @@ export const useComposerBoxPopup = ( const focusedIndex = list.findIndex((item) => item === focused); - return (focusedIndex > 0 ? list[focusedIndex - 1] : list[list.length - 1]) as T; + return focusedIndex > 0 ? list[focusedIndex - 1] : list[list.length - 1]; }); event.preventDefault(); event.stopImmediatePropagation(); @@ -213,7 +213,7 @@ export const useComposerBoxPopup = ( setFocused((focused) => { const list = items .filter((item) => item.isSuccess) - .flatMap((item) => item.data as T[]) + .flatMap((item) => item.data) .sort((a, b) => (('sort' in a && a.sort) || 0) - (('sort' in b && b.sort) || 0)); if (!list) { @@ -222,7 +222,7 @@ export const useComposerBoxPopup = ( const focusedIndex = list.findIndex((item) => item === focused); - return (focusedIndex < list.length - 1 ? list[focusedIndex + 1] : list[0]) as T; + return focusedIndex < list.length - 1 ? list[focusedIndex + 1] : list[0]; }); event.preventDefault(); event.stopImmediatePropagation(); diff --git a/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopupQueries.ts b/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopupQueries.ts index 76a68f14d85b1..4394338db2e6d 100644 --- a/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopupQueries.ts +++ b/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopupQueries.ts @@ -27,17 +27,17 @@ export const useComposerBoxPopupQueries = (popup?.getItemsFromLocal && popup.getItemsFromLocal(filter)) || [], + queryFn: () => popup?.getItemsFromLocal?.(filter) || [], enabled: enableQuery, }, { placeholderData: keepPreviousData, queryKey: ['message-popup', 'server', filter, popup], - queryFn: () => (popup?.getItemsFromServer && popup.getItemsFromServer(filter)) || [], + queryFn: () => popup?.getItemsFromServer?.(filter) || [], enabled: counter > 0, }, ], - }) as QueriesResults; + }); useEffect(() => { if (Array.isArray(queries[0].data) && queries[0].data.length < 5) { diff --git a/apps/meteor/client/views/room/composer/hooks/useMessageComposerIsArchived.ts b/apps/meteor/client/views/room/composer/hooks/useMessageComposerIsArchived.ts index 4417288d78f8c..16a29ac1b9079 100644 --- a/apps/meteor/client/views/room/composer/hooks/useMessageComposerIsArchived.ts +++ b/apps/meteor/client/views/room/composer/hooks/useMessageComposerIsArchived.ts @@ -1,4 +1,4 @@ import type { IRoom, ISubscription } from '@rocket.chat/core-typings'; export const useMessageComposerIsArchived = (room: IRoom, subscription?: ISubscription): boolean => - !!room?.archived || Boolean(subscription && subscription.t === 'd' && subscription.archived); + !!room?.archived || Boolean(subscription?.t === 'd' && subscription.archived); diff --git a/apps/meteor/client/views/room/composer/messageBox/MessageBoxActionsToolbar/MessageBoxActionsToolbar.tsx b/apps/meteor/client/views/room/composer/messageBox/MessageBoxActionsToolbar/MessageBoxActionsToolbar.tsx index 9a1ed5db7c80a..fd1acc5f2907e 100644 --- a/apps/meteor/client/views/room/composer/messageBox/MessageBoxActionsToolbar/MessageBoxActionsToolbar.tsx +++ b/apps/meteor/client/views/room/composer/messageBox/MessageBoxActionsToolbar/MessageBoxActionsToolbar.tsx @@ -112,7 +112,7 @@ const MessageBoxActionsToolbar = ({ .filter((item) => !hiddenActions.includes(item.id)) .map((item) => ({ id: item.id, - icon: item.icon as ComponentProps['name'], + icon: item.icon, content: t(item.label), onClick: (event?: MouseEvent) => item.action({ diff --git a/apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoActions.tsx b/apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoActions.tsx index 082e5c867306d..7f16f95cfd8b1 100644 --- a/apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoActions.tsx +++ b/apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoActions.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/display-name, react/no-multi-comp */ import type { IRoom, IUser } from '@rocket.chat/core-typings'; import { ButtonGroup, IconButton, Skeleton } from '@rocket.chat/fuselage'; import { GenericMenu } from '@rocket.chat/ui-client'; diff --git a/apps/meteor/client/views/room/contextualBar/VideoConference/hooks/useVideoConfOpenCall.tsx b/apps/meteor/client/views/room/contextualBar/VideoConference/hooks/useVideoConfOpenCall.tsx index ec3e448050c06..d77fd1107e235 100644 --- a/apps/meteor/client/views/room/contextualBar/VideoConference/hooks/useVideoConfOpenCall.tsx +++ b/apps/meteor/client/views/room/contextualBar/VideoConference/hooks/useVideoConfOpenCall.tsx @@ -7,7 +7,7 @@ export const useVideoConfOpenCall = () => { const setModal = useSetModal(); const handleOpenCall = useCallback( - (callUrl: string, providerName?: string | undefined) => { + (callUrl: string, providerName?: string) => { const desktopApp = window.RocketChatDesktop; if (!desktopApp?.openInternalVideoChatWindow) { diff --git a/apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.spec.tsx b/apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.spec.tsx index 1730a9151f2fc..2cdd7240ca28f 100644 --- a/apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.spec.tsx +++ b/apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.spec.tsx @@ -1,7 +1,7 @@ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { useCurrentRoutePath, useRouter } from '@rocket.chat/ui-contexts'; import { render } from '@testing-library/react'; -import React from 'react'; +import type React from 'react'; import LayoutWithSidebar from './LayoutWithSidebar'; diff --git a/apps/meteor/client/views/root/hooks/loggedIn/useUnread.ts b/apps/meteor/client/views/root/hooks/loggedIn/useUnread.ts index e27a91ed62e33..8655a770c1de5 100644 --- a/apps/meteor/client/views/root/hooks/loggedIn/useUnread.ts +++ b/apps/meteor/client/views/root/hooks/loggedIn/useUnread.ts @@ -35,7 +35,7 @@ export const useUnread = () => { const { rid, unread: unreadValue, alert, unreadAlert: subscriptionUnreadAlert } = subscription; const prev = prevSubsRef.current.get(rid); // Emit per-sub event only if something that influences unread UI changed. - if (!prev || prev.unread !== unreadValue || prev.alert !== alert || prev.unreadAlert !== subscriptionUnreadAlert) { + if (prev?.unread !== unreadValue || prev.alert !== alert || prev.unreadAlert !== subscriptionUnreadAlert) { fireEventUnreadChangedBySubscription(subscription); } nextSnapshot.set(rid, { unread: unreadValue, alert, unreadAlert: subscriptionUnreadAlert }); diff --git a/apps/meteor/client/views/teams/ChannelDesertionTable/ChannelDesertionTable.tsx b/apps/meteor/client/views/teams/ChannelDesertionTable/ChannelDesertionTable.tsx index 7df0d6f7ac710..de4d6b02813f0 100644 --- a/apps/meteor/client/views/teams/ChannelDesertionTable/ChannelDesertionTable.tsx +++ b/apps/meteor/client/views/teams/ChannelDesertionTable/ChannelDesertionTable.tsx @@ -40,10 +40,7 @@ const ChannelDesertionTable = ({ const direction = sortDirection === 'asc' ? 1 : -1; - return rooms.sort((a, b) => - // eslint-disable-next-line no-nested-ternary - a[sortBy] && b[sortBy] ? (a[sortBy]?.localeCompare(b[sortBy] ?? '') ?? 1) * direction : direction, - ); + return rooms.sort((a, b) => (a[sortBy] && b[sortBy] ? (a[sortBy]?.localeCompare(b[sortBy] ?? '') ?? 1) * direction : direction)); }, [rooms, sortBy, sortDirection]); return ( diff --git a/apps/meteor/definition/externals/meteor/accounts-base.d.ts b/apps/meteor/definition/externals/meteor/accounts-base.d.ts index 875b3cb5291e6..a3ad8478ba3c8 100644 --- a/apps/meteor/definition/externals/meteor/accounts-base.d.ts +++ b/apps/meteor/definition/externals/meteor/accounts-base.d.ts @@ -65,7 +65,6 @@ declare module 'meteor/accounts-base' { export const _options: AccountsServerOptions; - // eslint-disable-next-line @typescript-eslint/no-namespace namespace oauth { function credentialRequestCompleteHandler( callback?: (error?: globalThis.Error | Meteor.Error | Meteor.TypedError) => void, diff --git a/apps/meteor/ee/app/livechat-enterprise/server/api/lib/inquiries.ts b/apps/meteor/ee/app/livechat-enterprise/server/api/lib/inquiries.ts index c86dd1a9cb03b..5e28f63f2981b 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/api/lib/inquiries.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/api/lib/inquiries.ts @@ -4,7 +4,7 @@ import { updateRoomSLA } from './sla'; export async function setSLAToInquiry({ userId, roomId, sla }: { userId: string; roomId: string; sla?: string }): Promise { const inquiry = await LivechatInquiry.findOneByRoomId(roomId, { projection: { status: 1 } }); - if (!inquiry || inquiry.status !== 'queued') { + if (inquiry?.status !== 'queued') { throw new Error('error-invalid-inquiry'); } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts b/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts index 89a28af413420..5c358d5b8ffee 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts @@ -28,7 +28,7 @@ const handleAfterOnHold = async (room: Pick): Promise('Livechat_auto_close_on_hold_chats_timeout', (value) => { - autoCloseOnHoldChatTimeout = value as number; + autoCloseOnHoldChatTimeout = value; if (!value || value <= 0) { callbacks.remove('livechat:afterOnHold', 'livechat-auto-close-on-hold'); } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts b/apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts index 57f29a4d87ede..16776d415934c 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts @@ -177,7 +177,7 @@ export const LivechatEnterprise = { async removeSLA(executedBy: string, _id: string) { const removedResult = await OmnichannelServiceLevelAgreements.removeById(_id); - if (!removedResult || removedResult.deletedCount !== 1) { + if (removedResult?.deletedCount !== 1) { throw new Error(`SLA with id ${_id} not found`); } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/lib/QueueInactivityMonitor.ts b/apps/meteor/ee/app/livechat-enterprise/server/lib/QueueInactivityMonitor.ts index 2d1842da65fcf..f91e51a8ed21f 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/lib/QueueInactivityMonitor.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/lib/QueueInactivityMonitor.ts @@ -112,7 +112,7 @@ export class OmnichannelQueueInactivityMonitorClass { const { inquiryId } = data; // TODO: add projection and maybe use findOneQueued to avoid fetching the whole inquiry const inquiry = await LivechatInquiryRaw.findOneById(inquiryId); - if (!inquiry || inquiry.status !== 'queued') { + if (inquiry?.status !== 'queued') { return; } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts b/apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts index ed81fa5f6f5d8..1e71e9623f64c 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts @@ -11,7 +11,7 @@ import { settings } from '../../../../../app/settings/server'; import { callbacks } from '../../../../../server/lib/callbacks'; import { i18n } from '../../../../../server/lib/i18n'; -const isPromiseRejectedResult = (result: any): result is PromiseRejectedResult => result && result.status === 'rejected'; +const isPromiseRejectedResult = (result: any): result is PromiseRejectedResult => result?.status === 'rejected'; export class VisitorInactivityMonitor { _started: boolean; diff --git a/apps/meteor/ee/app/livechat-enterprise/server/lib/debounceByParams.ts b/apps/meteor/ee/app/livechat-enterprise/server/lib/debounceByParams.ts index 24dd03e9c6d2d..323f7a2464618 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/lib/debounceByParams.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/lib/debounceByParams.ts @@ -9,10 +9,7 @@ interface IMemoizeDebouncedFunction any> { // Debounce `func` based on passed parameters // ref: https://github.com/lodash/lodash/issues/2403#issuecomment-816137402 export function memoizeDebounce any>(func: F, wait = 0, options: any = {}): IMemoizeDebouncedFunction { - const debounceMemo = mem( - // eslint-disable-next-line @typescript-eslint/no-unused-vars - (..._args: Parameters) => debounce(func, wait, options), - ); + const debounceMemo = mem((..._args: Parameters) => debounce(func, wait, options)); function wrappedFunction(this: IMemoizeDebouncedFunction, ...args: Parameters): ReturnType | undefined { return debounceMemo(...args)(...args); diff --git a/apps/meteor/ee/server/api/audit.ts b/apps/meteor/ee/server/api/audit.ts index fbbbde91fff30..32b4d7987ace3 100644 --- a/apps/meteor/ee/server/api/audit.ts +++ b/apps/meteor/ee/server/api/audit.ts @@ -154,11 +154,11 @@ API.v1.get( async function action() { const { start, end, settingId, actor } = this.queryParams; - if (start && isNaN(Date.parse(start as string))) { + if (start && isNaN(Date.parse(start))) { return API.v1.failure('The "start" query parameter must be a valid date.'); } - if (end && isNaN(Date.parse(end as string))) { + if (end && isNaN(Date.parse(end))) { return API.v1.failure('The "end" query parameter must be a valid date.'); } @@ -171,8 +171,8 @@ API.v1.get( ...(settingId && { 'data.key': 'id', 'data.value': settingId }), ...(actor && convertSubObjectsIntoPaths({ actor })), ts: { - $gte: start ? new Date(start as string) : new Date(0), - $lte: end ? new Date(end as string) : new Date(), + $gte: start ? new Date(start) : new Date(0), + $lte: end ? new Date(end) : new Date(), }, t: 'settings.changed', }, diff --git a/apps/meteor/ee/server/api/engagementDashboard/channels.ts b/apps/meteor/ee/server/api/engagementDashboard/channels.ts index 96f2d5776ac02..02513d396750c 100644 --- a/apps/meteor/ee/server/api/engagementDashboard/channels.ts +++ b/apps/meteor/ee/server/api/engagementDashboard/channels.ts @@ -14,7 +14,7 @@ declare module '@rocket.chat/rest-typings' { channels: { room: { _id: IRoom['_id']; - name: IRoom['name'] | IRoom['fname']; + name: IRoom['name']; ts: IRoom['ts']; t: IRoom['t']; _updatedAt: IRoom['_updatedAt']; diff --git a/apps/meteor/ee/server/api/engagementDashboard/messages.ts b/apps/meteor/ee/server/api/engagementDashboard/messages.ts index d048369ca502a..ffd6dfd1e90b0 100644 --- a/apps/meteor/ee/server/api/engagementDashboard/messages.ts +++ b/apps/meteor/ee/server/api/engagementDashboard/messages.ts @@ -25,7 +25,7 @@ declare module '@rocket.chat/rest-typings' { channels: { t: IRoom['t']; messages: number; - name: IRoom['name'] | IRoom['fname']; + name: IRoom['name']; usernames?: IDirectMessageRoom['usernames']; }[]; }; diff --git a/apps/meteor/ee/server/api/sessions.ts b/apps/meteor/ee/server/api/sessions.ts index 64e9531024255..605ba70030ace 100644 --- a/apps/meteor/ee/server/api/sessions.ts +++ b/apps/meteor/ee/server/api/sessions.ts @@ -209,7 +209,7 @@ API.v1.addRoute( return API.v1.forbidden(); } - const sessionId = this.queryParams?.sessionId as string; + const sessionId = this.queryParams?.sessionId; const { sessions } = await Sessions.aggregateSessionsAndPopulate({ search: sessionId, count: 1 }); if (!sessions?.length) { return API.v1.notFound('Session not found'); diff --git a/apps/meteor/ee/server/apps/communication/endpoints/appsCountHandler.ts b/apps/meteor/ee/server/apps/communication/endpoints/appsCountHandler.ts index 402ceb709a16a..5d82fcd97aec7 100644 --- a/apps/meteor/ee/server/apps/communication/endpoints/appsCountHandler.ts +++ b/apps/meteor/ee/server/apps/communication/endpoints/appsCountHandler.ts @@ -11,7 +11,7 @@ export const registerAppsCountHandler = ({ api, _manager }: AppsRestApi) => { authRequired: false }, { async get() { - const manager = _manager as AppManager; + const manager = _manager; const apps = await manager.get({ enabled: true }); const { maxMarketplaceApps, maxPrivateApps } = License.getAppsConfig(); diff --git a/apps/meteor/ee/server/apps/communication/uikit.ts b/apps/meteor/ee/server/apps/communication/uikit.ts index 1dcd1c169d578..6780c83077e12 100644 --- a/apps/meteor/ee/server/apps/communication/uikit.ts +++ b/apps/meteor/ee/server/apps/communication/uikit.ts @@ -48,7 +48,7 @@ Meteor.startup(() => { // use specific rate limit of 600 (which is 60 times the default limits) requests per minute (around 10/second) const apiLimiter = rateLimit({ windowMs: settings.get('API_Enable_Rate_Limiter_Limit_Time_Default'), - max: (settings.get('API_Enable_Rate_Limiter_Limit_Calls_Default') as number) * 60, + max: settings.get('API_Enable_Rate_Limiter_Limit_Calls_Default') * 60, skip: () => settings.get('API_Enable_Rate_Limiter') !== true || (process.env.NODE_ENV === 'development' && settings.get('API_Enable_Rate_Limiter_Dev') !== true), diff --git a/apps/meteor/ee/server/configuration/saml.ts b/apps/meteor/ee/server/configuration/saml.ts index 6ab5f10926233..dc522592eebd5 100644 --- a/apps/meteor/ee/server/configuration/saml.ts +++ b/apps/meteor/ee/server/configuration/saml.ts @@ -9,7 +9,7 @@ import { addSettings } from '../settings/saml'; await License.onLicense('saml-enterprise', () => { SAMLUtils.events.on('mapUser', async ({ profile, userObject }: { profile: Record; userObject: ISAMLUser }) => { - const roleAttributeName = settings.get('SAML_Custom_Default_role_attribute_name') as string; + const roleAttributeName = settings.get('SAML_Custom_Default_role_attribute_name'); const roleAttributeSync = settings.get('SAML_Custom_Default_role_attribute_sync'); if (!roleAttributeSync) { @@ -48,7 +48,7 @@ await License.onLicense('saml-enterprise', () => { }); SAMLUtils.events.on('updateCustomFields', async (loginResult: Record, updatedUser: { userId: string; token: string }) => { - const userDataCustomFieldMap = settings.get('SAML_Custom_Default_user_data_custom_fieldmap') as string; + const userDataCustomFieldMap = settings.get('SAML_Custom_Default_user_data_custom_fieldmap'); const customMap: Record = JSON.parse(userDataCustomFieldMap); const customFieldsList: Record = {}; diff --git a/apps/meteor/ee/server/lib/engagementDashboard/channels.ts b/apps/meteor/ee/server/lib/engagementDashboard/channels.ts index a71d7c99b21df..7da22d7415624 100644 --- a/apps/meteor/ee/server/lib/engagementDashboard/channels.ts +++ b/apps/meteor/ee/server/lib/engagementDashboard/channels.ts @@ -20,7 +20,7 @@ export const findChannelsWithNumberOfMessages = async ({ channels: { room: { _id: IRoom['_id']; - name: IRoom['name'] | IRoom['fname']; + name: IRoom['name']; ts: IRoom['ts']; t: IRoom['t']; _updatedAt: IRoom['_updatedAt']; diff --git a/apps/meteor/ee/server/lib/engagementDashboard/messages.ts b/apps/meteor/ee/server/lib/engagementDashboard/messages.ts index 55bcae0da3aeb..edd1c3eb6fead 100644 --- a/apps/meteor/ee/server/lib/engagementDashboard/messages.ts +++ b/apps/meteor/ee/server/lib/engagementDashboard/messages.ts @@ -143,7 +143,7 @@ export const findTopFivePopularChannelsByMessageSentQuantity = async ({ channels: { t: IRoom['t']; messages: number; - name: IRoom['name'] | IRoom['fname']; + name: IRoom['name']; usernames?: IDirectMessageRoom['usernames']; }[]; }> => { diff --git a/apps/meteor/ee/server/lib/ldap/Manager.ts b/apps/meteor/ee/server/lib/ldap/Manager.ts index a8ec3d84d9769..f8b2cc5ba8a1e 100644 --- a/apps/meteor/ee/server/lib/ldap/Manager.ts +++ b/apps/meteor/ee/server/lib/ldap/Manager.ts @@ -299,7 +299,7 @@ export class LDAPEEManager extends LDAPManager { return; } - const roles = (await Roles.find( + const roles = await Roles.find( {}, { projection: { @@ -307,7 +307,7 @@ export class LDAPEEManager extends LDAPManager { name: 1, }, }, - ).toArray()) as Array; + ).toArray(); if (!roles) { return; diff --git a/apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts b/apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts index 76befbd38b004..c886d93fcd1ce 100644 --- a/apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts +++ b/apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts @@ -10,7 +10,7 @@ import { i18n } from '../i18n'; const hideUserName = (username: string, userData: Pick | undefined, usersMap: Record) => { if (!usersMap[username]) { - if (userData && username === userData.username) { + if (username === userData?.username) { usersMap[username] = username; } else { usersMap[username] = `User_${Object.keys(usersMap).length + 1}`; @@ -49,7 +49,7 @@ const getAttachmentData = (attachment: MessageAttachment, message: IMessage) => }; export type MessageData = Pick & { - username?: IUser['username'] | IUser['name']; + username?: IUser['username']; attachments?: ReturnType[]; type?: IMessage['t']; }; diff --git a/apps/meteor/server/lib/dataExport/sendEmail.ts b/apps/meteor/server/lib/dataExport/sendEmail.ts index 88ae72d738326..a3dde11f78b07 100644 --- a/apps/meteor/server/lib/dataExport/sendEmail.ts +++ b/apps/meteor/server/lib/dataExport/sendEmail.ts @@ -12,7 +12,7 @@ export const sendEmail = async (userData: Pick, subjec } const to = `${userData.name} <${emailAddress}>`; - const from = settings.get('From_Email') as string; + const from = settings.get('From_Email'); if (!Mailer.checkAddressFormat(emailAddress)) { return; diff --git a/apps/meteor/server/lib/http/call.ts b/apps/meteor/server/lib/http/call.ts index bf03cb449506f..290744fd0e8b9 100644 --- a/apps/meteor/server/lib/http/call.ts +++ b/apps/meteor/server/lib/http/call.ts @@ -187,7 +187,7 @@ function httpCallAsync(httpMethod: string, url: string, callback: callbackFn): v function httpCallAsync(httpMethod: string, url: string, optionsOrCallback: HttpCallOptions | callbackFn = {}, callback?: callbackFn): void { // If the options argument was omitted, adjust the arguments: if (!callback && typeof optionsOrCallback === 'function') { - return _call(httpMethod, url, {}, optionsOrCallback as callbackFn); + return _call(httpMethod, url, {}, optionsOrCallback); } return _call(httpMethod, url, optionsOrCallback as HttpCallOptions, callback as callbackFn); diff --git a/apps/meteor/server/lib/i18n.ts b/apps/meteor/server/lib/i18n.ts index 86265b8d378bf..93a4e9b366579 100644 --- a/apps/meteor/server/lib/i18n.ts +++ b/apps/meteor/server/lib/i18n.ts @@ -87,7 +87,7 @@ void i18n.init({ language, extractTranslationNamespaces( // TODO: commonjs is terrible but we don't have esm build yet - // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require + // eslint-disable-next-line import/no-dynamic-require require(`@rocket.chat/i18n/dist/resources/${language}.i18n.json`) as unknown as Record, ), ]), diff --git a/apps/meteor/server/lib/ldap/Manager.ts b/apps/meteor/server/lib/ldap/Manager.ts index 1dac8ad89ed52..4874068556e4b 100644 --- a/apps/meteor/server/lib/ldap/Manager.ts +++ b/apps/meteor/server/lib/ldap/Manager.ts @@ -171,7 +171,7 @@ export class LDAPManager { }; } - protected static mapUserData(ldapUser: ILDAPEntry, usedUsername?: string | undefined): IImportUser { + protected static mapUserData(ldapUser: ILDAPEntry, usedUsername?: string): IImportUser { const uniqueId = this.getLdapUserUniqueID(ldapUser); if (!uniqueId) { throw new Error('Failed to generate unique identifier for ldap entry'); @@ -364,7 +364,7 @@ export class LDAPManager { private static async syncUserForLogin( ldapUser: ILDAPEntry, existingUser?: IUser, - usedUsername?: string | undefined, + usedUsername?: string, ): Promise { logger.debug({ msg: 'Syncing user data', diff --git a/apps/meteor/server/lib/rooms/roomTypes/private.ts b/apps/meteor/server/lib/rooms/roomTypes/private.ts index 5349c1da133d2..69df98e9878c9 100644 --- a/apps/meteor/server/lib/rooms/roomTypes/private.ts +++ b/apps/meteor/server/lib/rooms/roomTypes/private.ts @@ -35,7 +35,7 @@ roomCoordinator.add(PrivateRoomType, { }, async allowMemberAction(_room, action, _userId) { - if (isRoomFederated(_room as IRoom)) { + if (isRoomFederated(_room)) { if (isRoomNativeFederated(_room) && isFederationEnabled()) { return true; } diff --git a/apps/meteor/server/lib/rooms/roomTypes/public.ts b/apps/meteor/server/lib/rooms/roomTypes/public.ts index ead4609c11c8d..b83ee23c615f3 100644 --- a/apps/meteor/server/lib/rooms/roomTypes/public.ts +++ b/apps/meteor/server/lib/rooms/roomTypes/public.ts @@ -35,7 +35,7 @@ roomCoordinator.add(PublicRoomType, { }, async allowMemberAction(_room, action, _userId) { - if (isRoomFederated(_room as IRoom)) { + if (isRoomFederated(_room)) { if (isRoomNativeFederated(_room) && isFederationEnabled()) { return true; } diff --git a/apps/meteor/server/services/analytics/service.ts b/apps/meteor/server/services/analytics/service.ts index de454fb64bcec..8608913cb9009 100644 --- a/apps/meteor/server/services/analytics/service.ts +++ b/apps/meteor/server/services/analytics/service.ts @@ -11,7 +11,7 @@ export class AnalyticsService extends ServiceClassInternal implements IAnalytics } async getSeatRequestCount(): Promise { - const result = (await Analytics.findOne({ type: 'seat-request' }, {})) as IAnalyticsSeatRequest | null; + const result = await Analytics.findOne({ type: 'seat-request' }, {}); return result?.count ? result.count : 0; } diff --git a/apps/meteor/server/services/image/service.ts b/apps/meteor/server/services/image/service.ts index 85b4d2d05f979..c0306c36d5f75 100644 --- a/apps/meteor/server/services/image/service.ts +++ b/apps/meteor/server/services/image/service.ts @@ -40,7 +40,7 @@ export class MediaService extends ServiceClassInternal implements IMediaService keepType: boolean, blur: boolean, enlarge: boolean, - fit?: keyof sharp.FitEnum | undefined, + fit?: keyof sharp.FitEnum, ): Promise { const stream = this.bufferToStream(input); return this.resizeFromStream(stream, width, height, keepType, blur, enlarge, fit); @@ -53,7 +53,7 @@ export class MediaService extends ServiceClassInternal implements IMediaService keepType: boolean, blur: boolean, enlarge: boolean, - fit?: keyof sharp.FitEnum | undefined, + fit?: keyof sharp.FitEnum, ): Promise { const transformer = sharp().resize({ width, height, fit, withoutEnlargement: !enlarge }); diff --git a/apps/meteor/server/services/meteor/userReactivity.ts b/apps/meteor/server/services/meteor/userReactivity.ts index eb1b10eacee62..c9c9f93485e4a 100644 --- a/apps/meteor/server/services/meteor/userReactivity.ts +++ b/apps/meteor/server/services/meteor/userReactivity.ts @@ -82,7 +82,7 @@ export const processOnChange = (diff: Record, id: string): void => const cbs = userCallbacks.get(id); if (cbs) { [...cbs] - .filter(({ hashedToken }) => tokens === undefined || !tokens.includes(hashedToken)) + .filter(({ hashedToken }) => !tokens?.includes(hashedToken)) .forEach((item) => { item.callbacks.removed(id); cbs.delete(item); diff --git a/apps/meteor/server/services/omnichannel-analytics/AgentData.ts b/apps/meteor/server/services/omnichannel-analytics/AgentData.ts index 49717f8e7b783..709566f50b10b 100644 --- a/apps/meteor/server/services/omnichannel-analytics/AgentData.ts +++ b/apps/meteor/server/services/omnichannel-analytics/AgentData.ts @@ -145,7 +145,7 @@ export class AgentOverviewData { }; await this.roomsModel.getAnalyticsMetricsBetweenDate('l', date, { departmentId }, extraQuery).forEach(({ metrics, servedBy }) => { - if (servedBy && metrics && metrics.chatDuration) { + if (servedBy && metrics?.chatDuration) { if (agentChatDurations.has(servedBy.username)) { agentChatDurations.set(servedBy.username, { chatDuration: agentChatDurations.get(servedBy.username).chatDuration + metrics.chatDuration, @@ -237,7 +237,7 @@ export class AgentOverviewData { }; await this.roomsModel.getAnalyticsMetricsBetweenDate('l', date, { departmentId }, extraQuery).forEach(({ metrics, responseBy }) => { - if (responseBy && metrics && metrics.response && metrics.response.ft) { + if (responseBy && metrics?.response?.ft) { if (agentAvgRespTime.has(responseBy.username)) { agentAvgRespTime.set(responseBy.username, { frt: agentAvgRespTime.get(responseBy.username).frt + metrics.response.ft, @@ -287,7 +287,7 @@ export class AgentOverviewData { }; await this.roomsModel.getAnalyticsMetricsBetweenDate('l', date, { departmentId }, extraQuery).forEach(({ metrics, responseBy }) => { - if (responseBy && metrics && metrics.response && metrics.response.ft) { + if (responseBy && metrics?.response?.ft) { if (agentFirstRespTime.has(responseBy.username)) { agentFirstRespTime.set(responseBy.username, Math.min(agentFirstRespTime.get(responseBy.username), metrics.response.ft)); } else { @@ -329,7 +329,7 @@ export class AgentOverviewData { }; await this.roomsModel.getAnalyticsMetricsBetweenDate('l', date, { departmentId }, extraQuery).forEach(({ metrics, servedBy }) => { - if (servedBy && metrics && metrics.response && metrics.response.avg) { + if (servedBy && metrics?.response?.avg) { if (agentAvgRespTime.has(servedBy.username)) { agentAvgRespTime.set(servedBy.username, { avg: agentAvgRespTime.get(servedBy.username).avg + metrics.response.avg, @@ -379,7 +379,7 @@ export class AgentOverviewData { }; await this.roomsModel.getAnalyticsMetricsBetweenDate('l', date, { departmentId }, extraQuery).forEach(({ metrics, servedBy }) => { - if (servedBy && metrics && metrics.reaction && metrics.reaction.ft) { + if (servedBy && metrics?.reaction?.ft) { if (agentAvgReactionTime.has(servedBy.username)) { agentAvgReactionTime.set(servedBy.username, { frt: agentAvgReactionTime.get(servedBy.username).frt + metrics.reaction.ft, diff --git a/apps/meteor/server/services/omnichannel-analytics/service.ts b/apps/meteor/server/services/omnichannel-analytics/service.ts index 24ce8ded79f2a..a665979de4910 100644 --- a/apps/meteor/server/services/omnichannel-analytics/service.ts +++ b/apps/meteor/server/services/omnichannel-analytics/service.ts @@ -1,4 +1,3 @@ -/* eslint-disable new-cap */ import { ServiceClassInternal } from '@rocket.chat/core-services'; import type { AgentOverviewDataOptions, diff --git a/apps/meteor/server/services/team/service.ts b/apps/meteor/server/services/team/service.ts index 9d5b3bb0356ab..431c912eb7048 100644 --- a/apps/meteor/server/services/team/service.ts +++ b/apps/meteor/server/services/team/service.ts @@ -204,7 +204,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { async search

( userId: string, term: string | RegExp, - options?: undefined | FindOptions | FindOptions

, + options?: FindOptions | FindOptions

, ): Promise { if (typeof term === 'string') { term = new RegExp(`^${escapeRegExp(term)}`, 'i'); @@ -296,7 +296,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { async listByNames

( names: Array, - options?: undefined | FindOptions | FindOptions

, + options?: FindOptions | FindOptions

, ): Promise { if (options === undefined) { return Team.findByNames(names).toArray(); @@ -497,7 +497,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { listTeamsBySubscriberUserId

( uid: string, - options?: undefined | FindOptions | FindOptions

, + options?: FindOptions | FindOptions

, ): Promise { if (options) { return TeamMember.findByUserId(uid, options).toArray(); @@ -893,7 +893,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { getAllPublicTeams(options: FindOptions): Promise; - async getAllPublicTeams(options?: undefined | FindOptions): Promise { + async getAllPublicTeams(options?: FindOptions): Promise { return options ? Team.findByType(TeamType.PUBLIC, options).toArray() : Team.findByType(TeamType.PUBLIC).toArray(); } @@ -908,7 +908,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { async getOneByName(teamName: string | RegExp, options: FindOptions): Promise; - async getOneByName(teamName: string | RegExp, options?: undefined | FindOptions): Promise { + async getOneByName(teamName: string | RegExp, options?: FindOptions): Promise { if (!options) { return Team.findOneByName(teamName); } diff --git a/apps/meteor/server/startup/migrations/v294.ts b/apps/meteor/server/startup/migrations/v294.ts index 07f6dc2acc1fe..2c1dd74a8d69c 100644 --- a/apps/meteor/server/startup/migrations/v294.ts +++ b/apps/meteor/server/startup/migrations/v294.ts @@ -14,7 +14,7 @@ addMigration({ Apps.initialize(); - const sigMan = Apps.getManager()?.getSignatureManager() as AppSignatureManager; + const sigMan = Apps.getManager()?.getSignatureManager(); const appsStorage = Apps.getStorage() as AppRealStorage; const apps = await appsStorage.retrieveAll(); diff --git a/apps/meteor/server/startup/migrations/v304.ts b/apps/meteor/server/startup/migrations/v304.ts index 48cb217643d05..26d4ff3c00737 100644 --- a/apps/meteor/server/startup/migrations/v304.ts +++ b/apps/meteor/server/startup/migrations/v304.ts @@ -8,11 +8,7 @@ addMigration({ async up() { const indexes = await Analytics.col.indexes(); - if ( - indexes.find( - (index) => index.name === 'room._id_1_date_1' && index.partialFilterExpression && index.partialFilterExpression.type === 'rooms', - ) - ) { + if (indexes.find((index) => index.name === 'room._id_1_date_1' && index.partialFilterExpression?.type === 'rooms')) { return; } diff --git a/apps/meteor/server/startup/migrations/v307.ts b/apps/meteor/server/startup/migrations/v307.ts index d16d16220edc8..1a4b7099a35c0 100644 --- a/apps/meteor/server/startup/migrations/v307.ts +++ b/apps/meteor/server/startup/migrations/v307.ts @@ -21,7 +21,7 @@ addMigration({ Apps.initialize(); - const sigMan = Apps.getManager()?.getSignatureManager() as AppSignatureManager; + const sigMan = Apps.getManager()?.getSignatureManager(); const appsStorage = Apps.getStorage() as AppRealStorage; const apps = await appsStorage.retrieveAllPrivate(); diff --git a/apps/meteor/server/ufs/ufs-server.ts b/apps/meteor/server/ufs/ufs-server.ts index 34b3422981a63..42da2a597eb2e 100644 --- a/apps/meteor/server/ufs/ufs-server.ts +++ b/apps/meteor/server/ufs/ufs-server.ts @@ -176,7 +176,6 @@ WebApp.connectHandlers.use(async (req, res, next) => { if ( (file.modifiedAt instanceof Date && file.modifiedAt > modifiedSince) || - // eslint-disable-next-line no-mixed-operators (file.uploadedAt instanceof Date && file.uploadedAt > modifiedSince) ) { res.writeHead(304); // Not Modified diff --git a/apps/meteor/server/ufs/ufs-store.ts b/apps/meteor/server/ufs/ufs-store.ts index 3c6d6c983850f..a4e3f6417aef7 100644 --- a/apps/meteor/server/ufs/ufs-store.ts +++ b/apps/meteor/server/ufs/ufs-store.ts @@ -240,7 +240,6 @@ export class Store { generateToken(pattern?: string) { return (pattern || 'xyxyxyxyxy').replace(/[xy]/g, (c) => { - // eslint-disable-next-line no-mixed-operators const r = (Math.random() * 16) | 0; const v = c === 'x' ? r : (r & 0x3) | 0x8; const s = v.toString(16); diff --git a/apps/meteor/tests/data/rooms.helper.ts b/apps/meteor/tests/data/rooms.helper.ts index 24857005970ff..8d53fc5c6e7f9 100644 --- a/apps/meteor/tests/data/rooms.helper.ts +++ b/apps/meteor/tests/data/rooms.helper.ts @@ -294,7 +294,6 @@ export const findRoomMember = async ( await new Promise((resolve) => setTimeout(resolve, initialDelay)); } - // eslint-disable-next-line no-await-in-loop for (let attempt = 1; attempt <= maxRetries; attempt++) { try { // eslint-disable-next-line no-await-in-loop diff --git a/apps/meteor/tests/e2e/e2e-encryption/e2ee-legacy-format.spec.ts b/apps/meteor/tests/e2e/e2e-encryption/e2ee-legacy-format.spec.ts index 342761526ccf4..6bb04acf26fe4 100644 --- a/apps/meteor/tests/e2e/e2e-encryption/e2ee-legacy-format.spec.ts +++ b/apps/meteor/tests/e2e/e2e-encryption/e2ee-legacy-format.spec.ts @@ -72,7 +72,7 @@ test.describe('E2EE Legacy Format', () => { await page.evaluate( async ({ rid, kid, encryptedKey }) => { - // eslint-disable-next-line import/no-unresolved, @typescript-eslint/no-var-requires, import/no-absolute-path, @typescript-eslint/consistent-type-imports + // eslint-disable-next-line import/no-absolute-path const { e2e } = require('/client/lib/e2ee/rocketchat.e2e.ts') as typeof import('../../../client/lib/e2ee/rocketchat.e2e'); const room = await e2e.getInstanceByRoomId(rid); await room?.importGroupKey(kid + encryptedKey); diff --git a/apps/meteor/tests/e2e/page-objects/login.ts b/apps/meteor/tests/e2e/page-objects/login.ts index dcf3e4802484c..7b81c91f6513f 100644 --- a/apps/meteor/tests/e2e/page-objects/login.ts +++ b/apps/meteor/tests/e2e/page-objects/login.ts @@ -46,7 +46,7 @@ export class LoginPage { items.forEach(({ name, value }) => { window.localStorage.setItem(name, value); }); - // eslint-disable-next-line @typescript-eslint/no-var-requires + require('meteor/accounts-base').Accounts._pollStoredLoginToken(); }, localStorageItems); diff --git a/apps/meteor/tests/unit/app/license/server/canEnableApp.spec.ts b/apps/meteor/tests/unit/app/license/server/canEnableApp.spec.ts index 0cb68734fb462..694f50f99c07f 100644 --- a/apps/meteor/tests/unit/app/license/server/canEnableApp.spec.ts +++ b/apps/meteor/tests/unit/app/license/server/canEnableApp.spec.ts @@ -35,7 +35,6 @@ const getDefaultApp = (): IAppStorageItem => ({ }); // We will be passing promises to the `expect` function -/* eslint-disable @typescript-eslint/no-floating-promises */ describe('canEnableApp', () => { it('should throw the message "apps-engine-not-initialized" when appropriate', () => { diff --git a/apps/meteor/tests/unit/server/services/omnichannel-analytics/AgentData.tests.ts b/apps/meteor/tests/unit/server/services/omnichannel-analytics/AgentData.tests.ts index 7e3003332d503..fbbda13a7e2a4 100644 --- a/apps/meteor/tests/unit/server/services/omnichannel-analytics/AgentData.tests.ts +++ b/apps/meteor/tests/unit/server/services/omnichannel-analytics/AgentData.tests.ts @@ -70,7 +70,7 @@ describe('AgentData Analytics', () => { try { // @ts-expect-error - test - // eslint-disable-next-line prettier/prettier, no-return-await + await agentOverview.callAction('invalid', moment(), moment()); } catch (e) { expect(e).to.be.instanceOf(Error); From a44e004e469d28ab028ba372bca2fcc64b96cce1 Mon Sep 17 00:00:00 2001 From: alchemycodess Date: Thu, 5 Mar 2026 01:30:02 +0530 Subject: [PATCH 4/5] Revert "fix: apply eslint fixes" This reverts commit 4c4ed70f0b562ac9107a645318035d4179f5f234. --- apps/meteor/.scripts/run-ha.ts | 2 +- apps/meteor/app/2fa/server/code/EmailCheck.ts | 4 +-- apps/meteor/app/2fa/server/code/index.ts | 2 +- apps/meteor/app/api/server/ApiClass.ts | 6 ++-- .../app/api/server/helpers/parseJsonQuery.ts | 2 +- .../meteor/app/api/server/lib/isValidQuery.ts | 1 + apps/meteor/app/api/server/v1/calendar.ts | 6 ++-- apps/meteor/app/api/server/v1/channels.ts | 2 +- apps/meteor/app/api/server/v1/chat.ts | 22 +++++++-------- .../meteor/app/api/server/v1/custom-sounds.ts | 2 +- .../app/api/server/v1/custom-user-status.ts | 2 +- apps/meteor/app/api/server/v1/e2e.ts | 1 + apps/meteor/app/api/server/v1/groups.ts | 6 ++-- apps/meteor/app/api/server/v1/im.ts | 2 +- apps/meteor/app/api/server/v1/integrations.ts | 2 +- apps/meteor/app/api/server/v1/roles.ts | 4 +-- apps/meteor/app/api/server/v1/rooms.ts | 13 +++++---- .../meteor/app/api/server/v1/subscriptions.ts | 4 +-- .../app/api/server/v1/videoConference.ts | 2 +- apps/meteor/app/apple/server/loginHandler.ts | 2 +- .../app/apps/server/bridges/activation.ts | 1 + .../app/apps/server/bridges/livechat.ts | 15 +++++----- apps/meteor/app/apps/server/bridges/roles.ts | 2 +- .../app/apps/server/bridges/scheduler.ts | 2 +- .../app/apps/server/converters/threads.ts | 4 +-- .../server/functions/getUsersInRole.ts | 8 ++++-- .../authorization/server/functions/hasRole.ts | 8 ++++-- .../autotranslate/server/googleTranslate.ts | 6 ++-- apps/meteor/app/crowd/server/crowd.ts | 2 +- .../server/methods/createDiscussion.ts | 2 +- apps/meteor/app/emoji/client/emojiParser.ts | 2 +- .../server/lib/RocketChat.ErrorHandler.ts | 1 + .../app/file-upload/server/lib/FileUpload.ts | 13 +++++---- .../classes/converters/RoomConverter.ts | 4 +-- .../meteor/app/integrations/server/api/api.ts | 3 +- .../server/lib/isolated-vm/buildSandbox.ts | 2 +- .../integrations/server/lib/triggerHandler.ts | 7 +++-- .../incoming/updateIncomingIntegration.ts | 1 + .../app/lib/server/functions/createRoom.ts | 1 + .../app/lib/server/functions/deleteMessage.ts | 2 +- .../lib/server/functions/isTheLastMessage.ts | 1 + .../server/functions/saveUser/saveNewUser.ts | 2 +- .../app/lib/server/functions/setEmail.ts | 2 +- .../app/lib/server/functions/setRealName.ts | 2 +- .../app/lib/server/functions/setUsername.ts | 2 +- .../server/functions/updateGroupDMsName.ts | 1 + .../app/lib/server/lib/processDirectEmail.ts | 2 +- .../server/lib/sendNotificationsOnMessage.ts | 2 +- .../app/lib/server/methods/saveSettings.ts | 4 +-- .../meteor/app/lib/server/methods/setEmail.ts | 2 +- .../meteor/app/livechat/server/api/v1/room.ts | 8 +++--- .../app/livechat/server/api/v1/visitor.ts | 2 +- ...ilterBusinessHoursThatMustBeOpened.spec.ts | 4 +-- apps/meteor/app/livechat/server/lib/Helper.ts | 4 +-- .../app/livechat/server/lib/RoutingManager.ts | 4 +-- .../app/livechat/server/lib/closeRoom.ts | 2 +- .../lib/contacts/resolveContactConflicts.ts | 2 +- .../app/livechat/server/lib/departmentsLib.ts | 2 +- .../roomAccessValidator.compatibility.ts | 2 +- .../LivechatAgentActivityMonitor.ts | 4 +-- .../app/message-pin/server/pinMessage.ts | 2 +- .../meteor-accounts-saml/server/lib/SAML.ts | 2 +- .../meteor-accounts-saml/server/lib/Utils.ts | 2 +- .../server/lib/settings.ts | 2 +- .../app/settings/server/SettingsRegistry.ts | 1 + .../server/functions/settings.mocks.ts | 8 +++--- apps/meteor/app/settings/server/startup.ts | 1 + .../app/slackbridge/server/RocketAdapter.ts | 14 +++++----- .../meteor/app/slackbridge/server/SlackAPI.ts | 6 ++-- .../app/slackbridge/server/SlackAdapter.ts | 28 +++++++++---------- .../app/slashcommands-create/server/server.ts | 2 +- .../app/slashcommands-invite/server/server.ts | 2 +- .../app/slashcommands-open/client/client.ts | 2 +- .../server/functions/sendUsageReport.ts | 2 +- .../app/ui-message/client/ActionManager.ts | 2 +- apps/meteor/app/ui/client/lib/UserAction.ts | 2 +- apps/meteor/app/utils/client/getURL.ts | 2 +- apps/meteor/app/utils/lib/getURL.ts | 4 +-- apps/meteor/app/utils/server/getURL.ts | 2 +- .../server/getUserNotificationPreference.ts | 6 +++- apps/meteor/client/apps/orchestrator.ts | 2 +- .../GenericUpsellModal.spec.tsx | 1 + .../Sidebar/SidebarNavigationItem.tsx | 2 +- apps/meteor/client/definitions/global.d.ts | 2 ++ .../hooks/notification/useNotification.ts | 2 +- .../meteor/client/lib/2fa/process2faReturn.ts | 4 +-- apps/meteor/client/lib/chats/data.ts | 8 +++--- .../client/lib/customOAuth/CustomOAuth.ts | 2 +- apps/meteor/client/lib/e2ee/crypto/shared.ts | 4 +-- .../client/lib/e2ee/rocketchat.e2e.room.ts | 6 ++-- apps/meteor/client/lib/getDirtyFields.ts | 2 +- apps/meteor/client/lib/streamer/streamer.ts | 2 +- apps/meteor/client/lib/userData.ts | 1 + apps/meteor/client/lib/userStatuses.ts | 2 +- .../client/lib/utils/getUidDirectMessage.ts | 2 +- .../hooks/useAdministrationMenu.spec.tsx | 2 +- .../AuthenticationProvider.tsx | 2 +- apps/meteor/client/router/index.tsx | 2 +- .../RoomList/SidebarItemTemplateWithData.tsx | 1 + .../ABACAttributesTab/AttributesForm.spec.tsx | 1 + .../views/admin/EditableSettingsContext.ts | 2 +- .../views/admin/customEmoji/CustomEmoji.tsx | 2 +- .../customEmoji/EditCustomEmojiWithData.tsx | 2 +- .../channels/useChannelsList.ts | 1 + .../messages/useMessageOrigins.ts | 1 + .../messages/useMessagesSent.ts | 1 + .../messages/useTopFivePopularChannels.ts | 1 + .../users/useActiveUsers.ts | 1 + .../users/useHourlyChatActivity.ts | 1 + .../users/useUsersByTimeOfTheDay.ts | 1 + .../users/useWeeklyChatActivity.ts | 1 + .../admin/integrations/IntegrationsTable.tsx | 2 +- .../outgoing/OutgoingWebhookForm.tsx | 5 +++- .../views/admin/invites/InvitesPage.tsx | 2 +- .../client/views/audit/hooks/useAuditTab.ts | 2 +- .../EnterE2EPasswordModal.spec.tsx | 1 + .../AppDetailsPage/AppDetailsPage.tsx | 2 +- .../client/views/marketplace/helpers.ts | 2 +- .../views/marketplace/hooks/useAppInfo.ts | 4 +-- .../client/views/modal/uikit/ModalBlock.tsx | 4 +-- .../sidebar/RoomList/SidebarItemWithData.tsx | 1 + .../sidepanel/SidePanelInternal.tsx | 2 +- .../views/omnichannel/components/Tags.tsx | 2 +- .../OutboundMessageWizard.stories.tsx | 1 + .../forms/RecipientForm/RecipientForm.tsx | 4 +-- .../forms/RepliesForm/RepliesForm.spec.tsx | 4 +-- .../steps/MessageStep.spec.tsx | 1 + .../steps/MessageStep.stories.tsx | 1 + .../steps/RecipientStep.spec.tsx | 1 + .../steps/RecipientStep.stories.tsx | 1 + .../steps/RepliesStep.spec.tsx | 1 + .../steps/RepliesStep.stories.tsx | 1 + .../outboundMessage/utils/template.spec.ts | 2 +- .../directory/hooks/useDisplayFilters.ts | 2 +- .../composer/hooks/useComposerBoxPopup.ts | 10 +++---- .../hooks/useComposerBoxPopupQueries.ts | 6 ++-- .../hooks/useMessageComposerIsArchived.ts | 2 +- .../MessageBoxActionsToolbar.tsx | 2 +- .../UserInfo/UserInfoActions.tsx | 1 + .../hooks/useVideoConfOpenCall.tsx | 2 +- .../MainLayout/LayoutWithSidebar.spec.tsx | 2 +- .../views/root/hooks/loggedIn/useUnread.ts | 2 +- .../ChannelDesertionTable.tsx | 5 +++- .../externals/meteor/accounts-base.d.ts | 1 + .../server/api/lib/inquiries.ts | 2 +- .../server/hooks/afterOnHold.ts | 2 +- .../server/lib/LivechatEnterprise.ts | 2 +- .../server/lib/QueueInactivityMonitor.ts | 2 +- .../server/lib/VisitorInactivityMonitor.ts | 2 +- .../server/lib/debounceByParams.ts | 5 +++- apps/meteor/ee/server/api/audit.ts | 8 +++--- .../api/engagementDashboard/channels.ts | 2 +- .../api/engagementDashboard/messages.ts | 2 +- apps/meteor/ee/server/api/sessions.ts | 2 +- .../endpoints/appsCountHandler.ts | 2 +- .../ee/server/apps/communication/uikit.ts | 2 +- apps/meteor/ee/server/configuration/saml.ts | 4 +-- .../lib/engagementDashboard/channels.ts | 2 +- .../lib/engagementDashboard/messages.ts | 2 +- apps/meteor/ee/server/lib/ldap/Manager.ts | 4 +-- .../dataExport/exportRoomMessagesToFile.ts | 4 +-- .../meteor/server/lib/dataExport/sendEmail.ts | 2 +- apps/meteor/server/lib/http/call.ts | 2 +- apps/meteor/server/lib/i18n.ts | 2 +- apps/meteor/server/lib/ldap/Manager.ts | 4 +-- .../server/lib/rooms/roomTypes/private.ts | 2 +- .../server/lib/rooms/roomTypes/public.ts | 2 +- .../server/services/analytics/service.ts | 2 +- apps/meteor/server/services/image/service.ts | 4 +-- .../server/services/meteor/userReactivity.ts | 2 +- .../omnichannel-analytics/AgentData.ts | 10 +++---- .../services/omnichannel-analytics/service.ts | 1 + apps/meteor/server/services/team/service.ts | 10 +++---- apps/meteor/server/startup/migrations/v294.ts | 2 +- apps/meteor/server/startup/migrations/v304.ts | 6 +++- apps/meteor/server/startup/migrations/v307.ts | 2 +- apps/meteor/server/ufs/ufs-server.ts | 1 + apps/meteor/server/ufs/ufs-store.ts | 1 + apps/meteor/tests/data/rooms.helper.ts | 1 + .../e2e-encryption/e2ee-legacy-format.spec.ts | 2 +- apps/meteor/tests/e2e/page-objects/login.ts | 2 +- .../app/license/server/canEnableApp.spec.ts | 1 + .../omnichannel-analytics/AgentData.tests.ts | 2 +- 183 files changed, 325 insertions(+), 251 deletions(-) diff --git a/apps/meteor/.scripts/run-ha.ts b/apps/meteor/.scripts/run-ha.ts index 2b53a960d7c06..a1a3775000690 100644 --- a/apps/meteor/.scripts/run-ha.ts +++ b/apps/meteor/.scripts/run-ha.ts @@ -56,7 +56,7 @@ async function runMain(config: IConfig): Promise { async function runInstance(config: IConfig): Promise { // Desctructuring the unused variables allows us to omit them in the `mainConfig` - + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { customEnv, parentEnv, ...mainConfig } = config; const env = { diff --git a/apps/meteor/app/2fa/server/code/EmailCheck.ts b/apps/meteor/app/2fa/server/code/EmailCheck.ts index 4f98e2c5abef8..8c9865c0b0042 100644 --- a/apps/meteor/app/2fa/server/code/EmailCheck.ts +++ b/apps/meteor/app/2fa/server/code/EmailCheck.ts @@ -101,7 +101,7 @@ ${t('If_you_didnt_try_to_login_in_your_account_please_ignore_this_email')} const random = Random._randomString(6, '0123456789'); const encryptedRandom = await bcrypt.hash(random, Accounts._bcryptRounds()); const expire = new Date(); - const expirationInSeconds = parseInt(settings.get('Accounts_TwoFactorAuthentication_By_Email_Code_Expiration'), 10); + const expirationInSeconds = parseInt(settings.get('Accounts_TwoFactorAuthentication_By_Email_Code_Expiration') as string, 10); expire.setSeconds(expire.getSeconds() + expirationInSeconds); @@ -145,6 +145,6 @@ ${t('If_you_didnt_try_to_login_in_your_account_please_ignore_this_email')} public async maxFaildedAttemtpsReached(user: IUser) { const maxAttempts = settings.get('Accounts_TwoFactorAuthentication_Max_Invalid_Email_Code_Attempts'); - return await Users.maxInvalidEmailCodeAttemptsReached(user._id, maxAttempts); + return (await Users.maxInvalidEmailCodeAttemptsReached(user._id, maxAttempts)) as boolean; } } diff --git a/apps/meteor/app/2fa/server/code/index.ts b/apps/meteor/app/2fa/server/code/index.ts index 1a3050e480834..cfe7b8ab7d4d4 100644 --- a/apps/meteor/app/2fa/server/code/index.ts +++ b/apps/meteor/app/2fa/server/code/index.ts @@ -64,7 +64,7 @@ function getFingerprintFromConnection(connection: IMethodConnection): string { } function getRememberDate(from: Date = new Date()): Date | undefined { - const rememberFor = parseInt(settings.get('Accounts_TwoFactorAuthentication_RememberFor'), 10); + const rememberFor = parseInt(settings.get('Accounts_TwoFactorAuthentication_RememberFor') as string, 10); if (rememberFor <= 0) { return; diff --git a/apps/meteor/app/api/server/ApiClass.ts b/apps/meteor/app/api/server/ApiClass.ts index 7ed7e2fe6b282..8d44fb85941ad 100644 --- a/apps/meteor/app/api/server/ApiClass.ts +++ b/apps/meteor/app/api/server/ApiClass.ts @@ -276,7 +276,7 @@ export class APIClass; - return finalResult; + return finalResult as SuccessResult; } public redirect(code: C, result: T): RedirectResult { @@ -799,7 +799,7 @@ export class APIClass; if (typeof operations[method as keyof Operations] === 'function') { - (operations as Record)[method] = { + (operations as Record)[method as string] = { action: operations[method as keyof Operations], }; } else { @@ -953,7 +953,7 @@ export class APIClass] as Record).action, + (operations[method as keyof Operations] as Record).action as any, ); this._routes.push({ path: route, diff --git a/apps/meteor/app/api/server/helpers/parseJsonQuery.ts b/apps/meteor/app/api/server/helpers/parseJsonQuery.ts index 33b51cbfb1d4a..fafaebcf59c94 100644 --- a/apps/meteor/app/api/server/helpers/parseJsonQuery.ts +++ b/apps/meteor/app/api/server/helpers/parseJsonQuery.ts @@ -94,7 +94,7 @@ export async function parseJsonQuery(api: GenericRouteExecutionContext): Promise Object.keys(fields).forEach((k) => { if (nonSelectableFields.includes(k) || nonSelectableFields.includes(k.split(API.v1.fieldSeparator)[0])) { - fields && delete fields[k]; + fields && delete fields[k as keyof typeof fields]; } }); } diff --git a/apps/meteor/app/api/server/lib/isValidQuery.ts b/apps/meteor/app/api/server/lib/isValidQuery.ts index 912c14c7ae595..ef8a0716505cb 100644 --- a/apps/meteor/app/api/server/lib/isValidQuery.ts +++ b/apps/meteor/app/api/server/lib/isValidQuery.ts @@ -15,6 +15,7 @@ export const isValidQuery: { throw new Error('query must be an object'); } + // eslint-disable-next-line @typescript-eslint/no-use-before-define return verifyQuery(query, allowedAttributes, allowedOperations); }, { diff --git a/apps/meteor/app/api/server/v1/calendar.ts b/apps/meteor/app/api/server/v1/calendar.ts index 4318037fbd379..5eff639a80f5e 100644 --- a/apps/meteor/app/api/server/v1/calendar.ts +++ b/apps/meteor/app/api/server/v1/calendar.ts @@ -35,7 +35,7 @@ API.v1.addRoute( const event = await Calendar.get(id); - if (event?.uid !== userId) { + if (!event || event.uid !== userId) { return API.v1.failure(); } @@ -104,7 +104,7 @@ API.v1.addRoute( const event = await Calendar.get(eventId); - if (event?.uid !== userId) { + if (!event || event.uid !== userId) { throw new Error('invalid-calendar-event'); } @@ -133,7 +133,7 @@ API.v1.addRoute( const event = await Calendar.get(eventId); - if (event?.uid !== userId) { + if (!event || event.uid !== userId) { throw new Error('invalid-calendar-event'); } diff --git a/apps/meteor/app/api/server/v1/channels.ts b/apps/meteor/app/api/server/v1/channels.ts index c141d02747912..5dfdc22c237ee 100644 --- a/apps/meteor/app/api/server/v1/channels.ts +++ b/apps/meteor/app/api/server/v1/channels.ts @@ -309,7 +309,7 @@ API.v1.addRoute( rid: findResult._id, ...parseIds(mentionIds, 'mentions._id'), ...parseIds(starredIds, 'starred._id'), - ...(pinned?.toLowerCase() === 'true' ? { pinned: true } : {}), + ...(pinned && pinned.toLowerCase() === 'true' ? { pinned: true } : {}), _hidden: { $ne: true }, }; diff --git a/apps/meteor/app/api/server/v1/chat.ts b/apps/meteor/app/api/server/v1/chat.ts index 1aae3fe767a29..50fc5165f7387 100644 --- a/apps/meteor/app/api/server/v1/chat.ts +++ b/apps/meteor/app/api/server/v1/chat.ts @@ -410,17 +410,17 @@ const chatEndpoints = API.v1 this.userId, hasContent ? { - _id: msg._id, - rid: msg.rid, - content: bodyParams.content, - ...(bodyParams.e2eMentions && { e2eMentions: bodyParams.e2eMentions }), - } + _id: msg._id, + rid: msg.rid, + content: bodyParams.content, + ...(bodyParams.e2eMentions && { e2eMentions: bodyParams.e2eMentions }), + } : { - _id: msg._id, - rid: msg.rid, - msg: bodyParams.text, - ...(bodyParams.customFields && { customFields: bodyParams.customFields }), - }, + _id: msg._id, + rid: msg.rid, + msg: bodyParams.text, + ...(bodyParams.customFields && { customFields: bodyParams.customFields }), + }, 'previewUrls' in bodyParams ? bodyParams.previewUrls : undefined, ]; @@ -1072,5 +1072,5 @@ export type ChatEndpoints = ExtractRoutesFromAPI; declare module '@rocket.chat/rest-typings' { // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface - interface Endpoints extends ChatEndpoints {} + interface Endpoints extends ChatEndpoints { } } diff --git a/apps/meteor/app/api/server/v1/custom-sounds.ts b/apps/meteor/app/api/server/v1/custom-sounds.ts index 1fb4e384d1b22..a2fa2b675f07f 100644 --- a/apps/meteor/app/api/server/v1/custom-sounds.ts +++ b/apps/meteor/app/api/server/v1/custom-sounds.ts @@ -100,7 +100,7 @@ const customSoundsEndpoints = API.v1 const filter = { ...query, - ...(name ? { name: { $regex: escapeRegExp(name), $options: 'i' } } : {}), + ...(name ? { name: { $regex: escapeRegExp(name as string), $options: 'i' } } : {}), }; const { cursor, totalCount } = CustomSounds.findPaginated(filter, { diff --git a/apps/meteor/app/api/server/v1/custom-user-status.ts b/apps/meteor/app/api/server/v1/custom-user-status.ts index 1e9b2f2210bb7..4d4297cfe001c 100644 --- a/apps/meteor/app/api/server/v1/custom-user-status.ts +++ b/apps/meteor/app/api/server/v1/custom-user-status.ts @@ -100,7 +100,7 @@ const customUserStatusEndpoints = API.v1.get( const filter = { ...query, - ...(name ? { name: { $regex: escapeRegExp(name), $options: 'i' } } : {}), + ...(name ? { name: { $regex: escapeRegExp(name as string), $options: 'i' } } : {}), ...(_id ? { _id } : {}), }; diff --git a/apps/meteor/app/api/server/v1/e2e.ts b/apps/meteor/app/api/server/v1/e2e.ts index 827006f68c9d0..aba7e3a0db952 100644 --- a/apps/meteor/app/api/server/v1/e2e.ts +++ b/apps/meteor/app/api/server/v1/e2e.ts @@ -510,6 +510,7 @@ API.v1.addRoute( }, { async post() { + // eslint-disable-next-line @typescript-eslint/naming-convention const { public_key, private_key, force } = this.bodyParams; await setUserPublicAndPrivateKeysMethod(this.userId, { diff --git a/apps/meteor/app/api/server/v1/groups.ts b/apps/meteor/app/api/server/v1/groups.ts index 93f6210c981ac..2437813860836 100644 --- a/apps/meteor/app/api/server/v1/groups.ts +++ b/apps/meteor/app/api/server/v1/groups.ts @@ -67,7 +67,7 @@ async function getRoomFromParams(params: { roomId?: string } | { roomName?: stri } })(); - if (room?.t !== 'p') { + if (!room || room.t !== 'p') { throw new Meteor.Error('error-room-not-found', 'The required "roomId" or "roomName" param provided does not match any group'); } @@ -273,7 +273,7 @@ API.v1.addRoute( room = await Rooms.findOneByName(params.roomName || ''); } - if (room?.t !== 'p') { + if (!room || room.t !== 'p') { throw new Meteor.Error('error-room-not-found', 'The required "roomId" or "roomName" param provided does not match any group'); } @@ -791,7 +791,7 @@ API.v1.addRoute( rid: findResult.rid, ...parseIds(mentionIds, 'mentions._id'), ...parseIds(starredIds, 'starred._id'), - ...(pinned?.toLowerCase() === 'true' ? { pinned: true } : {}), + ...(pinned && pinned.toLowerCase() === 'true' ? { pinned: true } : {}), _hidden: { $ne: true }, }; diff --git a/apps/meteor/app/api/server/v1/im.ts b/apps/meteor/app/api/server/v1/im.ts index 55d6c4c2a5eb1..f97bd6e7e9161 100644 --- a/apps/meteor/app/api/server/v1/im.ts +++ b/apps/meteor/app/api/server/v1/im.ts @@ -510,7 +510,7 @@ API.v1.addRoute( ...query, ...parseIds(mentionIds, 'mentions._id'), ...parseIds(starredIds, 'starred._id'), - ...(pinned?.toLowerCase() === 'true' ? { pinned: true } : {}), + ...(pinned && pinned.toLowerCase() === 'true' ? { pinned: true } : {}), _hidden: { $ne: true }, }; const sortObj = sort || { ts: -1 }; diff --git a/apps/meteor/app/api/server/v1/integrations.ts b/apps/meteor/app/api/server/v1/integrations.ts index 6457666882729..78d77fe007f39 100644 --- a/apps/meteor/app/api/server/v1/integrations.ts +++ b/apps/meteor/app/api/server/v1/integrations.ts @@ -110,7 +110,7 @@ API.v1.addRoute( const filter = { ...query, - ...(name ? { name: { $regex: escapeRegExp(name), $options: 'i' } } : {}), + ...(name ? { name: { $regex: escapeRegExp(name as string), $options: 'i' } } : {}), ...(type ? { type } : {}), }; diff --git a/apps/meteor/app/api/server/v1/roles.ts b/apps/meteor/app/api/server/v1/roles.ts index 931ab7d3cba4a..8985e48c0aff5 100644 --- a/apps/meteor/app/api/server/v1/roles.ts +++ b/apps/meteor/app/api/server/v1/roles.ts @@ -119,9 +119,9 @@ API.v1.addRoute( } const { cursor, totalCount } = await getUsersInRolePaginated(roleData._id, roomId, { - limit: count, + limit: count as number, sort: { username: 1 }, - skip: offset, + skip: offset as number, projection, }); diff --git a/apps/meteor/app/api/server/v1/rooms.ts b/apps/meteor/app/api/server/v1/rooms.ts index 08bb8f9979bb5..930e9cd8168cb 100644 --- a/apps/meteor/app/api/server/v1/rooms.ts +++ b/apps/meteor/app/api/server/v1/rooms.ts @@ -322,7 +322,7 @@ API.v1.addRoute( } await Promise.all( - Object.entries(notifications).map(async ([notificationKey, notificationValue]) => + Object.entries(notifications as Notifications).map(async ([notificationKey, notificationValue]) => saveNotificationSettingsMethod(this.userId, roomId, notificationKey as NotificationFieldType, notificationValue), ), ); @@ -421,6 +421,7 @@ API.v1.addRoute( { authRequired: true /* , validateParams: isRoomsCreateDiscussionProps */ }, { async post() { + // eslint-disable-next-line @typescript-eslint/naming-convention const { prid, pmid, reply, t_name, users, encrypted, topic } = this.bodyParams; if (!prid) { return API.v1.failure('Body parameter "prid" is required.'); @@ -515,7 +516,7 @@ API.v1.addRoute( const [files, total] = await Promise.all([cursor.toArray(), totalCount]); // If the initial image was not returned in the query, insert it as the first element of the list - if (initialImage && !files.find(({ _id }) => _id === initialImage._id)) { + if (initialImage && !files.find(({ _id }) => _id === (initialImage as IUpload)._id)) { files.splice(0, 0, initialImage); } @@ -732,7 +733,7 @@ API.v1.addRoute( void dataExport.sendFile( { rid, - format, + format: format as 'html' | 'json', dateFrom: convertedDateFrom, dateTo: convertedDateTo, }, @@ -780,7 +781,7 @@ API.v1.addRoute( const [room, user] = await Promise.all([ findRoomByIdOrName({ params: { roomId }, - }), + }) as Promise, Users.findOneByIdOrUsername(userId || username), ]); @@ -1210,7 +1211,9 @@ export const roomEndpoints = API.v1 }, ); -type RoomEndpoints = ExtractRoutesFromAPI & ExtractRoutesFromAPI; +type RoomEndpoints = ExtractRoutesFromAPI & + ExtractRoutesFromAPI & + ExtractRoutesFromAPI; declare module '@rocket.chat/rest-typings' { // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface diff --git a/apps/meteor/app/api/server/v1/subscriptions.ts b/apps/meteor/app/api/server/v1/subscriptions.ts index b36fa4f4aff40..b6e406bbfc969 100644 --- a/apps/meteor/app/api/server/v1/subscriptions.ts +++ b/apps/meteor/app/api/server/v1/subscriptions.ts @@ -24,10 +24,10 @@ API.v1.addRoute( let updatedSinceDate: Date | undefined; if (updatedSince) { - if (isNaN(Date.parse(updatedSince))) { + if (isNaN(Date.parse(updatedSince as string))) { throw new Meteor.Error('error-roomId-param-invalid', 'The "lastUpdate" query parameter must be a valid date.'); } - updatedSinceDate = new Date(updatedSince); + updatedSinceDate = new Date(updatedSince as string); } const result = await getSubscriptions(this.userId, updatedSinceDate); diff --git a/apps/meteor/app/api/server/v1/videoConference.ts b/apps/meteor/app/api/server/v1/videoConference.ts index 16226d149e8c9..5036eed09cc2d 100644 --- a/apps/meteor/app/api/server/v1/videoConference.ts +++ b/apps/meteor/app/api/server/v1/videoConference.ts @@ -29,7 +29,7 @@ API.v1.addRoute( } try { - await canSendMessageAsync(roomId, { uid: userId, username: this.user.username!, type: this.user.type }); + await canSendMessageAsync(roomId, { uid: userId, username: this.user.username!, type: this.user.type! }); } catch (error) { return API.v1.forbidden(); } diff --git a/apps/meteor/app/apple/server/loginHandler.ts b/apps/meteor/app/apple/server/loginHandler.ts index c9b335fcba5de..18ac7ddd75268 100644 --- a/apps/meteor/app/apple/server/loginHandler.ts +++ b/apps/meteor/app/apple/server/loginHandler.ts @@ -32,7 +32,7 @@ Accounts.registerLoginHandler('apple', async (loginRequest) => { const result = Accounts.updateOrCreateUserFromExternalService('apple', serviceData, { profile }); // Ensure processing succeeded - if (result?.userId === undefined) { + if (result === undefined || result.userId === undefined) { return { type: 'apple', error: new Meteor.Error(Accounts.LoginCancelledError.numericError, 'User creation failed from Apple response token'), diff --git a/apps/meteor/app/apps/server/bridges/activation.ts b/apps/meteor/app/apps/server/bridges/activation.ts index 13feb717663d1..399dfd285e65e 100644 --- a/apps/meteor/app/apps/server/bridges/activation.ts +++ b/apps/meteor/app/apps/server/bridges/activation.ts @@ -5,6 +5,7 @@ import { UserStatus } from '@rocket.chat/core-typings'; import { Users } from '@rocket.chat/models'; export class AppActivationBridge extends ActivationBridge { + // eslint-disable-next-line no-empty-function constructor(private readonly orch: IAppServerOrchestrator) { super(); } diff --git a/apps/meteor/app/apps/server/bridges/livechat.ts b/apps/meteor/app/apps/server/bridges/livechat.ts index 05b61f2bf9ab9..6952ac6f5457c 100644 --- a/apps/meteor/app/apps/server/bridges/livechat.ts +++ b/apps/meteor/app/apps/server/bridges/livechat.ts @@ -57,7 +57,7 @@ export class AppLivechatBridge extends LivechatBridge { // #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed. const guest = this.orch.getConverters().get('visitors').convertAppVisitor(message.visitor); - const appMessage = await this.orch.getConverters().get('messages').convertAppMessage(message); + const appMessage = (await this.orch.getConverters().get('messages').convertAppMessage(message)) as IMessage | undefined; const livechatMessage = appMessage as ILivechatMessage | undefined; const msg = await sendMessage({ @@ -121,12 +121,13 @@ export class AppLivechatBridge extends LivechatBridge { type: OmnichannelSourceType.APP, id: appId, alias: this.orch.getManager()?.getOneById(appId)?.getName(), - ...(source?.type === 'app' && { - sidebarIcon: source.sidebarIcon, - defaultIcon: source.defaultIcon, - label: source.label, - destination: source.destination, - }), + ...(source && + source.type === 'app' && { + sidebarIcon: source.sidebarIcon, + defaultIcon: source.defaultIcon, + label: source.label, + destination: source.destination, + }), }, }, agent: agentRoom, diff --git a/apps/meteor/app/apps/server/bridges/roles.ts b/apps/meteor/app/apps/server/bridges/roles.ts index 25dadf8471213..aa0fcdc7b80b7 100644 --- a/apps/meteor/app/apps/server/bridges/roles.ts +++ b/apps/meteor/app/apps/server/bridges/roles.ts @@ -8,7 +8,7 @@ export class AppRoleBridge extends RoleBridge { super(); } - protected async getOneByIdOrName(idOrName: IAppsRole['id'], appId: string): Promise { + protected async getOneByIdOrName(idOrName: IAppsRole['id'] | IAppsRole['name'], appId: string): Promise { this.orch.debugLog(`The App ${appId} is getting the roleByIdOrName: "${idOrName}"`); // #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed. diff --git a/apps/meteor/app/apps/server/bridges/scheduler.ts b/apps/meteor/app/apps/server/bridges/scheduler.ts index 088f0e49e1604..b08d49182c9bc 100644 --- a/apps/meteor/app/apps/server/bridges/scheduler.ts +++ b/apps/meteor/app/apps/server/bridges/scheduler.ts @@ -90,7 +90,7 @@ export class AppSchedulerBridge extends SchedulerBridge { }); if (runAfterRegister.length) { - return Promise.all(runAfterRegister); + return Promise.all(runAfterRegister) as Promise>; } } diff --git a/apps/meteor/app/apps/server/converters/threads.ts b/apps/meteor/app/apps/server/converters/threads.ts index 72f794763c07b..376488f3ec3ca 100644 --- a/apps/meteor/app/apps/server/converters/threads.ts +++ b/apps/meteor/app/apps/server/converters/threads.ts @@ -51,7 +51,7 @@ export class AppThreadsConverter implements IAppThreadsConverter { const replies = await Messages.find(query).toArray(); - const room = await this.orch.getConverters().get('rooms').convertById(mainMessage.rid); + const room = (await this.orch.getConverters().get('rooms').convertById(mainMessage.rid)) as IRoom | undefined; if (!room) { return []; @@ -120,7 +120,7 @@ export class AppThreadsConverter implements IAppThreadsConverter { user = await convertToApp(message.u as unknown as IUser); } - return user; + return user as IAppsUser; }, files: async (message: IMessage) => convertMessageFiles(message.files, attachments), } as const; diff --git a/apps/meteor/app/authorization/server/functions/getUsersInRole.ts b/apps/meteor/app/authorization/server/functions/getUsersInRole.ts index d4cb49abfa349..3b3af203221a6 100644 --- a/apps/meteor/app/authorization/server/functions/getUsersInRole.ts +++ b/apps/meteor/app/authorization/server/functions/getUsersInRole.ts @@ -14,7 +14,11 @@ export function getUsersInRole

( options: FindOptions

, ): Promise>; -export function getUsersInRole

(roleId: IRole['_id'], scope: string | undefined, options?: any): Promise> { +export function getUsersInRole

( + roleId: IRole['_id'], + scope: string | undefined, + options?: any | undefined, +): Promise> { // TODO move the code from Roles.findUsersInRole to here and change all places to use this function return Roles.findUsersInRole(roleId, scope, options); } @@ -22,7 +26,7 @@ export function getUsersInRole

(roleId: IRole['_id'], scope: string | export async function getUsersInRolePaginated( roleId: IRole['_id'], scope: string | undefined, - options?: any, + options?: any | undefined, ): Promise>> { if (process.env.NODE_ENV === 'development' && (scope === 'Users' || scope === 'Subscriptions')) { throw new Error('Roles.findUsersInRole method received a role scope instead of a scope value.'); diff --git a/apps/meteor/app/authorization/server/functions/hasRole.ts b/apps/meteor/app/authorization/server/functions/hasRole.ts index 6326d76800802..00f781725c55c 100644 --- a/apps/meteor/app/authorization/server/functions/hasRole.ts +++ b/apps/meteor/app/authorization/server/functions/hasRole.ts @@ -4,7 +4,11 @@ import { Roles } from '@rocket.chat/models'; /** * @deprecated use `Authorization.hasAnyRole` instead */ -export const hasAnyRoleAsync = async (userId: IUser['_id'], roleIds: IRole['_id'][], scope?: IRoom['_id']): Promise => { +export const hasAnyRoleAsync = async ( + userId: IUser['_id'], + roleIds: IRole['_id'][], + scope?: IRoom['_id'] | undefined, +): Promise => { if (!Array.isArray(roleIds)) { throw new Error('error-invalid-arguments'); } @@ -16,7 +20,7 @@ export const hasAnyRoleAsync = async (userId: IUser['_id'], roleIds: IRole['_id' return Roles.isUserInRoles(userId, roleIds, scope); }; -export const hasRoleAsync = async (userId: IUser['_id'], roleId: IRole['_id'], scope?: IRoom['_id']): Promise => { +export const hasRoleAsync = async (userId: IUser['_id'], roleId: IRole['_id'], scope?: IRoom['_id'] | undefined): Promise => { if (Array.isArray(roleId)) { throw new Error('error-invalid-arguments'); } diff --git a/apps/meteor/app/autotranslate/server/googleTranslate.ts b/apps/meteor/app/autotranslate/server/googleTranslate.ts index ae73abce93d16..4ffa557406154 100644 --- a/apps/meteor/app/autotranslate/server/googleTranslate.ts +++ b/apps/meteor/app/autotranslate/server/googleTranslate.ts @@ -157,7 +157,8 @@ class GoogleAutoTranslate extends AutoTranslate { if ( result.status === 200 && - body.data?.translations && + body.data && + body.data.translations && Array.isArray(body.data.translations) && body.data.translations.length > 0 ) { @@ -205,7 +206,8 @@ class GoogleAutoTranslate extends AutoTranslate { if ( result.status === 200 && - body.data?.translations && + body.data && + body.data.translations && Array.isArray(body.data.translations) && body.data.translations.length > 0 ) { diff --git a/apps/meteor/app/crowd/server/crowd.ts b/apps/meteor/app/crowd/server/crowd.ts index 0fd045caa4f3b..54cefce69ad48 100644 --- a/apps/meteor/app/crowd/server/crowd.ts +++ b/apps/meteor/app/crowd/server/crowd.ts @@ -378,7 +378,7 @@ Accounts.registerLoginHandler('crowd', async function (this: typeof Accounts, lo const crowd = new CROWD(); const user = await crowd.authenticate(loginRequest.username, loginRequest.crowdPassword); - if (user?.crowd === false) { + if (user && user.crowd === false) { logger.debug({ msg: 'User is not a valid crowd user, falling back', username: loginRequest.username }); return fallbackDefaultAccountSystem(this, loginRequest.username, loginRequest.crowdPassword); } diff --git a/apps/meteor/app/discussion/server/methods/createDiscussion.ts b/apps/meteor/app/discussion/server/methods/createDiscussion.ts index 36712024b63a2..65804410c405a 100644 --- a/apps/meteor/app/discussion/server/methods/createDiscussion.ts +++ b/apps/meteor/app/discussion/server/methods/createDiscussion.ts @@ -85,7 +85,7 @@ const create = async ({ } if (prid) { const parentRoom = await getParentRoom(message.rid); - if (prid !== parentRoom?._id) { + if (!parentRoom || prid !== parentRoom._id) { throw new Meteor.Error('error-invalid-arguments', 'Root message room ID does not match parent room ID ', { method: 'DiscussionCreation', }); diff --git a/apps/meteor/app/emoji/client/emojiParser.ts b/apps/meteor/app/emoji/client/emojiParser.ts index e7455b8416a1d..c919642d28345 100644 --- a/apps/meteor/app/emoji/client/emojiParser.ts +++ b/apps/meteor/app/emoji/client/emojiParser.ts @@ -26,7 +26,7 @@ export const emojiParser = (html: string) => { emojis.forEach((emojiElement) => { const htmlElement = emojiElement.parentElement; - if (htmlElement?.nodeName === 'CODE') { + if (htmlElement && htmlElement.nodeName === 'CODE') { emojiElement.replaceWith(emojiElement.getAttribute('title') ?? ''); } }); diff --git a/apps/meteor/app/error-handler/server/lib/RocketChat.ErrorHandler.ts b/apps/meteor/app/error-handler/server/lib/RocketChat.ErrorHandler.ts index de20cc8f43aed..68300cb24e59c 100644 --- a/apps/meteor/app/error-handler/server/lib/RocketChat.ErrorHandler.ts +++ b/apps/meteor/app/error-handler/server/lib/RocketChat.ErrorHandler.ts @@ -68,6 +68,7 @@ Meteor.startup(async () => { }); }); +// eslint-disable-next-line @typescript-eslint/no-this-alias const originalMeteorDebug = Meteor._debug; Meteor._debug = function (message, stack, ...args) { diff --git a/apps/meteor/app/file-upload/server/lib/FileUpload.ts b/apps/meteor/app/file-upload/server/lib/FileUpload.ts index 3cddf565aebaf..89878e783a413 100644 --- a/apps/meteor/app/file-upload/server/lib/FileUpload.ts +++ b/apps/meteor/app/file-upload/server/lib/FileUpload.ts @@ -238,8 +238,8 @@ export const FileUpload = { const tempFilePath = UploadFS.getTempFilePath(file._id); - const height = settings.get('Accounts_AvatarSize'); - const width = height; + const height = settings.get('Accounts_AvatarSize') as number; + const width = height as number; const s = sharp(tempFilePath); if (settings.get('FileUpload_RotateImages') === true) { @@ -307,8 +307,8 @@ export const FileUpload = { return; } - const width = settings.get('Message_Attachments_Thumbnails_Width'); - const height = settings.get('Message_Attachments_Thumbnails_Height'); + const width = settings.get('Message_Attachments_Thumbnails_Width') as number; + const height = settings.get('Message_Attachments_Thumbnails_Height') as number; if (fileParam.identify?.size && fileParam.identify.size.height < height && fileParam.identify?.size.width < width) { return; @@ -334,7 +334,7 @@ export const FileUpload = { height, thumbFileType: (mime.lookup(format) as string) || '', thumbFileName: file?.name as string, - originalFileId: file?._id, + originalFileId: file?._id as string, })); image.pipe(transformer); @@ -454,7 +454,7 @@ export const FileUpload = { } const { query } = URL.parse(url, true); - + // eslint-disable-next-line @typescript-eslint/naming-convention let { rc_uid, rc_token, rc_rid, rc_room_type } = query as Record; const { token } = query; @@ -671,6 +671,7 @@ export const FileUpload = { return; } + // eslint-disable-next-line prettier/prettier const headersToProxy = ['age', 'cache-control', 'content-length', 'content-type', 'date', 'expired', 'last-modified']; headersToProxy.forEach((header) => { diff --git a/apps/meteor/app/importer/server/classes/converters/RoomConverter.ts b/apps/meteor/app/importer/server/classes/converters/RoomConverter.ts index 3db5e4a21b56b..97ed061ec8377 100644 --- a/apps/meteor/app/importer/server/classes/converters/RoomConverter.ts +++ b/apps/meteor/app/importer/server/classes/converters/RoomConverter.ts @@ -53,7 +53,7 @@ export class RoomConverter extends RecordConverter { } async findExistingRoom(data: IImportChannel): Promise { - if (data._id?.toUpperCase() === 'GENERAL') { + if (data._id && data._id.toUpperCase() === 'GENERAL') { const room = await Rooms.findOneById('GENERAL', {}); // Prevent the importer from trying to create a new general if (!room) { @@ -84,7 +84,7 @@ export class RoomConverter extends RecordConverter { async updateRoom(room: IRoom, roomData: IImportChannel, startedByUserId: string): Promise { roomData._id = room._id; - if (roomData._id.toUpperCase() === 'GENERAL' && roomData.name !== room.name) { + if ((roomData._id as string).toUpperCase() === 'GENERAL' && roomData.name !== room.name) { await saveRoomSettings(startedByUserId, 'GENERAL', 'roomName', roomData.name); } diff --git a/apps/meteor/app/integrations/server/api/api.ts b/apps/meteor/app/integrations/server/api/api.ts index 8759079cb9d9e..511b22f3f97d0 100644 --- a/apps/meteor/app/integrations/server/api/api.ts +++ b/apps/meteor/app/integrations/server/api/api.ts @@ -27,6 +27,7 @@ import { deleteOutgoingIntegration } from '../methods/outgoing/deleteOutgoingInt const ivmEngine = new IsolatedVMScriptEngine(true); +// eslint-disable-next-line no-unused-vars function getEngine(_integration: IIntegration): IsolatedVMScriptEngine { return ivmEngine; } @@ -58,7 +59,7 @@ async function createIntegration(options: IntegrationOptions, user: IUser): Prom if (options.data == null) { options.data = {}; } - if (options.data.channel_name?.indexOf('#') === -1) { + if (options.data.channel_name != null && options.data.channel_name.indexOf('#') === -1) { options.data.channel_name = `#${options.data.channel_name}`; } return addOutgoingIntegration(user._id, { diff --git a/apps/meteor/app/integrations/server/lib/isolated-vm/buildSandbox.ts b/apps/meteor/app/integrations/server/lib/isolated-vm/buildSandbox.ts index 3c57740fc7bd7..1bbefb6a2ee7a 100644 --- a/apps/meteor/app/integrations/server/lib/isolated-vm/buildSandbox.ts +++ b/apps/meteor/app/integrations/server/lib/isolated-vm/buildSandbox.ts @@ -17,7 +17,7 @@ const proxyObject = (obj: Record, forbiddenKeys: string[] = []): Re if (typeof value === 'function') { return new ivm.Reference(async (...args: any[]) => { - const result = obj[key](...args); + const result = (obj[key] as any)(...args); if (result && result instanceof Promise) { return new Promise(async (resolve, reject) => { diff --git a/apps/meteor/app/integrations/server/lib/triggerHandler.ts b/apps/meteor/app/integrations/server/lib/triggerHandler.ts index 7ed8811b7193e..135c88bdde228 100644 --- a/apps/meteor/app/integrations/server/lib/triggerHandler.ts +++ b/apps/meteor/app/integrations/server/lib/triggerHandler.ts @@ -92,6 +92,7 @@ class RocketChatIntegrationHandler { } } + // eslint-disable-next-line no-unused-vars getEngine(_integration: any): IsolatedVMScriptEngine { return this.ivmEngine; } @@ -796,11 +797,11 @@ class RocketChatIntegrationHandler { } async replay(integration: IOutgoingIntegration, history: IIntegrationHistory) { - if (integration?.type !== 'webhook-outgoing') { + if (!integration || integration.type !== 'webhook-outgoing') { throw new Meteor.Error('integration-type-must-be-outgoing', 'The integration type to replay must be an outgoing webhook.'); } - if (!history?.data) { + if (!history || !history.data) { throw new Meteor.Error('history-data-must-be-defined', 'The history data must be defined to replay an integration.'); } @@ -810,7 +811,7 @@ class RocketChatIntegrationHandler { let room; let user; - if (history.data.owner?._id) { + if (history.data.owner && history.data.owner._id) { owner = await Users.findOneById(history.data.owner._id); } if (history.data.message_id) { diff --git a/apps/meteor/app/integrations/server/methods/incoming/updateIncomingIntegration.ts b/apps/meteor/app/integrations/server/methods/incoming/updateIncomingIntegration.ts index be370184e1bab..774d7a0d597a0 100644 --- a/apps/meteor/app/integrations/server/methods/incoming/updateIncomingIntegration.ts +++ b/apps/meteor/app/integrations/server/methods/incoming/updateIncomingIntegration.ts @@ -206,6 +206,7 @@ export const updateIncomingIntegration = async ( }; Meteor.methods({ + // eslint-disable-next-line complexity async updateIncomingIntegration(integrationId, integration) { if (!this.userId) { throw new Meteor.Error('error-invalid-user', 'Invalid user', { diff --git a/apps/meteor/app/lib/server/functions/createRoom.ts b/apps/meteor/app/lib/server/functions/createRoom.ts index 1297af8839f6e..a9cd1330d6148 100644 --- a/apps/meteor/app/lib/server/functions/createRoom.ts +++ b/apps/meteor/app/lib/server/functions/createRoom.ts @@ -139,6 +139,7 @@ async function createUsersSubscriptions({ await Rooms.incUsersCountById(room._id, subs.length); } +// eslint-disable-next-line complexity export const createRoom = async ( type: T, name: T extends 'd' ? undefined : string, diff --git a/apps/meteor/app/lib/server/functions/deleteMessage.ts b/apps/meteor/app/lib/server/functions/deleteMessage.ts index 65193c59c4753..f00e7edb98e7b 100644 --- a/apps/meteor/app/lib/server/functions/deleteMessage.ts +++ b/apps/meteor/app/lib/server/functions/deleteMessage.ts @@ -120,7 +120,7 @@ async function deleteThreadMessage(message: IThreadMessage, user: IUser, room: I } } - if (updatedParentMessage?.tcount === 0) { + if (updatedParentMessage && updatedParentMessage.tcount === 0) { void notifyOnMessageChange({ id: message.tmid, }); diff --git a/apps/meteor/app/lib/server/functions/isTheLastMessage.ts b/apps/meteor/app/lib/server/functions/isTheLastMessage.ts index 1680cfc13a6fa..f1f1fb4c1497d 100644 --- a/apps/meteor/app/lib/server/functions/isTheLastMessage.ts +++ b/apps/meteor/app/lib/server/functions/isTheLastMessage.ts @@ -2,5 +2,6 @@ import type { IMessage, IRoom, AtLeast } from '@rocket.chat/core-typings'; import { settings } from '../../../settings/server'; +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const isTheLastMessage = (room: AtLeast, message: Pick) => settings.get('Store_Last_Message') && (!room.lastMessage || room.lastMessage._id === message._id); diff --git a/apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts b/apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts index 1a72ffffc741b..35fb39b5336f6 100644 --- a/apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts +++ b/apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts @@ -16,7 +16,7 @@ export const saveNewUser = async function (userData: SaveUserData, sendPassword: await validateEmailDomain(userData.email); const roles = (!!userData.roles && userData.roles.length > 0 && userData.roles) || getNewUserRoles(); - const isGuest = roles?.length === 1 && roles.includes('guest'); + const isGuest = roles && roles.length === 1 && roles.includes('guest'); // insert user const createUser: Record = { diff --git a/apps/meteor/app/lib/server/functions/setEmail.ts b/apps/meteor/app/lib/server/functions/setEmail.ts index 14a08be7ec04f..f9a911e85b3c3 100644 --- a/apps/meteor/app/lib/server/functions/setEmail.ts +++ b/apps/meteor/app/lib/server/functions/setEmail.ts @@ -66,7 +66,7 @@ export const setEmail = async function ( } // User already has desired username, return - if (user?.emails?.[0]?.address === email) { + if (user?.emails?.[0] && user.emails[0].address === email) { return user; } diff --git a/apps/meteor/app/lib/server/functions/setRealName.ts b/apps/meteor/app/lib/server/functions/setRealName.ts index 7689973f69519..d33aa01406230 100644 --- a/apps/meteor/app/lib/server/functions/setRealName.ts +++ b/apps/meteor/app/lib/server/functions/setRealName.ts @@ -27,7 +27,7 @@ export const setRealName = async function ( } // User already has desired name, return - if (user.name?.trim() === name) { + if (user.name && user.name.trim() === name) { return user; } diff --git a/apps/meteor/app/lib/server/functions/setUsername.ts b/apps/meteor/app/lib/server/functions/setUsername.ts index c7e8f318a6c28..9eeff3a14a0e3 100644 --- a/apps/meteor/app/lib/server/functions/setUsername.ts +++ b/apps/meteor/app/lib/server/functions/setUsername.ts @@ -49,7 +49,7 @@ export const setUsernameWithValidation = async (userId: string, username: string throw new Meteor.Error('error-not-allowed', 'Not allowed'); } - if (user.username === username || user.username?.toLowerCase() === username.toLowerCase()) { + if (user.username === username || (user.username && user.username.toLowerCase() === username.toLowerCase())) { return; } diff --git a/apps/meteor/app/lib/server/functions/updateGroupDMsName.ts b/apps/meteor/app/lib/server/functions/updateGroupDMsName.ts index ba7427ee4d42c..6e0eb970b9bc5 100644 --- a/apps/meteor/app/lib/server/functions/updateGroupDMsName.ts +++ b/apps/meteor/app/lib/server/functions/updateGroupDMsName.ts @@ -57,6 +57,7 @@ export const updateGroupDMsName = async ( const rooms = Rooms.findGroupDMsByUids([userThatChangedName._id], { projection: { uids: 1 }, session }); + // eslint-disable-next-line @typescript-eslint/explicit-function-return-type const getMembers = (uids: string[]) => uids.map((uid) => users.get(uid)).filter(isNotUndefined); // loop rooms to update the subscriptions from them all diff --git a/apps/meteor/app/lib/server/lib/processDirectEmail.ts b/apps/meteor/app/lib/server/lib/processDirectEmail.ts index 61c786730de32..e88b7d58468e4 100644 --- a/apps/meteor/app/lib/server/lib/processDirectEmail.ts +++ b/apps/meteor/app/lib/server/lib/processDirectEmail.ts @@ -29,7 +29,7 @@ export const processDirectEmail = async function (email: ParsedMail): Promise settings.get('Message_MaxAllowedSize')) { + if (msg && msg.length > (settings.get('Message_MaxAllowedSize') as number)) { return; } const emailAdress = email.from.value[0].address; diff --git a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts index 5a4e553346b0a..0a347c7526abc 100644 --- a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts +++ b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts @@ -401,7 +401,7 @@ export async function sendAllNotifications(message: IMessage, room: IRoom) { return message; } - if (room?.t == null) { + if (!room || room.t == null) { return message; } diff --git a/apps/meteor/app/lib/server/methods/saveSettings.ts b/apps/meteor/app/lib/server/methods/saveSettings.ts index e8efa3be6ebd1..11458f2f0be78 100644 --- a/apps/meteor/app/lib/server/methods/saveSettings.ts +++ b/apps/meteor/app/lib/server/methods/saveSettings.ts @@ -130,8 +130,8 @@ Meteor.methods({ const auditSettingOperation = updateAuditedByUser({ _id: uid, username: (await Meteor.userAsync())!.username!, - ip: this.connection.clientAddress || '', - useragent: this.connection.httpHeaders['user-agent'] || '', + ip: this.connection!.clientAddress || '', + useragent: this.connection!.httpHeaders['user-agent'] || '', }); const promises = params.map(({ _id, value }) => auditSettingOperation(Settings.updateValueById, _id, value)); diff --git a/apps/meteor/app/lib/server/methods/setEmail.ts b/apps/meteor/app/lib/server/methods/setEmail.ts index fd78b077a1b06..e1faece1e9919 100644 --- a/apps/meteor/app/lib/server/methods/setEmail.ts +++ b/apps/meteor/app/lib/server/methods/setEmail.ts @@ -24,7 +24,7 @@ export const setEmailFunction = async (email: string, user: Meteor.User | IUser) }); } - if (user.emails?.[0]?.address === email) { + if (user.emails?.[0] && user.emails[0].address === email) { return email; } diff --git a/apps/meteor/app/livechat/server/api/v1/room.ts b/apps/meteor/app/livechat/server/api/v1/room.ts index add9393af786c..a06c8c2743753 100644 --- a/apps/meteor/app/livechat/server/api/v1/room.ts +++ b/apps/meteor/app/livechat/server/api/v1/room.ts @@ -67,7 +67,7 @@ API.v1.addRoute( agentId: Match.Maybe(String), }); - check(this.queryParams, extraCheckParams); + check(this.queryParams, extraCheckParams as any); const { token, rid, agentId, ...extraParams } = this.queryParams; @@ -291,7 +291,7 @@ API.v1.addRoute( }; const room = await LivechatRooms.findOneById(this.bodyParams.roomId); - if (room?.t !== 'l') { + if (!room || room.t !== 'l') { throw new Error('error-invalid-room'); } @@ -358,7 +358,7 @@ const livechatVisitorDepartmentTransfer = API.v1.post( } const room = await LivechatRooms.findOneById(rid); - if (room?.t !== 'l') { + if (!room || room.t !== 'l') { return API.v1.failure('error-invalid-room'); } @@ -463,7 +463,7 @@ API.v1.addRoute( const firstError = result.find((item) => item.status === 'rejected'); if (firstError) { - throw new Error(firstError.reason.error); + throw new Error((firstError as PromiseRejectedResult).reason.error); } await callbacks.run('livechat.saveInfo', await LivechatRooms.findOneById(roomData._id), { diff --git a/apps/meteor/app/livechat/server/api/v1/visitor.ts b/apps/meteor/app/livechat/server/api/v1/visitor.ts index c0ced64e56312..706260f80afba 100644 --- a/apps/meteor/app/livechat/server/api/v1/visitor.ts +++ b/apps/meteor/app/livechat/server/api/v1/visitor.ts @@ -55,7 +55,7 @@ API.v1.addRoute( ...(department && { department }), ...(username && { username }), ...(connectionData && { connectionData }), - ...(phone && typeof phone === 'string' && { phone: { number: phone } }), + ...(phone && typeof phone === 'string' && { phone: { number: phone as string } }), connectionData: normalizeHttpHeaderData(this.request.headers), }; diff --git a/apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.spec.ts b/apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.spec.ts index a308191b5fcef..6fe3c1e2c9bf7 100644 --- a/apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.spec.ts +++ b/apps/meteor/app/livechat/server/business-hour/filterBusinessHoursThatMustBeOpened.spec.ts @@ -2,7 +2,7 @@ import { LivechatBusinessHourTypes } from '@rocket.chat/core-typings'; import { filterBusinessHoursThatMustBeOpened } from './filterBusinessHoursThatMustBeOpened'; -describe('different timezones between server and business hours saturday', () => { +describe('different timezones between server and business hours saturday ', () => { beforeEach(() => jest.useFakeTimers().setSystemTime(new Date('2024-04-20T20:10:11Z'))); afterEach(() => jest.useRealTimers()); it('should return a bh when the finish time resolves to a different day on server', async () => { @@ -53,7 +53,7 @@ describe('different timezones between server and business hours saturday', () => }); }); -describe('different timezones between server and business hours sunday', () => { +describe('different timezones between server and business hours sunday ', () => { beforeEach(() => jest.useFakeTimers().setSystemTime(new Date('2025-07-27T11:02:11Z'))); afterEach(() => jest.useRealTimers()); it('should return a bh when the finish time resolves to a different day on server', async () => { diff --git a/apps/meteor/app/livechat/server/lib/Helper.ts b/apps/meteor/app/livechat/server/lib/Helper.ts index 31a3d35bdf3fa..2ce0a3a66fe40 100644 --- a/apps/meteor/app/livechat/server/lib/Helper.ts +++ b/apps/meteor/app/livechat/server/lib/Helper.ts @@ -512,7 +512,7 @@ export const forwardRoomToAgent = async (room: IOmnichannelRoom, transferData: T throw new Error('error-invalid-inquiry'); } - if (agentId === oldServedBy?._id) { + if (oldServedBy && agentId === oldServedBy._id) { throw new Error('error-selected-agent-room-agent-are-same'); } @@ -724,7 +724,7 @@ export const forwardRoomToDepartment = async (room: IOmnichannelRoom, guest: ILi } const { servedBy, chatQueued } = roomTaken; - if (!chatQueued && oldServedBy && oldServedBy._id === servedBy?._id) { + if (!chatQueued && oldServedBy && servedBy && oldServedBy._id === servedBy._id) { if (!department?.fallbackForwardDepartment?.length) { logger.debug({ msg: 'Cannot forward room. Chat assigned to agent instead', diff --git a/apps/meteor/app/livechat/server/lib/RoutingManager.ts b/apps/meteor/app/livechat/server/lib/RoutingManager.ts index 3a371b7b1eb4d..8c6fb51c08b2d 100644 --- a/apps/meteor/app/livechat/server/lib/RoutingManager.ts +++ b/apps/meteor/app/livechat/server/lib/RoutingManager.ts @@ -253,7 +253,7 @@ export const RoutingManager: Routing = { return room; } - if (room.servedBy?._id === agent.agentId) { + if (room.servedBy && room.servedBy._id === agent.agentId) { logger.debug({ msg: 'Cannot take inquiry. Already taken by agent', inquiryId: inquiry._id, agentId: room.servedBy._id }); return room; } @@ -368,7 +368,7 @@ export const RoutingManager: Routing = { const subscriptions = await Subscriptions.findByRoomId(roomId).toArray(); subscriptions?.forEach(({ u }) => { - if (ignoreUser?._id === u._id) { + if (ignoreUser && ignoreUser._id === u._id) { return; } void removeAgentFromSubscription(roomId, u); diff --git a/apps/meteor/app/livechat/server/lib/closeRoom.ts b/apps/meteor/app/livechat/server/lib/closeRoom.ts index 50b90e0be1763..dbaa2ad5d4b54 100644 --- a/apps/meteor/app/livechat/server/lib/closeRoom.ts +++ b/apps/meteor/app/livechat/server/lib/closeRoom.ts @@ -186,7 +186,7 @@ async function doCloseRoom( } const updatedRoom = await LivechatRooms.closeRoomById(rid, closeData, { session }); - if (!params.forceClose && updatedRoom?.modifiedCount !== 1) { + if (!params.forceClose && (!updatedRoom || updatedRoom.modifiedCount !== 1)) { throw new Error('Error closing room'); } diff --git a/apps/meteor/app/livechat/server/lib/contacts/resolveContactConflicts.ts b/apps/meteor/app/livechat/server/lib/contacts/resolveContactConflicts.ts index a8c9efc02e3f1..84e36c5995b3e 100644 --- a/apps/meteor/app/livechat/server/lib/contacts/resolveContactConflicts.ts +++ b/apps/meteor/app/livechat/server/lib/contacts/resolveContactConflicts.ts @@ -54,7 +54,7 @@ export async function resolveContactConflicts(params: ResolveContactConflictsPar updatedConflictingFieldsArr = contact.conflictingFields.filter( (conflictingField: ILivechatContactConflictingField) => !fieldsToRemove.has(conflictingField.field), - ); + ) as ILivechatContactConflictingField[]; } const set = { diff --git a/apps/meteor/app/livechat/server/lib/departmentsLib.ts b/apps/meteor/app/livechat/server/lib/departmentsLib.ts index 56f45cfc50343..3612ba48415a6 100644 --- a/apps/meteor/app/livechat/server/lib/departmentsLib.ts +++ b/apps/meteor/app/livechat/server/lib/departmentsLib.ts @@ -42,7 +42,7 @@ export async function saveDepartment( }) : null; - if (departmentUnit && !departmentUnit._id && department?.parentId) { + if (departmentUnit && !departmentUnit._id && department && department.parentId) { const isLastDepartmentInUnit = (await LivechatDepartment.countDepartmentsInUnit(department.parentId)) === 1; if (isLastDepartmentInUnit) { throw new Meteor.Error('error-unit-cant-be-empty', "The last department in a unit can't be removed", { diff --git a/apps/meteor/app/livechat/server/roomAccessValidator.compatibility.ts b/apps/meteor/app/livechat/server/roomAccessValidator.compatibility.ts index bbeebd5ef73b6..be0c765dd7891 100644 --- a/apps/meteor/app/livechat/server/roomAccessValidator.compatibility.ts +++ b/apps/meteor/app/livechat/server/roomAccessValidator.compatibility.ts @@ -70,7 +70,7 @@ export const validators: OmnichannelRoomAccessValidator[] = [ // TODO: findone filtering if the inquiry is queued instead of checking here const inquiry = await LivechatInquiry.findOne(filter, { projection: { status: 1 } }); - return inquiry?.status === 'queued'; + return inquiry && inquiry.status === 'queued'; }, async function (room, user) { if (!room.departmentId || room.open || !user?._id) { diff --git a/apps/meteor/app/livechat/server/statistics/LivechatAgentActivityMonitor.ts b/apps/meteor/app/livechat/server/statistics/LivechatAgentActivityMonitor.ts index 869d00170a2ba..dc112b33c28ae 100644 --- a/apps/meteor/app/livechat/server/statistics/LivechatAgentActivityMonitor.ts +++ b/apps/meteor/app/livechat/server/statistics/LivechatAgentActivityMonitor.ts @@ -109,7 +109,7 @@ export class LivechatAgentActivityMonitor { } const user = await Users.findOneById>(userId, { projection: { statusLivechat: 1 } }); - if (user?.statusLivechat !== 'available') { + if (!user || user.statusLivechat !== 'available') { return; } @@ -126,7 +126,7 @@ export class LivechatAgentActivityMonitor { } const user = await Users.findOneById>(userId, { projection: { status: 1 } }); - if (user?.status === 'offline') { + if (user && user.status === 'offline') { return; } diff --git a/apps/meteor/app/message-pin/server/pinMessage.ts b/apps/meteor/app/message-pin/server/pinMessage.ts index af6f3d6e43de6..204868d9dcda3 100644 --- a/apps/meteor/app/message-pin/server/pinMessage.ts +++ b/apps/meteor/app/message-pin/server/pinMessage.ts @@ -136,7 +136,7 @@ export const unpinMessage = async (userId: string, message: IMessage) => { } let originalMessage = await Messages.findOneById(message._id); - if (originalMessage?._id == null) { + if (originalMessage == null || originalMessage._id == null) { throw new Meteor.Error('error-invalid-message', 'Message you are unpinning was not found', { method: 'unpinMessage', action: 'Message_pinning', diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts b/apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts index 48273ee682862..fdac8b0b77fa8 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts +++ b/apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts @@ -295,7 +295,7 @@ export class SAML { } let timeoutHandler: NodeJS.Timeout | undefined = undefined; - const redirect = (url?: string): void => { + const redirect = (url?: string | undefined): void => { if (!timeoutHandler) { // If the handler is null, then we already ended the response; return; diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts b/apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts index 94a022a485393..ec8924c69a7f4 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts +++ b/apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts @@ -367,7 +367,7 @@ export class SAMLUtils { } } - if (mapping.regex && mainValue?.match) { + if (mapping.regex && mainValue && mainValue.match) { let regexValue; const match = mainValue.match(new RegExp(mapping.regex)); if (match?.length) { diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts b/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts index 489a9c27085e5..dacdd014806e4 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts +++ b/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts @@ -45,7 +45,7 @@ const getSamlConfigs = function (service: string): SAMLConfiguration { privateKey: settings.get(`${service}_private_key`), publicCert: settings.get(`${service}_public_cert`), // People often overlook the instruction to remove the header and footer of the certificate on this specific setting, so let's do it for them. - cert: SAMLUtils.normalizeCert(settings.get(`${service}_cert`) || ''), + cert: SAMLUtils.normalizeCert((settings.get(`${service}_cert`) as string) || ''), algorithm: settings.get(`${service}_signature_algorithm`) || 'SHA1', }, signatureValidationType: settings.get(`${service}_signature_validation_type`), diff --git a/apps/meteor/app/settings/server/SettingsRegistry.ts b/apps/meteor/app/settings/server/SettingsRegistry.ts index 6b0eb83f2ad0b..3b93ca5c0bfb6 100644 --- a/apps/meteor/app/settings/server/SettingsRegistry.ts +++ b/apps/meteor/app/settings/server/SettingsRegistry.ts @@ -208,6 +208,7 @@ export class SettingsRegistry { */ async addGroup(_id: string, cb?: addGroupCallback): Promise; + // eslint-disable-next-line no-dupe-class-members async addGroup(_id: string, groupOptions: ISettingAddGroupOptions | addGroupCallback = {}, cb?: addGroupCallback): Promise { if (!_id || (groupOptions instanceof Function && cb)) { throw new Error('Invalid arguments'); diff --git a/apps/meteor/app/settings/server/functions/settings.mocks.ts b/apps/meteor/app/settings/server/functions/settings.mocks.ts index 758f96a6904b6..fb31c3021b1b3 100644 --- a/apps/meteor/app/settings/server/functions/settings.mocks.ts +++ b/apps/meteor/app/settings/server/functions/settings.mocks.ts @@ -41,7 +41,7 @@ class SettingsClass { insertOne(doc: any): void { this.data.set(doc._id, doc); - + // eslint-disable-next-line @typescript-eslint/no-var-requires this.settings.set(doc); this.insertCalls++; } @@ -77,13 +77,13 @@ class SettingsClass { this.data.set(query._id, data); // Can't import before the mock command on end of this file! - + // eslint-disable-next-line @typescript-eslint/no-var-requires this.settings.set(data); }, this.delay); } else { this.data.set(query._id, data); // Can't import before the mock command on end of this file! - + // eslint-disable-next-line @typescript-eslint/no-var-requires this.settings.set(data); } @@ -98,7 +98,7 @@ class SettingsClass { updateValueById(id: string, value: any): void { this.data.set(id, { ...this.data.get(id), value }); // Can't import before the mock command on end of this file! - + // eslint-disable-next-line @typescript-eslint/no-var-requires if (this.delay) { setTimeout(() => { this.settings.set(this.data.get(id) as ISetting); diff --git a/apps/meteor/app/settings/server/startup.ts b/apps/meteor/app/settings/server/startup.ts index 450d46cc45599..5c0f4cdee5fe6 100644 --- a/apps/meteor/app/settings/server/startup.ts +++ b/apps/meteor/app/settings/server/startup.ts @@ -3,6 +3,7 @@ import type { Settings } from '@rocket.chat/models'; import type { ICachedSettings } from './CachedSettings'; +// eslint-disable-next-line @typescript-eslint/naming-convention export async function initializeSettings({ model, settings }: { model: typeof Settings; settings: ICachedSettings }): Promise { await model.find().forEach((record: ISetting) => { settings.set(record); diff --git a/apps/meteor/app/slackbridge/server/RocketAdapter.ts b/apps/meteor/app/slackbridge/server/RocketAdapter.ts index 6bf34a2cb0ca7..925bb4ef2dc4d 100644 --- a/apps/meteor/app/slackbridge/server/RocketAdapter.ts +++ b/apps/meteor/app/slackbridge/server/RocketAdapter.ts @@ -188,7 +188,7 @@ export default class RocketAdapter { return; } - if (!rocketMessage.attachments?.length) { + if (!rocketMessage.attachments || !rocketMessage.attachments.length) { return; } @@ -252,7 +252,7 @@ export default class RocketAdapter { for await (const member of members) { if (member !== slackChannel.creator) { const rocketUser = (await this.findUser(member)) || (await this.addUser(member)); - if (rocketUser?.username) { + if (rocketUser && rocketUser.username) { rocketUsers.push(rocketUser.username); } } @@ -314,12 +314,12 @@ export default class RocketAdapter { }; let lastSetTopic = 0; - if (slackChannel.topic?.value) { + if (slackChannel.topic && slackChannel.topic.value) { roomUpdate.topic = slackChannel.topic.value; lastSetTopic = slackChannel.topic.last_set; } - if (slackChannel.purpose?.value && slackChannel.purpose.last_set > lastSetTopic) { + if (slackChannel.purpose && slackChannel.purpose.value && slackChannel.purpose.last_set > lastSetTopic) { roomUpdate.topic = slackChannel.purpose.value; } await Rooms.addImportIds(slackChannel.rocketId, slackChannel.id); @@ -359,7 +359,7 @@ export default class RocketAdapter { if (user) { const rocketUserData = user; const isBot = rocketUserData.is_bot === true; - const email = rocketUserData.profile?.email || ''; + const email = (rocketUserData.profile && rocketUserData.profile.email) || ''; let existingRocketUser; if (!isBot) { existingRocketUser = @@ -391,7 +391,7 @@ export default class RocketAdapter { roles: isBot ? ['bot'] : ['user'], }; - if (rocketUserData.profile?.real_name) { + if (rocketUserData.profile && rocketUserData.profile.real_name) { userUpdate.name = rocketUserData.profile.real_name; } @@ -422,7 +422,7 @@ export default class RocketAdapter { } const importIds = [rocketUserData.id]; - if (isBot && rocketUserData.profile?.bot_id) { + if (isBot && rocketUserData.profile && rocketUserData.profile.bot_id) { importIds.push(rocketUserData.profile.bot_id); } await Users.addImportIds(rocketUserData.rocketId, importIds); diff --git a/apps/meteor/app/slackbridge/server/SlackAPI.ts b/apps/meteor/app/slackbridge/server/SlackAPI.ts index 1ba1d7a920479..a352537059c0c 100644 --- a/apps/meteor/app/slackbridge/server/SlackAPI.ts +++ b/apps/meteor/app/slackbridge/server/SlackAPI.ts @@ -28,7 +28,7 @@ export class SlackAPI { if (response && response && Array.isArray(response.channels) && response.channels.length > 0) { channels = channels.concat(response.channels); - if (response.response_metadata?.next_cursor) { + if (response.response_metadata && response.response_metadata.next_cursor) { const nextChannels = await this.getChannels(response.response_metadata.next_cursor); channels = channels.concat(nextChannels); } @@ -56,7 +56,7 @@ export class SlackAPI { if (response && response && Array.isArray(response.channels) && response.channels.length > 0) { groups = groups.concat(response.channels); - if (response.response_metadata?.next_cursor) { + if (response.response_metadata && response.response_metadata.next_cursor) { const nextGroups = await this.getGroups(response.response_metadata.next_cursor); groups = groups.concat(nextGroups); } @@ -104,7 +104,7 @@ export class SlackAPI { const response = await request.json(); if (response && response && request.status === 200 && request.ok && Array.isArray(response.members)) { members = members.concat(response.members); - const hasMoreItems = response.response_metadata?.next_cursor; + const hasMoreItems = response.response_metadata && response.response_metadata.next_cursor; if (hasMoreItems) { currentCursor = response.response_metadata.next_cursor; } diff --git a/apps/meteor/app/slackbridge/server/SlackAdapter.ts b/apps/meteor/app/slackbridge/server/SlackAdapter.ts index 3d4aeb66c7017..e62d0bcdcd932 100644 --- a/apps/meteor/app/slackbridge/server/SlackAdapter.ts +++ b/apps/meteor/app/slackbridge/server/SlackAdapter.ts @@ -607,7 +607,7 @@ export default class SlackAdapter { * https://api.slack.com/events/message */ async onMessage(slackMessage, isImporting) { - const isAFileShare = slackMessage?.files && Array.isArray(slackMessage.files) && slackMessage.files.length; + const isAFileShare = slackMessage && slackMessage.files && Array.isArray(slackMessage.files) && slackMessage.files.length; if (isAFileShare) { await this.processFileShare(slackMessage); return; @@ -841,22 +841,22 @@ export default class SlackAdapter { } async postMessage(slackChannel, rocketMessage) { - if (slackChannel?.id) { - let iconUrl = getUserAvatarURL(rocketMessage.u?.username); + if (slackChannel && slackChannel.id) { + let iconUrl = getUserAvatarURL(rocketMessage.u && rocketMessage.u.username); if (iconUrl) { iconUrl = Meteor.absoluteUrl().replace(/\/$/, '') + iconUrl; } const data = { text: rocketMessage.msg, channel: slackChannel.id, - username: rocketMessage.u?.username, + username: rocketMessage.u && rocketMessage.u.username, icon_url: iconUrl, link_names: 1, }; if (rocketMessage.tmid) { const tmessage = await Messages.findOneById(rocketMessage.tmid); - if (tmessage?.slackTs) { + if (tmessage && tmessage.slackTs) { data.thread_ts = tmessage.slackTs; } } @@ -873,7 +873,7 @@ export default class SlackAdapter { this.removeMessageBeingSent(data); } - if (postResult?.message?.bot_id && postResult.message.ts) { + if (postResult && postResult.message && postResult.message.bot_id && postResult.message.ts) { this.slackBotId = postResult.message.bot_id; await Messages.setSlackBotIdAndSlackTs(rocketMessage._id, postResult.message.bot_id, postResult.message.ts); slackLogger.debug({ @@ -890,7 +890,7 @@ export default class SlackAdapter { https://api.slack.com/methods/chat.update */ async postMessageUpdate(slackChannel, rocketMessage) { - if (slackChannel?.id) { + if (slackChannel && slackChannel.id) { const data = { ts: this.getTimeStamp(rocketMessage), channel: slackChannel.id, @@ -931,7 +931,7 @@ export default class SlackAdapter { } const file = slackMessage.files[0]; - if (file?.url_private_download !== undefined) { + if (file && file.url_private_download !== undefined) { const rocketChannel = await this.rocket.getChannel(slackMessage); const rocketUser = await this.rocket.getUser(slackMessage.user); @@ -1158,7 +1158,7 @@ export default class SlackAdapter { } async processShareMessage(rocketChannel, rocketUser, slackMessage, isImporting) { - if (slackMessage.file?.url_private_download !== undefined) { + if (slackMessage.file && slackMessage.file.url_private_download !== undefined) { const details = { message_id: this.createSlackMessageId(slackMessage.ts), name: slackMessage.file.name, @@ -1178,7 +1178,7 @@ export default class SlackAdapter { } async processPinnedItemMessage(rocketChannel, rocketUser, slackMessage, isImporting) { - if (slackMessage.attachments?.[0]?.text) { + if (slackMessage.attachments && slackMessage.attachments[0] && slackMessage.attachments[0].text) { // TODO: refactor this logic to use the service to send this system message instead of using sendMessage const rocketMsgObj = { rid: rocketChannel._id, @@ -1288,7 +1288,7 @@ export default class SlackAdapter { attachment.image_url = url; attachment.image_type = file.type; attachment.image_size = file.size; - attachment.image_dimensions = file.identify?.size; + attachment.image_dimensions = file.identify && file.identify.size; } if (/^audio\/.+/.test(file.type)) { attachment.audio_url = url; @@ -1359,13 +1359,13 @@ export default class SlackAdapter { let topic = ''; let topic_last_set = 0; let topic_creator = null; - if (channel?.topic?.value) { + if (channel && channel.topic && channel.topic.value) { topic = channel.topic.value; topic_last_set = channel.topic.last_set; topic_creator = channel.topic.creator; } - if (channel?.purpose?.value) { + if (channel && channel.purpose && channel.purpose.value) { if (topic_last_set) { if (topic_last_set < channel.purpose.last_set) { topic = channel.purpose.topic; @@ -1433,7 +1433,7 @@ export default class SlackAdapter { channel: this.getSlackChannel(rid).id, oldest: 1, }); - while (results?.has_more) { + while (results && results.has_more) { // eslint-disable-next-line no-await-in-loop results = await this.importFromHistory({ channel: this.getSlackChannel(rid).id, diff --git a/apps/meteor/app/slashcommands-create/server/server.ts b/apps/meteor/app/slashcommands-create/server/server.ts index 4406c21ce3f7f..6abee71c56fdd 100644 --- a/apps/meteor/app/slashcommands-create/server/server.ts +++ b/apps/meteor/app/slashcommands-create/server/server.ts @@ -24,7 +24,7 @@ slashCommands.add({ return result; } - const regexp = new RegExp(settings.get('UTF8_Channel_Names_Validation')); + const regexp = new RegExp(settings.get('UTF8_Channel_Names_Validation') as string); const channel = regexp.exec(params.trim()); diff --git a/apps/meteor/app/slashcommands-invite/server/server.ts b/apps/meteor/app/slashcommands-invite/server/server.ts index 6f228d0845791..26ea1256c3c34 100644 --- a/apps/meteor/app/slashcommands-invite/server/server.ts +++ b/apps/meteor/app/slashcommands-invite/server/server.ts @@ -77,7 +77,7 @@ slashCommands.add({ projection: { _id: 1 }, }); if (subscription == null) { - usersFiltered.push(user); + usersFiltered.push(user as IUser); continue; } const usernameStr = user.username as string; diff --git a/apps/meteor/app/slashcommands-open/client/client.ts b/apps/meteor/app/slashcommands-open/client/client.ts index b4995db1a8bff..88cee2fda319a 100644 --- a/apps/meteor/app/slashcommands-open/client/client.ts +++ b/apps/meteor/app/slashcommands-open/client/client.ts @@ -27,7 +27,7 @@ slashCommands.add({ roomCoordinator.openRouteLink(subscription.t, subscription, router.getSearchParameters()); } - if (type?.indexOf('d') === -1) { + if (type && type.indexOf('d') === -1) { return; } try { diff --git a/apps/meteor/app/statistics/server/functions/sendUsageReport.ts b/apps/meteor/app/statistics/server/functions/sendUsageReport.ts index a8ee0920427ee..b96c8177da17a 100644 --- a/apps/meteor/app/statistics/server/functions/sendUsageReport.ts +++ b/apps/meteor/app/statistics/server/functions/sendUsageReport.ts @@ -47,7 +47,7 @@ export async function sendUsageReport(logger: Logger): Promise>(); -const rooms = new Map void>(); +const rooms = new Map void>(); const performingUsers = new Map(); const performingUsersEmitter = new Emitter<{ changed: void }>(); diff --git a/apps/meteor/app/utils/client/getURL.ts b/apps/meteor/app/utils/client/getURL.ts index 0da322dad27f7..b427c7110ccef 100644 --- a/apps/meteor/app/utils/client/getURL.ts +++ b/apps/meteor/app/utils/client/getURL.ts @@ -3,7 +3,7 @@ import { getURLWithoutSettings } from '../lib/getURL'; import { Info } from '../rocketchat.info'; export const getURL = function ( - path: string, + path: string, // eslint-disable-next-line @typescript-eslint/naming-convention params: { cdn?: boolean; full?: boolean; diff --git a/apps/meteor/app/utils/lib/getURL.ts b/apps/meteor/app/utils/lib/getURL.ts index e45469b98f520..3d757abb6c83c 100644 --- a/apps/meteor/app/utils/lib/getURL.ts +++ b/apps/meteor/app/utils/lib/getURL.ts @@ -37,7 +37,7 @@ function getCloudUrl( export const _getURL = ( path: string, - + // eslint-disable-next-line @typescript-eslint/naming-convention { cdn, full, cloud, cloud_route, cloud_params, _cdn_prefix, _root_url_path_prefix, _site_url }: Record, deeplinkUrl?: string, ): string => { @@ -76,7 +76,7 @@ export const _getURL = ( export const getURLWithoutSettings = ( path: string, - + // eslint-disable-next-line @typescript-eslint/naming-convention { cdn = true, full = false, diff --git a/apps/meteor/app/utils/server/getURL.ts b/apps/meteor/app/utils/server/getURL.ts index 61f386ee14a8b..4703569736add 100644 --- a/apps/meteor/app/utils/server/getURL.ts +++ b/apps/meteor/app/utils/server/getURL.ts @@ -2,7 +2,7 @@ import { settings } from '../../settings/server'; import { getURLWithoutSettings } from '../lib/getURL'; export const getURL = function ( - path: string, + path: string, // eslint-disable-next-line @typescript-eslint/naming-convention params: { cdn?: boolean; full?: boolean; diff --git a/apps/meteor/app/utils/server/getUserNotificationPreference.ts b/apps/meteor/app/utils/server/getUserNotificationPreference.ts index 9874a8a112eec..2c70a7a11a18c 100644 --- a/apps/meteor/app/utils/server/getUserNotificationPreference.ts +++ b/apps/meteor/app/utils/server/getUserNotificationPreference.ts @@ -29,7 +29,11 @@ export const getUserNotificationPreference = async (user: IUser | string, pref: return null; } - if (typeof user?.settings?.preferences?.[preferenceKey] !== 'undefined' && user.settings.preferences[preferenceKey] !== 'default') { + if ( + user?.settings?.preferences && + typeof user.settings.preferences[preferenceKey] !== 'undefined' && + user.settings.preferences[preferenceKey] !== 'default' + ) { return { value: user.settings.preferences[preferenceKey], origin: 'user', diff --git a/apps/meteor/client/apps/orchestrator.ts b/apps/meteor/client/apps/orchestrator.ts index ba50259e1faab..d08641da34d22 100644 --- a/apps/meteor/client/apps/orchestrator.ts +++ b/apps/meteor/client/apps/orchestrator.ts @@ -74,7 +74,7 @@ class AppClientOrchestrator { return { apps: [], error: 'Invalid response from API' }; } - const apps = result.map((app: App) => { + const apps = (result as App[]).map((app: App) => { const { latest, appRequestStats, price, pricingPlans, purchaseType, isEnterpriseOnly, modifiedAt, bundledIn, requestedEndUser } = app; return { ...latest, diff --git a/apps/meteor/client/components/GenericUpsellModal/GenericUpsellModal.spec.tsx b/apps/meteor/client/components/GenericUpsellModal/GenericUpsellModal.spec.tsx index 431f092178153..f9f944ce5bb39 100644 --- a/apps/meteor/client/components/GenericUpsellModal/GenericUpsellModal.spec.tsx +++ b/apps/meteor/client/components/GenericUpsellModal/GenericUpsellModal.spec.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { composeStories } from '@storybook/react'; import { render, screen } from '@testing-library/react'; diff --git a/apps/meteor/client/components/Sidebar/SidebarNavigationItem.tsx b/apps/meteor/client/components/Sidebar/SidebarNavigationItem.tsx index 6cb5488a7ba57..a5ea0be9492cb 100644 --- a/apps/meteor/client/components/Sidebar/SidebarNavigationItem.tsx +++ b/apps/meteor/client/components/Sidebar/SidebarNavigationItem.tsx @@ -28,7 +28,7 @@ const SidebarNavigationItem = ({ badge: Badge, }: SidebarNavigationItemProps) => { const path = pathSection; - const isActive = !!path && currentPath?.includes(path); + const isActive = !!path && currentPath?.includes(path as string); if (permissionGranted === false || (typeof permissionGranted === 'function' && !permissionGranted())) { return null; diff --git a/apps/meteor/client/definitions/global.d.ts b/apps/meteor/client/definitions/global.d.ts index 1f1072ec6313b..3cefc38cc8362 100644 --- a/apps/meteor/client/definitions/global.d.ts +++ b/apps/meteor/client/definitions/global.d.ts @@ -1,6 +1,7 @@ import type { IRocketChatDesktop } from '@rocket.chat/desktop-api'; declare global { + // eslint-disable-next-line @typescript-eslint/naming-convention interface Window { RocketChatDesktop?: IRocketChatDesktop; @@ -69,6 +70,7 @@ declare global { addStream(stream: MediaStream): void; } + // eslint-disable-next-line @typescript-eslint/naming-convention interface MediaTrackConstraints { /** @deprecated */ mozMediaSource?: string; diff --git a/apps/meteor/client/hooks/notification/useNotification.ts b/apps/meteor/client/hooks/notification/useNotification.ts index 5f2f9ea6891ab..cb6fe93077d34 100644 --- a/apps/meteor/client/hooks/notification/useNotification.ts +++ b/apps/meteor/client/hooks/notification/useNotification.ts @@ -33,7 +33,7 @@ export const useNotification = () => { } as any); const n = new Notification(notification.title, { - icon: notification.icon || getUserAvatarURL(notification.payload.sender?.username), + icon: notification.icon || getUserAvatarURL(notification.payload.sender?.username as string), body: stripTags(message?.msg), tag: msgId, canReply: true, diff --git a/apps/meteor/client/lib/2fa/process2faReturn.ts b/apps/meteor/client/lib/2fa/process2faReturn.ts index 9669107bb3e2f..4042370caae39 100644 --- a/apps/meteor/client/lib/2fa/process2faReturn.ts +++ b/apps/meteor/client/lib/2fa/process2faReturn.ts @@ -74,7 +74,7 @@ export async function process2faReturn({ const props = { ...getProps(error.details.method, emailOrUsername || error.details.emailOrUsername), - + // eslint-disable-next-line no-nested-ternary invalidAttempt: isTotpInvalidError(error), }; @@ -111,7 +111,7 @@ export async function process2faAsyncReturn({ const props = { method: error.details.method, emailOrUsername: emailOrUsername || error.details.emailOrUsername || getUser()?.username, - + // eslint-disable-next-line no-nested-ternary invalidAttempt: isTotpInvalidError(error), }; diff --git a/apps/meteor/client/lib/chats/data.ts b/apps/meteor/client/lib/chats/data.ts index b72a7bcb0ee8e..5206e802e7d0c 100644 --- a/apps/meteor/client/lib/chats/data.ts +++ b/apps/meteor/client/lib/chats/data.ts @@ -67,14 +67,14 @@ export const createDataAPI = ({ rid, tmid }: { rid: IRoom['_id']; tmid: IMessage } const canEditMessage = hasAtLeastOnePermission('edit-message', message.rid); - const editAllowed = settings.peek('Message_AllowEditing') ?? false; + const editAllowed = (settings.peek('Message_AllowEditing') as boolean | undefined) ?? false; const editOwn = message?.u && message.u._id === getUserId(); if (!canEditMessage && (!editAllowed || !editOwn)) { return false; } - const blockEditInMinutes = settings.peek('Message_AllowEditing_BlockEditInMinutes'); + const blockEditInMinutes = settings.peek('Message_AllowEditing_BlockEditInMinutes') as number | undefined; const bypassBlockTimeLimit = hasPermission('bypass-time-limit-edit-and-delete', message.rid); const elapsedMinutes = moment().diff(message.ts, 'minutes'); @@ -200,7 +200,7 @@ export const createDataAPI = ({ rid, tmid }: { rid: IRoom['_id']; tmid: IMessage return true; } - const deletionEnabled = settings.peek('Message_AllowDeleting'); + const deletionEnabled = settings.peek('Message_AllowDeleting') as boolean | undefined; if (!deletionEnabled) { return false; } @@ -213,7 +213,7 @@ export const createDataAPI = ({ rid, tmid }: { rid: IRoom['_id']; tmid: IMessage return false; } - const blockDeleteInMinutes = settings.peek('Message_AllowDeleting_BlockDeleteInMinutes'); + const blockDeleteInMinutes = settings.peek('Message_AllowDeleting_BlockDeleteInMinutes') as number | undefined; const bypassBlockTimeLimit = hasPermission('bypass-time-limit-edit-and-delete', message.rid); const elapsedMinutes = moment().diff(message.ts, 'minutes'); const onTimeForDelete = bypassBlockTimeLimit || !blockDeleteInMinutes || !elapsedMinutes || elapsedMinutes <= blockDeleteInMinutes; diff --git a/apps/meteor/client/lib/customOAuth/CustomOAuth.ts b/apps/meteor/client/lib/customOAuth/CustomOAuth.ts index 57938577cf6b8..8ac31adc0a5ce 100644 --- a/apps/meteor/client/lib/customOAuth/CustomOAuth.ts +++ b/apps/meteor/client/lib/customOAuth/CustomOAuth.ts @@ -54,7 +54,7 @@ export class CustomOAuth implements IOAuth } configureLogin() { - const loginWithService = `loginWith${capitalize(this.name)}` as const; + const loginWithService = `loginWith${capitalize(this.name) as Capitalize}` as const; const loginWithOAuthTokenAndTOTP = createOAuthTotpLoginMethod(this); diff --git a/apps/meteor/client/lib/e2ee/crypto/shared.ts b/apps/meteor/client/lib/e2ee/crypto/shared.ts index 2d298591ebbc4..1605a106e53b3 100644 --- a/apps/meteor/client/lib/e2ee/crypto/shared.ts +++ b/apps/meteor/client/lib/e2ee/crypto/shared.ts @@ -34,12 +34,12 @@ export const encryptBuffer = > key: HasUsage, params: TParams, data: BufferSource, -): Promise => subtle.encrypt(params, key, data); +): Promise => subtle.encrypt(params, key, data) as Promise; export const decryptBuffer = ( key: HasUsage, params: ParamsOf, data: BufferSource, -): Promise => subtle.decrypt(params, key, data); +): Promise => subtle.decrypt(params, key, data) as Promise; export const deriveBits = (...args: Parameters) => subtle.deriveBits(...args); type AesParams = { diff --git a/apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts b/apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts index e2e22a89416d7..625e305365af1 100644 --- a/apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts +++ b/apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts @@ -401,7 +401,7 @@ export class E2ERoom extends Emitter { // Import session key for use. try { - const key = await Aes.importKey(JSON.parse(this.sessionKeyExportedString)); + const key = await Aes.importKey(JSON.parse(this.sessionKeyExportedString!)); // Key has been obtained. E2E is now in session. this.groupSessionKey = key; span.info('Group key imported'); @@ -498,13 +498,13 @@ export class E2ERoom extends Emitter { }[] > = { [this.roomId]: [] }; for await (const user of users) { - const encryptedGroupKey = await this.encryptGroupKeyForParticipant(user.e2e!.public_key); + const encryptedGroupKey = await this.encryptGroupKeyForParticipant(user.e2e!.public_key!); if (!encryptedGroupKey) { span.warn(`Could not encrypt group key for user ${user._id}`); return; } if (decryptedOldGroupKeys) { - const oldKeys = await this.encryptOldKeysForParticipant(user.e2e!.public_key, decryptedOldGroupKeys); + const oldKeys = await this.encryptOldKeysForParticipant(user.e2e!.public_key!, decryptedOldGroupKeys); if (oldKeys) { usersSuggestedGroupKeys[this.roomId].push({ _id: user._id, key: encryptedGroupKey, oldKeys }); continue; diff --git a/apps/meteor/client/lib/getDirtyFields.ts b/apps/meteor/client/lib/getDirtyFields.ts index 5ef62b04dc627..ede3197a23d57 100644 --- a/apps/meteor/client/lib/getDirtyFields.ts +++ b/apps/meteor/client/lib/getDirtyFields.ts @@ -12,7 +12,7 @@ export const getDirtyFields = ( ): Partial => { const dirtyFieldsObjValue = Object.keys(dirtyFields).reduce((acc, currentField) => { const isDirty = Array.isArray(dirtyFields[currentField]) - ? dirtyFields[currentField].some((value) => value === true) + ? (dirtyFields[currentField] as boolean[]).some((value) => value === true) : dirtyFields[currentField] === true; if (isDirty) { return { diff --git a/apps/meteor/client/lib/streamer/streamer.ts b/apps/meteor/client/lib/streamer/streamer.ts index e1c60b16bc9b2..1eb31015acaf5 100644 --- a/apps/meteor/client/lib/streamer/streamer.ts +++ b/apps/meteor/client/lib/streamer/streamer.ts @@ -75,7 +75,7 @@ export class StreamerCentral extends EV { getStreamer(name: N, options: StreamerOptions): Streamer { const existingInstance = this.instances[name]; if (existingInstance) { - return existingInstance; + return existingInstance as Streamer; } const streamer = new Streamer(name, options); diff --git a/apps/meteor/client/lib/userData.ts b/apps/meteor/client/lib/userData.ts index ced79b7a00313..2b768bad7a597 100644 --- a/apps/meteor/client/lib/userData.ts +++ b/apps/meteor/client/lib/userData.ts @@ -64,6 +64,7 @@ export const synchronizeUserData = async (uid: IUser['_id']): Promise { switch (data.type) { case 'inserted': { + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { type, id, ...user } = data; Users.state.store(user.data); break; diff --git a/apps/meteor/client/lib/userStatuses.ts b/apps/meteor/client/lib/userStatuses.ts index 27a20f0275ae8..631c1d1ea0442 100644 --- a/apps/meteor/client/lib/userStatuses.ts +++ b/apps/meteor/client/lib/userStatuses.ts @@ -41,7 +41,7 @@ export class UserStatuses implements Iterable { return { name: customUserStatus.name, id: customUserStatus._id, - statusType: customUserStatus.statusType, + statusType: customUserStatus.statusType as UserStatus, localizeName: false, }; } diff --git a/apps/meteor/client/lib/utils/getUidDirectMessage.ts b/apps/meteor/client/lib/utils/getUidDirectMessage.ts index 342aa31d01067..6f56110629855 100644 --- a/apps/meteor/client/lib/utils/getUidDirectMessage.ts +++ b/apps/meteor/client/lib/utils/getUidDirectMessage.ts @@ -6,7 +6,7 @@ import { getUserId } from '../user'; export const getUidDirectMessage = (rid: IRoom['_id'], uid: IUser['_id'] | undefined = getUserId() ?? undefined): string | undefined => { const room = Rooms.state.get(rid); - if (room?.t !== 'd' || !room.uids || room.uids.length > 2) { + if (!room || room.t !== 'd' || !room.uids || room.uids.length > 2) { return undefined; } diff --git a/apps/meteor/client/navbar/NavBarSettingsToolbar/hooks/useAdministrationMenu.spec.tsx b/apps/meteor/client/navbar/NavBarSettingsToolbar/hooks/useAdministrationMenu.spec.tsx index 7ec820c09c1bd..6eb991ca61afb 100644 --- a/apps/meteor/client/navbar/NavBarSettingsToolbar/hooks/useAdministrationMenu.spec.tsx +++ b/apps/meteor/client/navbar/NavBarSettingsToolbar/hooks/useAdministrationMenu.spec.tsx @@ -3,7 +3,7 @@ import { renderHook, waitFor } from '@testing-library/react'; import { useAdministrationMenu } from './useAdministrationMenu'; -it('should return omnichannel item if has `view-livechat-manager` permission', async () => { +it('should return omnichannel item if has `view-livechat-manager` permission ', async () => { const { result } = renderHook(() => useAdministrationMenu(), { wrapper: mockAppRoot() .withEndpoint('GET', '/v1/licenses.info', () => ({ diff --git a/apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx b/apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx index 47e7cdd4e8eda..d32e6ec52a411 100644 --- a/apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx +++ b/apps/meteor/client/providers/AuthenticationProvider/AuthenticationProvider.tsx @@ -73,7 +73,7 @@ const AuthenticationProvider = ({ children }: AuthenticationProviderProps): Reac const loginWithService = `loginWith${loginMethods[serviceName] || capitalize(String(serviceName || ''))}`; - const method: (config: unknown, cb: (error: any) => void) => Promise = (Meteor as any)[loginWithService]; + const method: (config: unknown, cb: (error: any) => void) => Promise = (Meteor as any)[loginWithService] as any; if (!method) { return () => Promise.reject(new Error('Login method not found')); diff --git a/apps/meteor/client/router/index.tsx b/apps/meteor/client/router/index.tsx index 297507ab70823..04083e9f89834 100644 --- a/apps/meteor/client/router/index.tsx +++ b/apps/meteor/client/router/index.tsx @@ -220,7 +220,7 @@ export class Router implements RouterContextValue { readonly getLocationPathname = () => this.current?.path.replace(/\?.*/, '') as LocationPathname; - readonly getLocationSearch = () => location.search; + readonly getLocationSearch = () => location.search as LocationSearch; readonly getRouteParameters = () => (this.current?.params ? (Object.fromEntries(this.current.params.entries()) as RouteParameters) : {}); diff --git a/apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx b/apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx index c1ac9b141007f..445c5607c672e 100644 --- a/apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx +++ b/apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx @@ -161,6 +161,7 @@ const keys: (keyof RoomListRowProps)[] = [ 'videoConfActions', ]; +// eslint-disable-next-line react/no-multi-comp export default memo(SidebarItemTemplateWithData, (prevProps, nextProps) => { if (keys.some((key) => prevProps[key] !== nextProps[key])) { return false; diff --git a/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesForm.spec.tsx b/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesForm.spec.tsx index 9b5f5de2f0573..84927e6427a5a 100644 --- a/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesForm.spec.tsx +++ b/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesForm.spec.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { composeStories } from '@storybook/react'; import { render, screen, waitFor } from '@testing-library/react'; diff --git a/apps/meteor/client/views/admin/EditableSettingsContext.ts b/apps/meteor/client/views/admin/EditableSettingsContext.ts index d0c65e841032b..4b16e344db796 100644 --- a/apps/meteor/client/views/admin/EditableSettingsContext.ts +++ b/apps/meteor/client/views/admin/EditableSettingsContext.ts @@ -149,7 +149,7 @@ export const useEditableSettingsDispatch = (): ((changes: Partial state.mutate); }; -export const useEditableSettingVisibilityQuery = (query?: ISetting['enableQuery']): boolean => { +export const useEditableSettingVisibilityQuery = (query?: ISetting['enableQuery'] | ISetting['displayQuery']): boolean => { const { useEditableSettingsStore } = useContext(EditableSettingsContext); return useEditableSettingsStore((state) => { diff --git a/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx b/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx index cb98cc60e0f61..326531a20e9c6 100644 --- a/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx +++ b/apps/meteor/client/views/admin/customEmoji/CustomEmoji.tsx @@ -114,7 +114,7 @@ const CustomEmoji = ({ onClick, reload }: CustomEmojiProps) => { /> )} - {isSuccess && data?.emojis.length === 0 && } + {isSuccess && data && data.emojis.length === 0 && } {isError && ( diff --git a/apps/meteor/client/views/admin/customEmoji/EditCustomEmojiWithData.tsx b/apps/meteor/client/views/admin/customEmoji/EditCustomEmojiWithData.tsx index 24e9d769eae9b..a593e67333c7b 100644 --- a/apps/meteor/client/views/admin/customEmoji/EditCustomEmojiWithData.tsx +++ b/apps/meteor/client/views/admin/customEmoji/EditCustomEmojiWithData.tsx @@ -32,7 +32,7 @@ const EditCustomEmojiWithData = ({ _id, onChange, close, ...props }: EditCustomE return ; } - if (error || !data?.emojis || data.emojis.update.length < 1) { + if (error || !data || !data.emojis || data.emojis.update.length < 1) { return ; } diff --git a/apps/meteor/client/views/admin/engagementDashboard/channels/useChannelsList.ts b/apps/meteor/client/views/admin/engagementDashboard/channels/useChannelsList.ts index 4ba36195551f9..c8e9c82e74698 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/channels/useChannelsList.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/channels/useChannelsList.ts @@ -10,6 +10,7 @@ type UseChannelsListOptions = { count: number; }; +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useChannelsList = ({ period, offset, count }: UseChannelsListOptions) => { const getChannelsList = useEndpoint('GET', '/v1/engagement-dashboard/channels/list'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/messages/useMessageOrigins.ts b/apps/meteor/client/views/admin/engagementDashboard/messages/useMessageOrigins.ts index 33cc6327476c9..b451840427cd8 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/messages/useMessageOrigins.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/messages/useMessageOrigins.ts @@ -6,6 +6,7 @@ import { getPeriodRange } from '../../../../components/dashboards/periods'; type UseMessageOriginsOptions = { period: Period['key'] }; +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useMessageOrigins = ({ period }: UseMessageOriginsOptions) => { const getMessageOrigins = useEndpoint('GET', '/v1/engagement-dashboard/messages/origin'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/messages/useMessagesSent.ts b/apps/meteor/client/views/admin/engagementDashboard/messages/useMessagesSent.ts index 92c7c8911f4f8..a8e3bfe8bed1c 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/messages/useMessagesSent.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/messages/useMessagesSent.ts @@ -6,6 +6,7 @@ import { getPeriodRange } from '../../../../components/dashboards/periods'; type UseMessagesSentOptions = { period: Period['key']; utc: boolean }; +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useMessagesSent = ({ period, utc }: UseMessagesSentOptions) => { const getMessagesSent = useEndpoint('GET', '/v1/engagement-dashboard/messages/messages-sent'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/messages/useTopFivePopularChannels.ts b/apps/meteor/client/views/admin/engagementDashboard/messages/useTopFivePopularChannels.ts index 9e4f8828b63e5..bc6780a3e1270 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/messages/useTopFivePopularChannels.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/messages/useTopFivePopularChannels.ts @@ -6,6 +6,7 @@ import { getPeriodRange } from '../../../../components/dashboards/periods'; type UseTopFivePopularChannelsOptions = { period: Period['key'] }; +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useTopFivePopularChannels = ({ period }: UseTopFivePopularChannelsOptions) => { const getTopFivePopularChannels = useEndpoint('GET', '/v1/engagement-dashboard/messages/top-five-popular-channels'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/users/useActiveUsers.ts b/apps/meteor/client/views/admin/engagementDashboard/users/useActiveUsers.ts index 2c92ffc7456dd..cb5c7d6939047 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/users/useActiveUsers.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/users/useActiveUsers.ts @@ -5,6 +5,7 @@ import { getPeriodRange } from '../../../../components/dashboards/periods'; type UseActiveUsersOptions = { utc: boolean }; +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useActiveUsers = ({ utc }: UseActiveUsersOptions) => { const getActiveUsers = useEndpoint('GET', '/v1/engagement-dashboard/users/active-users'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/users/useHourlyChatActivity.ts b/apps/meteor/client/views/admin/engagementDashboard/users/useHourlyChatActivity.ts index b314c949147c4..7870cd8105c78 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/users/useHourlyChatActivity.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/users/useHourlyChatActivity.ts @@ -7,6 +7,7 @@ type UseHourlyChatActivityOptions = { utc: boolean; }; +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useHourlyChatActivity = ({ displacement, utc }: UseHourlyChatActivityOptions) => { const getHourlyChatActivity = useEndpoint('GET', '/v1/engagement-dashboard/users/chat-busier/hourly-data'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/users/useUsersByTimeOfTheDay.ts b/apps/meteor/client/views/admin/engagementDashboard/users/useUsersByTimeOfTheDay.ts index cb5f1b78cd895..4118edce0f1cd 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/users/useUsersByTimeOfTheDay.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/users/useUsersByTimeOfTheDay.ts @@ -6,6 +6,7 @@ import { getPeriodRange } from '../../../../components/dashboards/periods'; type UseUsersByTimeOfTheDayOptions = { period: Period['key']; utc: boolean }; +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useUsersByTimeOfTheDay = ({ period, utc }: UseUsersByTimeOfTheDayOptions) => { const getUsersByTimeOfTheDay = useEndpoint('GET', '/v1/engagement-dashboard/users/users-by-time-of-the-day-in-a-week'); diff --git a/apps/meteor/client/views/admin/engagementDashboard/users/useWeeklyChatActivity.ts b/apps/meteor/client/views/admin/engagementDashboard/users/useWeeklyChatActivity.ts index b0b6c99add788..6f9c0bde042df 100644 --- a/apps/meteor/client/views/admin/engagementDashboard/users/useWeeklyChatActivity.ts +++ b/apps/meteor/client/views/admin/engagementDashboard/users/useWeeklyChatActivity.ts @@ -7,6 +7,7 @@ type UseWeeklyChatActivityOptions = { utc: boolean; }; +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const useWeeklyChatActivity = ({ displacement, utc }: UseWeeklyChatActivityOptions) => { const getWeeklyChatActivity = useEndpoint('GET', '/v1/engagement-dashboard/users/chat-busier/weekly-data'); diff --git a/apps/meteor/client/views/admin/integrations/IntegrationsTable.tsx b/apps/meteor/client/views/admin/integrations/IntegrationsTable.tsx index 611dbc12e0371..f80ec353cc056 100644 --- a/apps/meteor/client/views/admin/integrations/IntegrationsTable.tsx +++ b/apps/meteor/client/views/admin/integrations/IntegrationsTable.tsx @@ -131,7 +131,7 @@ const IntegrationsTable = ({ type }: { type?: string }) => { /> )} - {isSuccess && data?.integrations.length === 0 && } + {isSuccess && data && data.integrations.length === 0 && } {isError && ( diff --git a/apps/meteor/client/views/admin/integrations/outgoing/OutgoingWebhookForm.tsx b/apps/meteor/client/views/admin/integrations/outgoing/OutgoingWebhookForm.tsx index ab29f359a5129..00e8d6aea8e78 100644 --- a/apps/meteor/client/views/admin/integrations/outgoing/OutgoingWebhookForm.tsx +++ b/apps/meteor/client/views/admin/integrations/outgoing/OutgoingWebhookForm.tsx @@ -71,7 +71,10 @@ const OutgoingWebhookForm = () => { [t], ); - const eventOptions: SelectOption[] = useMemo(() => Object.entries(outgoingEvents).map(([key, val]) => [key, t(val.label)]), [t]); + const eventOptions: SelectOption[] = useMemo( + () => Object.entries(outgoingEvents).map(([key, val]) => [key, t(val.label as TranslationKey)]), + [t], + ); const scriptEngineOptions: SelectOption[] = useMemo(() => [['isolated-vm', t('Script_Engine_isolated_vm')]], [t]); diff --git a/apps/meteor/client/views/admin/invites/InvitesPage.tsx b/apps/meteor/client/views/admin/invites/InvitesPage.tsx index 6ab2eddd84866..efc94915cdf7a 100644 --- a/apps/meteor/client/views/admin/invites/InvitesPage.tsx +++ b/apps/meteor/client/views/admin/invites/InvitesPage.tsx @@ -111,7 +111,7 @@ const InvitesPage = (): ReactElement => { )} - {isSuccess && data?.length === 0 && } + {isSuccess && data && data.length === 0 && } {isError && ( diff --git a/apps/meteor/client/views/audit/hooks/useAuditTab.ts b/apps/meteor/client/views/audit/hooks/useAuditTab.ts index 20b0dfc151046..42d24c5af3c00 100644 --- a/apps/meteor/client/views/audit/hooks/useAuditTab.ts +++ b/apps/meteor/client/views/audit/hooks/useAuditTab.ts @@ -11,7 +11,7 @@ const typeToTabMap: Record = { 'l': 'omnichannel', }; -const tabToTabMap = new Map(Object.entries(typeToTabMap).map(([type, tab]) => [tab, type])); +const tabToTabMap = new Map(Object.entries(typeToTabMap).map(([type, tab]) => [tab, type as IAuditLog['fields']['type']])); export const useAuditTab = () => { const tab = useRouteParameter('tab'); diff --git a/apps/meteor/client/views/e2e/EnterE2EPasswordModal/EnterE2EPasswordModal.spec.tsx b/apps/meteor/client/views/e2e/EnterE2EPasswordModal/EnterE2EPasswordModal.spec.tsx index 1130500962d78..0eb37d9037ad0 100644 --- a/apps/meteor/client/views/e2e/EnterE2EPasswordModal/EnterE2EPasswordModal.spec.tsx +++ b/apps/meteor/client/views/e2e/EnterE2EPasswordModal/EnterE2EPasswordModal.spec.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { composeStories } from '@storybook/react'; import { render, screen } from '@testing-library/react'; diff --git a/apps/meteor/client/views/marketplace/AppDetailsPage/AppDetailsPage.tsx b/apps/meteor/client/views/marketplace/AppDetailsPage/AppDetailsPage.tsx index 58fea5f46cade..eed2e5003868d 100644 --- a/apps/meteor/client/views/marketplace/AppDetailsPage/AppDetailsPage.tsx +++ b/apps/meteor/client/views/marketplace/AppDetailsPage/AppDetailsPage.tsx @@ -92,7 +92,7 @@ const AppDetailsPage = ({ id }: AppDetailsPageProps): ReactElement => { try { await AppClientOrchestratorInstance.setAppSettings( id, - Object.values(settings || {}).map((setting) => ({ + (Object.values(settings || {}) as ISetting[]).map((setting) => ({ ...setting, value: data[setting.id], })), diff --git a/apps/meteor/client/views/marketplace/helpers.ts b/apps/meteor/client/views/marketplace/helpers.ts index ed2ce3ce8244f..7f40f8f32f177 100644 --- a/apps/meteor/client/views/marketplace/helpers.ts +++ b/apps/meteor/client/views/marketplace/helpers.ts @@ -225,7 +225,7 @@ export const appStatusSpanProps = ( }; } - const isOnTrialPeriod = subscriptionInfo?.status === 'trialing'; + const isOnTrialPeriod = subscriptionInfo && subscriptionInfo.status === 'trialing'; if (isOnTrialPeriod) { return { icon: 'checkmark-circled', diff --git a/apps/meteor/client/views/marketplace/hooks/useAppInfo.ts b/apps/meteor/client/views/marketplace/hooks/useAppInfo.ts index c6fc3fecebdc3..c562017ef1899 100644 --- a/apps/meteor/client/views/marketplace/hooks/useAppInfo.ts +++ b/apps/meteor/client/views/marketplace/hooks/useAppInfo.ts @@ -64,8 +64,8 @@ export const useAppInfo = (appId: string, context: string): AppInfo | undefined appVersion: appId, }) .then(({ app }: any) => { - appResult.tosLink = app.tosLink; - appResult.privacyLink = app.privacyLink; + (appResult as App).tosLink = app.tosLink; + (appResult as App).privacyLink = app.privacyLink; return getBundledInApp(app); }) .catch(() => ({ diff --git a/apps/meteor/client/views/modal/uikit/ModalBlock.tsx b/apps/meteor/client/views/modal/uikit/ModalBlock.tsx index fbfb2be5746fb..ff102f00e773e 100644 --- a/apps/meteor/client/views/modal/uikit/ModalBlock.tsx +++ b/apps/meteor/client/views/modal/uikit/ModalBlock.tsx @@ -113,7 +113,7 @@ const ModalBlock = ({ view, errors, onSubmit, onClose, onCancel }: ModalBlockPar if (!ref.current) { return; } - const elements = Array.from(ref.current.querySelectorAll(focusableElementsString)); + const elements = Array.from(ref.current.querySelectorAll(focusableElementsString)) as HTMLElement[]; const [first] = elements; const last = elements.pop(); @@ -161,7 +161,7 @@ const ModalBlock = ({ view, errors, onSubmit, onClose, onCancel }: ModalBlockPar if (!container.contains(e.target as HTMLElement)) { return; } - return handleKeyDown(e); + return handleKeyDown(e as KeyboardEvent); }; document.addEventListener('keydown', ignoreIfNotContains); diff --git a/apps/meteor/client/views/navigation/sidebar/RoomList/SidebarItemWithData.tsx b/apps/meteor/client/views/navigation/sidebar/RoomList/SidebarItemWithData.tsx index 3c6f0458a3d9d..79b933e59ca3d 100644 --- a/apps/meteor/client/views/navigation/sidebar/RoomList/SidebarItemWithData.tsx +++ b/apps/meteor/client/views/navigation/sidebar/RoomList/SidebarItemWithData.tsx @@ -89,6 +89,7 @@ function safeDateNotEqualCheck(a: Date | string | undefined, b: Date | string | const keys: (keyof RoomListRowProps)[] = ['id', 'style', 't', 'videoConfActions']; +// eslint-disable-next-line react/no-multi-comp export default memo(SidebarItemWithData, (prevProps, nextProps) => { if (keys.some((key) => prevProps[key] !== nextProps[key])) { return false; diff --git a/apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.tsx b/apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.tsx index 1dd5ce480ad72..92e1e8475d433 100644 --- a/apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.tsx +++ b/apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.tsx @@ -52,7 +52,7 @@ const SidePanelInternal = ({ title, currentTab, unreadOnly, toggleUnreadOnly, ro - {rooms?.length === 0 && } + {rooms && rooms.length === 0 && } - {tagsResult?.tags?.length ? ( + {tagsResult?.tags && tagsResult?.tags.length ? ( { const data = await getContact({ contactId }); // TODO: Can be safely removed once unknown contacts handling is added to the endpoint - if (data?.contact?.unknown) { + if (data?.contact && data.contact.unknown) { throw new ContactNotFoundError(); } @@ -149,7 +149,7 @@ const RecipientForm = (props: RecipientFormProps) => { }, [clearErrors, isErrorProvider, validateProviderField]); useEffect(() => { - isDirty && onDirty?.(); + isDirty && onDirty && onDirty(); }, [isDirty, onDirty]); const submit = useEffectEvent(async (values: RecipientFormData) => { diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/forms/RepliesForm/RepliesForm.spec.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/forms/RepliesForm/RepliesForm.spec.tsx index f391bcf2e0c6c..886543e008ba3 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/forms/RepliesForm/RepliesForm.spec.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/forms/RepliesForm/RepliesForm.spec.tsx @@ -136,7 +136,7 @@ describe('RepliesForm', () => { expect(screen.getByLabelText('Agent (optional)')).toBeDisabled(); }); - it.skip('should render with default values', async () => { + xit('should render with default values', async () => { const defaultValues = { departmentId: 'department-1', agentId: 'agent-1', @@ -183,7 +183,7 @@ describe('RepliesForm', () => { await waitFor(() => expect(screen.queryByText('Error loading department information')).not.toBeInTheDocument()); }); - it.skip('should call submit with correct values when form is submitted', async () => { + xit('should call submit with correct values when form is submitted', async () => { const handleSubmit = jest.fn(); const defaultValues = { departmentId: 'department-1', diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.spec.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.spec.tsx index 022ac3229dc04..95339ff897cfe 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.spec.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.spec.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { WizardContext, StepsLinkedList } from '@rocket.chat/ui-client'; import { composeStories } from '@storybook/react'; diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.stories.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.stories.tsx index 7b87753ca5ec7..4960d4ac70299 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.stories.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/MessageStep.stories.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import { Box } from '@rocket.chat/fuselage'; import { WizardContext, StepsLinkedList } from '@rocket.chat/ui-client'; import { action } from '@storybook/addon-actions'; diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.spec.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.spec.tsx index 54e65e93f21d1..448a0f96dfc45 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.spec.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.spec.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { WizardContext, StepsLinkedList } from '@rocket.chat/ui-client'; import { composeStories } from '@storybook/react'; diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.stories.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.stories.tsx index e1e2643af82df..003bf14150b13 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.stories.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RecipientStep.stories.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import { Box } from '@rocket.chat/fuselage'; import { mockAppRoot } from '@rocket.chat/mock-providers'; import { WizardContext, StepsLinkedList } from '@rocket.chat/ui-client'; diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.spec.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.spec.tsx index f4b346c557c99..382b766579ad1 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.spec.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.spec.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { WizardContext, StepsLinkedList } from '@rocket.chat/ui-client'; import { composeStories } from '@storybook/react'; diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.stories.tsx b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.stories.tsx index c9c5396d7e640..391ef96567ec4 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.stories.tsx +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/components/OutboundMessageWizard/steps/RepliesStep.stories.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import { faker } from '@faker-js/faker'; import { Box } from '@rocket.chat/fuselage'; import { mockAppRoot } from '@rocket.chat/mock-providers'; diff --git a/apps/meteor/client/views/omnichannel/components/outboundMessage/utils/template.spec.ts b/apps/meteor/client/views/omnichannel/components/outboundMessage/utils/template.spec.ts index a605e3ce15699..99e1b06fcdc7b 100644 --- a/apps/meteor/client/views/omnichannel/components/outboundMessage/utils/template.spec.ts +++ b/apps/meteor/client/views/omnichannel/components/outboundMessage/utils/template.spec.ts @@ -55,7 +55,7 @@ describe('processTemplatePreviewText', () => { expect(text).toBe('Hello World'); }); - it('should keep the placeholder in case the parameter is an empty string', () => { + it('it should keep the placeholder in case the parameter is an empty string', () => { const text = processTemplatePreviewText('Hello {{1}}', [{ type: 'text', value: '', format: 'text' }]); expect(text).toBe('Hello {{1}}'); diff --git a/apps/meteor/client/views/omnichannel/directory/hooks/useDisplayFilters.ts b/apps/meteor/client/views/omnichannel/directory/hooks/useDisplayFilters.ts index c99de88ff0b93..8a7b38b50ed64 100644 --- a/apps/meteor/client/views/omnichannel/directory/hooks/useDisplayFilters.ts +++ b/apps/meteor/client/views/omnichannel/directory/hooks/useDisplayFilters.ts @@ -41,5 +41,5 @@ export const useDisplayFilters = (filtersQuery: ChatsFiltersQuery) => { }; const parseMultiSelect = (data: PaginatedMultiSelectOption[]) => { - return data.map((a) => a.label.split(' (')[0]).join(', '); + return data.map((a) => (a.label as string).split(' (')[0]).join(', '); }; diff --git a/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts b/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts index 9e0997dd5fcde..b4e24c3fff608 100644 --- a/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts +++ b/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts @@ -81,7 +81,7 @@ export const useComposerBoxPopup = ( setFocused((focused) => { const sortedItems = items .filter((item) => item.isSuccess) - .flatMap((item) => item.data) + .flatMap((item) => item.data as T[]) .sort((a, b) => (('sort' in a && a.sort) || 0) - (('sort' in b && b.sort) || 0)); return sortedItems.find((item) => item._id === focused?._id) ?? sortedItems[0]; }); @@ -194,7 +194,7 @@ export const useComposerBoxPopup = ( setFocused((focused) => { const list = items .filter((item) => item.isSuccess) - .flatMap((item) => item.data) + .flatMap((item) => item.data as T[]) .sort((a, b) => (('sort' in a && a.sort) || 0) - (('sort' in b && b.sort) || 0)); if (!list) { @@ -203,7 +203,7 @@ export const useComposerBoxPopup = ( const focusedIndex = list.findIndex((item) => item === focused); - return focusedIndex > 0 ? list[focusedIndex - 1] : list[list.length - 1]; + return (focusedIndex > 0 ? list[focusedIndex - 1] : list[list.length - 1]) as T; }); event.preventDefault(); event.stopImmediatePropagation(); @@ -213,7 +213,7 @@ export const useComposerBoxPopup = ( setFocused((focused) => { const list = items .filter((item) => item.isSuccess) - .flatMap((item) => item.data) + .flatMap((item) => item.data as T[]) .sort((a, b) => (('sort' in a && a.sort) || 0) - (('sort' in b && b.sort) || 0)); if (!list) { @@ -222,7 +222,7 @@ export const useComposerBoxPopup = ( const focusedIndex = list.findIndex((item) => item === focused); - return focusedIndex < list.length - 1 ? list[focusedIndex + 1] : list[0]; + return (focusedIndex < list.length - 1 ? list[focusedIndex + 1] : list[0]) as T; }); event.preventDefault(); event.stopImmediatePropagation(); diff --git a/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopupQueries.ts b/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopupQueries.ts index 4394338db2e6d..76a68f14d85b1 100644 --- a/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopupQueries.ts +++ b/apps/meteor/client/views/room/composer/hooks/useComposerBoxPopupQueries.ts @@ -27,17 +27,17 @@ export const useComposerBoxPopupQueries = popup?.getItemsFromLocal?.(filter) || [], + queryFn: () => (popup?.getItemsFromLocal && popup.getItemsFromLocal(filter)) || [], enabled: enableQuery, }, { placeholderData: keepPreviousData, queryKey: ['message-popup', 'server', filter, popup], - queryFn: () => popup?.getItemsFromServer?.(filter) || [], + queryFn: () => (popup?.getItemsFromServer && popup.getItemsFromServer(filter)) || [], enabled: counter > 0, }, ], - }); + }) as QueriesResults; useEffect(() => { if (Array.isArray(queries[0].data) && queries[0].data.length < 5) { diff --git a/apps/meteor/client/views/room/composer/hooks/useMessageComposerIsArchived.ts b/apps/meteor/client/views/room/composer/hooks/useMessageComposerIsArchived.ts index 16a29ac1b9079..4417288d78f8c 100644 --- a/apps/meteor/client/views/room/composer/hooks/useMessageComposerIsArchived.ts +++ b/apps/meteor/client/views/room/composer/hooks/useMessageComposerIsArchived.ts @@ -1,4 +1,4 @@ import type { IRoom, ISubscription } from '@rocket.chat/core-typings'; export const useMessageComposerIsArchived = (room: IRoom, subscription?: ISubscription): boolean => - !!room?.archived || Boolean(subscription?.t === 'd' && subscription.archived); + !!room?.archived || Boolean(subscription && subscription.t === 'd' && subscription.archived); diff --git a/apps/meteor/client/views/room/composer/messageBox/MessageBoxActionsToolbar/MessageBoxActionsToolbar.tsx b/apps/meteor/client/views/room/composer/messageBox/MessageBoxActionsToolbar/MessageBoxActionsToolbar.tsx index fd1acc5f2907e..9a1ed5db7c80a 100644 --- a/apps/meteor/client/views/room/composer/messageBox/MessageBoxActionsToolbar/MessageBoxActionsToolbar.tsx +++ b/apps/meteor/client/views/room/composer/messageBox/MessageBoxActionsToolbar/MessageBoxActionsToolbar.tsx @@ -112,7 +112,7 @@ const MessageBoxActionsToolbar = ({ .filter((item) => !hiddenActions.includes(item.id)) .map((item) => ({ id: item.id, - icon: item.icon, + icon: item.icon as ComponentProps['name'], content: t(item.label), onClick: (event?: MouseEvent) => item.action({ diff --git a/apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoActions.tsx b/apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoActions.tsx index 7f16f95cfd8b1..082e5c867306d 100644 --- a/apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoActions.tsx +++ b/apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoActions.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react/display-name, react/no-multi-comp */ import type { IRoom, IUser } from '@rocket.chat/core-typings'; import { ButtonGroup, IconButton, Skeleton } from '@rocket.chat/fuselage'; import { GenericMenu } from '@rocket.chat/ui-client'; diff --git a/apps/meteor/client/views/room/contextualBar/VideoConference/hooks/useVideoConfOpenCall.tsx b/apps/meteor/client/views/room/contextualBar/VideoConference/hooks/useVideoConfOpenCall.tsx index d77fd1107e235..ec3e448050c06 100644 --- a/apps/meteor/client/views/room/contextualBar/VideoConference/hooks/useVideoConfOpenCall.tsx +++ b/apps/meteor/client/views/room/contextualBar/VideoConference/hooks/useVideoConfOpenCall.tsx @@ -7,7 +7,7 @@ export const useVideoConfOpenCall = () => { const setModal = useSetModal(); const handleOpenCall = useCallback( - (callUrl: string, providerName?: string) => { + (callUrl: string, providerName?: string | undefined) => { const desktopApp = window.RocketChatDesktop; if (!desktopApp?.openInternalVideoChatWindow) { diff --git a/apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.spec.tsx b/apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.spec.tsx index 2cdd7240ca28f..1730a9151f2fc 100644 --- a/apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.spec.tsx +++ b/apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.spec.tsx @@ -1,7 +1,7 @@ import { mockAppRoot } from '@rocket.chat/mock-providers'; import { useCurrentRoutePath, useRouter } from '@rocket.chat/ui-contexts'; import { render } from '@testing-library/react'; -import type React from 'react'; +import React from 'react'; import LayoutWithSidebar from './LayoutWithSidebar'; diff --git a/apps/meteor/client/views/root/hooks/loggedIn/useUnread.ts b/apps/meteor/client/views/root/hooks/loggedIn/useUnread.ts index 8655a770c1de5..e27a91ed62e33 100644 --- a/apps/meteor/client/views/root/hooks/loggedIn/useUnread.ts +++ b/apps/meteor/client/views/root/hooks/loggedIn/useUnread.ts @@ -35,7 +35,7 @@ export const useUnread = () => { const { rid, unread: unreadValue, alert, unreadAlert: subscriptionUnreadAlert } = subscription; const prev = prevSubsRef.current.get(rid); // Emit per-sub event only if something that influences unread UI changed. - if (prev?.unread !== unreadValue || prev.alert !== alert || prev.unreadAlert !== subscriptionUnreadAlert) { + if (!prev || prev.unread !== unreadValue || prev.alert !== alert || prev.unreadAlert !== subscriptionUnreadAlert) { fireEventUnreadChangedBySubscription(subscription); } nextSnapshot.set(rid, { unread: unreadValue, alert, unreadAlert: subscriptionUnreadAlert }); diff --git a/apps/meteor/client/views/teams/ChannelDesertionTable/ChannelDesertionTable.tsx b/apps/meteor/client/views/teams/ChannelDesertionTable/ChannelDesertionTable.tsx index de4d6b02813f0..7df0d6f7ac710 100644 --- a/apps/meteor/client/views/teams/ChannelDesertionTable/ChannelDesertionTable.tsx +++ b/apps/meteor/client/views/teams/ChannelDesertionTable/ChannelDesertionTable.tsx @@ -40,7 +40,10 @@ const ChannelDesertionTable = ({ const direction = sortDirection === 'asc' ? 1 : -1; - return rooms.sort((a, b) => (a[sortBy] && b[sortBy] ? (a[sortBy]?.localeCompare(b[sortBy] ?? '') ?? 1) * direction : direction)); + return rooms.sort((a, b) => + // eslint-disable-next-line no-nested-ternary + a[sortBy] && b[sortBy] ? (a[sortBy]?.localeCompare(b[sortBy] ?? '') ?? 1) * direction : direction, + ); }, [rooms, sortBy, sortDirection]); return ( diff --git a/apps/meteor/definition/externals/meteor/accounts-base.d.ts b/apps/meteor/definition/externals/meteor/accounts-base.d.ts index a3ad8478ba3c8..875b3cb5291e6 100644 --- a/apps/meteor/definition/externals/meteor/accounts-base.d.ts +++ b/apps/meteor/definition/externals/meteor/accounts-base.d.ts @@ -65,6 +65,7 @@ declare module 'meteor/accounts-base' { export const _options: AccountsServerOptions; + // eslint-disable-next-line @typescript-eslint/no-namespace namespace oauth { function credentialRequestCompleteHandler( callback?: (error?: globalThis.Error | Meteor.Error | Meteor.TypedError) => void, diff --git a/apps/meteor/ee/app/livechat-enterprise/server/api/lib/inquiries.ts b/apps/meteor/ee/app/livechat-enterprise/server/api/lib/inquiries.ts index 5e28f63f2981b..c86dd1a9cb03b 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/api/lib/inquiries.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/api/lib/inquiries.ts @@ -4,7 +4,7 @@ import { updateRoomSLA } from './sla'; export async function setSLAToInquiry({ userId, roomId, sla }: { userId: string; roomId: string; sla?: string }): Promise { const inquiry = await LivechatInquiry.findOneByRoomId(roomId, { projection: { status: 1 } }); - if (inquiry?.status !== 'queued') { + if (!inquiry || inquiry.status !== 'queued') { throw new Error('error-invalid-inquiry'); } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts b/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts index 5c358d5b8ffee..89a28af413420 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHold.ts @@ -28,7 +28,7 @@ const handleAfterOnHold = async (room: Pick): Promise('Livechat_auto_close_on_hold_chats_timeout', (value) => { - autoCloseOnHoldChatTimeout = value; + autoCloseOnHoldChatTimeout = value as number; if (!value || value <= 0) { callbacks.remove('livechat:afterOnHold', 'livechat-auto-close-on-hold'); } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts b/apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts index 16776d415934c..57f29a4d87ede 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts @@ -177,7 +177,7 @@ export const LivechatEnterprise = { async removeSLA(executedBy: string, _id: string) { const removedResult = await OmnichannelServiceLevelAgreements.removeById(_id); - if (removedResult?.deletedCount !== 1) { + if (!removedResult || removedResult.deletedCount !== 1) { throw new Error(`SLA with id ${_id} not found`); } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/lib/QueueInactivityMonitor.ts b/apps/meteor/ee/app/livechat-enterprise/server/lib/QueueInactivityMonitor.ts index f91e51a8ed21f..2d1842da65fcf 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/lib/QueueInactivityMonitor.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/lib/QueueInactivityMonitor.ts @@ -112,7 +112,7 @@ export class OmnichannelQueueInactivityMonitorClass { const { inquiryId } = data; // TODO: add projection and maybe use findOneQueued to avoid fetching the whole inquiry const inquiry = await LivechatInquiryRaw.findOneById(inquiryId); - if (inquiry?.status !== 'queued') { + if (!inquiry || inquiry.status !== 'queued') { return; } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts b/apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts index 1e71e9623f64c..ed81fa5f6f5d8 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/lib/VisitorInactivityMonitor.ts @@ -11,7 +11,7 @@ import { settings } from '../../../../../app/settings/server'; import { callbacks } from '../../../../../server/lib/callbacks'; import { i18n } from '../../../../../server/lib/i18n'; -const isPromiseRejectedResult = (result: any): result is PromiseRejectedResult => result?.status === 'rejected'; +const isPromiseRejectedResult = (result: any): result is PromiseRejectedResult => result && result.status === 'rejected'; export class VisitorInactivityMonitor { _started: boolean; diff --git a/apps/meteor/ee/app/livechat-enterprise/server/lib/debounceByParams.ts b/apps/meteor/ee/app/livechat-enterprise/server/lib/debounceByParams.ts index 323f7a2464618..24dd03e9c6d2d 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/lib/debounceByParams.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/lib/debounceByParams.ts @@ -9,7 +9,10 @@ interface IMemoizeDebouncedFunction any> { // Debounce `func` based on passed parameters // ref: https://github.com/lodash/lodash/issues/2403#issuecomment-816137402 export function memoizeDebounce any>(func: F, wait = 0, options: any = {}): IMemoizeDebouncedFunction { - const debounceMemo = mem((..._args: Parameters) => debounce(func, wait, options)); + const debounceMemo = mem( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + (..._args: Parameters) => debounce(func, wait, options), + ); function wrappedFunction(this: IMemoizeDebouncedFunction, ...args: Parameters): ReturnType | undefined { return debounceMemo(...args)(...args); diff --git a/apps/meteor/ee/server/api/audit.ts b/apps/meteor/ee/server/api/audit.ts index 32b4d7987ace3..fbbbde91fff30 100644 --- a/apps/meteor/ee/server/api/audit.ts +++ b/apps/meteor/ee/server/api/audit.ts @@ -154,11 +154,11 @@ API.v1.get( async function action() { const { start, end, settingId, actor } = this.queryParams; - if (start && isNaN(Date.parse(start))) { + if (start && isNaN(Date.parse(start as string))) { return API.v1.failure('The "start" query parameter must be a valid date.'); } - if (end && isNaN(Date.parse(end))) { + if (end && isNaN(Date.parse(end as string))) { return API.v1.failure('The "end" query parameter must be a valid date.'); } @@ -171,8 +171,8 @@ API.v1.get( ...(settingId && { 'data.key': 'id', 'data.value': settingId }), ...(actor && convertSubObjectsIntoPaths({ actor })), ts: { - $gte: start ? new Date(start) : new Date(0), - $lte: end ? new Date(end) : new Date(), + $gte: start ? new Date(start as string) : new Date(0), + $lte: end ? new Date(end as string) : new Date(), }, t: 'settings.changed', }, diff --git a/apps/meteor/ee/server/api/engagementDashboard/channels.ts b/apps/meteor/ee/server/api/engagementDashboard/channels.ts index 02513d396750c..96f2d5776ac02 100644 --- a/apps/meteor/ee/server/api/engagementDashboard/channels.ts +++ b/apps/meteor/ee/server/api/engagementDashboard/channels.ts @@ -14,7 +14,7 @@ declare module '@rocket.chat/rest-typings' { channels: { room: { _id: IRoom['_id']; - name: IRoom['name']; + name: IRoom['name'] | IRoom['fname']; ts: IRoom['ts']; t: IRoom['t']; _updatedAt: IRoom['_updatedAt']; diff --git a/apps/meteor/ee/server/api/engagementDashboard/messages.ts b/apps/meteor/ee/server/api/engagementDashboard/messages.ts index ffd6dfd1e90b0..d048369ca502a 100644 --- a/apps/meteor/ee/server/api/engagementDashboard/messages.ts +++ b/apps/meteor/ee/server/api/engagementDashboard/messages.ts @@ -25,7 +25,7 @@ declare module '@rocket.chat/rest-typings' { channels: { t: IRoom['t']; messages: number; - name: IRoom['name']; + name: IRoom['name'] | IRoom['fname']; usernames?: IDirectMessageRoom['usernames']; }[]; }; diff --git a/apps/meteor/ee/server/api/sessions.ts b/apps/meteor/ee/server/api/sessions.ts index 605ba70030ace..64e9531024255 100644 --- a/apps/meteor/ee/server/api/sessions.ts +++ b/apps/meteor/ee/server/api/sessions.ts @@ -209,7 +209,7 @@ API.v1.addRoute( return API.v1.forbidden(); } - const sessionId = this.queryParams?.sessionId; + const sessionId = this.queryParams?.sessionId as string; const { sessions } = await Sessions.aggregateSessionsAndPopulate({ search: sessionId, count: 1 }); if (!sessions?.length) { return API.v1.notFound('Session not found'); diff --git a/apps/meteor/ee/server/apps/communication/endpoints/appsCountHandler.ts b/apps/meteor/ee/server/apps/communication/endpoints/appsCountHandler.ts index 5d82fcd97aec7..402ceb709a16a 100644 --- a/apps/meteor/ee/server/apps/communication/endpoints/appsCountHandler.ts +++ b/apps/meteor/ee/server/apps/communication/endpoints/appsCountHandler.ts @@ -11,7 +11,7 @@ export const registerAppsCountHandler = ({ api, _manager }: AppsRestApi) => { authRequired: false }, { async get() { - const manager = _manager; + const manager = _manager as AppManager; const apps = await manager.get({ enabled: true }); const { maxMarketplaceApps, maxPrivateApps } = License.getAppsConfig(); diff --git a/apps/meteor/ee/server/apps/communication/uikit.ts b/apps/meteor/ee/server/apps/communication/uikit.ts index 6780c83077e12..1dcd1c169d578 100644 --- a/apps/meteor/ee/server/apps/communication/uikit.ts +++ b/apps/meteor/ee/server/apps/communication/uikit.ts @@ -48,7 +48,7 @@ Meteor.startup(() => { // use specific rate limit of 600 (which is 60 times the default limits) requests per minute (around 10/second) const apiLimiter = rateLimit({ windowMs: settings.get('API_Enable_Rate_Limiter_Limit_Time_Default'), - max: settings.get('API_Enable_Rate_Limiter_Limit_Calls_Default') * 60, + max: (settings.get('API_Enable_Rate_Limiter_Limit_Calls_Default') as number) * 60, skip: () => settings.get('API_Enable_Rate_Limiter') !== true || (process.env.NODE_ENV === 'development' && settings.get('API_Enable_Rate_Limiter_Dev') !== true), diff --git a/apps/meteor/ee/server/configuration/saml.ts b/apps/meteor/ee/server/configuration/saml.ts index dc522592eebd5..6ab5f10926233 100644 --- a/apps/meteor/ee/server/configuration/saml.ts +++ b/apps/meteor/ee/server/configuration/saml.ts @@ -9,7 +9,7 @@ import { addSettings } from '../settings/saml'; await License.onLicense('saml-enterprise', () => { SAMLUtils.events.on('mapUser', async ({ profile, userObject }: { profile: Record; userObject: ISAMLUser }) => { - const roleAttributeName = settings.get('SAML_Custom_Default_role_attribute_name'); + const roleAttributeName = settings.get('SAML_Custom_Default_role_attribute_name') as string; const roleAttributeSync = settings.get('SAML_Custom_Default_role_attribute_sync'); if (!roleAttributeSync) { @@ -48,7 +48,7 @@ await License.onLicense('saml-enterprise', () => { }); SAMLUtils.events.on('updateCustomFields', async (loginResult: Record, updatedUser: { userId: string; token: string }) => { - const userDataCustomFieldMap = settings.get('SAML_Custom_Default_user_data_custom_fieldmap'); + const userDataCustomFieldMap = settings.get('SAML_Custom_Default_user_data_custom_fieldmap') as string; const customMap: Record = JSON.parse(userDataCustomFieldMap); const customFieldsList: Record = {}; diff --git a/apps/meteor/ee/server/lib/engagementDashboard/channels.ts b/apps/meteor/ee/server/lib/engagementDashboard/channels.ts index 7da22d7415624..a71d7c99b21df 100644 --- a/apps/meteor/ee/server/lib/engagementDashboard/channels.ts +++ b/apps/meteor/ee/server/lib/engagementDashboard/channels.ts @@ -20,7 +20,7 @@ export const findChannelsWithNumberOfMessages = async ({ channels: { room: { _id: IRoom['_id']; - name: IRoom['name']; + name: IRoom['name'] | IRoom['fname']; ts: IRoom['ts']; t: IRoom['t']; _updatedAt: IRoom['_updatedAt']; diff --git a/apps/meteor/ee/server/lib/engagementDashboard/messages.ts b/apps/meteor/ee/server/lib/engagementDashboard/messages.ts index edd1c3eb6fead..55bcae0da3aeb 100644 --- a/apps/meteor/ee/server/lib/engagementDashboard/messages.ts +++ b/apps/meteor/ee/server/lib/engagementDashboard/messages.ts @@ -143,7 +143,7 @@ export const findTopFivePopularChannelsByMessageSentQuantity = async ({ channels: { t: IRoom['t']; messages: number; - name: IRoom['name']; + name: IRoom['name'] | IRoom['fname']; usernames?: IDirectMessageRoom['usernames']; }[]; }> => { diff --git a/apps/meteor/ee/server/lib/ldap/Manager.ts b/apps/meteor/ee/server/lib/ldap/Manager.ts index f8b2cc5ba8a1e..a8ec3d84d9769 100644 --- a/apps/meteor/ee/server/lib/ldap/Manager.ts +++ b/apps/meteor/ee/server/lib/ldap/Manager.ts @@ -299,7 +299,7 @@ export class LDAPEEManager extends LDAPManager { return; } - const roles = await Roles.find( + const roles = (await Roles.find( {}, { projection: { @@ -307,7 +307,7 @@ export class LDAPEEManager extends LDAPManager { name: 1, }, }, - ).toArray(); + ).toArray()) as Array; if (!roles) { return; diff --git a/apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts b/apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts index c886d93fcd1ce..76befbd38b004 100644 --- a/apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts +++ b/apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts @@ -10,7 +10,7 @@ import { i18n } from '../i18n'; const hideUserName = (username: string, userData: Pick | undefined, usersMap: Record) => { if (!usersMap[username]) { - if (username === userData?.username) { + if (userData && username === userData.username) { usersMap[username] = username; } else { usersMap[username] = `User_${Object.keys(usersMap).length + 1}`; @@ -49,7 +49,7 @@ const getAttachmentData = (attachment: MessageAttachment, message: IMessage) => }; export type MessageData = Pick & { - username?: IUser['username']; + username?: IUser['username'] | IUser['name']; attachments?: ReturnType[]; type?: IMessage['t']; }; diff --git a/apps/meteor/server/lib/dataExport/sendEmail.ts b/apps/meteor/server/lib/dataExport/sendEmail.ts index a3dde11f78b07..88ae72d738326 100644 --- a/apps/meteor/server/lib/dataExport/sendEmail.ts +++ b/apps/meteor/server/lib/dataExport/sendEmail.ts @@ -12,7 +12,7 @@ export const sendEmail = async (userData: Pick, subjec } const to = `${userData.name} <${emailAddress}>`; - const from = settings.get('From_Email'); + const from = settings.get('From_Email') as string; if (!Mailer.checkAddressFormat(emailAddress)) { return; diff --git a/apps/meteor/server/lib/http/call.ts b/apps/meteor/server/lib/http/call.ts index 290744fd0e8b9..bf03cb449506f 100644 --- a/apps/meteor/server/lib/http/call.ts +++ b/apps/meteor/server/lib/http/call.ts @@ -187,7 +187,7 @@ function httpCallAsync(httpMethod: string, url: string, callback: callbackFn): v function httpCallAsync(httpMethod: string, url: string, optionsOrCallback: HttpCallOptions | callbackFn = {}, callback?: callbackFn): void { // If the options argument was omitted, adjust the arguments: if (!callback && typeof optionsOrCallback === 'function') { - return _call(httpMethod, url, {}, optionsOrCallback); + return _call(httpMethod, url, {}, optionsOrCallback as callbackFn); } return _call(httpMethod, url, optionsOrCallback as HttpCallOptions, callback as callbackFn); diff --git a/apps/meteor/server/lib/i18n.ts b/apps/meteor/server/lib/i18n.ts index 93a4e9b366579..86265b8d378bf 100644 --- a/apps/meteor/server/lib/i18n.ts +++ b/apps/meteor/server/lib/i18n.ts @@ -87,7 +87,7 @@ void i18n.init({ language, extractTranslationNamespaces( // TODO: commonjs is terrible but we don't have esm build yet - // eslint-disable-next-line import/no-dynamic-require + // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require require(`@rocket.chat/i18n/dist/resources/${language}.i18n.json`) as unknown as Record, ), ]), diff --git a/apps/meteor/server/lib/ldap/Manager.ts b/apps/meteor/server/lib/ldap/Manager.ts index 4874068556e4b..1dac8ad89ed52 100644 --- a/apps/meteor/server/lib/ldap/Manager.ts +++ b/apps/meteor/server/lib/ldap/Manager.ts @@ -171,7 +171,7 @@ export class LDAPManager { }; } - protected static mapUserData(ldapUser: ILDAPEntry, usedUsername?: string): IImportUser { + protected static mapUserData(ldapUser: ILDAPEntry, usedUsername?: string | undefined): IImportUser { const uniqueId = this.getLdapUserUniqueID(ldapUser); if (!uniqueId) { throw new Error('Failed to generate unique identifier for ldap entry'); @@ -364,7 +364,7 @@ export class LDAPManager { private static async syncUserForLogin( ldapUser: ILDAPEntry, existingUser?: IUser, - usedUsername?: string, + usedUsername?: string | undefined, ): Promise { logger.debug({ msg: 'Syncing user data', diff --git a/apps/meteor/server/lib/rooms/roomTypes/private.ts b/apps/meteor/server/lib/rooms/roomTypes/private.ts index 69df98e9878c9..5349c1da133d2 100644 --- a/apps/meteor/server/lib/rooms/roomTypes/private.ts +++ b/apps/meteor/server/lib/rooms/roomTypes/private.ts @@ -35,7 +35,7 @@ roomCoordinator.add(PrivateRoomType, { }, async allowMemberAction(_room, action, _userId) { - if (isRoomFederated(_room)) { + if (isRoomFederated(_room as IRoom)) { if (isRoomNativeFederated(_room) && isFederationEnabled()) { return true; } diff --git a/apps/meteor/server/lib/rooms/roomTypes/public.ts b/apps/meteor/server/lib/rooms/roomTypes/public.ts index b83ee23c615f3..ead4609c11c8d 100644 --- a/apps/meteor/server/lib/rooms/roomTypes/public.ts +++ b/apps/meteor/server/lib/rooms/roomTypes/public.ts @@ -35,7 +35,7 @@ roomCoordinator.add(PublicRoomType, { }, async allowMemberAction(_room, action, _userId) { - if (isRoomFederated(_room)) { + if (isRoomFederated(_room as IRoom)) { if (isRoomNativeFederated(_room) && isFederationEnabled()) { return true; } diff --git a/apps/meteor/server/services/analytics/service.ts b/apps/meteor/server/services/analytics/service.ts index 8608913cb9009..de454fb64bcec 100644 --- a/apps/meteor/server/services/analytics/service.ts +++ b/apps/meteor/server/services/analytics/service.ts @@ -11,7 +11,7 @@ export class AnalyticsService extends ServiceClassInternal implements IAnalytics } async getSeatRequestCount(): Promise { - const result = await Analytics.findOne({ type: 'seat-request' }, {}); + const result = (await Analytics.findOne({ type: 'seat-request' }, {})) as IAnalyticsSeatRequest | null; return result?.count ? result.count : 0; } diff --git a/apps/meteor/server/services/image/service.ts b/apps/meteor/server/services/image/service.ts index c0306c36d5f75..85b4d2d05f979 100644 --- a/apps/meteor/server/services/image/service.ts +++ b/apps/meteor/server/services/image/service.ts @@ -40,7 +40,7 @@ export class MediaService extends ServiceClassInternal implements IMediaService keepType: boolean, blur: boolean, enlarge: boolean, - fit?: keyof sharp.FitEnum, + fit?: keyof sharp.FitEnum | undefined, ): Promise { const stream = this.bufferToStream(input); return this.resizeFromStream(stream, width, height, keepType, blur, enlarge, fit); @@ -53,7 +53,7 @@ export class MediaService extends ServiceClassInternal implements IMediaService keepType: boolean, blur: boolean, enlarge: boolean, - fit?: keyof sharp.FitEnum, + fit?: keyof sharp.FitEnum | undefined, ): Promise { const transformer = sharp().resize({ width, height, fit, withoutEnlargement: !enlarge }); diff --git a/apps/meteor/server/services/meteor/userReactivity.ts b/apps/meteor/server/services/meteor/userReactivity.ts index c9c9f93485e4a..eb1b10eacee62 100644 --- a/apps/meteor/server/services/meteor/userReactivity.ts +++ b/apps/meteor/server/services/meteor/userReactivity.ts @@ -82,7 +82,7 @@ export const processOnChange = (diff: Record, id: string): void => const cbs = userCallbacks.get(id); if (cbs) { [...cbs] - .filter(({ hashedToken }) => !tokens?.includes(hashedToken)) + .filter(({ hashedToken }) => tokens === undefined || !tokens.includes(hashedToken)) .forEach((item) => { item.callbacks.removed(id); cbs.delete(item); diff --git a/apps/meteor/server/services/omnichannel-analytics/AgentData.ts b/apps/meteor/server/services/omnichannel-analytics/AgentData.ts index 709566f50b10b..49717f8e7b783 100644 --- a/apps/meteor/server/services/omnichannel-analytics/AgentData.ts +++ b/apps/meteor/server/services/omnichannel-analytics/AgentData.ts @@ -145,7 +145,7 @@ export class AgentOverviewData { }; await this.roomsModel.getAnalyticsMetricsBetweenDate('l', date, { departmentId }, extraQuery).forEach(({ metrics, servedBy }) => { - if (servedBy && metrics?.chatDuration) { + if (servedBy && metrics && metrics.chatDuration) { if (agentChatDurations.has(servedBy.username)) { agentChatDurations.set(servedBy.username, { chatDuration: agentChatDurations.get(servedBy.username).chatDuration + metrics.chatDuration, @@ -237,7 +237,7 @@ export class AgentOverviewData { }; await this.roomsModel.getAnalyticsMetricsBetweenDate('l', date, { departmentId }, extraQuery).forEach(({ metrics, responseBy }) => { - if (responseBy && metrics?.response?.ft) { + if (responseBy && metrics && metrics.response && metrics.response.ft) { if (agentAvgRespTime.has(responseBy.username)) { agentAvgRespTime.set(responseBy.username, { frt: agentAvgRespTime.get(responseBy.username).frt + metrics.response.ft, @@ -287,7 +287,7 @@ export class AgentOverviewData { }; await this.roomsModel.getAnalyticsMetricsBetweenDate('l', date, { departmentId }, extraQuery).forEach(({ metrics, responseBy }) => { - if (responseBy && metrics?.response?.ft) { + if (responseBy && metrics && metrics.response && metrics.response.ft) { if (agentFirstRespTime.has(responseBy.username)) { agentFirstRespTime.set(responseBy.username, Math.min(agentFirstRespTime.get(responseBy.username), metrics.response.ft)); } else { @@ -329,7 +329,7 @@ export class AgentOverviewData { }; await this.roomsModel.getAnalyticsMetricsBetweenDate('l', date, { departmentId }, extraQuery).forEach(({ metrics, servedBy }) => { - if (servedBy && metrics?.response?.avg) { + if (servedBy && metrics && metrics.response && metrics.response.avg) { if (agentAvgRespTime.has(servedBy.username)) { agentAvgRespTime.set(servedBy.username, { avg: agentAvgRespTime.get(servedBy.username).avg + metrics.response.avg, @@ -379,7 +379,7 @@ export class AgentOverviewData { }; await this.roomsModel.getAnalyticsMetricsBetweenDate('l', date, { departmentId }, extraQuery).forEach(({ metrics, servedBy }) => { - if (servedBy && metrics?.reaction?.ft) { + if (servedBy && metrics && metrics.reaction && metrics.reaction.ft) { if (agentAvgReactionTime.has(servedBy.username)) { agentAvgReactionTime.set(servedBy.username, { frt: agentAvgReactionTime.get(servedBy.username).frt + metrics.reaction.ft, diff --git a/apps/meteor/server/services/omnichannel-analytics/service.ts b/apps/meteor/server/services/omnichannel-analytics/service.ts index a665979de4910..24ce8ded79f2a 100644 --- a/apps/meteor/server/services/omnichannel-analytics/service.ts +++ b/apps/meteor/server/services/omnichannel-analytics/service.ts @@ -1,3 +1,4 @@ +/* eslint-disable new-cap */ import { ServiceClassInternal } from '@rocket.chat/core-services'; import type { AgentOverviewDataOptions, diff --git a/apps/meteor/server/services/team/service.ts b/apps/meteor/server/services/team/service.ts index 431c912eb7048..9d5b3bb0356ab 100644 --- a/apps/meteor/server/services/team/service.ts +++ b/apps/meteor/server/services/team/service.ts @@ -204,7 +204,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { async search

( userId: string, term: string | RegExp, - options?: FindOptions | FindOptions

, + options?: undefined | FindOptions | FindOptions

, ): Promise { if (typeof term === 'string') { term = new RegExp(`^${escapeRegExp(term)}`, 'i'); @@ -296,7 +296,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { async listByNames

( names: Array, - options?: FindOptions | FindOptions

, + options?: undefined | FindOptions | FindOptions

, ): Promise { if (options === undefined) { return Team.findByNames(names).toArray(); @@ -497,7 +497,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { listTeamsBySubscriberUserId

( uid: string, - options?: FindOptions | FindOptions

, + options?: undefined | FindOptions | FindOptions

, ): Promise { if (options) { return TeamMember.findByUserId(uid, options).toArray(); @@ -893,7 +893,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { getAllPublicTeams(options: FindOptions): Promise; - async getAllPublicTeams(options?: FindOptions): Promise { + async getAllPublicTeams(options?: undefined | FindOptions): Promise { return options ? Team.findByType(TeamType.PUBLIC, options).toArray() : Team.findByType(TeamType.PUBLIC).toArray(); } @@ -908,7 +908,7 @@ export class TeamService extends ServiceClassInternal implements ITeamService { async getOneByName(teamName: string | RegExp, options: FindOptions): Promise; - async getOneByName(teamName: string | RegExp, options?: FindOptions): Promise { + async getOneByName(teamName: string | RegExp, options?: undefined | FindOptions): Promise { if (!options) { return Team.findOneByName(teamName); } diff --git a/apps/meteor/server/startup/migrations/v294.ts b/apps/meteor/server/startup/migrations/v294.ts index 2c1dd74a8d69c..07f6dc2acc1fe 100644 --- a/apps/meteor/server/startup/migrations/v294.ts +++ b/apps/meteor/server/startup/migrations/v294.ts @@ -14,7 +14,7 @@ addMigration({ Apps.initialize(); - const sigMan = Apps.getManager()?.getSignatureManager(); + const sigMan = Apps.getManager()?.getSignatureManager() as AppSignatureManager; const appsStorage = Apps.getStorage() as AppRealStorage; const apps = await appsStorage.retrieveAll(); diff --git a/apps/meteor/server/startup/migrations/v304.ts b/apps/meteor/server/startup/migrations/v304.ts index 26d4ff3c00737..48cb217643d05 100644 --- a/apps/meteor/server/startup/migrations/v304.ts +++ b/apps/meteor/server/startup/migrations/v304.ts @@ -8,7 +8,11 @@ addMigration({ async up() { const indexes = await Analytics.col.indexes(); - if (indexes.find((index) => index.name === 'room._id_1_date_1' && index.partialFilterExpression?.type === 'rooms')) { + if ( + indexes.find( + (index) => index.name === 'room._id_1_date_1' && index.partialFilterExpression && index.partialFilterExpression.type === 'rooms', + ) + ) { return; } diff --git a/apps/meteor/server/startup/migrations/v307.ts b/apps/meteor/server/startup/migrations/v307.ts index 1a4b7099a35c0..d16d16220edc8 100644 --- a/apps/meteor/server/startup/migrations/v307.ts +++ b/apps/meteor/server/startup/migrations/v307.ts @@ -21,7 +21,7 @@ addMigration({ Apps.initialize(); - const sigMan = Apps.getManager()?.getSignatureManager(); + const sigMan = Apps.getManager()?.getSignatureManager() as AppSignatureManager; const appsStorage = Apps.getStorage() as AppRealStorage; const apps = await appsStorage.retrieveAllPrivate(); diff --git a/apps/meteor/server/ufs/ufs-server.ts b/apps/meteor/server/ufs/ufs-server.ts index 42da2a597eb2e..34b3422981a63 100644 --- a/apps/meteor/server/ufs/ufs-server.ts +++ b/apps/meteor/server/ufs/ufs-server.ts @@ -176,6 +176,7 @@ WebApp.connectHandlers.use(async (req, res, next) => { if ( (file.modifiedAt instanceof Date && file.modifiedAt > modifiedSince) || + // eslint-disable-next-line no-mixed-operators (file.uploadedAt instanceof Date && file.uploadedAt > modifiedSince) ) { res.writeHead(304); // Not Modified diff --git a/apps/meteor/server/ufs/ufs-store.ts b/apps/meteor/server/ufs/ufs-store.ts index a4e3f6417aef7..3c6d6c983850f 100644 --- a/apps/meteor/server/ufs/ufs-store.ts +++ b/apps/meteor/server/ufs/ufs-store.ts @@ -240,6 +240,7 @@ export class Store { generateToken(pattern?: string) { return (pattern || 'xyxyxyxyxy').replace(/[xy]/g, (c) => { + // eslint-disable-next-line no-mixed-operators const r = (Math.random() * 16) | 0; const v = c === 'x' ? r : (r & 0x3) | 0x8; const s = v.toString(16); diff --git a/apps/meteor/tests/data/rooms.helper.ts b/apps/meteor/tests/data/rooms.helper.ts index 8d53fc5c6e7f9..24857005970ff 100644 --- a/apps/meteor/tests/data/rooms.helper.ts +++ b/apps/meteor/tests/data/rooms.helper.ts @@ -294,6 +294,7 @@ export const findRoomMember = async ( await new Promise((resolve) => setTimeout(resolve, initialDelay)); } + // eslint-disable-next-line no-await-in-loop for (let attempt = 1; attempt <= maxRetries; attempt++) { try { // eslint-disable-next-line no-await-in-loop diff --git a/apps/meteor/tests/e2e/e2e-encryption/e2ee-legacy-format.spec.ts b/apps/meteor/tests/e2e/e2e-encryption/e2ee-legacy-format.spec.ts index 6bb04acf26fe4..342761526ccf4 100644 --- a/apps/meteor/tests/e2e/e2e-encryption/e2ee-legacy-format.spec.ts +++ b/apps/meteor/tests/e2e/e2e-encryption/e2ee-legacy-format.spec.ts @@ -72,7 +72,7 @@ test.describe('E2EE Legacy Format', () => { await page.evaluate( async ({ rid, kid, encryptedKey }) => { - // eslint-disable-next-line import/no-absolute-path + // eslint-disable-next-line import/no-unresolved, @typescript-eslint/no-var-requires, import/no-absolute-path, @typescript-eslint/consistent-type-imports const { e2e } = require('/client/lib/e2ee/rocketchat.e2e.ts') as typeof import('../../../client/lib/e2ee/rocketchat.e2e'); const room = await e2e.getInstanceByRoomId(rid); await room?.importGroupKey(kid + encryptedKey); diff --git a/apps/meteor/tests/e2e/page-objects/login.ts b/apps/meteor/tests/e2e/page-objects/login.ts index 7b81c91f6513f..dcf3e4802484c 100644 --- a/apps/meteor/tests/e2e/page-objects/login.ts +++ b/apps/meteor/tests/e2e/page-objects/login.ts @@ -46,7 +46,7 @@ export class LoginPage { items.forEach(({ name, value }) => { window.localStorage.setItem(name, value); }); - + // eslint-disable-next-line @typescript-eslint/no-var-requires require('meteor/accounts-base').Accounts._pollStoredLoginToken(); }, localStorageItems); diff --git a/apps/meteor/tests/unit/app/license/server/canEnableApp.spec.ts b/apps/meteor/tests/unit/app/license/server/canEnableApp.spec.ts index 694f50f99c07f..0cb68734fb462 100644 --- a/apps/meteor/tests/unit/app/license/server/canEnableApp.spec.ts +++ b/apps/meteor/tests/unit/app/license/server/canEnableApp.spec.ts @@ -35,6 +35,7 @@ const getDefaultApp = (): IAppStorageItem => ({ }); // We will be passing promises to the `expect` function +/* eslint-disable @typescript-eslint/no-floating-promises */ describe('canEnableApp', () => { it('should throw the message "apps-engine-not-initialized" when appropriate', () => { diff --git a/apps/meteor/tests/unit/server/services/omnichannel-analytics/AgentData.tests.ts b/apps/meteor/tests/unit/server/services/omnichannel-analytics/AgentData.tests.ts index fbbda13a7e2a4..7e3003332d503 100644 --- a/apps/meteor/tests/unit/server/services/omnichannel-analytics/AgentData.tests.ts +++ b/apps/meteor/tests/unit/server/services/omnichannel-analytics/AgentData.tests.ts @@ -70,7 +70,7 @@ describe('AgentData Analytics', () => { try { // @ts-expect-error - test - + // eslint-disable-next-line prettier/prettier, no-return-await await agentOverview.callAction('invalid', moment(), moment()); } catch (e) { expect(e).to.be.instanceOf(Error); From aecf0484712bad05db25592df9ffd312ebeb578d Mon Sep 17 00:00:00 2001 From: alchemycodess Date: Thu, 5 Mar 2026 02:13:12 +0530 Subject: [PATCH 5/5] fix: apply eslint fixes to migrated files only --- apps/meteor/app/api/server/v1/chat.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/meteor/app/api/server/v1/chat.ts b/apps/meteor/app/api/server/v1/chat.ts index 50fc5165f7387..1aae3fe767a29 100644 --- a/apps/meteor/app/api/server/v1/chat.ts +++ b/apps/meteor/app/api/server/v1/chat.ts @@ -410,17 +410,17 @@ const chatEndpoints = API.v1 this.userId, hasContent ? { - _id: msg._id, - rid: msg.rid, - content: bodyParams.content, - ...(bodyParams.e2eMentions && { e2eMentions: bodyParams.e2eMentions }), - } + _id: msg._id, + rid: msg.rid, + content: bodyParams.content, + ...(bodyParams.e2eMentions && { e2eMentions: bodyParams.e2eMentions }), + } : { - _id: msg._id, - rid: msg.rid, - msg: bodyParams.text, - ...(bodyParams.customFields && { customFields: bodyParams.customFields }), - }, + _id: msg._id, + rid: msg.rid, + msg: bodyParams.text, + ...(bodyParams.customFields && { customFields: bodyParams.customFields }), + }, 'previewUrls' in bodyParams ? bodyParams.previewUrls : undefined, ]; @@ -1072,5 +1072,5 @@ export type ChatEndpoints = ExtractRoutesFromAPI; declare module '@rocket.chat/rest-typings' { // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface - interface Endpoints extends ChatEndpoints { } + interface Endpoints extends ChatEndpoints {} }