Drop the mutation and sequential-await rules and the stale directives. [skip build]
Checks / checks (push) Successful in 2m6s
Trigger cinny-mobile / dispatch (push) Successful in 1s

This commit is contained in:
2026-11-02 00:09:28 +11:00
parent 48db806dd7
commit 45f38f2ac8
13 changed files with 9 additions and 28 deletions
+8
View File
@@ -97,6 +97,14 @@ export default [
// Genuine shift and mask work in discordCollectibles.ts and cryptE2ERoomKeys.js. // Genuine shift and mask work in discordCollectibles.ts and cryptE2ERoomKeys.js.
'no-bitwise': 'off', '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-unused-vars': 'error',
'@typescript-eslint/no-shadow': 'error', '@typescript-eslint/no-shadow': 'error',
}, },
-1
View File
@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import React, { import React, {
ClipboardEventHandler, ClipboardEventHandler,
KeyboardEventHandler, KeyboardEventHandler,
-1
View File
@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import { Descendant, Text } from 'slate'; import { Descendant, Text } from 'slate';
import parse from 'html-dom-parser'; import parse from 'html-dom-parser';
import { ChildNode, Element, isText, isTag } from 'domhandler'; import { ChildNode, Element, isText, isTag } from 'domhandler';
-1
View File
@@ -149,7 +149,6 @@ export const resetEditor = (editor: Editor) => {
}; };
export const resetEditorHistory = (editor: Editor) => { export const resetEditorHistory = (editor: Editor) => {
// eslint-disable-next-line no-param-reassign
editor.history = { editor.history = {
undos: [], undos: [],
redos: [], redos: [],
@@ -209,7 +209,6 @@ export function JoinSpacePrompt({
}); });
while (pageCount < MAX_PAGES) { while (pageCount < MAX_PAGES) {
// eslint-disable-next-line no-await-in-loop
const result = await Promise.race([ const result = await Promise.race([
mx.getRoomHierarchy(joinedSpaceId, PER_PAGE_COUNT, undefined, false, nextBatch), mx.getRoomHierarchy(joinedSpaceId, PER_PAGE_COUNT, undefined, false, nextBatch),
timeoutPromise, timeoutPromise,
@@ -162,7 +162,6 @@ export function RoomPacks({ onViewPack }: RoomPacksProps) {
useCallback(async () => { useCallback(async () => {
for (let i = 0; i < removedPacks.length; i += 1) { for (let i = 0; i < removedPacks.length; i += 1) {
const addr = removedPacks[i]; const addr = removedPacks[i];
// eslint-disable-next-line no-await-in-loop
await mx.sendStateEvent(room.roomId, StateEvent.PoniesRoomEmotes as any, {}, addr.stateKey); await mx.sendStateEvent(room.roomId, StateEvent.PoniesRoomEmotes as any, {}, addr.stateKey);
} }
}, [mx, room, removedPacks]), }, [mx, room, removedPacks]),
@@ -236,7 +236,6 @@ function LocalAddressesList({
async (aliases: string[]) => { async (aliases: string[]) => {
for (let i = 0; i < aliases.length; i += 1) { for (let i = 0; i < aliases.length; i += 1) {
const alias = aliases[i]; const alias = aliases[i];
// eslint-disable-next-line no-await-in-loop
await removeLocalAlias(alias); await removeLocalAlias(alias);
} }
}, },
-1
View File
@@ -70,7 +70,6 @@ async function fetchSpaceHierarchy(mx: MatrixClient, spaceId: string): Promise<I
while (pageCount < MAX_PAGES) { while (pageCount < MAX_PAGES) {
try { try {
// eslint-disable-next-line no-await-in-loop
const result = await mx.getRoomHierarchy( const result = await mx.getRoomHierarchy(
spaceId, spaceId,
PER_PAGE_COUNT, PER_PAGE_COUNT,
-2
View File
@@ -454,7 +454,6 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
let token: string | undefined = eventContext.start; let token: string | undefined = eventContext.start;
while (token) { while (token) {
// eslint-disable-next-line no-await-in-loop
const response = await mx.createMessagesRequest( const response = await mx.createMessagesRequest(
room.roomId, room.roomId,
token, token,
@@ -475,7 +474,6 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
const eventIds = eventsToDelete.map((roomEvent) => roomEvent.event_id); const eventIds = eventsToDelete.map((roomEvent) => roomEvent.event_id);
// eslint-disable-next-line no-await-in-loop
await rateLimitedActions(eventIds, (eventId) => await rateLimitedActions(eventIds, (eventId) =>
mx.redactEvent(room.roomId, eventId, undefined, { reason }), mx.redactEvent(room.roomId, eventId, undefined, { reason }),
); );
-10
View File
@@ -46,12 +46,10 @@ const fillMissingPowers = (powerLevels: IPowerLevels): IPowerLevels =>
const keys = Object.keys(DEFAULT_POWER_LEVELS) as unknown as (keyof IPowerLevels)[]; const keys = Object.keys(DEFAULT_POWER_LEVELS) as unknown as (keyof IPowerLevels)[];
keys.forEach((key) => { keys.forEach((key) => {
if (draftPl[key] === undefined) { if (draftPl[key] === undefined) {
// eslint-disable-next-line no-param-reassign
draftPl[key] = DEFAULT_POWER_LEVELS[key] as any; draftPl[key] = DEFAULT_POWER_LEVELS[key] as any;
} }
}); });
if (draftPl.notifications && typeof draftPl.notifications.room !== 'number') { if (draftPl.notifications && typeof draftPl.notifications.room !== 'number') {
// eslint-disable-next-line no-param-reassign
draftPl.notifications.room = DEFAULT_POWER_LEVELS.notifications.room; draftPl.notifications.room = DEFAULT_POWER_LEVELS.notifications.room;
} }
return draftPl; return draftPl;
@@ -236,23 +234,19 @@ export const applyPermissionPower = (
if (typeof location.key === 'string') { if (typeof location.key === 'string') {
const users = powerLevels.users ?? {}; const users = powerLevels.users ?? {};
users[location.key] = power; users[location.key] = power;
// eslint-disable-next-line no-param-reassign
powerLevels.users = users; powerLevels.users = users;
return powerLevels; return powerLevels;
} }
// eslint-disable-next-line no-param-reassign
powerLevels.users_default = power; powerLevels.users_default = power;
return powerLevels; return powerLevels;
} }
if ('action' in location) { if ('action' in location) {
// eslint-disable-next-line no-param-reassign
powerLevels[location.key] = power; powerLevels[location.key] = power;
return powerLevels; return powerLevels;
} }
if ('notification' in location) { if ('notification' in location) {
const notifications = powerLevels.notifications ?? {}; const notifications = powerLevels.notifications ?? {};
notifications[location.key] = power; notifications[location.key] = power;
// eslint-disable-next-line no-param-reassign
powerLevels.notifications = notifications; powerLevels.notifications = notifications;
return powerLevels; return powerLevels;
} }
@@ -260,11 +254,9 @@ export const applyPermissionPower = (
if (typeof location.key === 'string') { if (typeof location.key === 'string') {
const events = powerLevels.events ?? {}; const events = powerLevels.events ?? {};
events[location.key] = power; events[location.key] = power;
// eslint-disable-next-line no-param-reassign
powerLevels.events = events; powerLevels.events = events;
return powerLevels; return powerLevels;
} }
// eslint-disable-next-line no-param-reassign
powerLevels.state_default = power; powerLevels.state_default = power;
return powerLevels; return powerLevels;
} }
@@ -272,11 +264,9 @@ export const applyPermissionPower = (
if (typeof location.key === 'string') { if (typeof location.key === 'string') {
const events = powerLevels.events ?? {}; const events = powerLevels.events ?? {};
events[location.key] = power; events[location.key] = power;
// eslint-disable-next-line no-param-reassign
powerLevels.events = events; powerLevels.events = events;
return powerLevels; return powerLevels;
} }
// eslint-disable-next-line no-param-reassign
powerLevels.events_default = power; powerLevels.events_default = power;
return powerLevels; return powerLevels;
}; };
-2
View File
@@ -396,10 +396,8 @@ export const rateLimitedActions = async <T, R = void>(
for (let i = 0; i < data.length; i += 1) { for (let i = 0; i < data.length; i += 1) {
const dataItem = data[i]; const dataItem = data[i];
retryCount = 0; retryCount = 0;
// eslint-disable-next-line no-await-in-loop
await performAction(dataItem, i); await performAction(dataItem, i);
if (actionInterval > 0) { if (actionInterval > 0) {
// eslint-disable-next-line no-await-in-loop
await sleepForMs(actionInterval); await sleepForMs(actionInterval);
} }
} }
-5
View File
@@ -217,11 +217,9 @@ export async function importTelegramStickerPack(
try { try {
// Get file path from Telegram // Get file path from Telegram
// eslint-disable-next-line no-await-in-loop
const filePath = await getFilePath(botToken, sticker.file_id); const filePath = await getFilePath(botToken, sticker.file_id);
// Download the sticker // Download the sticker
// eslint-disable-next-line no-await-in-loop
let blob = await downloadFile(botToken, filePath); let blob = await downloadFile(botToken, filePath);
// Generate a shortcode from emoji or index // Generate a shortcode from emoji or index
@@ -235,20 +233,17 @@ export async function importTelegramStickerPack(
// Convert animated stickers to GIF // Convert animated stickers to GIF
if (isAnimated && filePath.endsWith('.tgs')) { if (isAnimated && filePath.endsWith('.tgs')) {
onProgress?.(i + 1, total, `Converting animated sticker ${i + 1}/${total} to GIF...`); 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); blob = await tgsToGif(blob, sticker.width, sticker.height);
finalMimeType = 'image/gif'; finalMimeType = 'image/gif';
extension = 'gif'; extension = 'gif';
} else if (isVideo && filePath.endsWith('.webm')) { } else if (isVideo && filePath.endsWith('.webm')) {
onProgress?.(i + 1, total, `Converting video sticker ${i + 1}/${total} to GIF...`); 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); blob = await webmToGif(blob, sticker.width, sticker.height);
finalMimeType = 'image/gif'; finalMimeType = 'image/gif';
extension = 'gif'; extension = 'gif';
} }
// Upload to Matrix // Upload to Matrix
// eslint-disable-next-line no-await-in-loop
const mxcUrl = await uploadToMatrix(mx, blob, `${shortcode}.${extension}`); const mxcUrl = await uploadToMatrix(mx, blob, `${shortcode}.${extension}`);
// Add to images // Add to images
+1 -2
View File
@@ -267,8 +267,7 @@ export async function decryptMegolmKeyFile(data, password) {
* key-derivation function. * key-derivation function.
* @return {Promise<ArrayBuffer>} promise for encrypted output * @return {Promise<ArrayBuffer>} promise for encrypted output
*/ */
export async function encryptMegolmKeyFile(data, password, options) { export async function encryptMegolmKeyFile(data, password, options = {}) {
options = options || {};
const kdfRounds = options.kdf_rounds || 500000; const kdfRounds = options.kdf_rounds || 500000;
const salt = new Uint8Array(16); const salt = new Uint8Array(16);