diff --git a/.eslintrc.js b/.eslintrc.js index 14702724f9..edbec961c2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -88,6 +88,7 @@ module.exports = { "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/explicit-member-accessibility": "off", "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/no-floating-promises": "off", }, }, ], diff --git a/src/vector/index.ts b/src/vector/index.ts index af22320d4f..e21fa5860a 100644 --- a/src/vector/index.ts +++ b/src/vector/index.ts @@ -180,7 +180,7 @@ async function start(): Promise { // error handling begins here // ########################## if (!acceptBrowser) { - await new Promise((resolve) => { + await new Promise((resolve, reject) => { logger.error("Browser is missing required features."); // take to a different landing page to AWOOOOOGA at the user showIncompatibleBrowser(() => { @@ -189,7 +189,7 @@ async function start(): Promise { } logger.log("User accepts the compatibility risks."); resolve(); - }); + }).catch(reject); }); } diff --git a/src/vector/init.tsx b/src/vector/init.tsx index 0b0e681c59..f5db07ba67 100644 --- a/src/vector/init.tsx +++ b/src/vector/init.tsx @@ -138,7 +138,7 @@ export async function loadLanguage(): Promise { } export async function loadTheme(): Promise { - setTheme(); + return setTheme(); } export async function loadApp(fragParams: {}): Promise { diff --git a/src/vector/jitsi/index.ts b/src/vector/jitsi/index.ts index 1d3a54b41c..b30ee666a8 100644 --- a/src/vector/jitsi/index.ts +++ b/src/vector/jitsi/index.ts @@ -177,17 +177,17 @@ const setupCompleted = (async (): Promise => { } } - await widgetApi!.transport.reply(ev.detail, response); + widgetApi!.transport.reply(ev.detail, response); }); }; handleAction(ElementWidgetActions.JoinCall, async ({ audioInput, videoInput }) => { - joinConference(audioInput as string | null, videoInput as string | null); + void joinConference(audioInput as string | null, videoInput as string | null); }); handleAction(ElementWidgetActions.HangupCall, async ({ force }) => { if (force === true) { meetApi?.dispose(); - notifyHangup(); + void notifyHangup(); meetApi = undefined; closeConference(); } else { @@ -297,7 +297,7 @@ function toggleConferenceVisibility(inConference: boolean): void { function skipToJitsiSplashScreen(): void { // really just a function alias for self-documenting code - joinConference(); + void joinConference(); } /** @@ -500,8 +500,8 @@ const onVideoConferenceJoined = (): void => { if (widgetApi) { // ignored promise because we don't care if it works // noinspection JSIgnoredPromiseFromCall - widgetApi.setAlwaysOnScreen(true); - widgetApi.transport.send(ElementWidgetActions.JoinCall, {}); + void widgetApi.setAlwaysOnScreen(true); + void widgetApi.transport.send(ElementWidgetActions.JoinCall, {}); } // Video rooms should start in tile mode @@ -509,7 +509,7 @@ const onVideoConferenceJoined = (): void => { }; const onVideoConferenceLeft = (): void => { - notifyHangup(); + void notifyHangup(); meetApi = undefined; }; @@ -517,7 +517,7 @@ const onErrorOccurred = ({ error }: Parameters { const action = muted ? ElementWidgetActions.MuteAudio : ElementWidgetActions.UnmuteAudio; - widgetApi?.transport.send(action, {}); + void widgetApi?.transport.send(action, {}); }; const onVideoMuteStatusChanged = ({ muted }: VideoMuteStatusChangedEvent): void => { @@ -535,15 +535,15 @@ const onVideoMuteStatusChanged = ({ muted }: VideoMuteStatusChangedEvent): void // otherwise the React SDK will mistakenly think the user turned off // their video by hand setTimeout(() => { - if (meetApi) widgetApi?.transport.send(ElementWidgetActions.MuteVideo, {}); + if (meetApi) void widgetApi?.transport.send(ElementWidgetActions.MuteVideo, {}); }, 200); } else { - widgetApi?.transport.send(ElementWidgetActions.UnmuteVideo, {}); + void widgetApi?.transport.send(ElementWidgetActions.UnmuteVideo, {}); } }; const updateParticipants = (): void => { - widgetApi?.transport.send(ElementWidgetActions.CallParticipants, { + void widgetApi?.transport.send(ElementWidgetActions.CallParticipants, { participants: meetApi?.getParticipantsInfo(), }); }; diff --git a/src/vector/mobile_guide/index.ts b/src/vector/mobile_guide/index.ts index 7c14a25867..91e10181f1 100644 --- a/src/vector/mobile_guide/index.ts +++ b/src/vector/mobile_guide/index.ts @@ -120,4 +120,4 @@ async function initPage(): Promise { } } -initPage(); +void initPage(); diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index 1fca1c37d1..0ec3cf4e8b 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -167,15 +167,14 @@ export default class ElectronPlatform extends VectorBasePlatform { }); }); - window.electron.on("openDesktopCapturerSourcePicker", () => { + window.electron.on("openDesktopCapturerSourcePicker", async () => { const { finished } = Modal.createDialog(DesktopCapturerSourcePicker); - finished.then(([source]) => { - // getDisplayMedia promise does not return if no dummy is passed here as source - this.ipc.call("callDisplayMediaCallback", source ?? { id: "", name: "", thumbnailURL: "" }); - }); + const [source] = await finished; + // getDisplayMedia promise does not return if no dummy is passed here as source + await this.ipc.call("callDisplayMediaCallback", source ?? { id: "", name: "", thumbnailURL: "" }); }); - this.ipc.call("startSSOFlow", this.ssoID); + void this.ipc.call("startSSOFlow", this.ssoID); BreadcrumbsStore.instance.on(UPDATE_EVENT, this.onBreadcrumbsUpdate); } @@ -195,7 +194,7 @@ export default class ElectronPlatform extends VectorBasePlatform { ), initial: getInitialLetter(r.name), })); - this.ipc.call("breadcrumbs", rooms); + void this.ipc.call("breadcrumbs", rooms); }; private onUpdateDownloaded = async (ev: Event, { releaseNotes, releaseName }: SquirrelUpdate): Promise => { @@ -261,7 +260,7 @@ export default class ElectronPlatform extends VectorBasePlatform { const handler = notification.onclick as Function; notification.onclick = (): void => { handler?.(); - this.ipc.call("focusWindow"); + void this.ipc.call("focusWindow"); }; return notification; @@ -399,7 +398,7 @@ export default class ElectronPlatform extends VectorBasePlatform { } public navigateForwardBack(back: boolean): void { - this.ipc.call(back ? "navigateBack" : "navigateForward"); + void this.ipc.call(back ? "navigateBack" : "navigateForward"); } public overrideBrowserShortcuts(): boolean { diff --git a/src/vector/platform/WebPlatform.ts b/src/vector/platform/WebPlatform.ts index da6f61b323..99c3c778a9 100644 --- a/src/vector/platform/WebPlatform.ts +++ b/src/vector/platform/WebPlatform.ts @@ -113,10 +113,10 @@ export default class WebPlatform extends VectorBasePlatform { // annoyingly, the latest spec says this returns a // promise, but this is only supported in Chrome 46 // and Firefox 47, so adapt the callback API. - return new Promise(function (resolve) { + return new Promise(function (resolve, reject) { window.Notification.requestPermission((result) => { resolve(result); - }); + }).catch(reject); }); } @@ -148,7 +148,7 @@ export default class WebPlatform extends VectorBasePlatform { // Ideally, loading an old copy would be impossible with the // cache-control: nocache HTTP header set, but Firefox doesn't always obey it :/ console.log("startUpdater, current version is " + getNormalizedAppVersion(WebPlatform.VERSION)); - this.pollForUpdate((version: string, newVersion: string) => { + void this.pollForUpdate((version: string, newVersion: string) => { const query = parseQs(location); if (query.updated) { console.log("Update reloaded but still on an old version, stopping"); @@ -207,7 +207,7 @@ export default class WebPlatform extends VectorBasePlatform { public startUpdateCheck(): void { super.startUpdateCheck(); - this.pollForUpdate(showUpdateToast, hideUpdateToast).then((updateState) => { + void this.pollForUpdate(showUpdateToast, hideUpdateToast).then((updateState) => { dis.dispatch({ action: Action.CheckUpdates, ...updateState, diff --git a/src/vector/rageshakesetup.ts b/src/vector/rageshakesetup.ts index 50370eb163..67746b1afe 100644 --- a/src/vector/rageshakesetup.ts +++ b/src/vector/rageshakesetup.ts @@ -35,7 +35,7 @@ export function initRageshake(): Promise { // we manually check persistence for rageshakes ourselves const prom = rageshake.init(/*setUpPersistence=*/ false); prom.then( - () => { + async () => { logger.log("Initialised rageshake."); logger.log( "To fix line numbers in Chrome: " + @@ -48,7 +48,7 @@ export function initRageshake(): Promise { rageshake.flush(); }); - rageshake.cleanup(); + await rageshake.cleanup(); }, (err) => { logger.error("Failed to initialise rageshake: " + err);