1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 04:20:53 +01:00

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.
This commit is contained in:
Whymarrh Whitby 2020-08-13 17:30:09 -02:30 committed by GitHub
parent 5991043cd7
commit b91cf74d14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 15 deletions

View File

@ -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',

View File

@ -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('')
} }

View File

@ -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
} }

View File

@ -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]

View File

@ -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">