finally make linter happy

This commit is contained in:
Florian Dold 2020-04-07 13:58:55 +05:30
parent fb2e2f8993
commit faba5e9db8
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
12 changed files with 43 additions and 44 deletions

View File

@ -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",

View File

@ -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();

View File

@ -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)) {

View File

@ -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);

View File

@ -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

View File

@ -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!
}

View File

@ -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 });
});
});

View File

@ -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}`,
);

View File

@ -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;

View File

@ -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" &&

View File

@ -170,4 +170,3 @@ export interface MessageMap {
* String literal types for messages.
*/
export type MessageType = keyof MessageMap;

View File

@ -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],