gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: finally make linter happy


From: gnunet
Subject: [taler-wallet-core] branch master updated: finally make linter happy
Date: Tue, 07 Apr 2020 10:29:03 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new faba5e9d finally make linter happy
faba5e9d is described below

commit faba5e9db8e0d1fdc4845de6b504b4e2ea3ca72b
Author: Florian Dold <address@hidden>
AuthorDate: Tue Apr 7 13:58:55 2020 +0530

    finally make linter happy
---
 .eslintrc.js                             |  1 +
 src/crypto/talerCrypto-test.ts           | 15 ---------------
 src/crypto/workers/browserWorkerEntry.ts |  6 +++++-
 src/headless/NodeHttpLib.ts              | 33 ++++++++++++++++----------------
 src/headless/integrationtest.ts          |  4 ++--
 src/types/dbTypes.ts                     |  1 +
 src/util/codec-test.ts                   |  2 +-
 src/util/query.ts                        |  6 +++++-
 src/util/taleruri.ts                     |  5 ++++-
 src/webex/i18n.tsx                       |  6 +++---
 src/webex/messages.ts                    |  1 -
 src/webex/pages/popup.tsx                |  7 +++++--
 12 files changed, 43 insertions(+), 44 deletions(-)

diff --git a/.eslintrc.js b/.eslintrc.js
index 0d84f0f5..102bc223 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 1efa766f..1cd9da3e 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 5ac762c1..87cb0b28 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<void> {
   const impl = new CryptoImplementation();
 
   if (!(operation in impl)) {
diff --git a/src/headless/NodeHttpLib.ts b/src/headless/NodeHttpLib.ts
index 735d6b3c..118fb9e9 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<any> => {
       let responseJson;
       try {
         responseJson = JSON.parse(respText);
diff --git a/src/headless/integrationtest.ts b/src/headless/integrationtest.ts
index 9934f204..24ceb9ce 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<void> {
   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<void> {
   const walletDbPath = cfg.getString("integrationtest", "walletdb").required();
 
   const bankBaseUrl = cfg
diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts
index 009b0531..a9344c04 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 e25a9d3c..b429c318 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 8dd3ff1e..401d22e7 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 46cc199f..2eaea284 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 3f23267d..4c111a05 100644
--- a/src/webex/i18n.tsx
+++ b/src/webex/i18n.tsx
@@ -129,7 +129,7 @@ export class Translate extends 
React.Component<TranslateProps, {}> {
       .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 19d125a8..745e309c 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 cdb09d44..0fd2477f 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<any, any> {
     const listing = Object.keys(wallet.byCurrency).map((key) => {
       const entry: WalletBalanceEntry = wallet.byCurrency[key];
       return (
-        <p>
+        <p key={key}>
           {bigAmount(entry.available)} {this.formatPending(entry)}
         </p>
       );
@@ -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],

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]