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 --- packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts | 8 +++----- .../taler-wallet-webextension/src/hooks/useBackupDeviceName.ts | 4 ++-- .../taler-wallet-webextension/src/hooks/useExtendedPermissions.ts | 2 +- packages/taler-wallet-webextension/src/hooks/useLocalStorage.ts | 4 ++-- packages/taler-wallet-webextension/src/hooks/useProviderStatus.ts | 8 ++++---- packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts | 2 +- 6 files changed, 13 insertions(+), 15 deletions(-) (limited to 'packages/taler-wallet-webextension/src/hooks') diff --git a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts index 5bd2d6f81..68bc9aed7 100644 --- a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts +++ b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts @@ -14,9 +14,7 @@ TALER; see the file COPYING. If not, see */ import { - NotificationType, - TalerErrorCode, - TalerErrorDetail, + NotificationType, TalerErrorDetail } from "@gnu-taler/taler-util"; import { TalerError } from "@gnu-taler/taler-wallet-core"; import { useEffect, useState } from "preact/hooks"; @@ -50,7 +48,7 @@ export function useAsyncAsHook( ): HookResponse { const [result, setHookResponse] = useState>(undefined); useEffect(() => { - async function doAsync() { + async function doAsync(): Promise { try { const response = await fn(); setHookResponse({ hasError: false, response }); @@ -76,6 +74,6 @@ export function useAsyncAsHook( doAsync(); }); } - }, []); + }); return result; } diff --git a/packages/taler-wallet-webextension/src/hooks/useBackupDeviceName.ts b/packages/taler-wallet-webextension/src/hooks/useBackupDeviceName.ts index 7f484b0a4..4bb332da8 100644 --- a/packages/taler-wallet-webextension/src/hooks/useBackupDeviceName.ts +++ b/packages/taler-wallet-webextension/src/hooks/useBackupDeviceName.ts @@ -29,11 +29,11 @@ export function useBackupDeviceName(): BackupDeviceName { }); useEffect(() => { - async function run() { + async function run(): Promise { //create a first list of backup info by currency const status = await wxApi.getBackupInfo(); - async function update(newName: string) { + async function update(newName: string): Promise { await wxApi.setWalletDeviceId(newName); setStatus((old) => ({ ...old, name: newName })); } diff --git a/packages/taler-wallet-webextension/src/hooks/useExtendedPermissions.ts b/packages/taler-wallet-webextension/src/hooks/useExtendedPermissions.ts index 8d563cb6d..18283995f 100644 --- a/packages/taler-wallet-webextension/src/hooks/useExtendedPermissions.ts +++ b/packages/taler-wallet-webextension/src/hooks/useExtendedPermissions.ts @@ -22,7 +22,7 @@ import { getReadRequestPermissions } from "../permissions.js"; export function useExtendedPermissions(): [boolean, () => Promise] { const [enabled, setEnabled] = useState(false); - const toggle = async () => { + const toggle = async (): Promise => { return handleExtendedPerm(enabled, setEnabled) }; diff --git a/packages/taler-wallet-webextension/src/hooks/useLocalStorage.ts b/packages/taler-wallet-webextension/src/hooks/useLocalStorage.ts index 4be82976f..31d54e451 100644 --- a/packages/taler-wallet-webextension/src/hooks/useLocalStorage.ts +++ b/packages/taler-wallet-webextension/src/hooks/useLocalStorage.ts @@ -35,7 +35,7 @@ export function useLocalStorage( const setValue = ( value?: string | ((val?: string) => string | undefined), - ) => { + ): void => { setStoredValue((p) => { const toStore = value instanceof Function ? value(p) : value; if (typeof window !== "undefined") { @@ -63,7 +63,7 @@ export function useNotNullLocalStorage( : initialValue; }); - const setValue = (value: string | ((val: string) => string)) => { + const setValue = (value: string | ((val: string) => string)): void => { const valueToStore = value instanceof Function ? value(storedValue) : value; setStoredValue(valueToStore); if (typeof window !== "undefined") { diff --git a/packages/taler-wallet-webextension/src/hooks/useProviderStatus.ts b/packages/taler-wallet-webextension/src/hooks/useProviderStatus.ts index 14af7c0aa..4e7cab393 100644 --- a/packages/taler-wallet-webextension/src/hooks/useProviderStatus.ts +++ b/packages/taler-wallet-webextension/src/hooks/useProviderStatus.ts @@ -28,7 +28,7 @@ export function useProviderStatus(url: string): ProviderStatus | undefined { const [status, setStatus] = useState(undefined); useEffect(() => { - async function run() { + async function run(): Promise { //create a first list of backup info by currency const status = await wxApi.getBackupInfo(); @@ -37,13 +37,13 @@ export function useProviderStatus(url: string): ProviderStatus | undefined { ); const info = providers.length ? providers[0] : undefined; - async function sync() { + async function sync(): Promise { if (info) { await wxApi.syncOneProvider(info.syncProviderBaseUrl); } } - async function remove() { + async function remove(): Promise { if (info) { await wxApi.removeProvider(info.syncProviderBaseUrl); } @@ -52,7 +52,7 @@ export function useProviderStatus(url: string): ProviderStatus | undefined { setStatus({ info, sync, remove }); } run(); - }, []); + }); return status; } diff --git a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts index be0a3262e..b2dd739e2 100644 --- a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts +++ b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts @@ -33,7 +33,7 @@ export function useTalerActionURL(): [ setTalerActionUrl(talerUri); } check(); - }, []); + }); const url = dismissed ? undefined : talerActionUrl; return [url, setDismissed]; } -- cgit v1.2.3