From a08c3bc01b11fbd0e3a243359befbe9fc909edf4 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 21 Jun 2016 13:18:32 -0700 Subject: Auto linted --- ui/app/components/account-export.js | 21 +++++---- ui/app/components/account-panel.js | 15 +++---- ui/app/components/drop-menu-item.js | 8 ++-- ui/app/components/editable-label.js | 19 ++++---- ui/app/components/eth-balance.js | 4 +- ui/app/components/identicon.js | 6 +-- ui/app/components/mascot.js | 14 +++--- ui/app/components/network.js | 58 ++++++++++++------------- ui/app/components/panel.js | 5 +-- ui/app/components/pending-msg.js | 9 ++-- ui/app/components/pending-tx.js | 9 ++-- ui/app/components/template.js | 5 +-- ui/app/components/transaction-list-item-icon.js | 11 +++-- ui/app/components/transaction-list-item.js | 22 +++++----- ui/app/components/transaction-list.js | 8 ++-- 15 files changed, 98 insertions(+), 116 deletions(-) (limited to 'ui/app/components') diff --git a/ui/app/components/account-export.js b/ui/app/components/account-export.js index e31951a7d..f36b9faeb 100644 --- a/ui/app/components/account-export.js +++ b/ui/app/components/account-export.js @@ -6,14 +6,13 @@ const actions = require('../actions') module.exports = ExportAccountView - inherits(ExportAccountView, Component) -function ExportAccountView() { +function ExportAccountView () { Component.call(this) } -ExportAccountView.prototype.render = function() { - console.log("EXPORT VIEW") +ExportAccountView.prototype.render = function () { + console.log('EXPORT VIEW') console.dir(this.props) var state = this.props var accountDetail = state.accountDetail @@ -47,13 +46,13 @@ ExportAccountView.prototype.render = function() { style: { position: 'relative', top: '1.5px', - } + }, }), h('button', { onClick: () => this.onExportKeyPress({ key: 'Enter', preventDefault: () => {} }), }, 'Submit'), h('button', { - onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)) + onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)), }, 'Cancel'), ]) @@ -72,18 +71,18 @@ ExportAccountView.prototype.render = function() { webkitUserSelect: 'text', width: '100%', }, - onClick: function(event) { + onClick: function (event) { copyToClipboard(accountDetail.privateKey) - } + }, }, accountDetail.privateKey), h('button', { - onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)) + onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)), }, 'Done'), ]) } } -ExportAccountView.prototype.onExportKeyPress = function(event) { +ExportAccountView.prototype.onExportKeyPress = function (event) { if (event.key !== 'Enter') return event.preventDefault() @@ -96,6 +95,6 @@ ExportAccountView.prototype.onExportKeyPress = function(event) { } } -ExportAccountView.prototype.exportAccount = function(address) { +ExportAccountView.prototype.exportAccount = function (address) { this.props.dispatch(actions.exportAccount(address)) } diff --git a/ui/app/components/account-panel.js b/ui/app/components/account-panel.js index 5583d06ae..05ac5d67b 100644 --- a/ui/app/components/account-panel.js +++ b/ui/app/components/account-panel.js @@ -10,13 +10,12 @@ const Panel = require('./panel') module.exports = AccountPanel - inherits(AccountPanel, Component) -function AccountPanel() { +function AccountPanel () { Component.call(this) } -AccountPanel.prototype.render = function() { +AccountPanel.prototype.render = function () { var state = this.props var identity = state.identity || {} var account = state.account || {} @@ -40,21 +39,19 @@ AccountPanel.prototype.render = function() { value: addressSummary(identity.address), }, balanceOrFaucetingIndication(account, isFauceting), - ] + ], } return h(Panel, panelOpts, !state.onShowDetail ? null : h('.arrow-right.cursor-pointer', [ h('i.fa.fa-chevron-right.fa-lg'), ])) - } -function balanceOrFaucetingIndication(account, isFauceting) { - +function balanceOrFaucetingIndication (account, isFauceting) { // Temporarily deactivating isFauceting indication // because it shows fauceting for empty restored accounts. - if (/*isFauceting*/ false) { + if (/* isFauceting*/ false) { return { key: 'Account is auto-funding.', value: 'Please wait.', @@ -62,7 +59,7 @@ function balanceOrFaucetingIndication(account, isFauceting) { } else { return { key: 'BALANCE', - value: formatBalance(account.balance) + value: formatBalance(account.balance), } } } diff --git a/ui/app/components/drop-menu-item.js b/ui/app/components/drop-menu-item.js index c8e61278c..d9fde72ac 100644 --- a/ui/app/components/drop-menu-item.js +++ b/ui/app/components/drop-menu-item.js @@ -4,16 +4,14 @@ const inherits = require('util').inherits module.exports = DropMenuItem - inherits(DropMenuItem, Component) -function DropMenuItem() { +function DropMenuItem () { Component.call(this) } -DropMenuItem.prototype.render = function() { - +DropMenuItem.prototype.render = function () { return h('li.drop-menu-item', { - onClick:() => { + onClick: () => { this.props.closeMenu() this.props.action() }, diff --git a/ui/app/components/editable-label.js b/ui/app/components/editable-label.js index 41c129d4e..303c49c44 100644 --- a/ui/app/components/editable-label.js +++ b/ui/app/components/editable-label.js @@ -5,46 +5,43 @@ const findDOMNode = require('react-dom').findDOMNode module.exports = EditableLabel - inherits(EditableLabel, Component) -function EditableLabel() { +function EditableLabel () { Component.call(this) } -EditableLabel.prototype.render = function() { +EditableLabel.prototype.render = function () { const props = this.props let state = this.state if (state && state.isEditingLabel) { - return h('div.editable-label', [ h('input.sizing-input', { defaultValue: props.textValue, - onKeyPress:(event) => { + onKeyPress: (event) => { this.saveIfEnter(event) }, }), h('button.editable-button', { - onClick:() => this.saveText(), - }, 'Save') + onClick: () => this.saveText(), + }, 'Save'), ]) - } else { return h('div.name-label', { - onClick:(event) => { + onClick: (event) => { this.setState({ isEditingLabel: true }) }, }, this.props.children) } } -EditableLabel.prototype.saveIfEnter = function(event) { +EditableLabel.prototype.saveIfEnter = function (event) { if (event.key === 'Enter') { this.saveText() } } -EditableLabel.prototype.saveText = function() { +EditableLabel.prototype.saveText = function () { var container = findDOMNode(this) var text = container.querySelector('.editable-label input').value this.props.saveText(text) diff --git a/ui/app/components/eth-balance.js b/ui/app/components/eth-balance.js index 76b75d4c8..0423d2ab6 100644 --- a/ui/app/components/eth-balance.js +++ b/ui/app/components/eth-balance.js @@ -7,11 +7,11 @@ const formatBalance = require('../util').formatBalance module.exports = EthBalanceComponent inherits(EthBalanceComponent, Component) -function EthBalanceComponent() { +function EthBalanceComponent () { Component.call(this) } -EthBalanceComponent.prototype.render = function() { +EthBalanceComponent.prototype.render = function () { var state = this.props var style = state.style var value = formatBalance(state.value) diff --git a/ui/app/components/identicon.js b/ui/app/components/identicon.js index fd61b3125..5fe07ce7a 100644 --- a/ui/app/components/identicon.js +++ b/ui/app/components/identicon.js @@ -9,13 +9,13 @@ const iconFactory = iconFactoryGen(jazzicon) module.exports = IdenticonComponent inherits(IdenticonComponent, Component) -function IdenticonComponent() { +function IdenticonComponent () { Component.call(this) this.defaultDiameter = 46 } -IdenticonComponent.prototype.render = function() { +IdenticonComponent.prototype.render = function () { var state = this.props var diameter = state.diameter || this.defaultDiameter return ( @@ -32,7 +32,7 @@ IdenticonComponent.prototype.render = function() { ) } -IdenticonComponent.prototype.componentDidMount = function(){ +IdenticonComponent.prototype.componentDidMount = function () { var state = this.props var address = state.address diff --git a/ui/app/components/mascot.js b/ui/app/components/mascot.js index e043caca1..3e0ecc14f 100644 --- a/ui/app/components/mascot.js +++ b/ui/app/components/mascot.js @@ -7,9 +7,8 @@ const debounce = require('debounce') module.exports = Mascot - inherits(Mascot, Component) -function Mascot() { +function Mascot () { Component.call(this) this.logo = metamaskLogo({ followMouse: true, @@ -22,8 +21,7 @@ function Mascot() { this.unfollowMouse = this.logo.setFollowMouse.bind(this.logo, false) } - -Mascot.prototype.render = function() { +Mascot.prototype.render = function () { // this is a bit hacky // the event emitter is on `this.props` // and we dont get that until render @@ -36,19 +34,19 @@ Mascot.prototype.render = function() { ) } -Mascot.prototype.componentDidMount = function() { +Mascot.prototype.componentDidMount = function () { if (!this.logo) return var targetDivId = 'metamask-mascot-container' var container = document.getElementById(targetDivId) container.appendChild(this.logo.canvas) } -Mascot.prototype.componentWillUnmount = function() { +Mascot.prototype.componentWillUnmount = function () { if (!this.logo) return this.logo.canvas.remove() } -Mascot.prototype.handleAnimationEvents = function(){ +Mascot.prototype.handleAnimationEvents = function () { if (!this.logo) return // only setup listeners once if (this.animations) return @@ -57,7 +55,7 @@ Mascot.prototype.handleAnimationEvents = function(){ this.animations.on('setFollowMouse', this.logo.setFollowMouse.bind(this.logo)) } -Mascot.prototype.lookAt = function(target){ +Mascot.prototype.lookAt = function (target) { if (!this.logo) return this.unfollowMouse() this.logo.lookAt(target) diff --git a/ui/app/components/network.js b/ui/app/components/network.js index b226a6db6..5a84e7d58 100644 --- a/ui/app/components/network.js +++ b/ui/app/components/network.js @@ -6,34 +6,34 @@ module.exports = Network inherits(Network, Component) -function Network() { +function Network () { Component.call(this) } -Network.prototype.render = function() { +Network.prototype.render = function () { const state = this.props const networkNumber = state.network let iconName, hoverText - const imagePath = "/images/" + const imagePath = '/images/' - if (networkNumber == 'loading') { + if (networkNumber == 'loading') { return h('img', { title: 'Attempting to connect to blockchain.', - onClick:(event) => this.props.onClick(event), + onClick: (event) => this.props.onClick(event), style: { width: '27px', - marginRight: '-27px' + marginRight: '-27px', }, src: 'images/loading.svg', }) - } else if (parseInt(networkNumber) == 1) { + } else if (parseInt(networkNumber) == 1) { hoverText = 'Main Ethereum Network' iconName = 'ethereum-network' - }else if (parseInt(networkNumber) == 2) { - hoverText = "Morden Test Network" + } else if (parseInt(networkNumber) == 2) { + hoverText = 'Morden Test Network' iconName = 'morden-test-network' - }else { - hoverText = "Unknown Private Network" + } else { + hoverText = 'Unknown Private Network' iconName = 'unknown-private-network' } return ( @@ -43,24 +43,24 @@ Network.prototype.render = function() { marginLeft: '-3px', }, title: hoverText, - onClick:(event) => this.props.onClick(event), - },[ - function() { - switch (iconName) { - case 'ethereum-network': - return h('.menu-icon.ether-icon') - case 'morden-test-network': - return h('.menu-icon.morden-icon') - default: - return h('i.fa.fa-question-circle.fa-lg', { - ariaHidden: true, - style: { - margin: '10px', - color: 'rgb(125, 128, 130)', - }, - }) - } - }() + onClick: (event) => this.props.onClick(event), + }, [ + function () { + switch (iconName) { + case 'ethereum-network': + return h('.menu-icon.ether-icon') + case 'morden-test-network': + return h('.menu-icon.morden-icon') + default: + return h('i.fa.fa-question-circle.fa-lg', { + ariaHidden: true, + style: { + margin: '10px', + color: 'rgb(125, 128, 130)', + }, + }) + } + }(), ]) ) } diff --git a/ui/app/components/panel.js b/ui/app/components/panel.js index 5d72d6068..8841247a7 100644 --- a/ui/app/components/panel.js +++ b/ui/app/components/panel.js @@ -6,13 +6,12 @@ const Identicon = require('./identicon') module.exports = Panel - inherits(Panel, Component) -function Panel() { +function Panel () { Component.call(this) } -Panel.prototype.render = function() { +Panel.prototype.render = function () { var state = this.props var identity = state.identity || {} diff --git a/ui/app/components/pending-msg.js b/ui/app/components/pending-msg.js index b0a6bb87d..2f1b88493 100644 --- a/ui/app/components/pending-msg.js +++ b/ui/app/components/pending-msg.js @@ -10,18 +10,17 @@ const dataSize = require('../util').dataSize module.exports = PendingMsg - inherits(PendingMsg, Component) -function PendingMsg() { +function PendingMsg () { Component.call(this) } -PendingMsg.prototype.render = function() { +PendingMsg.prototype.render = function () { var state = this.props var msgData = state.txData var msgParams = msgData.msgParams || {} - var address = msgParams.from || state.selectedAddress + var address = msgParams.from || state.selectedAddress var identity = state.identities[address] || { address: address } var account = state.accounts[address] || { address: address } @@ -34,7 +33,7 @@ PendingMsg.prototype.render = function() { style: { fontWeight: 'bold', textAlign: 'center', - } + }, }, 'Sign Message'), // account that will sign diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 2bfb89705..69b9d2962 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -10,18 +10,17 @@ const dataSize = require('../util').dataSize module.exports = PendingTx - inherits(PendingTx, Component) -function PendingTx() { +function PendingTx () { Component.call(this) } -PendingTx.prototype.render = function() { +PendingTx.prototype.render = function () { var state = this.props var txData = state.txData var txParams = txData.txParams || {} - var address = txParams.from || state.selectedAddress + var address = txParams.from || state.selectedAddress var identity = state.identities[address] || { address: address } var account = state.accounts[address] || { address: address } @@ -34,7 +33,7 @@ PendingTx.prototype.render = function() { style: { fontWeight: 'bold', textAlign: 'center', - } + }, }, 'Submit Transaction'), // account that will sign diff --git a/ui/app/components/template.js b/ui/app/components/template.js index 9e4eca20f..a5203aec8 100644 --- a/ui/app/components/template.js +++ b/ui/app/components/template.js @@ -4,13 +4,12 @@ const inherits = require('util').inherits module.exports = NewComponent - inherits(NewComponent, Component) -function NewComponent() { +function NewComponent () { Component.call(this) } -NewComponent.prototype.render = function() { +NewComponent.prototype.render = function () { var state = this.props return ( diff --git a/ui/app/components/transaction-list-item-icon.js b/ui/app/components/transaction-list-item-icon.js index fbee4b218..beeec5192 100644 --- a/ui/app/components/transaction-list-item-icon.js +++ b/ui/app/components/transaction-list-item-icon.js @@ -6,20 +6,19 @@ const Identicon = require('./identicon') module.exports = TransactionIcon - inherits(TransactionIcon, Component) -function TransactionIcon() { +function TransactionIcon () { Component.call(this) } -TransactionIcon.prototype.render = function() { +TransactionIcon.prototype.render = function () { const { transaction, txParams, isTx, isMsg } = this.props if (transaction.status === 'rejected') { return h('i.fa.fa-exclamation-triangle.fa-lg.error', { style: { width: '24px', - } + }, }) } @@ -27,7 +26,7 @@ TransactionIcon.prototype.render = function() { return h('i.fa.fa-certificate.fa-lg', { style: { width: '24px', - } + }, }) } @@ -40,7 +39,7 @@ TransactionIcon.prototype.render = function() { return h('i.fa.fa-file-text-o.fa-lg', { style: { width: '24px', - } + }, }) } } diff --git a/ui/app/components/transaction-list-item.js b/ui/app/components/transaction-list-item.js index fc1c3c630..f7b357d61 100644 --- a/ui/app/components/transaction-list-item.js +++ b/ui/app/components/transaction-list-item.js @@ -12,13 +12,12 @@ const TransactionIcon = require('./transaction-list-item-icon') module.exports = TransactionListItem - inherits(TransactionListItem, Component) -function TransactionListItem() { +function TransactionListItem () { Component.call(this) } -TransactionListItem.prototype.render = function() { +TransactionListItem.prototype.render = function () { const { transaction, i, network } = this.props var date = formatDate(transaction.time) @@ -76,24 +75,24 @@ TransactionListItem.prototype.render = function() { ) } -function domainField(txParams) { +function domainField (txParams) { return h('div', { style: { fontSize: 'small', color: '#ABA9AA', }, - },[ + }, [ txParams.origin, ]) } -function recipientField(txParams, transaction, isTx, isMsg) { +function recipientField (txParams, transaction, isTx, isMsg) { let message if (isMsg) { message = 'Signature Requested' } else if (txParams.to) { - message = addressSummary(txParams.to) + message = addressSummary(txParams.to) } else { message = 'Contract Published' } @@ -103,23 +102,22 @@ function recipientField(txParams, transaction, isTx, isMsg) { fontSize: 'small', color: '#ABA9AA', }, - },[ + }, [ message, failIfFailed(transaction), ]) - } -TransactionListItem.prototype.renderMessage = function() { +TransactionListItem.prototype.renderMessage = function () { const { transaction, i, network } = this.props return h('div', 'wowie, thats a message') } -function formatDate(date){ +function formatDate (date) { return vreme.format(new Date(date), 'March 16 2014 14:30') } -function failIfFailed(transaction) { +function failIfFailed (transaction) { if (transaction.status === 'rejected') { return h('span.error', ' (Rejected)') } diff --git a/ui/app/components/transaction-list.js b/ui/app/components/transaction-list.js index ed2e1ee0a..e1b41fb44 100644 --- a/ui/app/components/transaction-list.js +++ b/ui/app/components/transaction-list.js @@ -8,11 +8,11 @@ module.exports = TransactionList inherits(TransactionList, Component) -function TransactionList() { +function TransactionList () { Component.call(this) } -TransactionList.prototype.render = function() { +TransactionList.prototype.render = function () { const { txsToRender, network, unconfTxs, unconfMsgs } = this.props const transactions = txsToRender.concat(unconfMsgs) .sort((a, b) => b.time - a.time) @@ -53,7 +53,7 @@ TransactionList.prototype.render = function() { transactions.map((transaction, i) => { return h(TransactionListItem, { transaction, i, network, - showTx:(txId) => { + showTx: (txId) => { this.props.viewPendingTx(txId) }, }) @@ -64,7 +64,7 @@ TransactionList.prototype.render = function() { height: '100%', }, }, 'No transaction history...')] - )) + )), ]) ) } -- cgit