Fix no-case-declarations issues (#9191)

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

This change enables `no-case-declarations` and fixes the issues raised by the rule.
feature/default_network_editable
Whymarrh Whitby 4 years ago committed by GitHub
parent b2813f0b54
commit 885125ad03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .eslintrc.js
  2. 12
      app/scripts/controllers/permissions/permissionsMethodMiddleware.js
  3. 3
      app/scripts/controllers/preferences.js
  4. 3
      app/scripts/lib/createMethodMiddleware.js
  5. 3
      app/scripts/lib/typed-message-manager.js
  6. 6
      ui/app/ducks/app/app.js
  7. 12
      ui/app/ducks/confirm-transaction/confirm-transaction.duck.js
  8. 9
      ui/app/ducks/metamask/metamask.js

@ -46,6 +46,7 @@ module.exports = {
'callback-return': 'error',
'global-require': 'error',
'guard-for-in': 'error',
'no-case-declarations': 'error',
/* End v2 rules */
'arrow-parens': 'error',
'no-tabs': 'error',

@ -24,12 +24,13 @@ export default function createPermissionsMethodMiddleware ({
// Intercepting eth_accounts requests for backwards compatibility:
// The getAccounts call below wraps the rpc-cap middleware, and returns
// an empty array in case of errors (such as 4100:unauthorized)
case 'eth_accounts':
case 'eth_accounts': {
res.result = await getAccounts()
return
}
case 'eth_requestAccounts':
case 'eth_requestAccounts': {
if (isProcessingRequestAccounts) {
res.error = ethErrors.rpc.resourceUnavailable(
@ -73,19 +74,21 @@ export default function createPermissionsMethodMiddleware ({
}
return
}
// custom method for getting metadata from the requesting domain,
// sent automatically by the inpage provider when it's initialized
case 'wallet_sendDomainMetadata':
case 'wallet_sendDomainMetadata': {
if (typeof req.domainMetadata?.name === 'string') {
addDomainMetadata(req.origin, req.domainMetadata)
}
res.result = true
return
}
// register return handler to send accountsChanged notification
case 'wallet_requestPermissions':
case 'wallet_requestPermissions': {
if ('eth_accounts' in req.params?.[0]) {
@ -101,6 +104,7 @@ export default function createPermissionsMethodMiddleware ({
}
}
break
}
default:
break

@ -198,7 +198,7 @@ export default class PreferencesController {
) {
const { type, options } = req.params
switch (type) {
case 'ERC20':
case 'ERC20': {
const result = await this._handleWatchAssetERC20(options)
if (result instanceof Error) {
end(result)
@ -207,6 +207,7 @@ export default class PreferencesController {
end()
}
return
}
default:
end(new Error(`Asset of type ${type} not supported`))
return

@ -11,7 +11,7 @@ export default function createMethodMiddleware ({ origin, sendMetrics }) {
return function methodMiddleware (req, res, next, end) {
switch (req.method) {
case 'metamask_logInjectedWeb3Usage':
case 'metamask_logInjectedWeb3Usage': {
const { action, name } = req.params[0]
@ -23,6 +23,7 @@ export default function createMethodMiddleware ({ origin, sendMetrics }) {
res.result = true
break
}
default:
return next()

@ -154,7 +154,7 @@ export default class TypedMessageManager extends EventEmitter {
}, 'Signing data must be valid EIP-712 typed data.')
break
case 'V3':
case 'V4':
case 'V4': {
assert.equal(typeof params.data, 'string', '"params.data" must be a string.')
let data
assert.doesNotThrow(() => {
@ -167,6 +167,7 @@ export default class TypedMessageManager extends EventEmitter {
const activeChainId = parseInt(this.networkController.getNetworkState())
chainId && assert.equal(chainId, activeChainId, `Provided chainId "${chainId}" must match the active chainId "${activeChainId}"`)
break
}
default:
assert.fail(`Unknown typed data version "${params.version}"`)
}

@ -110,7 +110,7 @@ export default function reduceApp (state = {}, action) {
// modal methods:
case actionConstants.MODAL_OPEN:
case actionConstants.MODAL_OPEN: {
const { name, ...modalProps } = action.payload
return {
@ -124,6 +124,7 @@ export default function reduceApp (state = {}, action) {
previousModalState: { ...appState.modal.modalState },
},
}
}
case actionConstants.MODAL_CLOSE:
return {
@ -232,7 +233,7 @@ export default function reduceApp (state = {}, action) {
warning: '',
}
case actionConstants.SET_HARDWARE_WALLET_DEFAULT_HD_PATH:
case actionConstants.SET_HARDWARE_WALLET_DEFAULT_HD_PATH: {
const { device, path } = action.value
const newDefaults = { ...appState.defaultHdPaths }
newDefaults[device] = path
@ -241,6 +242,7 @@ export default function reduceApp (state = {}, action) {
...appState,
defaultHdPaths: newDefaults,
}
}
case actionConstants.SHOW_LOADING:
return {

@ -104,7 +104,7 @@ export default function reducer (state = initState, action = {}) {
...state,
methodData: {},
}
case UPDATE_TRANSACTION_AMOUNTS:
case UPDATE_TRANSACTION_AMOUNTS: {
const { fiatTransactionAmount, ethTransactionAmount, hexTransactionAmount } = action.payload
return {
...state,
@ -112,7 +112,8 @@ export default function reducer (state = initState, action = {}) {
ethTransactionAmount: ethTransactionAmount || state.ethTransactionAmount,
hexTransactionAmount: hexTransactionAmount || state.hexTransactionAmount,
}
case UPDATE_TRANSACTION_FEES:
}
case UPDATE_TRANSACTION_FEES: {
const { fiatTransactionFee, ethTransactionFee, hexTransactionFee } = action.payload
return {
...state,
@ -120,7 +121,8 @@ export default function reducer (state = initState, action = {}) {
ethTransactionFee: ethTransactionFee || state.ethTransactionFee,
hexTransactionFee: hexTransactionFee || state.hexTransactionFee,
}
case UPDATE_TRANSACTION_TOTALS:
}
case UPDATE_TRANSACTION_TOTALS: {
const { fiatTransactionTotal, ethTransactionTotal, hexTransactionTotal } = action.payload
return {
...state,
@ -128,7 +130,8 @@ export default function reducer (state = initState, action = {}) {
ethTransactionTotal: ethTransactionTotal || state.ethTransactionTotal,
hexTransactionTotal: hexTransactionTotal || state.hexTransactionTotal,
}
case UPDATE_TOKEN_PROPS:
}
case UPDATE_TOKEN_PROPS: {
const { tokenSymbol = '', tokenDecimals = '' } = action.payload
return {
...state,
@ -138,6 +141,7 @@ export default function reducer (state = initState, action = {}) {
tokenDecimals,
},
}
}
case UPDATE_NONCE:
return {
...state,

@ -84,13 +84,14 @@ export default function reduceMetamask (state = {}, action) {
selectedAddress: action.value,
}
case actionConstants.SET_ACCOUNT_LABEL:
case actionConstants.SET_ACCOUNT_LABEL: {
const account = action.value.account
const name = action.value.label
const id = {}
id[account] = Object.assign({}, metamaskState.identities[account], { name })
const identities = Object.assign({}, metamaskState.identities, id)
return Object.assign(metamaskState, { identities })
}
case actionConstants.SET_CURRENT_FIAT:
return Object.assign(metamaskState, {
@ -197,7 +198,7 @@ export default function reduceMetamask (state = {}, action) {
},
})
case actionConstants.UPDATE_SEND_TOKEN:
case actionConstants.UPDATE_SEND_TOKEN: {
const newSend = {
...metamaskState.send,
token: action.value,
@ -225,6 +226,7 @@ export default function reduceMetamask (state = {}, action) {
return Object.assign(metamaskState, {
send: newSend,
})
}
case actionConstants.UPDATE_SEND_ENS_RESOLUTION:
return {
@ -265,7 +267,7 @@ export default function reduceMetamask (state = {}, action) {
},
}
case actionConstants.UPDATE_TRANSACTION_PARAMS:
case actionConstants.UPDATE_TRANSACTION_PARAMS: {
const { id: txId, value } = action
let { currentNetworkTxList } = metamaskState
currentNetworkTxList = currentNetworkTxList.map((tx) => {
@ -281,6 +283,7 @@ export default function reduceMetamask (state = {}, action) {
...metamaskState,
currentNetworkTxList,
}
}
case actionConstants.SET_PARTICIPATE_IN_METAMETRICS:
return {

Loading…
Cancel
Save