From 3dd1047b085fa7795f322c5829f39208465bff13 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 29 Mar 2022 09:58:06 -0300 Subject: added react eslint and fix most of the warns --- .../taler-wallet-webextension/src/platform/api.ts | 4 +-- .../src/platform/chrome.ts | 34 +++++++++++----------- .../taler-wallet-webextension/src/platform/dev.ts | 8 ++--- .../src/platform/firefox.ts | 6 ++-- 4 files changed, 26 insertions(+), 26 deletions(-) (limited to 'packages/taler-wallet-webextension/src/platform') diff --git a/packages/taler-wallet-webextension/src/platform/api.ts b/packages/taler-wallet-webextension/src/platform/api.ts index 112f9721c..65bc36545 100644 --- a/packages/taler-wallet-webextension/src/platform/api.ts +++ b/packages/taler-wallet-webextension/src/platform/api.ts @@ -14,7 +14,7 @@ TALER; see the file COPYING. If not, see */ -import { CoreApiResponse, NotificationType, TalerUriType } from "@gnu-taler/taler-util"; +import { CoreApiResponse, NotificationType } from "@gnu-taler/taler-util"; export interface Permissions { /** @@ -186,6 +186,6 @@ export interface PlatformAPI { } export let platform: PlatformAPI = undefined as any; -export function setupPlatform(impl: PlatformAPI) { +export function setupPlatform(impl: PlatformAPI): void { platform = impl; } diff --git a/packages/taler-wallet-webextension/src/platform/chrome.ts b/packages/taler-wallet-webextension/src/platform/chrome.ts index 5134a5c15..67b293ec7 100644 --- a/packages/taler-wallet-webextension/src/platform/chrome.ts +++ b/packages/taler-wallet-webextension/src/platform/chrome.ts @@ -99,7 +99,7 @@ function getPermissionsApi(): CrossBrowserPermissionsApi { * * @param callback function to be called */ -function notifyWhenAppIsReady(callback: () => void) { +function notifyWhenAppIsReady(callback: () => void): void { if (chrome.runtime && chrome.runtime.getManifest().manifest_version === 3) { callback() } else { @@ -108,7 +108,7 @@ function notifyWhenAppIsReady(callback: () => void) { } -function openWalletURIFromPopup(talerUri: string) { +function openWalletURIFromPopup(talerUri: string): void { const uriType = classifyTalerUri(talerUri); let url: string | undefined = undefined; @@ -138,14 +138,14 @@ function openWalletURIFromPopup(talerUri: string) { ); } -function openWalletPage(page: string) { +function openWalletPage(page: string): void { const url = chrome.runtime.getURL(`/static/wallet.html#${page}`) chrome.tabs.create( { active: true, url, }, ); } -function openWalletPageFromPopup(page: string) { +function openWalletPageFromPopup(page: string): void { const url = chrome.runtime.getURL(`/static/wallet.html#${page}`) chrome.tabs.create( { active: true, url, }, @@ -167,12 +167,12 @@ async function sendMessageToWalletBackground(operation: string, payload: any): P } let notificationPort: chrome.runtime.Port | undefined; -function listenToWalletBackground(listener: (m: any) => void) { +function listenToWalletBackground(listener: (m: any) => void): () => void { if (notificationPort === undefined) { notificationPort = chrome.runtime.connect({ name: "notifications" }) } notificationPort.onMessage.addListener(listener) - function removeListener() { + function removeListener(): void { if (notificationPort !== undefined) { notificationPort.onMessage.removeListener(listener) } @@ -183,7 +183,7 @@ function listenToWalletBackground(listener: (m: any) => void) { const allPorts: chrome.runtime.Port[] = []; -function sendMessageToAllChannels(message: MessageFromBackend) { +function sendMessageToAllChannels(message: MessageFromBackend): void { for (const notif of allPorts) { // const message: MessageFromBackend = { type: msg.type }; try { @@ -194,7 +194,7 @@ function sendMessageToAllChannels(message: MessageFromBackend) { } } -function registerAllIncomingConnections() { +function registerAllIncomingConnections(): void { chrome.runtime.onConnect.addListener((port) => { allPorts.push(port); port.onDisconnect.addListener((discoPort) => { @@ -206,7 +206,7 @@ function registerAllIncomingConnections() { }); } -function listenToAllChannels(cb: (message: any, sender: any, callback: (r: CoreApiResponse) => void) => void) { +function listenToAllChannels(cb: (message: any, sender: any, callback: (r: CoreApiResponse) => void) => void): void { chrome.runtime.onMessage.addListener((m, s, c) => { cb(m, s, c) @@ -215,7 +215,7 @@ function listenToAllChannels(cb: (message: any, sender: any, callback: (r: CoreA }); } -function registerReloadOnNewVersion() { +function registerReloadOnNewVersion(): void { // Explicitly unload the extension page as soon as an update is available, // so the update gets installed as soon as possible. chrome.runtime.onUpdateAvailable.addListener((details) => { @@ -228,7 +228,7 @@ function registerReloadOnNewVersion() { function redirectTabToWalletPage( tabId: number, page: string, -) { +): void { const url = chrome.runtime.getURL(`/static/wallet.html#${page}`); console.log("redirecting tabId: ", tabId, " to: ", url); chrome.tabs.update(tabId, { url }); @@ -250,7 +250,7 @@ function registerTalerHeaderListener(callback: (tabId: number, url: string) => v function headerListener( details: chrome.webRequest.WebResponseHeadersDetails, - ) { + ): void { if (chrome.runtime.lastError) { console.error(JSON.stringify(chrome.runtime.lastError)); return; @@ -299,7 +299,7 @@ function registerTalerHeaderListener(callback: (tabId: number, url: string) => v }); } -function registerOnInstalled(callback: () => void) { +function registerOnInstalled(callback: () => void): void { // This needs to be outside of main, as Firefox won't fire the event if // the listener isn't created synchronously on loading the backend. chrome.runtime.onInstalled.addListener((details) => { @@ -310,7 +310,7 @@ function registerOnInstalled(callback: () => void) { }); } -function useServiceWorkerAsBackgroundProcess() { +function useServiceWorkerAsBackgroundProcess(): boolean { return chrome.runtime.getManifest().manifest_version === 3 } @@ -323,9 +323,9 @@ function searchForTalerLinks(): string | undefined { return undefined } -async function getCurrentTab() { - let queryOptions = { active: true, currentWindow: true }; - let [tab] = await chrome.tabs.query(queryOptions); +async function getCurrentTab(): Promise { + const queryOptions = { active: true, currentWindow: true }; + const [tab] = await chrome.tabs.query(queryOptions); return tab; } diff --git a/packages/taler-wallet-webextension/src/platform/dev.ts b/packages/taler-wallet-webextension/src/platform/dev.ts index 87f542bc0..38fcf29f4 100644 --- a/packages/taler-wallet-webextension/src/platform/dev.ts +++ b/packages/taler-wallet-webextension/src/platform/dev.ts @@ -14,7 +14,7 @@ GNU Taler; see the file COPYING. If not, see */ -import { classifyTalerUri, CoreApiResponse, TalerUriType } from "@gnu-taler/taler-util"; +import { CoreApiResponse } from "@gnu-taler/taler-util"; import { MessageFromBackend, PlatformAPI } from "./api.js"; const frames = ["popup", "wallet"] @@ -30,7 +30,7 @@ const api: PlatformAPI = ({ }), notifyWhenAppIsReady: (fn: () => void) => { let total = frames.length - function waitAndNotify() { + function waitAndNotify(): void { total-- if (total < 1) { console.log('done') @@ -96,7 +96,7 @@ const api: PlatformAPI = ({ }) }, listenToWalletBackground: (onNewMessage: (m: MessageFromBackend) => void) => { - function listener(event: MessageEvent) { + function listener(event: MessageEvent): void { if (event.data.type !== 'notification') return onNewMessage(event.data.body) } @@ -115,7 +115,7 @@ const api: PlatformAPI = ({ window.parent.postMessage(message) return new Promise((res, rej) => { - function listener(event: MessageEvent) { + function listener(event: MessageEvent): void { if (event.data.type !== "response" || event.data.header.responseId !== replyMe) { return } diff --git a/packages/taler-wallet-webextension/src/platform/firefox.ts b/packages/taler-wallet-webextension/src/platform/firefox.ts index 2f2c0fc1d..21d0e187b 100644 --- a/packages/taler-wallet-webextension/src/platform/firefox.ts +++ b/packages/taler-wallet-webextension/src/platform/firefox.ts @@ -50,7 +50,7 @@ function getPermissionsApi(): CrossBrowserPermissionsApi { * * @param callback function to be called */ -function notifyWhenAppIsReady(callback: () => void) { +function notifyWhenAppIsReady(callback: () => void): void { if (chrome.runtime && chrome.runtime.getManifest().manifest_version === 3) { callback() } else { @@ -62,13 +62,13 @@ function notifyWhenAppIsReady(callback: () => void) { function redirectTabToWalletPage( tabId: number, page: string, -) { +): void { const url = chrome.runtime.getURL(`/static/wallet.html#${page}`); console.log("redirecting tabId: ", tabId, " to: ", url); chrome.tabs.update(tabId, { url, loadReplace: true } as any); } -function useServiceWorkerAsBackgroundProcess() { +function useServiceWorkerAsBackgroundProcess(): false { return false } -- cgit v1.2.3