Fix no-nested-ternary issues (#9214)

See [`no-nested-ternary`](https://eslint.org/docs/rules/no-nested-ternary) for more information.

This change enables `no-nested-ternary` and fixes the issues raised by the rule.
feature/default_network_editable
Whymarrh Whitby 4 years ago committed by GitHub
parent 5991043cd7
commit b91cf74d14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .eslintrc.js
  2. 12
      ui/app/helpers/utils/metametrics.util.js
  3. 7
      ui/app/helpers/utils/transactions.util.js
  4. 11
      ui/app/pages/confirm-transaction-base/confirm-transaction-base.container.js
  5. 1
      ui/app/pages/send/send-content/send-gas-row/gas-fee-display/gas-fee-display.component.js

@ -55,6 +55,7 @@ module.exports = {
'no-eq-null': 'error', 'no-eq-null': 'error',
'no-global-assign': 'error', 'no-global-assign': 'error',
'no-loop-func': 'error', 'no-loop-func': 'error',
'no-nested-ternary': 'error',
'no-plusplus': ['error', { 'allowForLoopAfterthoughts': true }], 'no-plusplus': ['error', { 'allowForLoopAfterthoughts': true }],
'no-useless-catch': 'error', 'no-useless-catch': 'error',
'no-useless-concat': 'error', 'no-useless-concat': 'error',

@ -170,11 +170,13 @@ function composeUrl (config) {
const _id = metaMetricsId && !excludeMetaMetricsId ? `&_id=${metaMetricsId.slice(2, 18)}` : '' const _id = metaMetricsId && !excludeMetaMetricsId ? `&_id=${metaMetricsId.slice(2, 18)}` : ''
const rand = `&rand=${String(Math.random()).slice(2)}` const rand = `&rand=${String(Math.random()).slice(2)}`
const pv_id = currentPath ? `&pv_id=${ethUtil.bufferToHex(ethUtil.sha3(currentPath)).slice(2, 8)}` : '' const pv_id = currentPath ? `&pv_id=${ethUtil.bufferToHex(ethUtil.sha3(currentPath)).slice(2, 8)}` : ''
const uid = metaMetricsId && !excludeMetaMetricsId
? `&uid=${metaMetricsId.slice(2, 18)}` let uid = ''
: excludeMetaMetricsId if (excludeMetaMetricsId) {
? '&uid=0000000000000000' uid = '&uid=0000000000000000'
: '' } else if (metaMetricsId) {
uid = `&uid=${metaMetricsId.slice(2, 18)}`
}
return [ base, e_c, e_a, e_n, cvar, action_name, urlref, dimensions, url, _id, rand, pv_id, uid, new_visit ].join('') return [ base, e_c, e_a, e_n, cvar, action_name, urlref, dimensions, url, _id, rand, pv_id, uid, new_visit ].join('')
} }

@ -181,9 +181,10 @@ export function getLatestSubmittedTxWithNonce (transactions = [], nonce = '0x0')
const { submittedTime, txParams: { nonce: currentNonce } = {} } = current const { submittedTime, txParams: { nonce: currentNonce } = {} } = current
if (currentNonce === nonce) { if (currentNonce === nonce) {
return acc.submittedTime if (!acc.submittedTime) {
? submittedTime > acc.submittedTime ? current : acc return current
: current }
return submittedTime > acc.submittedTime ? current : acc
} else { } else {
return acc return acc
} }

@ -93,13 +93,10 @@ const mapStateToProps = (state, ownProps) => {
const { balance } = accounts[fromAddress] const { balance } = accounts[fromAddress]
const { name: fromName } = identities[fromAddress] const { name: fromName } = identities[fromAddress]
const toAddress = propsToAddress || txParamsToAddress const toAddress = propsToAddress || txParamsToAddress
const toName = identities[toAddress]
? identities[toAddress].name const toName = identities[toAddress]?.name ||
: ( casedContractMap[toAddress]?.name ||
casedContractMap[toAddress] shortenAddress(checksumAddress(toAddress))
? casedContractMap[toAddress].name
: shortenAddress(checksumAddress(toAddress))
)
const checksummedAddress = checksumAddress(toAddress) const checksummedAddress = checksumAddress(toAddress)
const addressBookObject = addressBook[checksummedAddress] const addressBookObject = addressBook[checksummedAddress]

@ -20,6 +20,7 @@ export default class GasFeeDisplay extends Component {
return ( return (
<div className="send-v2__gas-fee-display"> <div className="send-v2__gas-fee-display">
{/* eslint-disable-next-line no-nested-ternary */}
{gasTotal {gasTotal
? ( ? (
<div className="currency-display"> <div className="currency-display">

Loading…
Cancel
Save