Merge pull request #28007 from element-hq/renovate/major-typescript-eslint-monorepo

This commit is contained in:
Michael Telatynski 2024-10-18 14:55:51 +01:00 committed by GitHub
commit e5a436a00a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
126 changed files with 267 additions and 268 deletions

View File

@ -198,6 +198,8 @@ module.exports = {
"@typescript-eslint/ban-ts-comment": "off",
// We're okay with assertion errors when we ask for them
"@typescript-eslint/no-non-null-assertion": "off",
// We do this sometimes to brand interfaces
"@typescript-eslint/no-empty-object-type": "off",
},
},
// temporary override for offending icon require files

View File

@ -186,6 +186,7 @@
"@playwright/test": "^1.40.1",
"@principalstudio/html-webpack-inject-preload": "^1.2.7",
"@sentry/webpack-plugin": "^2.7.1",
"@stylistic/eslint-plugin": "^2.9.0",
"@svgr/webpack": "^8.0.0",
"@testing-library/dom": "^9.0.0",
"@testing-library/jest-dom": "^6.0.0",
@ -223,8 +224,8 @@
"@types/tar-js": "^0.3.5",
"@types/ua-parser-js": "^0.7.36",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"axe-core": "4.10.0",
"babel-jest": "^29.0.0",
"babel-loader": "^9.0.0",
@ -246,7 +247,7 @@
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^28.0.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-matrix-org": "1.2.1",
"eslint-plugin-matrix-org": "^2.0.2",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-unicorn": "^56.0.0",

View File

@ -69,7 +69,7 @@ export class MessageBuilder {
/**
* Map of message content -> event.
*/
messages = new Map<String, Promise<JSHandle<MatrixEvent>>>();
messages = new Map<string, Promise<JSHandle<MatrixEvent>>>();
/**
* Utility to find a MatrixEvent by its body content

View File

@ -70,7 +70,7 @@ export class MessageBuilder {
/**
* Map of message content -> event.
*/
messages = new Map<String, Promise<JSHandle<MatrixEvent>>>();
messages = new Map<string, Promise<JSHandle<MatrixEvent>>>();
/**
* Utility to find a MatrixEvent by its body content

View File

@ -35,6 +35,7 @@ export type Defaultize<P, D> = P extends any
Partial<Pick<D, Exclude<keyof D, keyof P>>>
: never;
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
export type DeepReadonly<T> = T extends (infer R)[]
? DeepReadonlyArray<R>
: T extends Function
@ -42,6 +43,7 @@ export type DeepReadonly<T> = T extends (infer R)[]
: T extends object
? DeepReadonlyObject<T>
: T;
/* eslint-enable @typescript-eslint/no-unsafe-function-type */
interface DeepReadonlyArray<T> extends ReadonlyArray<DeepReadonly<T>> {}

View File

@ -129,7 +129,7 @@ export default abstract class BasePlatform {
try {
const [version, deferUntil] = JSON.parse(localStorage.getItem(UPDATE_DEFER_KEY)!);
return newVersion !== version || Date.now() > deferUntil;
} catch (e) {
} catch {
return true;
}
}
@ -380,7 +380,7 @@ export default abstract class BasePlatform {
try {
await idbSave("pickleKey", [userId, deviceId], data);
} catch (e) {
} catch {
return null;
}
return encodeUnpaddedBase64(randomArray);

View File

@ -48,7 +48,7 @@ function shouldCleanupDrafts(): boolean {
return true;
}
return Date.now() > parsedTimestamp + DRAFT_CLEANUP_PERIOD;
} catch (error) {
} catch {
return true;
}
}

View File

