1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Remove unused expressions (#6839)

Unused expressions are generally a mistake, as they don't do anything.
The exceptions to this rule (short-circuit expressions and ternary
expressions) have been allowed.

The `webrtc-adapter` was previously ignored by eslint because it has a
side-effect upon being imported. I removed the local variable instead,
which should preserve the same side-effect without making eslint
complain.
This commit is contained in:
Mark Stacey 2019-07-12 12:41:39 -03:00 committed by GitHub
parent 830c801ec3
commit 2eea388680
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 7 deletions

View File

@ -133,6 +133,7 @@
"no-unneeded-ternary": [2, { "defaultAssignment": false }],
"no-unreachable": 2,
"no-unsafe-finally": 2,
"no-unused-expressions": ["error", { "allowShortCircuit" : true, "allowTernary": true }],
"no-unused-vars": [2, { "vars": "all", "args": "all", "argsIgnorePattern": "[_]+" }],
"no-use-before-define": [2, { "functions": false }],
"no-useless-call": 2,

View File

@ -1,7 +1,7 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { BrowserQRCodeReader } from '@zxing/library'
import adapter from 'webrtc-adapter' // eslint-disable-line import/no-nodejs-modules, no-unused-vars
import 'webrtc-adapter'
import Spinner from '../../../ui/spinner'
import WebcamUtils from '../../../../../lib/webcam-utils'
import PageContainerFooter from '../../../ui/page-container/page-container-footer/page-container-footer.component'

View File

@ -3,7 +3,7 @@ import { compose } from 'recompose'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import { unconfirmedTransactionsCountSelector } from '../../selectors/confirm-transaction'
``
const mapStateToProps = state => {
const { metamask, appState } = state
const {

View File

@ -1476,7 +1476,9 @@ function cancelAllTx (txsData) {
txsData.forEach((txData, i) => {
background.cancelTransaction(txData.id, () => {
dispatch(actions.completedTx(txData.id))
i === txsData.length - 1 ? dispatch(actions.goHome()) : null
if (i === txsData.length - 1) {
dispatch(actions.goHome())
}
})
})
}
@ -2394,18 +2396,21 @@ function reshowQrCode (data, coin) {
}
}
function shapeShiftRequest (query, options, cb) {
function shapeShiftRequest (query, options = {}, cb) {
var queryResponse, method
!options ? options = {} : null
options.method ? method = options.method : method = 'GET'
var requestListner = function () {
try {
queryResponse = JSON.parse(this.responseText)
cb ? cb(queryResponse) : null
if (cb) {
cb(queryResponse)
}
return queryResponse
} catch (e) {
cb ? cb({error: e}) : null
if (cb) {
cb({error: e})
}
return e
}
}