Merge pull request #8062 from whymarrh/no-mixed-operators

Enable core ESLint no-mixed-operators rule
feature/default_network_editable
Jenny Pollack 5 years ago committed by GitHub
commit fd170ef8c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .eslintrc.js
  2. 2
      app/scripts/controllers/transactions/index.js
  3. 2
      gulpfile.js
  4. 4
      ui/app/components/app/gas-customization/gas-price-chart/gas-price-chart.component.js
  5. 2
      ui/app/components/app/transaction-activity-log/transaction-activity-log.util.js
  6. 2
      ui/app/components/app/transaction-breakdown/transaction-breakdown.container.js
  7. 2
      ui/app/components/app/transaction-list-item-details/transaction-list-item-details.container.js
  8. 2
      ui/app/components/app/transaction-list-item/transaction-list-item.component.js
  9. 8
      ui/app/components/app/user-preferenced-currency-display/user-preferenced-currency-display.container.js
  10. 2
      ui/app/components/ui/currency-display/currency-display.component.js
  11. 2
      ui/app/ducks/gas/gas-duck.test.js
  12. 4
      ui/app/ducks/gas/gas.duck.js
  13. 8
      ui/app/helpers/utils/metametrics.util.js
  14. 2
      ui/app/pages/confirm-transaction-base/confirm-transaction-base.container.js
  15. 4
      ui/app/pages/create-account/connect-hardware/index.js
  16. 4
      ui/app/pages/permissions-connect/permissions-connect.component.js
  17. 2
      ui/app/pages/send/send.selectors.js
  18. 2
      ui/app/pages/settings/networks-tab/networks-tab.component.js
  19. 4
      ui/app/pages/settings/networks-tab/networks-tab.container.js
  20. 4
      ui/app/selectors/confirm-transaction.js
  21. 2
      ui/app/selectors/selectors.js

