finally make linter happy
This commit is contained in:
parent
fb2e2f8993
commit
faba5e9db8
@ -18,6 +18,7 @@ module.exports = {
|
|||||||
rules: {
|
rules: {
|
||||||
"no-constant-condition": ["error", { "checkLoops": false }],
|
"no-constant-condition": ["error", { "checkLoops": false }],
|
||||||
"prefer-const": ["warn", { destructuring: "all" }],
|
"prefer-const": ["warn", { destructuring: "all" }],
|
||||||
|
"no-prototype-builtins": "off",
|
||||||
"@typescript-eslint/camelcase": "off",
|
"@typescript-eslint/camelcase": "off",
|
||||||
"@typescript-eslint/ban-ts-ignore": "off",
|
"@typescript-eslint/ban-ts-ignore": "off",
|
||||||
"@typescript-eslint/no-explicit-any": "off",
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
@ -32,21 +32,6 @@ import {
|
|||||||
import { sha512, kdf } from "./primitives/kdf";
|
import { sha512, kdf } from "./primitives/kdf";
|
||||||
import * as nacl from "./primitives/nacl-fast";
|
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) => {
|
test("encoding", (t) => {
|
||||||
const utf8decoder = new TextDecoder("utf-8");
|
const utf8decoder = new TextDecoder("utf-8");
|
||||||
const utf8encoder = new TextEncoder();
|
const utf8encoder = new TextEncoder();
|
||||||
|
@ -26,7 +26,11 @@ import { CryptoImplementation } from "./cryptoImplementation";
|
|||||||
|
|
||||||
const worker: Worker = (self as any) as Worker;
|
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();
|
const impl = new CryptoImplementation();
|
||||||
|
|
||||||
if (!(operation in impl)) {
|
if (!(operation in impl)) {
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
SPDX-License-Identifier: AGPL3.0-or-later
|
SPDX-License-Identifier: AGPL3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imports.
|
||||||
|
*/
|
||||||
import {
|
import {
|
||||||
Headers,
|
Headers,
|
||||||
HttpRequestLibrary,
|
HttpRequestLibrary,
|
||||||
@ -23,7 +26,7 @@ import {
|
|||||||
HttpResponse,
|
HttpResponse,
|
||||||
} from "../util/http";
|
} from "../util/http";
|
||||||
import { RequestThrottler } from "../util/RequestThrottler";
|
import { RequestThrottler } from "../util/RequestThrottler";
|
||||||
import Axios, { AxiosResponse } from "axios";
|
import Axios from "axios";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the HTTP request library interface for node.
|
* Implementation of the HTTP request library interface for node.
|
||||||
@ -35,7 +38,7 @@ export class NodeHttpLib implements HttpRequestLibrary {
|
|||||||
/**
|
/**
|
||||||
* Set whether requests should be throttled.
|
* Set whether requests should be throttled.
|
||||||
*/
|
*/
|
||||||
setThrottling(enabled: boolean) {
|
setThrottling(enabled: boolean): void {
|
||||||
this.throttlingEnabled = enabled;
|
this.throttlingEnabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,25 +51,21 @@ export class NodeHttpLib implements HttpRequestLibrary {
|
|||||||
if (this.throttlingEnabled && this.throttle.applyThrottle(url)) {
|
if (this.throttlingEnabled && this.throttle.applyThrottle(url)) {
|
||||||
throw Error("request throttled");
|
throw Error("request throttled");
|
||||||
}
|
}
|
||||||
let resp: AxiosResponse;
|
const resp = await Axios({
|
||||||
try {
|
method,
|
||||||
resp = await Axios({
|
url: url,
|
||||||
method,
|
responseType: "text",
|
||||||
url: url,
|
headers: opt?.headers,
|
||||||
responseType: "text",
|
validateStatus: () => true,
|
||||||
headers: opt?.headers,
|
transformResponse: (x) => x,
|
||||||
validateStatus: () => true,
|
data: body,
|
||||||
transformResponse: (x) => x,
|
});
|
||||||
data: body,
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
const respText = resp.data;
|
const respText = resp.data;
|
||||||
if (typeof respText !== "string") {
|
if (typeof respText !== "string") {
|
||||||
throw Error("unexpected response type");
|
throw Error("unexpected response type");
|
||||||
}
|
}
|
||||||
const makeJson = async () => {
|
const makeJson = async (): Promise<any> => {
|
||||||
let responseJson;
|
let responseJson;
|
||||||
try {
|
try {
|
||||||
responseJson = JSON.parse(respText);
|
responseJson = JSON.parse(respText);
|
||||||
|
@ -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);
|
logger.info("running test with arguments", args);
|
||||||
|
|
||||||
const parsedSpendAmount = Amounts.parseOrThrow(args.amountToSpend);
|
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 walletDbPath = cfg.getString("integrationtest", "walletdb").required();
|
||||||
|
|
||||||
const bankBaseUrl = cfg
|
const bankBaseUrl = cfg
|
||||||
|
@ -522,6 +522,7 @@ export interface ExchangeWireInfo {
|
|||||||
/**
|
/**
|
||||||
* Summary of updates to the exchange.
|
* Summary of updates to the exchange.
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||||
export interface ExchangeUpdateDiff {
|
export interface ExchangeUpdateDiff {
|
||||||
// FIXME: implement!
|
// FIXME: implement!
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ test("basic codec", (t) => {
|
|||||||
t.assert(res.foo === "hello");
|
t.assert(res.foo === "hello");
|
||||||
|
|
||||||
t.throws(() => {
|
t.throws(() => {
|
||||||
const res2 = myObjCodec.decode({ foo: 123 });
|
myObjCodec.decode({ foo: 123 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -431,7 +431,11 @@ export function openDatabase(
|
|||||||
};
|
};
|
||||||
req.onupgradeneeded = (e) => {
|
req.onupgradeneeded = (e) => {
|
||||||
const db = req.result;
|
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(
|
console.log(
|
||||||
`DB: upgrade needed: oldVersion=${e.oldVersion}, newVersion=${e.newVersion}`,
|
`DB: upgrade needed: oldVersion=${e.oldVersion}, newVersion=${e.newVersion}`,
|
||||||
);
|
);
|
||||||
|
@ -97,7 +97,10 @@ export function classifyTalerUri(s: string): TalerUriType {
|
|||||||
return TalerUriType.Unknown;
|
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);
|
const u = new URL("proposal", merchantBaseUrl);
|
||||||
u.searchParams.set("order_id", orderId);
|
u.searchParams.set("order_id", orderId);
|
||||||
return u.href;
|
return u.href;
|
||||||
|
@ -129,7 +129,7 @@ export class Translate extends React.Component<TranslateProps, {}> {
|
|||||||
.ngettext(s, s, 1)
|
.ngettext(s, s, 1)
|
||||||
.split(/%(\d+)\$s/)
|
.split(/%(\d+)\$s/)
|
||||||
.filter((e: any, i: number) => i % 2 === 0);
|
.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) {
|
for (let i = 0; i < childArray.length - 1; ++i) {
|
||||||
if (
|
if (
|
||||||
typeof childArray[i] === "string" &&
|
typeof childArray[i] === "string" &&
|
||||||
@ -220,7 +220,7 @@ export class TranslatePlural extends React.Component<
|
|||||||
.ngettext(s, s, 1)
|
.ngettext(s, s, 1)
|
||||||
.split(/%(\d+)\$s/)
|
.split(/%(\d+)\$s/)
|
||||||
.filter((e: any, i: number) => i % 2 === 0);
|
.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) {
|
for (let i = 0; i < childArray.length - 1; ++i) {
|
||||||
if (
|
if (
|
||||||
typeof childArray[i] === "string" &&
|
typeof childArray[i] === "string" &&
|
||||||
@ -261,7 +261,7 @@ export class TranslateSingular extends React.Component<
|
|||||||
.ngettext(s, s, 1)
|
.ngettext(s, s, 1)
|
||||||
.split(/%(\d+)\$s/)
|
.split(/%(\d+)\$s/)
|
||||||
.filter((e: any, i: number) => i % 2 === 0);
|
.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) {
|
for (let i = 0; i < childArray.length - 1; ++i) {
|
||||||
if (
|
if (
|
||||||
typeof childArray[i] === "string" &&
|
typeof childArray[i] === "string" &&
|
||||||
|
@ -170,4 +170,3 @@ export interface MessageMap {
|
|||||||
* String literal types for messages.
|
* String literal types for messages.
|
||||||
*/
|
*/
|
||||||
export type MessageType = keyof MessageMap;
|
export type MessageType = keyof MessageMap;
|
||||||
|
|
||||||
|
@ -40,6 +40,9 @@ import { HistoryEvent } from "../../types/history";
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { Timestamp } from "../../util/time";
|
import { Timestamp } from "../../util/time";
|
||||||
|
|
||||||
|
// FIXME: move to newer react functions
|
||||||
|
/* eslint-disable react/no-deprecated */
|
||||||
|
|
||||||
function onUpdateNotification(f: () => void): () => void {
|
function onUpdateNotification(f: () => void): () => void {
|
||||||
const port = chrome.runtime.connect({ name: "notifications" });
|
const port = chrome.runtime.connect({ name: "notifications" });
|
||||||
const listener = (): void => {
|
const listener = (): void => {
|
||||||
@ -290,7 +293,7 @@ class WalletBalanceView extends React.Component<any, any> {
|
|||||||
const listing = Object.keys(wallet.byCurrency).map((key) => {
|
const listing = Object.keys(wallet.byCurrency).map((key) => {
|
||||||
const entry: WalletBalanceEntry = wallet.byCurrency[key];
|
const entry: WalletBalanceEntry = wallet.byCurrency[key];
|
||||||
return (
|
return (
|
||||||
<p>
|
<p key={key}>
|
||||||
{bigAmount(entry.available)} {this.formatPending(entry)}
|
{bigAmount(entry.available)} {this.formatPending(entry)}
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
@ -414,7 +417,7 @@ function amountDiff(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseSummary(summary: string) {
|
function parseSummary(summary: string): { item: string; merchant: string } {
|
||||||
const parsed = summary.split(/: (.+)/);
|
const parsed = summary.split(/: (.+)/);
|
||||||
return {
|
return {
|
||||||
merchant: parsed[0],
|
merchant: parsed[0],
|
||||||
|
Loading…
Reference in New Issue
Block a user