diff --git a/.eslintrc.js b/.eslintrc.js index 0d84f0f58..102bc223a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -18,6 +18,7 @@ module.exports = { rules: { "no-constant-condition": ["error", { "checkLoops": false }], "prefer-const": ["warn", { destructuring: "all" }], + "no-prototype-builtins": "off", "@typescript-eslint/camelcase": "off", "@typescript-eslint/ban-ts-ignore": "off", "@typescript-eslint/no-explicit-any": "off", diff --git a/src/crypto/talerCrypto-test.ts b/src/crypto/talerCrypto-test.ts index 1efa766f3..1cd9da3e2 100644 --- a/src/crypto/talerCrypto-test.ts +++ b/src/crypto/talerCrypto-test.ts @@ -32,21 +32,6 @@ import { import { sha512, kdf } from "./primitives/kdf"; import * as nacl from "./primitives/nacl-fast"; -function hexToBytes(hex: string) { - for (var bytes = [], c = 0; c < hex.length; c += 2) - bytes.push(parseInt(hex.substr(c, 2), 16)); - return bytes; -} - -function bytesToHex(bytes: Uint8Array): string { - for (var hex = [], i = 0; i < bytes.length; i++) { - const current = bytes[i] < 0 ? bytes[i] + 256 : bytes[i]; - hex.push((current >>> 4).toString(16)); - hex.push((current & 0xf).toString(16)); - } - return hex.join(""); -} - test("encoding", (t) => { const utf8decoder = new TextDecoder("utf-8"); const utf8encoder = new TextEncoder(); diff --git a/src/crypto/workers/browserWorkerEntry.ts b/src/crypto/workers/browserWorkerEntry.ts index 5ac762c13..87cb0b28b 100644 --- a/src/crypto/workers/browserWorkerEntry.ts +++ b/src/crypto/workers/browserWorkerEntry.ts @@ -26,7 +26,11 @@ import { CryptoImplementation } from "./cryptoImplementation"; const worker: Worker = (self as any) as Worker; -async function handleRequest(operation: string, id: number, args: string[]) { +async function handleRequest( + operation: string, + id: number, + args: string[], +): Promise { const impl = new CryptoImplementation(); if (!(operation in impl)) { diff --git a/src/headless/NodeHttpLib.ts b/src/headless/NodeHttpLib.ts index 735d6b3cf..118fb9e96 100644 --- a/src/headless/NodeHttpLib.ts +++ b/src/headless/NodeHttpLib.ts @@ -16,6 +16,9 @@ SPDX-License-Identifier: AGPL3.0-or-later */ +/** + * Imports. + */ import { Headers, HttpRequestLibrary, @@ -23,7 +26,7 @@ import { HttpResponse, } from "../util/http"; import { RequestThrottler } from "../util/RequestThrottler"; -import Axios, { AxiosResponse } from "axios"; +import Axios from "axios"; /** * Implementation of the HTTP request library interface for node. @@ -35,7 +38,7 @@ export class NodeHttpLib implements HttpRequestLibrary { /** * Set whether requests should be throttled. */ - setThrottling(enabled: boolean) { + setThrottling(enabled: boolean): void { this.throttlingEnabled = enabled; } @@ -48,25 +51,21 @@ export class NodeHttpLib implements HttpRequestLibrary { if (this.throttlingEnabled && this.throttle.applyThrottle(url)) { throw Error("request throttled"); } - let resp: AxiosResponse; - try { - resp = await Axios({ - method, - url: url, - responseType: "text", - headers: opt?.headers, - validateStatus: () => true, - transformResponse: (x) => x, - data: body, - }); - } catch (e) { - throw e; - } + const resp = await Axios({ + method, + url: url, + responseType: "text", + headers: opt?.headers, + validateStatus: () => true, + transformResponse: (x) => x, + data: body, + }); + const respText = resp.data; if (typeof respText !== "string") { throw Error("unexpected response type"); } - const makeJson = async () => { + const makeJson = async (): Promise => { let responseJson; try { responseJson = JSON.parse(respText); diff --git a/src/headless/integrationtest.ts b/src/headless/integrationtest.ts index 9934f2048..24ceb9ce0 100644 --- a/src/headless/integrationtest.ts +++ b/src/headless/integrationtest.ts @@ -88,7 +88,7 @@ async function makePayment( }; } -export async function runIntegrationTest(args: IntegrationTestArgs) { +export async function runIntegrationTest(args: IntegrationTestArgs): Promise { logger.info("running test with arguments", args); const parsedSpendAmount = Amounts.parseOrThrow(args.amountToSpend); @@ -196,7 +196,7 @@ export async function runIntegrationTest(args: IntegrationTestArgs) { ); } -export async function runIntegrationTestBasic(cfg: Configuration) { +export async function runIntegrationTestBasic(cfg: Configuration): Promise { const walletDbPath = cfg.getString("integrationtest", "walletdb").required(); const bankBaseUrl = cfg diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts index 009b05315..a9344c045 100644 --- a/src/types/dbTypes.ts +++ b/src/types/dbTypes.ts @@ -522,6 +522,7 @@ export interface ExchangeWireInfo { /** * Summary of updates to the exchange. */ +// eslint-disable-next-line @typescript-eslint/no-empty-interface export interface ExchangeUpdateDiff { // FIXME: implement! } diff --git a/src/util/codec-test.ts b/src/util/codec-test.ts index e25a9d3cd..b429c318c 100644 --- a/src/util/codec-test.ts +++ b/src/util/codec-test.ts @@ -51,7 +51,7 @@ test("basic codec", (t) => { t.assert(res.foo === "hello"); t.throws(() => { - const res2 = myObjCodec.decode({ foo: 123 }); + myObjCodec.decode({ foo: 123 }); }); }); diff --git a/src/util/query.ts b/src/util/query.ts index 8dd3ff1e2..401d22e71 100644 --- a/src/util/query.ts +++ b/src/util/query.ts @@ -431,7 +431,11 @@ export function openDatabase( }; req.onupgradeneeded = (e) => { const db = req.result; - onUpgradeNeeded(db, e.oldVersion, e.newVersion!); + const newVersion = e.newVersion; + if (!newVersion) { + throw Error("upgrade needed, but new version unknown"); + } + onUpgradeNeeded(db, e.oldVersion, newVersion); console.log( `DB: upgrade needed: oldVersion=${e.oldVersion}, newVersion=${e.newVersion}`, ); diff --git a/src/util/taleruri.ts b/src/util/taleruri.ts index 46cc199f8..2eaea2846 100644 --- a/src/util/taleruri.ts +++ b/src/util/taleruri.ts @@ -97,7 +97,10 @@ export function classifyTalerUri(s: string): TalerUriType { return TalerUriType.Unknown; } -export function getOrderDownloadUrl(merchantBaseUrl: string, orderId: string): string { +export function getOrderDownloadUrl( + merchantBaseUrl: string, + orderId: string, +): string { const u = new URL("proposal", merchantBaseUrl); u.searchParams.set("order_id", orderId); return u.href; diff --git a/src/webex/i18n.tsx b/src/webex/i18n.tsx index 3f23267d5..4c111a05a 100644 --- a/src/webex/i18n.tsx +++ b/src/webex/i18n.tsx @@ -129,7 +129,7 @@ export class Translate extends React.Component { .ngettext(s, s, 1) .split(/%(\d+)\$s/) .filter((e: any, i: number) => i % 2 === 0); - const childArray = React.Children.toArray(this.props.children!); + const childArray = React.Children.toArray(this.props.children); for (let i = 0; i < childArray.length - 1; ++i) { if ( typeof childArray[i] === "string" && @@ -220,7 +220,7 @@ export class TranslatePlural extends React.Component< .ngettext(s, s, 1) .split(/%(\d+)\$s/) .filter((e: any, i: number) => i % 2 === 0); - const childArray = React.Children.toArray(this.props.children!); + const childArray = React.Children.toArray(this.props.children); for (let i = 0; i < childArray.length - 1; ++i) { if ( typeof childArray[i] === "string" && @@ -261,7 +261,7 @@ export class TranslateSingular extends React.Component< .ngettext(s, s, 1) .split(/%(\d+)\$s/) .filter((e: any, i: number) => i % 2 === 0); - const childArray = React.Children.toArray(this.props.children!); + const childArray = React.Children.toArray(this.props.children); for (let i = 0; i < childArray.length - 1; ++i) { if ( typeof childArray[i] === "string" && diff --git a/src/webex/messages.ts b/src/webex/messages.ts index 19d125a89..745e309c7 100644 --- a/src/webex/messages.ts +++ b/src/webex/messages.ts @@ -170,4 +170,3 @@ export interface MessageMap { * String literal types for messages. */ export type MessageType = keyof MessageMap; - diff --git a/src/webex/pages/popup.tsx b/src/webex/pages/popup.tsx index cdb09d444..0fd2477f6 100644 --- a/src/webex/pages/popup.tsx +++ b/src/webex/pages/popup.tsx @@ -40,6 +40,9 @@ import { HistoryEvent } from "../../types/history"; import moment from "moment"; import { Timestamp } from "../../util/time"; +// FIXME: move to newer react functions +/* eslint-disable react/no-deprecated */ + function onUpdateNotification(f: () => void): () => void { const port = chrome.runtime.connect({ name: "notifications" }); const listener = (): void => { @@ -290,7 +293,7 @@ class WalletBalanceView extends React.Component { const listing = Object.keys(wallet.byCurrency).map((key) => { const entry: WalletBalanceEntry = wallet.byCurrency[key]; return ( -

+

{bigAmount(entry.available)} {this.formatPending(entry)}

); @@ -414,7 +417,7 @@ function amountDiff( } } -function parseSummary(summary: string) { +function parseSummary(summary: string): { item: string; merchant: string } { const parsed = summary.split(/: (.+)/); return { merchant: parsed[0],