From b5c90d12219ca3a0df173ddf085d2353831a8ef6 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 29 May 2017 16:58:03 +0200 Subject: fix remaining lint warnings --- src/i18n.tsx | 41 ++++++++++++------------- src/memidb.ts | 3 ++ src/types.ts | 7 +++-- src/webex/pages/add-auditor.tsx | 58 ++++++++++++++++++++++-------------- src/webex/pages/auditors.tsx | 51 ++++++++++++++++++------------- src/webex/pages/confirm-contract.tsx | 39 ++++++++++++------------ src/webex/wxApi.ts | 2 +- 7 files changed, 114 insertions(+), 87 deletions(-) (limited to 'src') diff --git a/src/i18n.tsx b/src/i18n.tsx index 8c3d54192..8f2c15443 100644 --- a/src/i18n.tsx +++ b/src/i18n.tsx @@ -21,8 +21,9 @@ /** * Imports. */ -import * as jedLib from "jed"; import {strings} from "./i18n/strings"; + +import * as jedLib from "jed"; import * as React from "react"; let lang: string; @@ -111,15 +112,15 @@ interface TranslateProps { * * ``` */ -export class Translate extends React.Component { +export class Translate extends React.Component { render(): JSX.Element { const s = stringifyChildren(this.props.children); - const tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 == 0); + const tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 === 0); const childArray = React.Children.toArray(this.props.children!); for (let i = 0; i < childArray.length - 1; ++i) { - if ((typeof childArray[i]) == "string" && (typeof childArray[i+1]) == "string") { - childArray[i+1] = (childArray[i] as string).concat(childArray[i+1] as string); - childArray.splice(i,1); + if ((typeof childArray[i]) === "string" && (typeof childArray[i + 1]) === "string") { + childArray[i + 1] = (childArray[i] as string).concat(childArray[i + 1] as string); + childArray.splice(i, 1); } } const result = []; @@ -155,20 +156,20 @@ export class Translate extends React.Component { * * ``` */ -export class TranslateSwitch extends React.Component{ +export class TranslateSwitch extends React.Component { render(): JSX.Element { let singular: React.ReactElement | undefined; let plural: React.ReactElement | undefined; const children = this.props.children; if (children) { React.Children.forEach(children, (child: any) => { - if (child.type == TranslatePlural) { + if (child.type === TranslatePlural) { plural = child; } - if (child.type == TranslateSingular) { + if (child.type === TranslateSingular) { singular = child; } - }); + }); } if ((!singular) || (!plural)) { console.error("translation not found"); @@ -190,15 +191,15 @@ interface TranslationPluralProps { /** * See [[TranslateSwitch]]. */ -export class TranslatePlural extends React.Component { +export class TranslatePlural extends React.Component { render(): JSX.Element { const s = stringifyChildren(this.props.children); - const tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 == 0); + const tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 === 0); const childArray = React.Children.toArray(this.props.children!); for (let i = 0; i < childArray.length - 1; ++i) { - if ((typeof childArray[i]) == "string" && (typeof childArray[i + 1]) == "string") { - childArray[i+i] = childArray[i] as string + childArray[i + 1] as string; - childArray.splice(i,1); + if ((typeof childArray[i]) === "string" && (typeof childArray[i + 1]) === "string") { + childArray[i + i] = childArray[i] as string + childArray[i + 1] as string; + childArray.splice(i, 1); } } const result = []; @@ -222,15 +223,15 @@ export class TranslatePlural extends React.Component { +export class TranslateSingular extends React.Component { render(): JSX.Element { const s = stringifyChildren(this.props.children); - const tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 == 0); + const tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 === 0); const childArray = React.Children.toArray(this.props.children!); for (let i = 0; i < childArray.length - 1; ++i) { - if ((typeof childArray[i]) == "string" && (typeof childArray[i + 1]) == "string") { - childArray[i+i] = childArray[i] as string + childArray[i + 1] as string; - childArray.splice(i,1); + if ((typeof childArray[i]) === "string" && (typeof childArray[i + 1]) === "string") { + childArray[i + i] = childArray[i] as string + childArray[i + 1] as string; + childArray.splice(i, 1); } } const result = []; diff --git a/src/memidb.ts b/src/memidb.ts index e36183ffb..fe1d986f1 100644 --- a/src/memidb.ts +++ b/src/memidb.ts @@ -18,6 +18,9 @@ * In-memory implementation of the IndexedDB interface. */ +/* work in progres ... */ +/* tslint:disable */ + interface StoredObject { key: any; diff --git a/src/types.ts b/src/types.ts index 8b5f4063b..aac429c76 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1117,8 +1117,6 @@ export class OfferRecord { } - - /** * Wire fee for one wire method as stored in the * wallet's database. @@ -1380,8 +1378,11 @@ export function mkAmount(value: number, fraction: number, currency: string): Amo } /** - * Possible responses for checkPay. + * Possible results for checkPay. */ export type CheckPayResult = "paid" | "payment-possible" | "insufficient-balance"; +/** + * Possible results for confirmPay. + */ export type ConfirmPayResult = "paid" | "insufficient-balance"; diff --git a/src/webex/pages/add-auditor.tsx b/src/webex/pages/add-auditor.tsx index e4d84798b..72e800192 100644 --- a/src/webex/pages/add-auditor.tsx +++ b/src/webex/pages/add-auditor.tsx @@ -23,14 +23,14 @@ import { getTalerStampDate } from "../../helpers"; import { - ExchangeRecord, - DenominationRecord, AuditorRecord, - CurrencyRecord, - ReserveRecord, CoinRecord, + CurrencyRecord, + Denomination, + DenominationRecord, + ExchangeRecord, PreCoinRecord, - Denomination + ReserveRecord, } from "../../types"; import { ImplicitStateComponent, StateHolder } from "../components"; @@ -51,17 +51,17 @@ interface ConfirmAuditorProps { } class ConfirmAuditor extends ImplicitStateComponent { - addDone: StateHolder = this.makeState(false); + private addDone: StateHolder = this.makeState(false); constructor() { super(); } async add() { - let currencies = await getCurrencies(); - let currency: CurrencyRecord|undefined = undefined; + const currencies = await getCurrencies(); + let currency: CurrencyRecord|undefined; - for (let c of currencies) { - if (c.name == this.props.currency) { + for (const c of currencies) { + if (c.name === this.props.currency) { currency = c; } } @@ -70,12 +70,16 @@ class ConfirmAuditor extends ImplicitStateComponent { currency = { name: this.props.currency, auditors: [], fractionalDigits: 2, exchanges: [] }; } - let newAuditor = { auditorPub: this.props.auditorPub, baseUrl: this.props.url, expirationStamp: this.props.expirationStamp }; + const newAuditor = { + auditorPub: this.props.auditorPub, + baseUrl: this.props.url, + expirationStamp: this.props.expirationStamp, + }; let auditorFound = false; - for (let idx in currency.auditors) { - let a = currency.auditors[idx]; - if (a.baseUrl == this.props.url) { + for (const idx in currency.auditors) { + const a = currency.auditors[idx]; + if (a.baseUrl === this.props.url) { auditorFound = true; // Update auditor if already found by URL. currency.auditors[idx] = newAuditor; @@ -99,22 +103,30 @@ class ConfirmAuditor extends ImplicitStateComponent { return (

Do you want to let {this.props.auditorPub} audit the currency "{this.props.currency}"?

- {this.addDone() ? - (
Auditor was added! You can also view and edit auditors.
) - : - (
- - -
) + {this.addDone() ? + ( +
+ Auditor was added! You can also{" "} + view and edit{" "} + auditors. +
+ ) + : + ( +
+ + +
+ ) }
); } } -export function main() { +function main() { const walletPageUrl = new URI(document.location.href); - const query: any = JSON.parse((URI.parseQuery(walletPageUrl.query()) as any)["req"]); + const query: any = JSON.parse((URI.parseQuery(walletPageUrl.query()) as any).req); const url = query.url; const currency: string = query.currency; const auditorPub: string = query.auditorPub; diff --git a/src/webex/pages/auditors.tsx b/src/webex/pages/auditors.tsx index dac3c2be9..7c6a3aff1 100644 --- a/src/webex/pages/auditors.tsx +++ b/src/webex/pages/auditors.tsx @@ -23,15 +23,15 @@ import { getTalerStampDate } from "../../helpers"; import { - ExchangeRecord, - ExchangeForCurrencyRecord, - DenominationRecord, AuditorRecord, - CurrencyRecord, - ReserveRecord, CoinRecord, + CurrencyRecord, + Denomination, + DenominationRecord, + ExchangeForCurrencyRecord, + ExchangeRecord, PreCoinRecord, - Denomination + ReserveRecord, } from "../../types"; import { ImplicitStateComponent, StateHolder } from "../components"; @@ -39,6 +39,7 @@ import { getCurrencies, updateCurrency, } from "../wxApi"; + import * as React from "react"; import * as ReactDOM from "react-dom"; @@ -49,7 +50,7 @@ interface CurrencyListState { class CurrencyList extends React.Component { constructor() { super(); - let port = chrome.runtime.connect(); + const port = chrome.runtime.connect(); port.onMessage.addListener((msg: any) => { if (msg.notify) { console.log("got notified"); @@ -61,35 +62,39 @@ class CurrencyList extends React.Component { } async update() { - let currencies = await getCurrencies(); + const currencies = await getCurrencies(); console.log("currencies: ", currencies); this.setState({ currencies }); } async confirmRemoveAuditor(c: CurrencyRecord, a: AuditorRecord) { if (window.confirm(`Do you really want to remove auditor ${a.baseUrl} for currency ${c.name}?`)) { - c.auditors = c.auditors.filter((x) => x.auditorPub != a.auditorPub); + c.auditors = c.auditors.filter((x) => x.auditorPub !== a.auditorPub); await updateCurrency(c); } } async confirmRemoveExchange(c: CurrencyRecord, e: ExchangeForCurrencyRecord) { if (window.confirm(`Do you really want to remove exchange ${e.baseUrl} for currency ${c.name}?`)) { - c.exchanges = c.exchanges.filter((x) => x.baseUrl != e.baseUrl); + c.exchanges = c.exchanges.filter((x) => x.baseUrl !== e.baseUrl); await updateCurrency(c); } } renderAuditors(c: CurrencyRecord): any { - if (c.auditors.length == 0) { - return

No trusted auditors for this currency.

+ if (c.auditors.length === 0) { + return

No trusted auditors for this currency.

; } return (

Trusted Auditors:

    - {c.auditors.map(a => ( -
  • {a.baseUrl} + {c.auditors.map((a) => ( +
  • + {a.baseUrl}{" "} +
    • valid until {new Date(a.expirationStamp).toString()}
    • public key {a.auditorPub}
    • @@ -102,15 +107,19 @@ class CurrencyList extends React.Component { } renderExchanges(c: CurrencyRecord): any { - if (c.exchanges.length == 0) { - return

      No trusted exchanges for this currency.

      + if (c.exchanges.length === 0) { + return

      No trusted exchanges for this currency.

      ; } return (

      Trusted Exchanges:

        - {c.exchanges.map(e => ( -
      • {e.baseUrl} + {c.exchanges.map((e) => ( +
      • + {e.baseUrl}{" "} +
      • ))}
      @@ -119,13 +128,13 @@ class CurrencyList extends React.Component { } render(): JSX.Element { - let currencies = this.state.currencies; + const currencies = this.state.currencies; if (!currencies) { return ...; } return (
      - {currencies.map(c => ( + {currencies.map((c) => (

      Currency {c.name}

      Displayed with {c.fractionalDigits} fractional digits.

      @@ -140,7 +149,7 @@ class CurrencyList extends React.Component { } } -export function main() { +function main() { ReactDOM.render(, document.getElementById("container")!); } diff --git a/src/webex/pages/confirm-contract.tsx b/src/webex/pages/confirm-contract.tsx index cc3025847..dc7bd46af 100644 --- a/src/webex/pages/confirm-contract.tsx +++ b/src/webex/pages/confirm-contract.tsx @@ -44,8 +44,8 @@ interface DetailState { } interface DetailProps { - contract: Contract - collapsed: boolean + contract: Contract; + collapsed: boolean; exchanges: null|ExchangeRecord[]; } @@ -66,7 +66,7 @@ class Details extends React.Component { return (