Skip to content

Commit

Permalink
Merge pull request bitpay#8084 from bitjson/tslint/prefer-conditional…
Browse files Browse the repository at this point in the history
…-expression

lint: reenable tslint prefer-conditional-expression, fix
  • Loading branch information
cmgustavo committed Feb 20, 2018
2 parents 322451a + bcdfe73 commit f2fa241
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 100 deletions.
8 changes: 4 additions & 4 deletions src/pages/backup/backup-game/backup-game.ts
Expand Up @@ -113,10 +113,10 @@ export class BackupGamePage {
};

private shouldContinue(): void {
if (this.customWords.length == this.shuffledMnemonicWords.length)
this.selectComplete = true;
else
this.selectComplete = false;
this.selectComplete =
this.customWords.length === this.shuffledMnemonicWords.length
? true
: false;
};

private showBackupResult(): void {
Expand Down
Expand Up @@ -421,13 +421,9 @@ export class BitPayCardTopUpPage {
}

private openFinishModal(): void {
let finishComment: string;
if (this.wallet.credentials.m == 1) {
finishComment = this.translate.instant('Funds were added to debit card');
}
else {
finishComment = this.translate.instant('Transaction initiated');
}
const finishComment = this.wallet.credentials.m === 1
? this.translate.instant('Funds were added to debit card')
: this.translate.instant('Transaction initiated');
let finishText = '';
let modal = this.modalCtrl.create(FinishModalPage, { finishText, finishComment }, { showBackdrop: true, enableBackdropDismiss: false });
modal.present();
Expand Down
Expand Up @@ -45,10 +45,9 @@ export class MercadoLibreCardDetailsPage {
}

public openRedeemLink() {
let url;
let isSandbox = this.mercadoLibreProvider.getNetwork() == 'testnet' ? true : false;
if (isSandbox) url = 'https://beta.mercadolivre.com.br/vale-presente/resgate';
else url = 'https://www.mercadolivre.com.br/vale-presente/resgate';
const url = this.mercadoLibreProvider.getNetwork() === 'testnet'
? 'https://beta.mercadolivre.com.br/vale-presente/resgate'
: 'https://www.mercadolivre.com.br/vale-presente/resgate';
this.openExternalLink(url);
}

Expand Down
16 changes: 4 additions & 12 deletions src/pages/send/amount/amount.ts
Expand Up @@ -355,11 +355,7 @@ export class AmountPage {
if (a) {
this.alternativeAmount = this.txFormatProvider.formatAmount(a * this.unitToSatoshi, true);
} else {
if (result) {
this.alternativeAmount = 'N/A';
} else {
this.alternativeAmount = null;
}
this.alternativeAmount = result ? 'N/A' : null;
this.allowSend = false;
}
} else {
Expand Down Expand Up @@ -426,13 +422,9 @@ export class AmountPage {
};
} else {
let amount = _amount;

if (unit.isFiat) {
amount = (this.fromFiat(amount) * this.unitToSatoshi).toFixed(0);
} else {
amount = (amount * this.unitToSatoshi).toFixed(0);
}

amount = unit.isFiat
? (this.fromFiat(amount) * this.unitToSatoshi).toFixed(0)
: (amount * this.unitToSatoshi).toFixed(0);
data = {
recipientType: this.recipientType,
amount,
Expand Down
15 changes: 5 additions & 10 deletions src/pages/send/choose-fee-level/choose-fee-level.ts
Expand Up @@ -131,16 +131,11 @@ export class ChooseFeeLevelPage {

public checkFees(feePerSatByte: string): void {
let fee = Number(feePerSatByte);


if (fee <= this.minFeeAllowed) this.showError = true;
else this.showError = false;

if (fee > this.minFeeAllowed && fee < this.minFeeRecommended) this.showMinWarning = true;
else this.showMinWarning = false;

if (fee < this.maxFeeAllowed && fee > this.maxFeeRecommended) this.showMaxWarning = true;
else this.showMaxWarning = false;
this.showError = fee <= this.minFeeAllowed ? true : false;
this.showMinWarning =
fee > this.minFeeAllowed && fee < this.minFeeRecommended ? true : false;
this.showMaxWarning =
fee < this.maxFeeAllowed && fee > this.maxFeeRecommended ? true : false;
}

public ok(): void {
Expand Down
8 changes: 2 additions & 6 deletions src/pages/settings/addressbook/view/view.ts
Expand Up @@ -40,12 +40,8 @@ export class AddressbookViewPage {
this.name = this.navParams.data.contact.name;
this.email = this.navParams.data.contact.email;

var cashAddress = this.bitcoreCash.Address.isValid(this.address, 'livenet');
if (cashAddress) {
this.coin = 'bch';
} else {
this.coin = 'btc';
}
const cashAddress = this.bitcoreCash.Address.isValid(this.address, 'livenet');
this.coin = cashAddress ? 'bch' : 'btc';
}

ionViewDidLoad() {
Expand Down
8 changes: 3 additions & 5 deletions src/pages/tx-details/tx-details.ts
Expand Up @@ -65,11 +65,9 @@ export class TxDetailsPage {
this.txsUnsubscribedForNotifications = this.config.confirmedTxsNotifications ? !this.config.confirmedTxsNotifications.enabled : true;

let defaults = this.configProvider.getDefaults();
if (this.wallet.coin == 'bch') {
this.blockexplorerUrl = defaults.blockExplorerUrl.bch;
} else {
this.blockexplorerUrl = defaults.blockExplorerUrl.btc;
}
this.blockexplorerUrl = this.wallet.coin === 'bch'
? defaults.blockExplorerUrl.bch
: defaults.blockExplorerUrl.btc;

this.txConfirmNotificationProvider.checkIfEnabled(this.txId).then((res: any) => {
this.txNotification = {
Expand Down
9 changes: 2 additions & 7 deletions src/pages/wallet-details/wallet-details.ts
Expand Up @@ -122,11 +122,7 @@ export class WalletDetailsPage {
// };
// lodash.times(15, addOutput);
// txps.push(txp);
if (!txps) {
this.txps = [];
} else {
this.txps = _.sortBy(txps, 'createdOn').reverse();
}
this.txps = !txps ? [] : _.sortBy(txps, 'createdOn').reverse();
}

private updateTxHistory() {
Expand All @@ -146,8 +142,7 @@ export class WalletDetailsPage {
this.updatingTxHistory = false;

let hasTx = txHistory[0];
if (hasTx) this.showNoTransactionsYetMsg = false;
else this.showNoTransactionsYetMsg = true;
this.showNoTransactionsYetMsg = hasTx ? false : true;

this.wallet.completeHistory = txHistory;
this.showHistory();
Expand Down
9 changes: 3 additions & 6 deletions src/providers/amazon/amazon.ts
Expand Up @@ -28,12 +28,9 @@ export class AmazonProvider {
* Production: 'livenet'
*/
this.credentials.NETWORK = 'livenet';
// TODO this.credentials.NETWORK = 'testnet';
if (this.credentials.NETWORK == 'testnet') {
this.credentials.BITPAY_API_URL = "https://test.bitpay.com";
} else {
this.credentials.BITPAY_API_URL = "https://bitpay.com";
};
this.credentials.BITPAY_API_URL = this.credentials.NETWORK === 'testnet'
? "https://test.bitpay.com"
: "https://bitpay.com";
this.limitPerDay = 2000;
this.homeItem = {
name: 'amazon',
Expand Down
12 changes: 3 additions & 9 deletions src/providers/bwc-error/bwc-error.ts
Expand Up @@ -12,15 +12,9 @@ export class BwcErrorProvider {
if (!err)
return 'Unknown error';

let name;

if (err.name) {
if (err.name == 'Error')
name = err.message
else
name = err.name.replace(/^bwc.Error/g, '');
} else
name = err;
const name = err.name ?
(err.name === 'Error' ? err.message : err.name.replace(/^bwc.Error/g, ''))
: err;

let body = '';
prefix = prefix || '';
Expand Down
8 changes: 3 additions & 5 deletions src/providers/coinbase/coinbase.ts
Expand Up @@ -100,11 +100,9 @@ export class CoinbaseProvider {
'wallet:payment-methods:read';

// NW has a bug with Window Object
if (this.isCordova) {
this.credentials.REDIRECT_URI = coinbase.redirect_uri.mobile;
} else {
this.credentials.REDIRECT_URI = coinbase.redirect_uri.desktop;
}
this.credentials.REDIRECT_URI = this.isCordova
? coinbase.redirect_uri.mobile
: coinbase.redirect_uri.desktop;

if (this.credentials.NETWORK == 'testnet') {
this.credentials.HOST = coinbase.sandbox.host;
Expand Down
6 changes: 2 additions & 4 deletions src/providers/language/language.ts
Expand Up @@ -61,10 +61,8 @@ export class LanguageProvider {
if (!_.isEmpty(lang)) this.current = lang;
else {
// Get from browser
let browserLang = this.translate.getBrowserLang();
let validBrowserLang = this.getName(browserLang) ? true : false;
if (validBrowserLang) this.current = browserLang;
else this.current = this.getDefault();
const browserLang = this.translate.getBrowserLang();
this.current = this.getName(browserLang) ? browserLang : this.getDefault();
}
this.logger.info('Default language: ' + this.current);
this.translate.setDefaultLang(this.current);
Expand Down
3 changes: 1 addition & 2 deletions src/providers/logger/logger.ts
Expand Up @@ -92,8 +92,7 @@ export class Logger {
if (typeof v == 'undefined') v = 'undefined';
if (!v) v = 'null';
if (typeof v == 'object') {
if (v.message) v = v.message;
else v = JSON.stringify(v);
v = v.message ? v.message : JSON.stringify(v);
}
} catch (e) {
// tslint:disable-next-line:no-console
Expand Down
9 changes: 3 additions & 6 deletions src/providers/mercado-libre/mercado-libre.ts
Expand Up @@ -36,12 +36,9 @@ export class MercadoLibreProvider {
*/
this.credentials = {};
this.credentials.NETWORK = 'livenet';
// TODO this.credentials.NETWORK = 'testnet';
if (this.credentials.NETWORK == 'testnet') {
this.credentials.BITPAY_API_URL = "https://test.bitpay.com";
} else {
this.credentials.BITPAY_API_URL = "https://bitpay.com";
}
this.credentials.BITPAY_API_URL = this.credentials.NETWORK === 'testnet'
? "https://test.bitpay.com"
: "https://bitpay.com";

this.homeItem = {
name: 'mercadoLibre',
Expand Down
8 changes: 3 additions & 5 deletions src/providers/persistence/persistence.ts
Expand Up @@ -58,11 +58,9 @@ export class PersistenceProvider {
};

public load() {
if (this.platform.isCordova) {
this.storage = new FileStorage(this.file, this.logger);
} else {
this.storage = new LocalStorage();
}
this.storage = this.platform.isCordova
? new FileStorage(this.file, this.logger)
: new LocalStorage();
}

storeNewProfile(profile): Promise<void> {
Expand Down
10 changes: 3 additions & 7 deletions src/providers/shapeshift/shapeshift.ts
Expand Up @@ -34,14 +34,10 @@ export class ShapeshiftProvider {
* Production: 'livenet'
*/
this.credentials.NETWORK = 'livenet';
// TODO this.credentials.NETWORK = 'testnet';

if (this.credentials.NETWORK == 'testnet') {
this.credentials.API_URL = "";
} else {
this.credentials.API_URL = this.credentials.NETWORK === 'testnet'
? ""
// CORS: cors.shapeshift.io
this.credentials.API_URL = "https://shapeshift.io";
}
: "https://shapeshift.io";

this.homeItem = {
name: 'shapeshift',
Expand Down
1 change: 0 additions & 1 deletion tslint.json
Expand Up @@ -21,7 +21,6 @@
"no-implicit-dependencies": false,
"object-literal-sort-keys": false,
"interface-name": false,
"prefer-conditional-expression": false,
"prefer-for-of": false,
"forin": false,
"prefer-const": false,
Expand Down

0 comments on commit f2fa241

Please sign in to comment.