Drop the mutation and sequential-await rules and the stale directives. [skip build]
This commit is contained in:
@@ -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',
|
||||
},
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-param-reassign */
|
||||
import React, {
|
||||
ClipboardEventHandler,
|
||||
KeyboardEventHandler,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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: [],
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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]),
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -70,7 +70,6 @@ async function fetchSpaceHierarchy(mx: MatrixClient, spaceId: string): Promise<I
|
||||
|
||||
while (pageCount < MAX_PAGES) {
|
||||
try {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const result = await mx.getRoomHierarchy(
|
||||
spaceId,
|
||||
PER_PAGE_COUNT,
|
||||
|
||||
@@ -454,7 +454,6 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||
|
||||
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 }),
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -396,10 +396,8 @@ export const rateLimitedActions = async <T, R = void>(
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -267,8 +267,7 @@ export async function decryptMegolmKeyFile(data, password) {
|
||||
* key-derivation function.
|
||||
* @return {Promise<ArrayBuffer>} 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);
|
||||
|
||||
Reference in New Issue
Block a user