@ -45,6 +45,7 @@ module.exports = {
rules: {
'arrow-parens': 'error',
'no-mixed-operators': 'error',
'import/default': 'error',
'import/export': 'error',
'import/named': 'error',

@ -652,7 +652,7 @@ class TransactionController extends EventEmitter {
*/
async _determineTransactionCategory (txParams) {
const { data, to } = txParams
const { name } = data && abiDecoder.decodeMethod(data) || {}
const { name } = (data && abiDecoder.decodeMethod(data)) || {}
const tokenMethodName = [
TOKEN_METHOD_APPROVE,
TOKEN_METHOD_TRANSFER,

@ -31,7 +31,7 @@ const packageJSON = require('./package.json')
sass.compiler = require('node-sass')
const dependencies = Object.keys(packageJSON && packageJSON.dependencies || {})
const dependencies = Object.keys((packageJSON && packageJSON.dependencies) || {})
const materialUIDependencies = ['@material-ui/core']
const reactDepenendencies = dependencies.filter((dep) => dep.match(/react/))
const d3Dependencies = ['c3', 'd3']

@ -44,9 +44,9 @@ export default class GasPriceChart extends Component {
const { x: yAxisX } = getCoordinateData('.c3-axis-y-label')
const { x: tickX } = getCoordinateData('.c3-axis-x .tick')
d3.select('.c3-axis-x .tick').attr('transform', 'translate(' + (domainX - tickX) / 2 + ', 0)')
d3.select('.c3-axis-x .tick').attr('transform', `translate(${(domainX - tickX) / 2}, 0)`)
d3.select('.c3-axis-x-label').attr('transform', 'translate(0,-15)')
d3.select('.c3-axis-y-label').attr('transform', 'translate(' + (domainX - yAxisX - 12) + ', 2) rotate(-90)')
d3.select('.c3-axis-y-label').attr('transform', `translate(${domainX - yAxisX - 12}, 2) rotate(-90)`)
d3.select('.c3-xgrid-focus line').attr('y2', 98)
d3.select('.c3-chart').on('mouseout', () => {

@ -90,7 +90,7 @@ export function getActivities (transaction, isFirstTransaction = false) {
const { op, path, value, timestamp: entryTimestamp } = entry
// Not all sub-entries in a history entry have a timestamp. If the sub-entry does not have a
// timestamp, the first sub-entry in a history entry should.
const timestamp = entryTimestamp || base[0] && base[0].timestamp
const timestamp = entryTimestamp || (base[0] && base[0].timestamp)
if (path in eventPathsHash && op === REPLACE_OP) {
switch (path) {

@ -12,7 +12,7 @@ const mapStateToProps = (state, ownProps) => {
const gasLimit = typeof gasUsed === 'string' ? gasUsed : gas
const hexGasTotal = gasLimit && gasPrice && getHexGasTotal({ gasLimit, gasPrice }) || '0x0'
const hexGasTotal = (gasLimit && gasPrice && getHexGasTotal({ gasLimit, gasPrice })) || '0x0'
const totalInHex = sumHexes(hexGasTotal, value)
return {

@ -18,7 +18,7 @@ const mapStateToProps = (state, ownProps) => {
const entry = addressBook.find((contact) => {
return address.toLowerCase() === contact.address.toLowerCase()
})
return entry && entry.name || ''
return (entry && entry.name) || ''
}
return {

@ -195,7 +195,7 @@ export default class TransactionListItem extends PureComponent {
const { showTransactionDetails } = this.state
const fromAddress = txParams.from
const toAddress = tokenData
? tokenData.params && tokenData.params[0] && tokenData.params[0].value || txParams.to
? (tokenData.params && tokenData.params[0] && tokenData.params[0].value) || txParams.to
: txParams.to
const isFullScreen = getEnvironmentType() === ENVIRONMENT_TYPE_FULLSCREEN

@ -34,14 +34,14 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
let currency, numberOfDecimals, prefix
if (type === PRIMARY && useNativeCurrencyAsPrimaryCurrency ||
type === SECONDARY && !useNativeCurrencyAsPrimaryCurrency) {
if ((type === PRIMARY && useNativeCurrencyAsPrimaryCurrency) ||
(type === SECONDARY && !useNativeCurrencyAsPrimaryCurrency)) {
// Display ETH
currency = nativeCurrency || ETH
numberOfDecimals = propsNumberOfDecimals || ethNumberOfDecimals || 6
prefix = propsPrefix || ethPrefix
} else if (type === SECONDARY && useNativeCurrencyAsPrimaryCurrency ||
type === PRIMARY && !useNativeCurrencyAsPrimaryCurrency) {
} else if ((type === SECONDARY && useNativeCurrencyAsPrimaryCurrency) ||
(type === PRIMARY && !useNativeCurrencyAsPrimaryCurrency)) {
// Display Fiat
numberOfDecimals = propsNumberOfDecimals || fiatNumberOfDecimals || 2
prefix = propsPrefix || fiatPrefix

@ -23,7 +23,7 @@ export default class CurrencyDisplay extends PureComponent {
<div
className={classnames('currency-display-component', className)}
style={style}
title={!hideTitle && title || null}
title={(!hideTitle && title) || null}
>
{ prefixComponent }
<span className="currency-display-component__text">{ text }</span>

@ -647,7 +647,7 @@ describe('Gas Duck', function () {
const { type: thirdDispatchCallType, value: priceAndTimeEstimateResult } = mockDistpatch.getCall(2).args[0]
assert.equal(thirdDispatchCallType, SET_PRICE_AND_TIME_ESTIMATES)
assert(priceAndTimeEstimateResult.length < mockPredictTableResponse.length * 3 - 2)
assert(priceAndTimeEstimateResult.length < ((mockPredictTableResponse.length * 3) - 2))
assert(!priceAndTimeEstimateResult.find((d) => d.expectedTime > 100))
assert(!priceAndTimeEstimateResult.find((d, _, a) => a[a + 1] && d.expectedTime > a[a + 1].expectedTime))
assert(!priceAndTimeEstimateResult.find((d, _, a) => a[a + 1] && d.gasprice > a[a + 1].gasprice))

@ -352,8 +352,8 @@ function quartiles (data) {
function inliersByIQR (data, prop) {
const { lowerQuartile, upperQuartile } = quartiles(data.map((d) => (prop ? d[prop] : d)))
const IQR = upperQuartile - lowerQuartile
const lowerBound = lowerQuartile - 1.5 * IQR
const upperBound = upperQuartile + 1.5 * IQR
const lowerBound = lowerQuartile - (1.5 * IQR)
const upperBound = upperQuartile + (1.5 * IQR)
return data.filter((d) => {
const value = prop ? d[prop] : d
return value >= lowerBound && value <= upperBound

@ -145,7 +145,7 @@ function composeUrl (config) {
const e_n = composeParamAddition(eventOpts.name, 'e_n')
const new_visit = isNewVisit ? `&new_visit=1` : ''
const cvar = customVariables && composeCustomVarParamAddition(customVariables) || ''
const cvar = (customVariables && composeCustomVarParamAddition(customVariables)) || ''
const action_name = ''
@ -156,13 +156,13 @@ function composeUrl (config) {
environmentType,
activeCurrency,
accountType,
numberOfTokens: customVariables && customVariables.numberOfTokens || numberOfTokens,
numberOfAccounts: customVariables && customVariables.numberOfAccounts || numberOfAccounts,
numberOfTokens: (customVariables && customVariables.numberOfTokens) || numberOfTokens,
numberOfAccounts: (customVariables && customVariables.numberOfAccounts) || numberOfAccounts,
}) : ''
const url = configUrl || currentPath ? `&url=${encodeURIComponent(currentPath.replace(/chrome-extension:\/\/\w+/, METAMETRICS_TRACKING_URL))}` : ''
const _id = metaMetricsId && !excludeMetaMetricsId ? `&_id=${metaMetricsId.slice(2, 18)}` : ''
const rand = `&rand=${String(Math.random()).slice(2)}`
const pv_id = (url || currentPath) && `&pv_id=${ethUtil.bufferToHex(ethUtil.sha3(url || currentPath.match(/chrome-extension:\/\/\w+\/(.+)/)[0])).slice(2, 8)}` || ''
const pv_id = ((url || currentPath) && `&pv_id=${ethUtil.bufferToHex(ethUtil.sha3(url || currentPath.match(/chrome-extension:\/\/\w+\/(.+)/)[0])).slice(2, 8)}`) || ''
const uid = metaMetricsId && !excludeMetaMetricsId
? `&uid=${metaMetricsId.slice(2, 18)}`
: excludeMetaMetricsId

@ -77,7 +77,7 @@ const mapStateToProps = (state, ownProps) => {
gas: gasLimit,
value: amount,
data,
} = transaction && transaction.txParams || txParams
} = (transaction && transaction.txParams) || txParams
const accounts = getMetaMaskAccounts(state)
const assetImage = assetImages[txParamsToAddress]

@ -22,7 +22,7 @@ class ConnectHardwareForm extends Component {
const { accounts } = nextProps
const newAccounts = this.state.accounts.map((a) => {
const normalizedAddress = a.address.toLowerCase()
const balanceValue = accounts[normalizedAddress] && accounts[normalizedAddress].balance || null
const balanceValue = (accounts[normalizedAddress] && accounts[normalizedAddress].balance) || null
a.balance = balanceValue ? formatBalance(balanceValue, 6) : '...'
return a
})
@ -103,7 +103,7 @@ class ConnectHardwareForm extends Component {
// Map accounts with balances
newState.accounts = accounts.map((account) => {
const normalizedAddress = account.address.toLowerCase()
const balanceValue = this.props.accounts[normalizedAddress] && this.props.accounts[normalizedAddress].balance || null
const balanceValue = (this.props.accounts[normalizedAddress] && this.props.accounts[normalizedAddress].balance) || null
account.balance = balanceValue ? formatBalance(balanceValue, 6) : '...'
return account
})

@ -72,9 +72,9 @@ export default class PermissionConnect extends Component {
const { originName, page } = this.state
if (!permissionsRequest && prevProps.permissionsRequest && page !== null) {
const permissionDataForDomain = domains && domains[originName] || {}
const permissionDataForDomain = (domains && domains[originName]) || {}
const permissionsForDomain = permissionDataForDomain.permissions || []
const prevPermissionDataForDomain = prevProps.domains && prevProps.domains[originName] || {}
const prevPermissionDataForDomain = (prevProps.domains && prevProps.domains[originName]) || {}
const prevPermissionsForDomain = prevPermissionDataForDomain.permissions || []
const addedAPermission = permissionsForDomain.length > prevPermissionsForDomain.length
if (addedAPermission) {

@ -115,7 +115,7 @@ export function getSelectedTokenExchangeRate (state) {
const selectedToken = getSelectedToken(state) || {}
const { symbol = '' } = selectedToken
const pair = `${symbol.toLowerCase()}_eth`
const { rate: tokenExchangeRate = 0 } = tokenExchangeRates && tokenExchangeRates[pair] || {}
const { rate: tokenExchangeRate = 0 } = (tokenExchangeRates && tokenExchangeRates[pair]) || {}
return tokenExchangeRate
}

@ -195,7 +195,7 @@ export default class NetworksTab extends PureComponent {
rpcUrls={networksToRender.map((network) => network.rpcUrl)}
setRpcTarget={setRpcTarget}
editRpc={editRpc}
networkName={label || labelKey && t(labelKey) || ''}
networkName={label || (labelKey && t(labelKey)) || ''}
rpcUrl={rpcUrl}
chainId={chainId}
ticker={ticker}

@ -32,7 +32,7 @@ const mapStateToProps = (state) => {
rpcUrl: rpc.rpcUrl,
chainId: rpc.chainId,
ticker: rpc.ticker,
blockExplorerUrl: rpc.rpcPrefs && rpc.rpcPrefs.blockExplorerUrl || '',
blockExplorerUrl: (rpc.rpcPrefs && rpc.rpcPrefs.blockExplorerUrl) || '',
}
})
@ -43,7 +43,7 @@ const mapStateToProps = (state) => {
let networkDefaultedToProvider = false
if (!networkIsSelected && !networksTabIsInAddMode) {
selectedNetwork = networksToRender.find((network) => {
return network.rpcUrl === provider.rpcTarget || network.providerType !== 'rpc' && network.providerType === provider.type
return network.rpcUrl === provider.rpcTarget || (network.providerType !== 'rpc' && network.providerType === provider.type)
}) || {}
networkDefaultedToProvider = true
}

@ -118,12 +118,12 @@ const tokenDecimalsSelector = createSelector(
const tokenDataParamsSelector = createSelector(
tokenDataSelector,
(tokenData) => tokenData && tokenData.params || []
(tokenData) => (tokenData && tokenData.params) || []
)
const txParamsSelector = createSelector(
txDataSelector,
(txData) => txData && txData.txParams || {}
(txData) => (txData && txData.txParams) || {}
)
export const tokenAddressSelector = createSelector(

@ -56,7 +56,7 @@ export function getAccountType (state) {
export function getSelectedAsset (state) {
const selectedToken = getSelectedToken(state)
return selectedToken && selectedToken.symbol || 'ETH'
return (selectedToken && selectedToken.symbol) || 'ETH'
}
export function getCurrentNetworkId (state) {

Loading…
Cancel
Save