@ -52,7 +52,7 @@ export const EMOJI_REGEX = (() => {
// want the app to completely crash on older platforms. We use the
// constructor here to avoid a syntax error on such platforms.
return new RegExp("\\p{RGI_Emoji}(?!\\uFE0E)(?:(?<!\\uFE0F)\\uFE0F)?|[\\u{1f1e6}-\\u{1f1ff}]", "v");
} catch (_e) {
} catch {
// v mode not supported; fall back to matching nothing
return /(?!)/;
}
@ -61,7 +61,7 @@ export const EMOJI_REGEX = (() => {
const BIGEMOJI_REGEX = (() => {
try {
return new RegExp(`^(${EMOJI_REGEX.source})+$`, "iv");
} catch (_e) {
} catch {
// Fall back, just like for EMOJI_REGEX
return /(?!)/;
}
@ -120,7 +120,7 @@ export function isUrlPermitted(inputUrl: string): boolean {
try {
// URL parser protocol includes the trailing colon
return PERMITTED_URL_SCHEMES.includes(new URL(inputUrl).protocol.slice(0, -1));
} catch (e) {
} catch {
return false;
}
}

View File

@ -827,7 +827,7 @@ export default class LegacyCallHandler extends EventEmitter {
try {
this.addCallForRoom(roomId, call);
} catch (e) {
} catch {
Modal.createDialog(ErrorDialog, {
title: _t("voip|already_in_call"),
description: _t("voip|already_in_call_person"),

View File

@ -211,7 +211,7 @@ class MatrixClientPegClass implements IMatrixClientPeg {
const registrationTime = parseInt(window.localStorage.getItem("mx_registration_time")!, 10);
const diff = Date.now() - registrationTime;
return diff / 36e5 <= hours;
} catch (e) {
} catch {
return false;
}
}
@ -220,7 +220,7 @@ class MatrixClientPegClass implements IMatrixClientPeg {
try {
const registrationTime = parseInt(window.localStorage.getItem("mx_registration_time")!, 10);
return timestamp.getTime() <= registrationTime;
} catch (e) {
} catch {
return false;
}
}

View File

@ -236,7 +236,7 @@ export class PosthogAnalytics {
let appVersion: string | undefined;
try {
appVersion = await platform?.getAppVersion();
} catch (e) {
} catch {
// this happens if no version is set i.e. in dev
appVersion = "unknown";
}

View File

@ -36,7 +36,7 @@ class Presence {
try {
await this.unavailableTimer.finished();
this.setState(SetPresence.Unavailable);
} catch (e) {
} catch {
/* aborted, stop got called */
}
}

View File

@ -44,7 +44,7 @@ export function getRoomNotifsState(client: MatrixClient, roomId: string): RoomNo
let roomRule: IPushRule | undefined;
try {
roomRule = client.getRoomPushRule("global", roomId);
} catch (err) {
} catch {
// Possible that the client doesn't have pushRules yet. If so, it
// hasn't started either, so indicate that this room is not notifying.
return null;

View File

@ -855,14 +855,14 @@ const onMessage = function (event: MessageEvent<any>): void {
try {
if (!openManagerUrl) openManagerUrl = IntegrationManagers.sharedInstance().getPrimaryManager()?.uiUrl;
configUrl = new URL(openManagerUrl!);
} catch (e) {
} catch {
// No integrations UI URL, ignore silently.
return;
}
let eventOriginUrl: URL;
try {
eventOriginUrl = new URL(event.origin);
} catch (e) {
} catch {
return;
}
// TODO -- Scalar postMessage API should be namespaced with event.data.api field

View File

@ -42,6 +42,7 @@ export const DEFAULTS: DeepReadonly<IConfigOptions> = {
// be preferred over their config.
desktopBuilds: {
available: true,
// eslint-disable-next-line @typescript-eslint/no-require-imports
logo: require("../res/img/element-desktop-logo.svg").default,
url: "https://element.io/get-started",
},

View File

@ -252,7 +252,7 @@ export class SlidingSyncManager {
try {
// wait until the next sync before returning as RoomView may need to know the current state
await p;
} catch (err) {
} catch {
logger.warn("SlidingSync setRoomVisible:", roomId, visible, "failed to confirm transaction");
}
return roomId;
@ -305,7 +305,7 @@ export class SlidingSyncManager {
} else {
await this.slidingSync!.setListRanges(SlidingSyncManager.ListSearch, ranges);
}
} catch (err) {
} catch {
// do nothing, as we reject only when we get interrupted but that's fine as the next
// request will include our data
} finally {
@ -357,7 +357,7 @@ export class SlidingSyncManager {
}
const clientWellKnown = await AutoDiscovery.findClientConfig(clientDomain);
proxyUrl = clientWellKnown?.["org.matrix.msc3575.proxy"]?.url;
} catch (e) {
} catch {
// Either client.getDomain() is null so we've shorted out, or is invalid so `AutoDiscovery.findClientConfig` has thrown
}

View File

@ -213,7 +213,7 @@ export default class UserActivity {
attachedTimers.forEach((t) => t.start());
try {
await timeout.finished();
} catch (_e) {
} catch {
/* aborted */
}
attachedTimers.forEach((t) => t.abort());

View File

@ -9,6 +9,7 @@ Please see LICENSE files in the repository root for full details.
import React, { useEffect, useState } from "react";
import { _t } from "../../languageHandler";
import UploadBigSvg from "../../../res/img/upload-big.svg";
interface IProps {
parent: HTMLElement | null;
@ -106,11 +107,7 @@ const FileDropTarget: React.FC<IProps> = ({ parent, onFileDrop }) => {
if (state.dragging) {
return (
<div className="mx_FileDropTarget">
<img
src={require("../../../res/img/upload-big.svg").default}
className="mx_FileDropTarget_image"
alt=""
/>
<img src={UploadBigSvg} className="mx_FileDropTarget_image" alt="" />
{_t("room|drop_file_prompt")}
</div>
);

View File

@ -161,9 +161,11 @@ export default class LegacyCallEventGrouper extends EventEmitter {
public toggleSilenced = (): void => {
const silenced = LegacyCallHandler.instance.isCallSilenced(this.callId);
silenced
? LegacyCallHandler.instance.unSilenceCall(this.callId)
: LegacyCallHandler.instance.silenceCall(this.callId);
if (silenced) {
LegacyCallHandler.instance.unSilenceCall(this.callId);
} else {
LegacyCallHandler.instance.silenceCall(this.callId);
}
};
private setCallListeners(): void {

View File

@ -982,7 +982,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
try {
const config = await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(params.hs_url);
newState.serverConfig = config;
} catch (err) {
} catch {
logger.warn("Failed to load hs_url param:", params.hs_url);
}
} else if (params.client_secret && params.session_id && params.hs_url && params.is_url && params.sid) {

View File

@ -691,7 +691,7 @@ const ManageButtons: React.FC<IManageButtonsProps> = ({ hierarchy, selected, set
hierarchy.removeRelation(parentId, childId);
}
} catch (e) {
} catch {
setError(_t("space|failed_remove_rooms"));
}
setRemoving(false);
@ -724,7 +724,7 @@ const ManageButtons: React.FC<IManageButtonsProps> = ({ hierarchy, selected, set
// mutate the local state to save us having to refetch the world
existingContent.suggested = content.suggested;
}
} catch (e) {
} catch {
setError("Failed to update some suggestions. Try again later");
}
setSaving(false);

View File

@ -973,7 +973,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
UserActivity.sharedInstance().timeWhileActiveRecently(this.readMarkerActivityTimer);
try {
await this.readMarkerActivityTimer.finished();
} catch (e) {
} catch {
continue; /* aborted */
}
// outside of try/catch to not swallow errors
@ -988,7 +988,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
UserActivity.sharedInstance().timeWhileActiveNow(this.readReceiptActivityTimer);
try {
await this.readReceiptActivityTimer.finished();
} catch (e) {
} catch {
continue; /* aborted */
}
// outside of try/catch to not swallow errors

View File

@ -44,6 +44,7 @@ import { Icon as LiveIcon } from "../../../res/img/compound/live-8px.svg";
import { VoiceBroadcastRecording, VoiceBroadcastRecordingsStoreEvent } from "../../voice-broadcast";
import { SDKContext } from "../../contexts/SDKContext";
import { shouldShowFeedback } from "../../utils/Feedback";
import DarkLightModeSvg from "../../../res/img/element-icons/roomlist/dark-light-mode.svg";
interface IProps {
isPanelCollapsed: boolean;
@ -414,12 +415,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
: _t("user_menu|switch_theme_dark")
}
>
<img
src={require("../../../res/img/element-icons/roomlist/dark-light-mode.svg").default}
role="presentation"
alt=""
width={16}
/>
<img src={DarkLightModeSvg} role="presentation" alt="" width={16} />
</RovingAccessibleButton>
</div>
{topSection}

View File

@ -274,7 +274,7 @@ export default class ForgotPassword extends React.Component<Props, State> {
await this.reset.setNewPassword(this.state.password);
this.setState({ phase: Phase.Done });
modal.close();
} catch (e) {
} catch {
// Email not confirmed, yet. Retry after a while.
await sleep(emailCheckInterval);
}

View File

@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
*/
// We're importing via require specifically so the svg becomes a URI rather than a DOM element.
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const matrixSvg = require("../../../res/img/matrix.svg").default;
/**

View File

@ -20,6 +20,7 @@ interface IProps extends Omit<ComponentProps<BaseAvatarType>, "name" | "url" | "
}
const WidgetAvatar: React.FC<IProps> = ({ app, className, size = "20px", ...props }) => {
/* eslint-disable @typescript-eslint/no-require-imports */
let iconUrls = [require("../../../../res/img/element-icons/room/default_app.svg").default];
// heuristics for some better icons until Widgets support their own icons
if (app.type.includes("jitsi")) {
@ -31,6 +32,7 @@ const WidgetAvatar: React.FC<IProps> = ({ app, className, size = "20px", ...prop
} else if (app.type.includes("clock")) {
iconUrls = [require("../../../../res/img/element-icons/room/default_clock.svg").default];
}
/* eslint-enable @typescript-eslint/no-require-imports */
return (
<BaseAvatar

View File

@ -34,6 +34,7 @@ import LazyRenderList from "../elements/LazyRenderList";
import { useSettingValue } from "../../../hooks/useSettings";
import { filterBoolean } from "../../../utils/arrays";
import { NonEmptyArray } from "../../../@types/common";
import WarningBadgeSvg from "../../../../res/img/element-icons/warning-badge.svg";
// These values match CSS
const ROW_HEIGHT = 32 + 12;
@ -228,12 +229,7 @@ export const AddExistingToSpace: React.FC<IAddExistingToSpaceProps> = ({
if (error) {
footer = (
<>
<img
src={require("../../../../res/img/element-icons/warning-badge.svg").default}
height="24"
width="24"
alt=""
/>
<img src={WarningBadgeSvg} height="24" width="24" alt="" />
<span className="mx_AddExistingToSpaceDialog_error">
<div className="mx_AddExistingToSpaceDialog_errorHeading">

View File

@ -23,6 +23,8 @@ import {
TimelineEvents,
} from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
// eslint-disable-next-line no-restricted-imports
import OverflowHorizontalSvg from "@vector-im/compound-design-tokens/icons/overflow-horizontal.svg";
import { _t } from "../../../languageHandler";
import dis from "../../../dispatcher/dispatcher";
@ -104,7 +106,7 @@ const Entry: React.FC<IEntryProps<any>> = ({ room, type, content, matrixClient:
try {
await cli.sendEvent(room.roomId, type, content);
setSendState(SendState.Sent);
} catch (e) {
} catch {
setSendState(SendState.Failed);
}
};
@ -278,13 +280,7 @@ const ForwardDialog: React.FC<IProps> = ({ matrixClient: cli, event, permalinkCr
return (
<EntityTile
className="mx_EntityTile_ellipsis"
avatarJsx={
<BaseAvatar
url={require("@vector-im/compound-design-tokens/icons/overflow-horizontal.svg").default}
name="..."
size="36px"
/>
}
avatarJsx={<BaseAvatar url={OverflowHorizontalSvg} name="..." size="36px" />}
name={text}
showPresence={false}
onClick={() => setTruncateAt(totalCount)}

View File

@ -33,6 +33,7 @@ import { arrayFastClone } from "../../../utils/arrays";
import { ElementWidget } from "../../../stores/widgets/StopGapWidget";
import { ELEMENT_CLIENT_ID } from "../../../identifiers";
import SettingsStore from "../../../settings/SettingsStore";
import WarningBadgeSvg from "../../../../res/img/element-icons/warning-badge.svg";
interface IProps {
widgetDefinition: IModalWidgetOpenRequestData;
@ -185,12 +186,7 @@ export default class ModalWidgetDialog extends React.PureComponent<IProps, IStat
onFinished={this.props.onFinished}
>
<div className="mx_ModalWidgetDialog_warning">
<img
src={require("../../../../res/img/element-icons/warning-badge.svg").default}
height="16"
width="16"
alt=""
/>
<img src={WarningBadgeSvg} height="16" width="16" alt="" />
{_t("widget|modal_data_warning", {
widgetDomain: parsed.hostname,
})}

View File

@ -21,11 +21,12 @@ import BaseDialog from "./BaseDialog";
import CopyableText from "../elements/CopyableText";
import { XOR } from "../../../@types/common";
/* eslint-disable @typescript-eslint/no-require-imports */
const socials = [
{
name: "Facebook",
img: require("../../../../res/img/social/facebook.png"),
url: (url: String) => `https://www.facebook.com/sharer/sharer.php?u=${url}`,
url: (url: string) => `https://www.facebook.com/sharer/sharer.php?u=${url}`,
},
{
name: "Twitter",
@ -52,6 +53,7 @@ const socials = [
url: (url: string) => `mailto:?body=${url}`,
},
];
/* eslint-enable @typescript-eslint/no-require-imports */
interface BaseProps {
/**

View File

@ -107,7 +107,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
recoveryKeyValid: true,
recoveryKeyCorrect: correct,
});
} catch (e) {
} catch {
this.setState({
recoveryKeyValid: false,
recoveryKeyCorrect: false,

View File

@ -127,7 +127,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent<IProps,
try {
decodeRecoveryKey(recoveryKey);
return true;
} catch (e) {
} catch {
return false;
}
}

View File

@ -15,8 +15,10 @@ import { SetupEncryptionStore, Phase } from "../../../../stores/SetupEncryptionS
function iconFromPhase(phase?: Phase): string {
if (phase === Phase.Done) {
// eslint-disable-next-line @typescript-eslint/no-require-imports
return require("../../../../../res/img/e2e/verified-deprecated.svg").default;
} else {
// eslint-disable-next-line @typescript-eslint/no-require-imports
return require("../../../../../res/img/e2e/warning-deprecated.svg").default;
}
}

View File

@ -8,6 +8,8 @@ Please see LICENSE files in the repository root for full details.
import React from "react";
import WarningSvg from "../../../../res/img/warning.svg";
interface IProps {
errorMsg?: string;
}
@ -16,7 +18,7 @@ const AppWarning: React.FC<IProps> = (props) => {
return (
<div className="mx_AppWarning">
<div>
<img src={require("../../../../res/img/warning.svg").default} alt="" />
<img src={WarningSvg} alt="" />
</div>
<div>
<span>{props.errorMsg || "Error"}</span>

View File

@ -140,7 +140,7 @@ export default class ReplyChain extends React.Component<IProps, IState> {
const inReplyToEventId = getParentEventId(ev);
if (!inReplyToEventId) return null;
return await this.getEvent(inReplyToEventId);
} catch (e) {
} catch {
return null;
}
}
@ -154,7 +154,7 @@ export default class ReplyChain extends React.Component<IProps, IState> {
// ask the client to fetch the event we want using the context API, only interface to do so is to ask
// for a timeline with that event, but once it is loaded we can use findEventById to look up the ev map
await this.matrixClient.getEventTimeline(this.room.getUnfilteredTimelineSet(), eventId);
} catch (e) {
} catch {
// if it fails catch the error and return early, there's no point trying to find the event in this case.
// Return null as it is falsy and thus should be treated as an error (as the event cannot be resolved).
return null;

View File

@ -33,6 +33,7 @@ interface ISSOButtonProps extends IProps {
const getIcon = (brand: IdentityProviderBrand | string): string | null => {
switch (brand) {
/* eslint-disable @typescript-eslint/no-require-imports */
case IdentityProviderBrand.Apple:
return require(`../../../../res/img/element-icons/brands/apple.svg`).default;
case IdentityProviderBrand.Facebook:
@ -47,6 +48,7 @@ const getIcon = (brand: IdentityProviderBrand | string): string | null => {
return require(`../../../../res/img/element-icons/brands/twitter.svg`).default;
default:
return null;
/* eslint-enable @typescript-eslint/no-require-imports */
}
};

View File

@ -66,8 +66,8 @@ const useMapWithStyle = ({
throw new Error("Invalid geo URI");
}
map.setCenter({ lon: coords.longitude, lat: coords.latitude });
} catch (_error) {
logger.error("Could not set map center");
} catch (e) {
logger.error("Could not set map center", e);
}
}
}, [map, centerGeoUri]);
@ -80,8 +80,8 @@ const useMapWithStyle = ({
[bounds.east, bounds.north],
);
map.fitBounds(lngLatBounds, { padding: 100, maxZoom: 15 });
} catch (_error) {
logger.error("Invalid map bounds");
} catch (e) {
logger.error("Invalid map bounds", e);
}
}
}, [map, bounds]);
@ -170,7 +170,7 @@ const MapComponent: React.FC<MapProps> = ({
return;
}
onClick && onClick();
onClick?.();
};
return (

View File

@ -55,7 +55,7 @@ export default class LegacyCallEvent extends React.PureComponent<IProps, IState>
this.props.callEventGrouper.addListener(LegacyCallEventGrouperEvent.LengthChanged, this.onLengthChanged);
this.resizeObserver = new ResizeObserver(this.resizeObserverCallback);
this.wrapperElement.current && this.resizeObserver.observe(this.wrapperElement.current);
if (this.wrapperElement.current) this.resizeObserver.observe(this.wrapperElement.current);
}
public componentWillUnmount(): void {

View File

@ -27,7 +27,7 @@ export let DOWNLOAD_ICON_URL: string; // cached copy of the download.svg asset f
async function cacheDownloadIcon(): Promise<void> {
if (DOWNLOAD_ICON_URL) return; // cached already
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const svg = await fetch(require("@vector-im/compound-design-tokens/icons/download.svg").default).then((r) =>
r.text(),
);

View File

@ -11,6 +11,7 @@ import { MediaEventContent } from "matrix-js-sdk/src/types";
import MImageBody from "./MImageBody";
import { BLURHASH_FIELD } from "../../../utils/image-media";
import IconsShowStickersSvg from "../../../../res/img/icons-show-stickers.svg";
export default class MStickerBody extends MImageBody {
// Mostly empty to prevent default behaviour of MImageBody
@ -44,7 +45,7 @@ export default class MStickerBody extends MImageBody {
aria-hidden
alt=""
className="mx_MStickerBody_placeholder"
src={require("../../../../res/img/icons-show-stickers.svg").default}
src={IconsShowStickersSvg}
width="80"
height="80"
onMouseEnter={this.onImageEnter}

View File

@ -21,6 +21,8 @@ import { RightPanelPhases } from "../../../stores/right-panel/RightPanelStorePha
import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
import ErrorDialog from "../dialogs/ErrorDialog";
import { useMatrixClientContext } from "../../../contexts/MatrixClientContext";
import WarningDeprecatedSvg from "../../../../res/img/e2e/warning-deprecated.svg";
import WarningSvg from "../../../../res/img/e2e/warning.svg";
// cancellation codes which constitute a key mismatch
const MISMATCHES = ["m.key_mismatch", "m.user_error", "m.mismatched_sas"];
@ -79,7 +81,7 @@ const EncryptionPanel: React.FC<IProps> = (props: IProps) => {
) {
isShowingMismatchModal.current = true;
Modal.createDialog(ErrorDialog, {
headerImage: require("../../../../res/img/e2e/warning-deprecated.svg").default,
headerImage: WarningDeprecatedSvg,
title: _t("encryption|messages_not_secure|title"),
description: (
<div>
@ -118,7 +120,7 @@ const EncryptionPanel: React.FC<IProps> = (props: IProps) => {
setRequesting(false);
Modal.createDialog(ErrorDialog, {
headerImage: require("../../../../res/img/e2e/warning.svg").default,
headerImage: WarningSvg,
title: _t("encryption|verification|error_starting_title"),
description: _t("encryption|verification|error_starting_description"),
});

View File

@ -1356,7 +1356,7 @@ export const useDevices = (userId: string): IDevice[] | undefined | null => {
disambiguateDevices(devices);
setDevices(devices);
} catch (err) {
} catch {
setDevices(null);
}
}

View File

@ -27,6 +27,8 @@ import { KnownMembership } from "matrix-js-sdk/src/types";
import { throttle } from "lodash";
import { Button, Tooltip } from "@vector-im/compound-web";
import UserAddIcon from "@vector-im/compound-design-tokens/assets/web/icons/user-add-solid";
// eslint-disable-next-line no-restricted-imports
import OverflowHorizontalSvg from "@vector-im/compound-design-tokens/icons/overflow-horizontal.svg";
import { _t } from "../../../languageHandler";
import dis from "../../../dispatcher/dispatcher";
@ -237,13 +239,7 @@ export default class MemberList extends React.Component<IProps, IState> {
return (
<EntityTile
className="mx_EntityTile_ellipsis"
avatarJsx={
<BaseAvatar
url={require("@vector-im/compound-design-tokens/icons/overflow-horizontal.svg").default}
name="..."
size="36px"
/>
}
avatarJsx={<BaseAvatar url={OverflowHorizontalSvg} name="..." size="36px" />}
name={text}
showPresence={false}
onClick={onClick}

View File

@ -57,6 +57,7 @@ import { VoiceBroadcastInfoState } from "../../../voice-broadcast";
import { createCantStartVoiceMessageBroadcastDialog } from "../dialogs/CantStartVoiceMessageBroadcastDialog";
import { UIFeature } from "../../../settings/UIFeature";
import { formatTimeLeft } from "../../../DateUtils";
import RoomReplacedSvg from "../../../../res/img/room_replaced.svg";
// The prefix used when persisting editor drafts to localstorage.
export const WYSIWYG_EDITOR_STATE_STORAGE_PREFIX = "mx_wysiwyg_state_";
@ -619,7 +620,7 @@ export class MessageComposer extends React.Component<IProps, IState> {
aria-hidden
alt=""
className="mx_MessageComposer_roomReplaced_icon"
src={require("../../../../res/img/room_replaced.svg").default}
src={RoomReplacedSvg}
/>
<span className="mx_MessageComposer_roomReplaced_header">
{_t("composer|room_upgraded_notice")}

View File

@ -29,7 +29,7 @@ const RoomInfoLine: FC<IProps> = ({ room }) => {
if (room.getMyMembership() !== KnownMembership.Invite) return null;
try {
return await room.client.getRoomSummary(room.roomId);
} catch (e) {
} catch {
return null;
}
}, [room]);

View File

@ -202,11 +202,13 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
};
private defaultStickerpickerContent(): JSX.Element {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const imgSrc = require("../../../../res/img/stickerpack-placeholder.png");
return (
<AccessibleButton onClick={this.launchManageIntegrations} className="mx_Stickers_contentPlaceholder">
<p>{_t("stickers|empty")}</p>
<p className="mx_Stickers_addLink">{_t("stickers|empty_add_prompt")}</p>
<img src={require("../../../../res/img/stickerpack-placeholder.png")} alt="" />
<img src={imgSrc} alt="" />
</AccessibleButton>
);
}

View File

@ -57,7 +57,7 @@ export const AddPrivilegedUsers: React.FC<AddPrivilegedUsersProps> = ({ room, de
await client.setPowerLevel(room.roomId, userIds, powerLevel);
setSelectedUsers([]);
setPowerLevel(defaultUserLevel);
} catch (error) {
} catch {
Modal.createDialog(ErrorDialog, {
title: _t("common|error"),
description: _t("error|update_power_level"),

View File

@ -52,7 +52,7 @@ async function checkIdentityServerUrl(u: string): Promise<string | null> {
} else {
return _t("identity_server|error_connection");
}
} catch (e) {
} catch {
return _t("identity_server|error_connection");
}
}

View File

@ -61,7 +61,7 @@ export const UserPersonalInfoSettings: React.FC<UserPersonalInfoSettingsProps> =
setEmails(threepids.threepids.filter((a) => a.medium === ThreepidMedium.Email));
setPhoneNumbers(threepids.threepids.filter((a) => a.medium === ThreepidMedium.Phone));
setLoadingState("loaded");
} catch (e) {
} catch {
setLoadingState("error");
}
}, [client]);

View File

@ -156,7 +156,7 @@ const UserProfileSettings: React.FC<UserProfileSettingsProps> = ({
const { content_uri: uri } = await client.uploadContent(avatarFile);
await client.setAvatarUrl(uri);
setAvatarURL(uri);
} catch (e) {
} catch {
setAvatarError(true);
} finally {
removeToast();

View File

@ -40,7 +40,7 @@ const DeviceNameEditor: React.FC<Props & { stopEditing: () => void }> = ({ devic
try {
await saveDeviceName(deviceName);
stopEditing();
} catch (error) {
} catch {
setError(_t("settings|sessions|error_set_name"));
setIsLoading(false);
}

View File

@ -126,7 +126,7 @@ export const DiscoverySettings: React.FC = () => {
);
logger.warn(e);
}
} catch (e) {}
} catch {}
})();
}, [client, getThreepidState]);

View File

@ -101,7 +101,7 @@ export default class VoiceUserSettingsTab extends React.Component<{}, IState> {
this.setState<any>({ [kind]: deviceId });
try {
await MediaDeviceHandler.instance.setDevice(deviceId, kind);
} catch (error) {
} catch {
logger.error(`Failed to set device ${kind}: ${deviceId}`);
// reset state to current value
this.setState<any>({ [kind]: mapDeviceKindToHandlerValue(kind) });

View File

@ -63,7 +63,7 @@ const QuickThemeSwitcher: React.FC<Props> = ({ requestClose }) => {
SettingsStore.setValue("use_system_theme", null, SettingLevel.DEVICE, false),
]);
}
} catch (_error) {
} catch {
dis.dispatch<RecheckThemePayload>({ action: Action.RecheckTheme });
}

View File

@ -176,7 +176,7 @@ interface IItemProps extends InputHTMLAttributes<HTMLLIElement> {
activeSpaces: SpaceKey[];
isNested?: boolean;
isPanelCollapsed?: boolean;
onExpand?: Function;
onExpand?: () => void;
parents?: Set<string>;
innerRef?: LegacyRef<HTMLLIElement>;
dragHandleProps?: DraggableProvidedDragHandleProps | null;

View File

@ -34,6 +34,7 @@ export function UserOnboardingHeader({ useCase }: Props): JSX.Element {
let actionLabel: string;
switch (useCase) {
/* eslint-disable @typescript-eslint/no-require-imports */
case UseCase.PersonalMessaging:
title = _t("onboarding|personal_messaging_title");
image = require("../../../../res/img/user-onboarding/PersonalMessaging.png");
@ -60,6 +61,7 @@ export function UserOnboardingHeader({ useCase }: Props): JSX.Element {
image = require("../../../../res/img/user-onboarding/PersonalMessaging.png");
actionLabel = _t("onboarding|personal_messaging_action");
break;
/* eslint-enable @typescript-eslint/no-require-imports */
}
return (

View File

@ -6,6 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function getDisplayAliasForAliasSet(canonicalAlias: string | null, altAliases: string[]): string | null {
// E.g. prefer one of the aliases over another
return null;

View File

@ -24,6 +24,7 @@ import { UIComponent } from "../settings/UIFeature";
* @returns {boolean} True (default) if the user is able to see the component, false
* otherwise.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function shouldShowComponent(component: UIComponent): boolean {
return true; // default to visible
}

View File

@ -6,6 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function requireCanonicalAliasAccessToPublish(): boolean {
// Some environments may not care about this requirement and could return false
return true;

View File

@ -6,6 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function onLoggedOutAndStorageCleared(): void {
// E.g. redirect user or call other APIs after logout
}

View File

@ -21,6 +21,7 @@ import { Room } from "matrix-js-sdk/src/matrix";
* @param {Room} room The room to check the visibility of.
* @returns {boolean} True if the room should be visible, false otherwise.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function isRoomVisible(room: Room): boolean {
return true;
}

View File

@ -21,6 +21,7 @@ import { Capability, Widget } from "matrix-widget-api";
* @returns {Set<Capability>} Resolves to the capabilities that are approved for use
* by the widget. If none are approved, this should return an empty Set.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function preapproveCapabilities(
widget: Widget,
requestedCapabilities: Set<Capability>,

View File

@ -17,6 +17,7 @@ import { ITemplateParams } from "matrix-widget-api";
* This will not be called until after isReady() resolves.
* @returns {Partial<Omit<ITemplateParams, "widgetRoomId">>} The variables.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function provideVariables(): Partial<Omit<ITemplateParams, "widgetRoomId">> {
return {};
}
@ -26,6 +27,7 @@ function provideVariables(): Partial<Omit<ITemplateParams, "widgetRoomId">> {
* to be provided. This will block widgets being rendered.
* @returns {Promise<boolean>} Resolves when ready.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function isReady(): Promise<void> {
return; // default no waiting
}

View File

@ -12,7 +12,7 @@ const getValue = <T>(key: string, initialValue: T): T => {
try {
const item = window.localStorage.getItem(key);
return item ? JSON.parse(item) : initialValue;
} catch (error) {
} catch {
return initialValue;
}
};

View File

@ -376,7 +376,7 @@ export function replaceByRegexes(text: string, mapping: IVariables | Tags): stri
let replaced: SubstitutionValue;
// If substitution is a function, call it
if (mapping[regexpString] instanceof Function) {
replaced = ((mapping as Tags)[regexpString] as Function)(...capturedGroups);
replaced = ((mapping as Tags)[regexpString] as (...subs: string[]) => string)(...capturedGroups);
} else {
replaced = mapping[regexpString];
}

View File

@ -148,7 +148,7 @@ export const options: Opts = {
};
}
}
} catch (e) {
} catch {
// OK fine, it's not actually a permalink
}
break;
@ -215,7 +215,7 @@ export const options: Opts = {
} else {
return "_blank";
}
} catch (e) {
} catch {
// malformed URI
}
}

View File

@ -31,7 +31,7 @@ export class LocalRoom extends Room {
/** DM chat partner */
public targets: Member[] = [];
/** Callbacks that should be invoked after the actual room has been created. */
public afterCreateCallbacks: Function[] = [];
public afterCreateCallbacks: ((roomId: string) => void)[] = [];
public state: LocalRoomState = LocalRoomState.NEW;
public constructor(roomId: string, client: MatrixClient, myUserId: string) {

View File

@ -525,7 +525,7 @@ export function tryInitStorage(): Promise<void> {
let indexedDB;
try {
indexedDB = window.indexedDB;
} catch (e) {}
} catch {}
if (indexedDB) {
global.mx_rage_store = new IndexedDBLogStore(indexedDB, global.mx_rage_logger);

View File

@ -68,7 +68,7 @@ export async function collectBugReport(opts: IOpts = {}, gzipLogs = true): Promi
async function getAppVersion(): Promise<string | undefined> {
try {
return await PlatformPeg.get()?.getAppVersion();
} catch (err) {
} catch {
// this happens if no version is set i.e. in dev
}
}
@ -76,7 +76,7 @@ async function getAppVersion(): Promise<string | undefined> {
function matchesMediaQuery(query: string): string {
try {
return String(window.matchMedia(query).matches);
} catch (err) {
} catch {
// if not supported in browser
}
return "UNKNOWN";
@ -249,12 +249,12 @@ async function collectStorageStatInfo(body: FormData): Promise<void> {
if (navigator.storage && navigator.storage.persisted) {
try {
body.append("storageManager_persisted", String(await navigator.storage.persisted()));
} catch (e) {}
} catch {}
} else if (document.hasStorageAccess) {
// Safari
try {
body.append("storageManager_persisted", String(await document.hasStorageAccess()));
} catch (e) {}
} catch {}
}
if (navigator.storage && navigator.storage.estimate) {
try {
@ -266,7 +266,7 @@ async function collectStorageStatInfo(body: FormData): Promise<void> {
body.append(`storageManager_usage_${k}`, String(estimate.usageDetails![k]));
});
}
} catch (e) {}
} catch {}
}
}
@ -402,7 +402,7 @@ export async function submitFeedback(
let version: string | undefined;
try {
version = await PlatformPeg.get()?.getAppVersion();
} catch (err) {} // PlatformPeg already logs this.
} catch {} // PlatformPeg already logs this.
const body = new FormData();
if (label) body.append("label", label);

View File

@ -68,12 +68,12 @@ async function getStorageContext(): Promise<StorageContext> {
if (navigator.storage && navigator.storage.persisted) {
try {
result["storageManager_persisted"] = String(await navigator.storage.persisted());
} catch (e) {}
} catch {}
} else if (document.hasStorageAccess) {
// Safari
try {
result["storageManager_persisted"] = String(await document.hasStorageAccess());
} catch (e) {}
} catch {}
}
if (navigator.storage && navigator.storage.estimate) {
try {
@ -87,7 +87,7 @@ async function getStorageContext(): Promise<StorageContext> {
});
result[`storageManager_usage`] = usageDetails.join(", ");
}
} catch (e) {}
} catch {}
}
return result;

View File

@ -227,6 +227,7 @@ export const SETTINGS: { [setting: string]: ISetting } = {
),
feedbackLabel: "video-room-feedback",
feedbackSubheading: _td("labs|video_rooms_feedbackSubheading"),
// eslint-disable-next-line @typescript-eslint/no-require-imports
image: require("../../res/img/betas/video_rooms.png"),
requiresRefresh: true,
},

View File

@ -34,7 +34,7 @@ export function isPushNotifyDisabled(): boolean {
function getNotifier(): any {
// TODO: [TS] Formal type that doesn't cause a cyclical reference.
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
let Notifier = require("../../Notifier"); // avoids cyclical references
if (Notifier.default) Notifier = Notifier.default; // correct for webpack require() weirdness
return Notifier;

View File

@ -57,7 +57,7 @@ export default class LocalEchoWrapper extends SettingsHandler {
try {
await handlerPromise;
} catch (e) {
} catch {
// notify of a rollback
this.handler.watchers?.notifyUpdate(settingName, roomId, this.level, currentValue);
} finally {

View File

@ -16,9 +16,7 @@ import { SettingLevel } from "../SettingLevel";
import { WatchManager } from "../WatchManager";
const DEFAULT_SETTINGS_EVENT_TYPE = "im.vector.web.settings";
const PREVIEW_URLS_EVENT_TYPE = "org.matrix.room.preview_urls";
type RoomSettingsEventType = typeof DEFAULT_SETTINGS_EVENT_TYPE | typeof PREVIEW_URLS_EVENT_TYPE;
type RoomSettingsEventType = typeof DEFAULT_SETTINGS_EVENT_TYPE | "org.matrix.room.preview_urls";
/**
* Gets and sets settings at the "room" level.

View File

@ -34,7 +34,7 @@ export const UPDATE_EVENT = "update";
* To update the state, use updateState() and preferably await the result to
* help prevent lock conflicts.
*/
export abstract class AsyncStore<T extends Object> extends EventEmitter {
export abstract class AsyncStore<T extends object> extends EventEmitter {
private storeState: Readonly<T>;
private lock = new AwaitLock();
private readonly dispatcherRef: string;
@ -72,7 +72,7 @@ export abstract class AsyncStore<T extends Object> extends EventEmitter {
* Updates the state of the store.
* @param {T|*} newState The state to update in the store using Object.assign()
*/
protected async updateState(newState: T | Object): Promise<void> {
protected async updateState(newState: T | object): Promise<void> {
await this.lock.acquireAsync();
try {
this.storeState = Object.freeze(Object.assign(<T>{}, this.storeState, newState));
@ -87,7 +87,7 @@ export abstract class AsyncStore<T extends Object> extends EventEmitter {
* @param {T|*} newState The new state of the store.
* @param {boolean} quiet If true, the function will not raise an UPDATE_EVENT.
*/
protected async reset(newState: T | Object | null = null, quiet = false): Promise<void> {
protected async reset(newState: T | object | null = null, quiet = false): Promise<void> {
await this.lock.acquireAsync();
try {
this.storeState = Object.freeze(<T>(newState || {}));

View File

@ -13,7 +13,7 @@ import { ActionPayload } from "../dispatcher/payloads";
import { ReadyWatchingStore } from "./ReadyWatchingStore";
import { MatrixDispatcher } from "../dispatcher/dispatcher";
export abstract class AsyncStoreWithClient<T extends Object> extends AsyncStore<T> {
export abstract class AsyncStoreWithClient<T extends object> extends AsyncStore<T> {
protected readyStore: ReadyWatchingStore;
protected constructor(dispatcher: MatrixDispatcher, initialState: T = <T>{}) {

View File

@ -90,7 +90,7 @@ export class MemberListStore {
// load using traditional lazy loading
try {
await room.loadMembersIfNeeded();
} catch (ex) {
} catch {
/* already logged in RoomView */
}
}

View File

@ -77,9 +77,11 @@ export default class IncomingLegacyCallToast extends React.Component<IProps, ISt
private onSilenceClick = (e: ButtonEvent): void => {
e.stopPropagation();
const callId = this.props.call.callId;
this.state.silenced
? LegacyCallHandler.instance.unSilenceCall(callId)
: LegacyCallHandler.instance.silenceCall(callId);
if (this.state.silenced) {
LegacyCallHandler.instance.unSilenceCall(callId);
} else {
LegacyCallHandler.instance.silenceCall(callId);
}
};
public render(): React.ReactNode {

View File

@ -223,7 +223,7 @@ export async function fetchInitialEvent(
try {
const eventData = await client.fetchRoomEvent(roomId, eventId);
initialEvent = new MatrixEvent(eventData);
} catch (e) {
} catch {
logger.warn("Could not find initial event: " + eventId);
initialEvent = null;
}
@ -235,7 +235,7 @@ export async function fetchInitialEvent(
const rootEvent = room?.findEventById(threadId) ?? mapper(await client.fetchRoomEvent(roomId, threadId));
try {
room?.createThread(threadId, rootEvent, [initialEvent], true);
} catch (e) {
} catch {
logger.warn("Could not find root event: " + threadId);
}
}

View File

@ -105,6 +105,7 @@ export async function fixupColorFonts(): Promise<void> {
colrFontCheckStarted = true;
if (await isColrFontSupported()) {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const path = `url('${require("../../res/fonts/Twemoji_Mozilla/TwemojiMozilla-colr.woff2")}')`;
document.fonts.add(new FontFace("Twemoji", path, {}));
// For at least Chrome on Windows 10, we have to explictly add extra
@ -113,6 +114,7 @@ export async function fixupColorFonts(): Promise<void> {
document.fonts.add(new FontFace("Twemoji", path, { weight: "700" }));
} else {
// fall back to SBIX, generated via https://github.com/matrix-org/twemoji-colr/tree/matthew/sbix
// eslint-disable-next-line @typescript-eslint/no-require-imports
const path = `url('${require("../../res/fonts/Twemoji_Mozilla/TwemojiMozilla-sbix.woff2")}')`;
document.fonts.add(new FontFace("Twemoji", path, {}));
document.fonts.add(new FontFace("Twemoji", path, { weight: "600" }));

View File

@ -10,7 +10,7 @@ import { EnhancedMap } from "./maps";
// Inspired by https://pkg.go.dev/golang.org/x/sync/singleflight
const keyMap = new EnhancedMap<Object, EnhancedMap<string, unknown>>();
const keyMap = new EnhancedMap<object, EnhancedMap<string, unknown>>();
/**
* Access class to get a singleflight context. Singleflights execute a
@ -47,7 +47,7 @@ export class Singleflight {
* @param {string} key A string key relevant to that instance to namespace under.
* @returns {SingleflightContext} Returns the context to execute the function.
*/
public static for(instance?: Object | null, key?: string | null): SingleflightContext {
public static for(instance?: object | null, key?: string | null): SingleflightContext {
if (!instance || !key) throw new Error("An instance and key must be supplied");
return new SingleflightContext(instance, key);
}
@ -56,7 +56,7 @@ export class Singleflight {
* Forgets all results for a given instance.
* @param {Object} instance The instance to forget about.
*/
public static forgetAllFor(instance: Object): void {
public static forgetAllFor(instance: object): void {
keyMap.delete(instance);
}
@ -72,7 +72,7 @@ export class Singleflight {
class SingleflightContext {
public constructor(
private instance: Object,
private instance: object,
private key: string,
) {}

View File

@ -21,7 +21,7 @@ export function getIDBFactory(): IDBFactory | undefined {
// We check `self` first because `window` returns something which doesn't work for service workers.
// Note: `self?.indexedDB ?? window.indexedDB` breaks in service workers for unknown reasons.
return self?.indexedDB ? self.indexedDB : window.indexedDB;
} catch (e) {}
} catch {}
}
let idb: IDBDatabase | null = null;

View File

@ -251,7 +251,7 @@ export default class WidgetUtils {
// Delete existing widget with ID
try {
delete userWidgets[widgetId];
} catch (e) {
} catch {
logger.error(`$widgetId is non-configurable`);
}

View File

@ -65,7 +65,7 @@ export const useOwnLiveBeacons = (liveBeaconIds: BeaconIdentifier[]): LiveBeacon
setStoppingInProgress(true);
try {
await Promise.all(liveBeaconIds.map((beaconId) => OwnBeaconStore.instance.stopBeacon(beaconId)));
} catch (error) {
} catch {
setStoppingInProgress(false);
}
};

View File

@ -25,7 +25,7 @@ const localStorage = window.localStorage;
let indexedDB: IDBFactory;
try {
indexedDB = window.indexedDB;
} catch (e) {}
} catch {}
/**
* Create a new matrix client, with the persistent stores set up appropriately

View File

@ -26,7 +26,7 @@ export const isBulkUnverifiedDeviceReminderSnoozed = (): boolean => {
const parsedTimestamp = Number.parseInt(snoozedTimestamp || "", 10);
return Number.isInteger(parsedTimestamp) && parsedTimestamp + snoozePeriod > Date.now();
} catch (error) {
} catch {
return false;
}
};

View File

@ -229,7 +229,7 @@ export default abstract class Exporter {
const image = await fetch(media.srcHttp);
blob = await image.blob();
}
} catch (err) {
} catch {
logger.log("Error decrypting media");
}
if (!blob) {

View File

@ -76,7 +76,7 @@ export async function createThumbnail(
try {
canvas = new window.OffscreenCanvas(targetWidth, targetHeight);
context = canvas.getContext("2d") as OffscreenCanvasRenderingContext2D;
} catch (e) {
} catch {
// Fallback support for other browsers (Safari and Firefox for now)
canvas = document.createElement("canvas");
canvas.width = targetWidth;

View File

@ -377,7 +377,7 @@ export function tryTransformPermalinkToLocalHref(permalink: string): string {
if (m) {
return m[1];
}
} catch (e) {
} catch {
// Not a valid URI
return permalink;
}
@ -396,7 +396,7 @@ export function tryTransformPermalinkToLocalHref(permalink: string): string {
permalink = `#/user/${permalinkParts.userId}`;
} // else not a valid permalink for our purposes - do not handle
}
} catch (e) {
} catch {
// Not an href we need to care about
}
@ -421,7 +421,7 @@ export function getPrimaryPermalinkEntity(permalink: string): string | null {
if (!permalinkParts) return null; // not processable
if (permalinkParts.userId) return permalinkParts.userId;
if (permalinkParts.roomIdOrAlias) return permalinkParts.roomIdOrAlias;
} catch (e) {
} catch {
// no entity - not a permalink
}

View File

@ -120,7 +120,7 @@ export async function buildAndEncodePickleKey(
if (pickleKeyBuf) {
return encodeUnpaddedBase64(pickleKeyBuf);
}
} catch (e) {
} catch {
logger.error("Error decrypting pickle key");
}

View File

@ -150,7 +150,7 @@ export async function persistTokenInStorage(
// token if there is no token or we were unable to encrypt (e.g. if the browser doesn't
// have WebCrypto).
await StorageAccess.idbSave("account", storageKey, encryptedToken || token);
} catch (e) {
} catch {
// if we couldn't save to indexedDB, fall back to localStorage. We
// store the access token unencrypted since localStorage only saves
// strings.
@ -163,7 +163,7 @@ export async function persistTokenInStorage(
} else {
try {
await StorageAccess.idbSave("account", storageKey, token);
} catch (e) {
} catch {
if (!!token) {
localStorage.setItem(storageKey, token);
} else {

View File

@ -45,7 +45,7 @@ export function tooltipifyLinks(rootNodes: ArrayLike<Element>, ignoredNodes: Ele
let href = node.getAttribute("href")!;
try {
href = new URL(href, window.location.href).toString();
} catch (e) {
} catch {
// Not all hrefs will be valid URLs
}

View File

@ -28,7 +28,7 @@ export async function getVectorConfig(relativeLocation = ""): Promise<IConfigOpt
throw new Error(); // throw to enter the catch
}
return configJson;
} catch (e) {
} catch {
return generalConfigPromise;
}
}

View File

@ -20,8 +20,10 @@ import "./modernizr";
// Require common CSS here; this will make webpack process it into bundle.css.
// Our own CSS (which is themed) is imported via separate webpack entry points
// in webpack.config.js
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("katex/dist/katex.css");
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./localstorage-fix");
async function settled(...promises: Array<Promise<any>>): Promise<void> {

View File

@ -62,6 +62,7 @@ interface ExternalAPIOptions extends _ExternalAPIOptions {
}
// We have to trick webpack into loading our CSS for us.
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./index.pcss");
const JITSI_OPENIDTOKEN_JWT_AUTH = "openidtoken-jwt";

View File

@ -265,7 +265,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
const notification = super.displayNotification(title, msg, avatarUrl, room, ev);
const handler = notification.onclick as Function;
const handler = notification.onclick as () => void;
notification.onclick = (): void => {
handler?.();
void this.ipc.call("focusWindow");
@ -416,7 +416,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
public async getPickleKey(userId: string, deviceId: string): Promise<string | null> {
try {
return await this.ipc.call("getPickleKey", userId, deviceId);
} catch (e) {
} catch {
// if we can't connect to the password storage, assume there's no
// pickle key
return null;
@ -426,7 +426,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
public async createPickleKey(userId: string, deviceId: string): Promise<string | null> {
try {
return await this.ipc.call("createPickleKey", userId, deviceId);
} catch (e) {
} catch {
// if we can't connect to the password storage, assume there's no
// pickle key
return null;
@ -436,14 +436,14 @@ export default class ElectronPlatform extends VectorBasePlatform {
public async destroyPickleKey(userId: string, deviceId: string): Promise<void> {
try {
await this.ipc.call("destroyPickleKey", userId, deviceId);
} catch (e) {}
} catch {}
}
public async clearStorage(): Promise<void> {
try {
await super.clearStorage();
await this.ipc.call("clearStorage");
} catch (e) {}
} catch {}
}
public get baseUrl(): string {

View File

@ -76,7 +76,7 @@ export class VoiceBroadcastRecorder
public async stop(): Promise<Optional<ChunkRecordedPayload>> {
try {
await this.voiceRecording.stop();
} catch (e) {
} catch {
// Ignore if the recording raises any error.
}

View File

@ -31,7 +31,7 @@ export const retrieveStartedInfoEvent = async (
try {
const relatedEventData = await client.fetchRoomEvent(roomId, relatedEventId);
return new MatrixEvent(relatedEventData);
} catch (e) {}
} catch {}
return null;
};

View File

@ -50,7 +50,7 @@ export class Jitsi {
try {
const response = await fetch(`https://${this.preferredDomain}/.well-known/element/jitsi`);
data = await response.json();
} catch (error) {
} catch {
return null;
}
if (data.auth) {

View File

@ -35,6 +35,7 @@ beforeEach(() => {
//
// These are also require() calls to make sure they get called
// synchronously.
/* eslint-disable @typescript-eslint/no-require-imports */
require("./setup/setupManualMocks"); // must be first
require("./setup/setupLanguage");
require("./setup/setupConfig");

Some files were not shown because too many files have changed in this diff Show More