Auto-fix lint errors

This commit is contained in:
J. Ryan Stinnett 2021-06-29 13:11:58 +01:00
parent 4c5720a573
commit ae0a8b8da4
625 changed files with 3170 additions and 3232 deletions

View file

@ -15,9 +15,9 @@ limitations under the License.
*/
import React, { ReactNode } from 'react';
import {AutoDiscovery} from "matrix-js-sdk/src/autodiscovery";
import {_t, _td, newTranslatableError} from "../languageHandler";
import {makeType} from "./TypeUtils";
import { AutoDiscovery } from "matrix-js-sdk/src/autodiscovery";
import { _t, _td, newTranslatableError } from "../languageHandler";
import { makeType } from "./TypeUtils";
import SdkConfig from '../SdkConfig';
const LIVELINESS_DISCOVERY_ERRORS: string[] = [

View file

@ -86,7 +86,7 @@ export default class DMRoomMap {
this.userToRooms = null;
this.roomToUser = null;
}
}
};
/**
* some client bug somewhere is causing some DMs to be marked
@ -103,7 +103,7 @@ export default class DMRoomMap {
if (room) {
const userId = room.guessDMUserId();
if (userId && userId !== myUserId) {
return {userId, roomId};
return { userId, roomId };
}
}
}).filter((ids) => !!ids); //filter out
@ -116,7 +116,7 @@ export default class DMRoomMap {
return !guessedUserIdsThatChanged
.some((ids) => ids.roomId === roomId);
});
guessedUserIdsThatChanged.forEach(({userId, roomId}) => {
guessedUserIdsThatChanged.forEach(({ userId, roomId }) => {
const roomIds = userToRooms[userId];
if (!roomIds) {
userToRooms[userId] = [roomId];
@ -181,7 +181,7 @@ export default class DMRoomMap {
public getUniqueRoomsWithIndividuals(): {[userId: string]: Room} {
if (!this.roomToUser) return {}; // No rooms means no map.
return Object.keys(this.roomToUser)
.map(r => ({userId: this.getUserIdForRoomId(r), room: this.matrixClient.getRoom(r)}))
.map(r => ({ userId: this.getUserIdForRoomId(r), room: this.matrixClient.getRoom(r) }))
.filter(r => r.userId && r.room && r.room.getInvitedAndJoinedMemberCount() === 2)
.reduce((obj, r) => (obj[r.userId] = r.room) && obj, {});
}

View file

@ -16,7 +16,7 @@ limitations under the License.
// Pull in the encryption lib so that we can decrypt attachments.
import encrypt from 'browser-encrypt-attachment';
import {mediaFromContent} from "../customisations/Media";
import { mediaFromContent } from "../customisations/Media";
import { IEncryptedFile } from "../customisations/models/IMediaEventContent";
import { getBlobSafeMimeType } from "./blobs";
@ -29,7 +29,7 @@ import { getBlobSafeMimeType } from "./blobs";
* @returns {Promise<Blob>} Resolves to a Blob of the file.
*/
export function decryptFile(file: IEncryptedFile): Promise<Blob> {
const media = mediaFromContent({file});
const media = mediaFromContent({ file });
// Download the encrypted file as an array buffer.
return media.downloadSource().then((response) => {
return response.arrayBuffer();
@ -47,6 +47,6 @@ export function decryptFile(file: IEncryptedFile): Promise<Blob> {
let mimetype = file.mimetype ? file.mimetype.split(";")[0].trim() : '';
mimetype = getBlobSafeMimeType(mimetype);
return new Blob([dataArray], {type: mimetype});
return new Blob([dataArray], { type: mimetype });
});
}

View file

@ -53,7 +53,7 @@ export function canEditContent(mxEvent: MatrixEvent): boolean {
return false;
}
const content = mxEvent.getOriginalContent();
const {msgtype} = content;
const { msgtype } = content;
return (msgtype === "m.text" || msgtype === "m.emote") &&
content.body && typeof content.body === 'string' &&
mxEvent.getSender() === MatrixClientPeg.get().getUserId();

View file

@ -47,7 +47,7 @@ function safariVersionCheck(ua) {
async function isColrFontSupported() {
console.log("Checking for COLR support");
const {userAgent} = navigator;
const { userAgent } = navigator;
// Firefox has supported COLR fonts since version 26
// but doesn't support the check below without
// "Extract canvas data" permissions

View file

@ -18,7 +18,7 @@ import url from 'url';
import qs from 'qs';
import SdkConfig from '../SdkConfig';
import {MatrixClientPeg} from '../MatrixClientPeg';
import { MatrixClientPeg } from '../MatrixClientPeg';
export function getHostingLink(campaign) {
const hostingLink = SdkConfig.get().hosting_signup_link;

View file

@ -17,7 +17,7 @@ limitations under the License.
import { SERVICE_TYPES } from 'matrix-js-sdk/src/service-types';
import SdkConfig from '../SdkConfig';
import {MatrixClientPeg} from '../MatrixClientPeg';
import { MatrixClientPeg } from '../MatrixClientPeg';
export function getDefaultIdentityServerUrl(): string {
return SdkConfig.get()['validated_server_config']['isUrl'];

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {MatrixClientPeg} from '../MatrixClientPeg';
import { MatrixClientPeg } from '../MatrixClientPeg';
import { _t } from '../languageHandler';
export function getNameForEventRoom(userId, roomId) {
@ -27,7 +27,7 @@ export function getNameForEventRoom(userId, roomId) {
export function userLabelForEventRoom(userId, roomId) {
const name = getNameForEventRoom(userId, roomId);
if (name !== userId) {
return _t("%(name)s (%(userId)s)", {name, userId});
return _t("%(name)s (%(userId)s)", { name, userId });
} else {
return userId;
}

View file

@ -81,7 +81,7 @@ export async function decryptMegolmKeyFile(data, password) {
let isValid;
try {
isValid = await subtleCrypto.verify(
{name: 'HMAC'},
{ name: 'HMAC' },
hmacKey,
hmac,
toVerify,
@ -112,7 +112,6 @@ export async function decryptMegolmKeyFile(data, password) {
return new TextDecoder().decode(new Uint8Array(plaintext));
}
/**
* Encrypt a megolm key file
*
@ -174,7 +173,7 @@ export async function encryptMegolmKeyFile(data, password, options) {
let hmac;
try {
hmac = await subtleCrypto.sign(
{name: 'HMAC'},
{ name: 'HMAC' },
hmacKey,
toSign,
);
@ -182,7 +181,6 @@ export async function encryptMegolmKeyFile(data, password, options) {
throw friendlyError('subtleCrypto.sign failed: ' + e, cryptoFailMsg());
}
const hmacArray = new Uint8Array(hmac);
resultBuffer.set(hmacArray, idx);
return packMegolmKeyFile(resultBuffer);
@ -204,7 +202,7 @@ async function deriveKeys(salt, iterations, password) {
key = await subtleCrypto.importKey(
'raw',
new TextEncoder().encode(password),
{name: 'PBKDF2'},
{ name: 'PBKDF2' },
false,
['deriveBits'],
);
@ -237,7 +235,7 @@ async function deriveKeys(salt, iterations, password) {
const aesProm = subtleCrypto.importKey(
'raw',
aesKey,
{name: 'AES-CTR'},
{ name: 'AES-CTR' },
false,
['encrypt', 'decrypt'],
).catch((e) => {
@ -249,7 +247,7 @@ async function deriveKeys(salt, iterations, password) {
hmacKey,
{
name: 'HMAC',
hash: {name: 'SHA-256'},
hash: { name: 'SHA-256' },
},
false,
['sign', 'verify'],

View file

@ -147,7 +147,7 @@ function stringAsTextNode(string: string): Text {
}
function renderDifferenceInDOM(originalRootNode: Node, diff: IDiff, diffMathPatch: DiffMatchPatch): void {
const {refNode, refParentNode} = findRefNodes(originalRootNode, diff.route);
const { refNode, refParentNode } = findRefNodes(originalRootNode, diff.route);
switch (diff.action) {
case "replaceElement": {
const container = document.createElement("span");

View file

@ -184,7 +184,7 @@ export default class MultiInviter {
fatal = true;
errorText = _t('You do not have permission to invite people to this room.');
} else if (err.errcode === "RIOT.ALREADY_IN_ROOM") {
errorText = _t("User %(userId)s is already in the room", {userId: address});
errorText = _t("User %(userId)s is already in the room", { userId: address });
} else if (err.errcode === 'M_LIMIT_EXCEEDED') {
// we're being throttled so wait a bit & try again
setTimeout(() => {
@ -192,9 +192,9 @@ export default class MultiInviter {
}, 5000);
return;
} else if (['M_NOT_FOUND', 'M_USER_NOT_FOUND'].includes(err.errcode)) {
errorText = _t("User %(user_id)s does not exist", {user_id: address});
errorText = _t("User %(user_id)s does not exist", { user_id: address });
} else if (err.errcode === 'M_PROFILE_UNDISCLOSED') {
errorText = _t("User %(user_id)s may or may not exist", {user_id: address});
errorText = _t("User %(user_id)s may or may not exist", { user_id: address });
} else if (err.errcode === 'M_PROFILE_NOT_FOUND' && !ignoreProfile) {
// Invite without the profile check
console.warn(`User ${address} does not have a profile - inviting anyways automatically`);

View file

@ -16,7 +16,7 @@ limitations under the License.
import zxcvbn from 'zxcvbn';
import {MatrixClientPeg} from '../MatrixClientPeg';
import { MatrixClientPeg } from '../MatrixClientPeg';
import { _t, _td } from '../languageHandler';
const ZXCVBN_USER_INPUTS = [

View file

@ -26,7 +26,7 @@ export enum E2EStatus {
}
export async function shieldStatusForRoom(client: MatrixClient, room: Room): Promise<E2EStatus> {
const members = (await room.getEncryptionTargetMembers()).map(({userId}) => userId);
const members = (await room.getEncryptionTargetMembers()).map(({ userId }) => userId);
const inDMMap = !!DMRoomMap.shared().getUserIdForRoomId(room.roomId);
const verified: string[] = [];
@ -53,7 +53,7 @@ export async function shieldStatusForRoom(client: MatrixClient, room: Room): Pro
const targets = includeUser ? [...verified, client.getUserId()] : verified;
for (const userId of targets) {
const devices = client.getStoredDevicesForUser(userId);
const anyDeviceNotVerified = devices.some(({deviceId}) => {
const anyDeviceNotVerified = devices.some(({ deviceId }) => {
return !client.checkDeviceTrust(userId, deviceId).isVerified();
});
if (anyDeviceNotVerified) {

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {EnhancedMap} from "./maps";
import { EnhancedMap } from "./maps";
// Inspired by https://pkg.go.dev/golang.org/x/sync/singleflight

View file

@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {LocalStorageCryptoStore} from 'matrix-js-sdk/src/crypto/store/localStorage-crypto-store';
import { LocalStorageCryptoStore } from 'matrix-js-sdk/src/crypto/store/localStorage-crypto-store';
import Analytics from '../Analytics';
import {IndexedDBStore} from "matrix-js-sdk/src/store/indexeddb";
import {IndexedDBCryptoStore} from "matrix-js-sdk/src/crypto/store/indexeddb-crypto-store";
import { IndexedDBStore } from "matrix-js-sdk/src/store/indexeddb";
import { IndexedDBCryptoStore } from "matrix-js-sdk/src/crypto/store/indexeddb-crypto-store";
const localStorage = window.localStorage;

View file

@ -57,7 +57,7 @@ export default class Timer {
const delta = this.timeout - elapsed;
this.timerHandle = setTimeout(this.onTimeout, delta);
}
}
};
changeTimeout(timeout: number) {
if (timeout === this.timeout) {

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {MatrixClientPeg} from '../MatrixClientPeg';
import { MatrixClientPeg } from '../MatrixClientPeg';
const CALL_BEHAVIOUR_WK_KEY = "io.element.call_behaviour";
const E2EE_WK_KEY = "io.element.e2ee";
@ -43,7 +43,7 @@ export function getE2EEWellKnown(): IE2EEWellKnown {
return clientWellKnown[E2EE_WK_KEY];
}
if (clientWellKnown && clientWellKnown[E2EE_WK_KEY_DEPRECATED]) {
return clientWellKnown[E2EE_WK_KEY_DEPRECATED]
return clientWellKnown[E2EE_WK_KEY_DEPRECATED];
}
return null;
}

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { IDestroyable } from "./IDestroyable";
import { arrayFastClone } from "./arrays";
@ -36,7 +35,7 @@ export abstract class Whenable<T> implements IDestroyable {
* @returns This.
*/
public when(condition: T, fn: WhenFn<T>): Whenable<T> {
this.listeners.push({condition, fn});
this.listeners.push({ condition, fn });
return this;
}
@ -59,7 +58,7 @@ export abstract class Whenable<T> implements IDestroyable {
* @returns This.
*/
public whenAnything(fn: WhenFn<T>): Whenable<T> {
this.listeners.push({condition: null, fn});
this.listeners.push({ condition: null, fn });
return this;
}

View file

@ -408,7 +408,7 @@ export default class WidgetUtils {
WidgetType.INTEGRATION_MANAGER,
uiUrl,
"Integration Manager: " + name,
{"api_url": apiUrl},
{ "api_url": apiUrl },
);
}

View file

@ -39,19 +39,19 @@ export function humanizeTime(timeMillis: number): string {
if (msAgo >= 0) { // Past
if (msAgo <= MILLISECONDS_RECENT) return _t("a few seconds ago");
if (msAgo <= MILLISECONDS_1_MIN) return _t("about a minute ago");
if (minutes <= MINUTES_UNDER_1_HOUR) return _t("%(num)s minutes ago", {num: minutes});
if (minutes <= MINUTES_UNDER_1_HOUR) return _t("%(num)s minutes ago", { num: minutes });
if (minutes <= MINUTES_1_HOUR) return _t("about an hour ago");
if (hours <= HOURS_UNDER_1_DAY) return _t("%(num)s hours ago", {num: hours});
if (hours <= HOURS_UNDER_1_DAY) return _t("%(num)s hours ago", { num: hours });
if (hours <= HOURS_1_DAY) return _t("about a day ago");
return _t("%(num)s days ago", {num: days});
return _t("%(num)s days ago", { num: days });
} else { // Future
msAgo = Math.abs(msAgo);
if (msAgo <= MILLISECONDS_RECENT) return _t("a few seconds from now");
if (msAgo <= MILLISECONDS_1_MIN) return _t("about a minute from now");
if (minutes <= MINUTES_UNDER_1_HOUR) return _t("%(num)s minutes from now", {num: minutes});
if (minutes <= MINUTES_UNDER_1_HOUR) return _t("%(num)s minutes from now", { num: minutes });
if (minutes <= MINUTES_1_HOUR) return _t("about an hour from now");
if (hours <= HOURS_UNDER_1_DAY) return _t("%(num)s hours from now", {num: hours});
if (hours <= HOURS_UNDER_1_DAY) return _t("%(num)s hours from now", { num: hours });
if (hours <= HOURS_1_DAY) return _t("about a day from now");
return _t("%(num)s days from now", {num: days});
return _t("%(num)s days from now", { num: days });
}
}

View file

@ -30,7 +30,7 @@ export function mapDiff<K, V>(a: Map<K, V>, b: Map<K, V>): { changed: K[], added
const possibleChanges = arrayUnion(aKeys, bKeys);
const changes = possibleChanges.filter(k => a.get(k) !== b.get(k));
return {changed: changes, added: keyDiff.added, removed: keyDiff.removed};
return { changed: changes, added: keyDiff.added, removed: keyDiff.removed };
}
/**

View file

@ -102,7 +102,7 @@ export async function leaveRoomBehaviour(roomId: string) {
} catch (e) {
if (e && e.data && e.data.errcode) {
const message = e.data.error || _t("Unexpected server error trying to leave the room");
results[roomId] = Object.assign(new Error(message), {errcode: e.data.errcode});
results[roomId] = Object.assign(new Error(message), { errcode: e.data.errcode });
} else {
results[roomId] = e || new Error("Failed to leave room for unknown causes");
}
@ -140,6 +140,6 @@ export async function leaveRoomBehaviour(roomId: string) {
}
if (RoomViewStore.getRoomId() === roomId) {
dis.dispatch({action: 'view_home_page'});
dis.dispatch({ action: 'view_home_page' });
}
}

View file

@ -114,7 +114,7 @@ export function objectDiff<O extends {}>(a: O, b: O): Diff<keyof O> {
const possibleChanges = arrayUnion(aKeys, bKeys);
const changes = possibleChanges.filter(k => a[k] !== b[k]);
return {changed: changes, added: keyDiff.added, removed: keyDiff.removed};
return { changed: changes, added: keyDiff.added, removed: keyDiff.removed };
}
/**

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import PermalinkConstructor, {PermalinkParts} from "./PermalinkConstructor";
import PermalinkConstructor, { PermalinkParts } from "./PermalinkConstructor";
/**
* Generates permalinks that self-reference the running webapp

View file

@ -16,14 +16,14 @@ limitations under the License.
import isIp from "is-ip";
import * as utils from "matrix-js-sdk/src/utils";
import {Room} from "matrix-js-sdk/src/models/room";
import {EventType} from "matrix-js-sdk/src/@types/event";
import { Room } from "matrix-js-sdk/src/models/room";
import { EventType } from "matrix-js-sdk/src/@types/event";
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
import {MatrixClientPeg} from "../../MatrixClientPeg";
import SpecPermalinkConstructor, {baseUrl as matrixtoBaseUrl} from "./SpecPermalinkConstructor";
import PermalinkConstructor, {PermalinkParts} from "./PermalinkConstructor";
import { MatrixClientPeg } from "../../MatrixClientPeg";
import SpecPermalinkConstructor, { baseUrl as matrixtoBaseUrl } from "./SpecPermalinkConstructor";
import PermalinkConstructor, { PermalinkParts } from "./PermalinkConstructor";
import ElementPermalinkConstructor from "./ElementPermalinkConstructor";
import matrixLinkify from "../../linkify-matrix";
import SdkConfig from "../../SdkConfig";
@ -32,7 +32,6 @@ import SdkConfig from "../../SdkConfig";
// to add to permalinks. The servers are appended as ?via=example.org
const MAX_SERVER_CANDIDATES = 3;
// Permalinks can have servers appended to them so that the user
// receiving them can have a fighting chance at joining the room.
// These servers are called "candidates" at this point because
@ -172,7 +171,7 @@ export class RoomPermalinkCreator {
this.updateServerCandidates();
return;
}
}
};
private onMembership = (evt: MatrixEvent, member: RoomMember, oldMembership: string) => {
const userId = member.userId;
@ -189,7 +188,7 @@ export class RoomPermalinkCreator {
this.updateHighestPlUser();
this.updateServerCandidates();
}
};
private updateHighestPlUser() {
const plEvent = this.room.currentState.getStateEvents("m.room.power_levels", "");

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import PermalinkConstructor, {PermalinkParts} from "./PermalinkConstructor";
import PermalinkConstructor, { PermalinkParts } from "./PermalinkConstructor";
export const host = "matrix.to";
export const baseUrl = `https://${host}`;

View file

@ -16,9 +16,9 @@ limitations under the License.
import React from "react";
import ReactDOM from 'react-dom';
import {MatrixClientPeg} from '../MatrixClientPeg';
import { MatrixClientPeg } from '../MatrixClientPeg';
import SettingsStore from "../settings/SettingsStore";
import {PushProcessor} from 'matrix-js-sdk/src/pushprocessor';
import { PushProcessor } from 'matrix-js-sdk/src/pushprocessor';
import Pill from "../components/views/elements/Pill";
import { parseAppLocalLink } from "./permalinks/Permalinks";

View file

@ -48,7 +48,7 @@ export function defer<T>(): IDeferred<T> {
reject = _reject;
});
return {resolve, reject, promise};
return { resolve, reject, promise };
}
// Helper method to retry a Promise a given number of times or until a predicate fails

View file

@ -15,17 +15,17 @@ limitations under the License.
*/
import React from "react";
import {Room} from "matrix-js-sdk/src/models/room";
import {MatrixClient} from "matrix-js-sdk/src/client";
import {EventType} from "matrix-js-sdk/src/@types/event";
import { Room } from "matrix-js-sdk/src/models/room";
import { MatrixClient } from "matrix-js-sdk/src/client";
import { EventType } from "matrix-js-sdk/src/@types/event";
import {calculateRoomVia} from "../utils/permalinks/Permalinks";
import { calculateRoomVia } from "../utils/permalinks/Permalinks";
import Modal from "../Modal";
import SpaceSettingsDialog from "../components/views/dialogs/SpaceSettingsDialog";
import AddExistingToSpaceDialog from "../components/views/dialogs/AddExistingToSpaceDialog";
import CreateRoomDialog from "../components/views/dialogs/CreateRoomDialog";
import createRoom, {IOpts} from "../createRoom";
import {_t} from "../languageHandler";
import createRoom, { IOpts } from "../createRoom";
import { _t } from "../languageHandler";
import SpacePublicShare from "../components/views/spaces/SpacePublicShare";
import InfoDialog from "../components/views/dialogs/InfoDialog";
import { showRoomInviteDialog } from "../RoomInvite";

View file

@ -74,7 +74,6 @@ export function copyNode(ref: Element): boolean {
return document.execCommand('copy');
}
const collator = new Intl.Collator();
/**
* Performant language-sensitive string comparison