diff --git a/eslint.config.js b/eslint.config.js index 73edff5d..944d7c81 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -97,6 +97,14 @@ export default [ // Genuine shift and mask work in discordCollectibles.ts and cryptE2ERoomKeys.js. 'no-bitwise': 'off', + // 60 of the 61 findings are property mutations on objects the caller passes in, and the + // callers depend on the mutation. Reassigning the parameter itself is still a finding. + 'no-param-reassign': ['error', { props: false }], + + // The sequential awaits here are deliberate: the rate-limit delays in Permissions.tsx and + // the endpoint poll loop in backgroundSync.ts break if the awaits are parallelised. + 'no-await-in-loop': 'off', + '@typescript-eslint/no-unused-vars': 'error', '@typescript-eslint/no-shadow': 'error', }, diff --git a/src/app/components/editor/Editor.tsx b/src/app/components/editor/Editor.tsx index 8fc82a7c..39f38073 100644 --- a/src/app/components/editor/Editor.tsx +++ b/src/app/components/editor/Editor.tsx @@ -1,4 +1,3 @@ -/* eslint-disable no-param-reassign */ import React, { ClipboardEventHandler, KeyboardEventHandler, diff --git a/src/app/components/editor/input.ts b/src/app/components/editor/input.ts index b6e5dfa1..ad19558c 100644 --- a/src/app/components/editor/input.ts +++ b/src/app/components/editor/input.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-param-reassign */ import { Descendant, Text } from 'slate'; import parse from 'html-dom-parser'; import { ChildNode, Element, isText, isTag } from 'domhandler'; diff --git a/src/app/components/editor/utils.ts b/src/app/components/editor/utils.ts index 4fc38c39..9a215a42 100644 --- a/src/app/components/editor/utils.ts +++ b/src/app/components/editor/utils.ts @@ -149,7 +149,6 @@ export const resetEditor = (editor: Editor) => { }; export const resetEditorHistory = (editor: Editor) => { - // eslint-disable-next-line no-param-reassign editor.history = { undos: [], redos: [], diff --git a/src/app/components/join-space-prompt/JoinSpacePrompt.tsx b/src/app/components/join-space-prompt/JoinSpacePrompt.tsx index 8980f88e..d1fd449f 100644 --- a/src/app/components/join-space-prompt/JoinSpacePrompt.tsx +++ b/src/app/components/join-space-prompt/JoinSpacePrompt.tsx @@ -209,7 +209,6 @@ export function JoinSpacePrompt({ }); while (pageCount < MAX_PAGES) { - // eslint-disable-next-line no-await-in-loop const result = await Promise.race([ mx.getRoomHierarchy(joinedSpaceId, PER_PAGE_COUNT, undefined, false, nextBatch), timeoutPromise, diff --git a/src/app/features/common-settings/emojis-stickers/RoomPacks.tsx b/src/app/features/common-settings/emojis-stickers/RoomPacks.tsx index bb1df3d3..f4f79aa9 100644 --- a/src/app/features/common-settings/emojis-stickers/RoomPacks.tsx +++ b/src/app/features/common-settings/emojis-stickers/RoomPacks.tsx @@ -162,7 +162,6 @@ export function RoomPacks({ onViewPack }: RoomPacksProps) { useCallback(async () => { for (let i = 0; i < removedPacks.length; i += 1) { const addr = removedPacks[i]; - // eslint-disable-next-line no-await-in-loop await mx.sendStateEvent(room.roomId, StateEvent.PoniesRoomEmotes as any, {}, addr.stateKey); } }, [mx, room, removedPacks]), diff --git a/src/app/features/common-settings/general/RoomAddress.tsx b/src/app/features/common-settings/general/RoomAddress.tsx index 9cee3839..c967f769 100644 --- a/src/app/features/common-settings/general/RoomAddress.tsx +++ b/src/app/features/common-settings/general/RoomAddress.tsx @@ -236,7 +236,6 @@ function LocalAddressesList({ async (aliases: string[]) => { for (let i = 0; i < aliases.length; i += 1) { const alias = aliases[i]; - // eslint-disable-next-line no-await-in-loop await removeLocalAlias(alias); } }, diff --git a/src/app/hooks/useAutoJoinSpaceRooms.ts b/src/app/hooks/useAutoJoinSpaceRooms.ts index 166a005c..e4b1e180 100644 --- a/src/app/hooks/useAutoJoinSpaceRooms.ts +++ b/src/app/hooks/useAutoJoinSpaceRooms.ts @@ -70,7 +70,6 @@ async function fetchSpaceHierarchy(mx: MatrixClient, spaceId: string): Promise { let token: string | undefined = eventContext.start; while (token) { - // eslint-disable-next-line no-await-in-loop const response = await mx.createMessagesRequest( room.roomId, token, @@ -475,7 +474,6 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { const eventIds = eventsToDelete.map((roomEvent) => roomEvent.event_id); - // eslint-disable-next-line no-await-in-loop await rateLimitedActions(eventIds, (eventId) => mx.redactEvent(room.roomId, eventId, undefined, { reason }), ); diff --git a/src/app/hooks/usePowerLevels.ts b/src/app/hooks/usePowerLevels.ts index ae141272..e709ffdf 100644 --- a/src/app/hooks/usePowerLevels.ts +++ b/src/app/hooks/usePowerLevels.ts @@ -46,12 +46,10 @@ const fillMissingPowers = (powerLevels: IPowerLevels): IPowerLevels => const keys = Object.keys(DEFAULT_POWER_LEVELS) as unknown as (keyof IPowerLevels)[]; keys.forEach((key) => { if (draftPl[key] === undefined) { - // eslint-disable-next-line no-param-reassign draftPl[key] = DEFAULT_POWER_LEVELS[key] as any; } }); if (draftPl.notifications && typeof draftPl.notifications.room !== 'number') { - // eslint-disable-next-line no-param-reassign draftPl.notifications.room = DEFAULT_POWER_LEVELS.notifications.room; } return draftPl; @@ -236,23 +234,19 @@ export const applyPermissionPower = ( if (typeof location.key === 'string') { const users = powerLevels.users ?? {}; users[location.key] = power; - // eslint-disable-next-line no-param-reassign powerLevels.users = users; return powerLevels; } - // eslint-disable-next-line no-param-reassign powerLevels.users_default = power; return powerLevels; } if ('action' in location) { - // eslint-disable-next-line no-param-reassign powerLevels[location.key] = power; return powerLevels; } if ('notification' in location) { const notifications = powerLevels.notifications ?? {}; notifications[location.key] = power; - // eslint-disable-next-line no-param-reassign powerLevels.notifications = notifications; return powerLevels; } @@ -260,11 +254,9 @@ export const applyPermissionPower = ( if (typeof location.key === 'string') { const events = powerLevels.events ?? {}; events[location.key] = power; - // eslint-disable-next-line no-param-reassign powerLevels.events = events; return powerLevels; } - // eslint-disable-next-line no-param-reassign powerLevels.state_default = power; return powerLevels; } @@ -272,11 +264,9 @@ export const applyPermissionPower = ( if (typeof location.key === 'string') { const events = powerLevels.events ?? {}; events[location.key] = power; - // eslint-disable-next-line no-param-reassign powerLevels.events = events; return powerLevels; } - // eslint-disable-next-line no-param-reassign powerLevels.events_default = power; return powerLevels; }; diff --git a/src/app/utils/matrix.ts b/src/app/utils/matrix.ts index c8dba727..9121eb4e 100644 --- a/src/app/utils/matrix.ts +++ b/src/app/utils/matrix.ts @@ -396,10 +396,8 @@ export const rateLimitedActions = async ( for (let i = 0; i < data.length; i += 1) { const dataItem = data[i]; retryCount = 0; - // eslint-disable-next-line no-await-in-loop await performAction(dataItem, i); if (actionInterval > 0) { - // eslint-disable-next-line no-await-in-loop await sleepForMs(actionInterval); } } diff --git a/src/app/utils/telegramStickerImport.ts b/src/app/utils/telegramStickerImport.ts index bec9e34e..98aefb3e 100644 --- a/src/app/utils/telegramStickerImport.ts +++ b/src/app/utils/telegramStickerImport.ts @@ -217,11 +217,9 @@ export async function importTelegramStickerPack( try { // Get file path from Telegram - // eslint-disable-next-line no-await-in-loop const filePath = await getFilePath(botToken, sticker.file_id); // Download the sticker - // eslint-disable-next-line no-await-in-loop let blob = await downloadFile(botToken, filePath); // Generate a shortcode from emoji or index @@ -235,20 +233,17 @@ export async function importTelegramStickerPack( // Convert animated stickers to GIF if (isAnimated && filePath.endsWith('.tgs')) { onProgress?.(i + 1, total, `Converting animated sticker ${i + 1}/${total} to GIF...`); - // eslint-disable-next-line no-await-in-loop blob = await tgsToGif(blob, sticker.width, sticker.height); finalMimeType = 'image/gif'; extension = 'gif'; } else if (isVideo && filePath.endsWith('.webm')) { onProgress?.(i + 1, total, `Converting video sticker ${i + 1}/${total} to GIF...`); - // eslint-disable-next-line no-await-in-loop blob = await webmToGif(blob, sticker.width, sticker.height); finalMimeType = 'image/gif'; extension = 'gif'; } // Upload to Matrix - // eslint-disable-next-line no-await-in-loop const mxcUrl = await uploadToMatrix(mx, blob, `${shortcode}.${extension}`); // Add to images diff --git a/src/util/cryptE2ERoomKeys.js b/src/util/cryptE2ERoomKeys.js index 7da95ab4..c8dde889 100644 --- a/src/util/cryptE2ERoomKeys.js +++ b/src/util/cryptE2ERoomKeys.js @@ -267,8 +267,7 @@ export async function decryptMegolmKeyFile(data, password) { * key-derivation function. * @return {Promise} promise for encrypted output */ -export async function encryptMegolmKeyFile(data, password, options) { - options = options || {}; +export async function encryptMegolmKeyFile(data, password, options = {}) { const kdfRounds = options.kdf_rounds || 500000; const salt = new Uint8Array(16);