mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
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.
This commit is contained in:
parent
b2813f0b54
commit
885125ad03
@ -46,6 +46,7 @@ module.exports = {
|
|||||||
'callback-return': 'error',
|
'callback-return': 'error',
|
||||||
'global-require': 'error',
|
'global-require': 'error',
|
||||||
'guard-for-in': 'error',
|
'guard-for-in': 'error',
|
||||||
|
'no-case-declarations': 'error',
|
||||||
/* End v2 rules */
|
/* End v2 rules */
|
||||||
'arrow-parens': 'error',
|
'arrow-parens': 'error',
|
||||||
'no-tabs': 'error',
|
'no-tabs': 'error',
|
||||||
|
@ -24,12 +24,13 @@ export default function createPermissionsMethodMiddleware ({
|
|||||||
// Intercepting eth_accounts requests for backwards compatibility:
|
// Intercepting eth_accounts requests for backwards compatibility:
|
||||||
// The getAccounts call below wraps the rpc-cap middleware, and returns
|
// The getAccounts call below wraps the rpc-cap middleware, and returns
|
||||||
// an empty array in case of errors (such as 4100:unauthorized)
|
// an empty array in case of errors (such as 4100:unauthorized)
|
||||||
case 'eth_accounts':
|
case 'eth_accounts': {
|
||||||
|
|
||||||
res.result = await getAccounts()
|
res.result = await getAccounts()
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
case 'eth_requestAccounts':
|
case 'eth_requestAccounts': {
|
||||||
|
|
||||||
if (isProcessingRequestAccounts) {
|
if (isProcessingRequestAccounts) {
|
||||||
res.error = ethErrors.rpc.resourceUnavailable(
|
res.error = ethErrors.rpc.resourceUnavailable(
|
||||||
@ -73,19 +74,21 @@ export default function createPermissionsMethodMiddleware ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// custom method for getting metadata from the requesting domain,
|
// custom method for getting metadata from the requesting domain,
|
||||||
// sent automatically by the inpage provider when it's initialized
|
// sent automatically by the inpage provider when it's initialized
|
||||||
case 'wallet_sendDomainMetadata':
|
case 'wallet_sendDomainMetadata': {
|
||||||
|
|
||||||
if (typeof req.domainMetadata?.name === 'string') {
|
if (typeof req.domainMetadata?.name === 'string') {
|
||||||
addDomainMetadata(req.origin, req.domainMetadata)
|
addDomainMetadata(req.origin, req.domainMetadata)
|
||||||
}
|
}
|
||||||
res.result = true
|
res.result = true
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// register return handler to send accountsChanged notification
|
// register return handler to send accountsChanged notification
|
||||||
case 'wallet_requestPermissions':
|
case 'wallet_requestPermissions': {
|
||||||
|
|
||||||
if ('eth_accounts' in req.params?.[0]) {
|
if ('eth_accounts' in req.params?.[0]) {
|
||||||
|
|
||||||
@ -101,6 +104,7 @@ export default function createPermissionsMethodMiddleware ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
|
@ -198,7 +198,7 @@ export default class PreferencesController {
|
|||||||
) {
|
) {
|
||||||
const { type, options } = req.params
|
const { type, options } = req.params
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'ERC20':
|
case 'ERC20': {
|
||||||
const result = await this._handleWatchAssetERC20(options)
|
const result = await this._handleWatchAssetERC20(options)
|
||||||
if (result instanceof Error) {
|
if (result instanceof Error) {
|
||||||
end(result)
|
end(result)
|
||||||
@ -207,6 +207,7 @@ export default class PreferencesController {
|
|||||||
end()
|
end()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
end(new Error(`Asset of type ${type} not supported`))
|
end(new Error(`Asset of type ${type} not supported`))
|
||||||
return
|
return
|
||||||
|
@ -11,7 +11,7 @@ export default function createMethodMiddleware ({ origin, sendMetrics }) {
|
|||||||
return function methodMiddleware (req, res, next, end) {
|
return function methodMiddleware (req, res, next, end) {
|
||||||
switch (req.method) {
|
switch (req.method) {
|
||||||
|
|
||||||
case 'metamask_logInjectedWeb3Usage':
|
case 'metamask_logInjectedWeb3Usage': {
|
||||||
|
|
||||||
const { action, name } = req.params[0]
|
const { action, name } = req.params[0]
|
||||||
|
|
||||||
@ -23,6 +23,7 @@ export default function createMethodMiddleware ({ origin, sendMetrics }) {
|
|||||||
|
|
||||||
res.result = true
|
res.result = true
|
||||||
break
|
break
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return next()
|
return next()
|
||||||
|
@ -154,7 +154,7 @@ export default class TypedMessageManager extends EventEmitter {
|
|||||||
}, 'Signing data must be valid EIP-712 typed data.')
|
}, 'Signing data must be valid EIP-712 typed data.')
|
||||||
break
|
break
|
||||||
case 'V3':
|
case 'V3':
|
||||||
case 'V4':
|
case 'V4': {
|
||||||
assert.equal(typeof params.data, 'string', '"params.data" must be a string.')
|
assert.equal(typeof params.data, 'string', '"params.data" must be a string.')
|
||||||
let data
|
let data
|
||||||
assert.doesNotThrow(() => {
|
assert.doesNotThrow(() => {
|
||||||
@ -167,6 +167,7 @@ export default class TypedMessageManager extends EventEmitter {
|
|||||||
const activeChainId = parseInt(this.networkController.getNetworkState())
|
const activeChainId = parseInt(this.networkController.getNetworkState())
|
||||||
chainId && assert.equal(chainId, activeChainId, `Provided chainId "${chainId}" must match the active chainId "${activeChainId}"`)
|
chainId && assert.equal(chainId, activeChainId, `Provided chainId "${chainId}" must match the active chainId "${activeChainId}"`)
|
||||||
break
|
break
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
assert.fail(`Unknown typed data version "${params.version}"`)
|
assert.fail(`Unknown typed data version "${params.version}"`)
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
|
|
||||||
|
|
||||||
// modal methods:
|
// modal methods:
|
||||||
case actionConstants.MODAL_OPEN:
|
case actionConstants.MODAL_OPEN: {
|
||||||
const { name, ...modalProps } = action.payload
|
const { name, ...modalProps } = action.payload
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -124,6 +124,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
previousModalState: { ...appState.modal.modalState },
|
previousModalState: { ...appState.modal.modalState },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case actionConstants.MODAL_CLOSE:
|
case actionConstants.MODAL_CLOSE:
|
||||||
return {
|
return {
|
||||||
@ -232,7 +233,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
warning: '',
|
warning: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
case actionConstants.SET_HARDWARE_WALLET_DEFAULT_HD_PATH:
|
case actionConstants.SET_HARDWARE_WALLET_DEFAULT_HD_PATH: {
|
||||||
const { device, path } = action.value
|
const { device, path } = action.value
|
||||||
const newDefaults = { ...appState.defaultHdPaths }
|
const newDefaults = { ...appState.defaultHdPaths }
|
||||||
newDefaults[device] = path
|
newDefaults[device] = path
|
||||||
@ -241,6 +242,7 @@ export default function reduceApp (state = {}, action) {
|
|||||||
...appState,
|
...appState,
|
||||||
defaultHdPaths: newDefaults,
|
defaultHdPaths: newDefaults,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case actionConstants.SHOW_LOADING:
|
case actionConstants.SHOW_LOADING:
|
||||||
return {
|
return {
|
||||||
|
@ -104,7 +104,7 @@ export default function reducer (state = initState, action = {}) {
|
|||||||
...state,
|
...state,
|
||||||
methodData: {},
|
methodData: {},
|
||||||
}
|
}
|
||||||
case UPDATE_TRANSACTION_AMOUNTS:
|
case UPDATE_TRANSACTION_AMOUNTS: {
|
||||||
const { fiatTransactionAmount, ethTransactionAmount, hexTransactionAmount } = action.payload
|
const { fiatTransactionAmount, ethTransactionAmount, hexTransactionAmount } = action.payload
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@ -112,7 +112,8 @@ export default function reducer (state = initState, action = {}) {
|
|||||||
ethTransactionAmount: ethTransactionAmount || state.ethTransactionAmount,
|
ethTransactionAmount: ethTransactionAmount || state.ethTransactionAmount,
|
||||||
hexTransactionAmount: hexTransactionAmount || state.hexTransactionAmount,
|
hexTransactionAmount: hexTransactionAmount || state.hexTransactionAmount,
|
||||||
}
|
}
|
||||||
case UPDATE_TRANSACTION_FEES:
|
}
|
||||||
|
case UPDATE_TRANSACTION_FEES: {
|
||||||
const { fiatTransactionFee, ethTransactionFee, hexTransactionFee } = action.payload
|
const { fiatTransactionFee, ethTransactionFee, hexTransactionFee } = action.payload
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@ -120,7 +121,8 @@ export default function reducer (state = initState, action = {}) {
|
|||||||
ethTransactionFee: ethTransactionFee || state.ethTransactionFee,
|
ethTransactionFee: ethTransactionFee || state.ethTransactionFee,
|
||||||
hexTransactionFee: hexTransactionFee || state.hexTransactionFee,
|
hexTransactionFee: hexTransactionFee || state.hexTransactionFee,
|
||||||
}
|
}
|
||||||
case UPDATE_TRANSACTION_TOTALS:
|
}
|
||||||
|
case UPDATE_TRANSACTION_TOTALS: {
|
||||||
const { fiatTransactionTotal, ethTransactionTotal, hexTransactionTotal } = action.payload
|
const { fiatTransactionTotal, ethTransactionTotal, hexTransactionTotal } = action.payload
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@ -128,7 +130,8 @@ export default function reducer (state = initState, action = {}) {
|
|||||||
ethTransactionTotal: ethTransactionTotal || state.ethTransactionTotal,
|
ethTransactionTotal: ethTransactionTotal || state.ethTransactionTotal,
|
||||||
hexTransactionTotal: hexTransactionTotal || state.hexTransactionTotal,
|
hexTransactionTotal: hexTransactionTotal || state.hexTransactionTotal,
|
||||||
}
|
}
|
||||||
case UPDATE_TOKEN_PROPS:
|
}
|
||||||
|
case UPDATE_TOKEN_PROPS: {
|
||||||
const { tokenSymbol = '', tokenDecimals = '' } = action.payload
|
const { tokenSymbol = '', tokenDecimals = '' } = action.payload
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@ -138,6 +141,7 @@ export default function reducer (state = initState, action = {}) {
|
|||||||
tokenDecimals,
|
tokenDecimals,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case UPDATE_NONCE:
|
case UPDATE_NONCE:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
@ -84,13 +84,14 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
selectedAddress: action.value,
|
selectedAddress: action.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
case actionConstants.SET_ACCOUNT_LABEL:
|
case actionConstants.SET_ACCOUNT_LABEL: {
|
||||||
const account = action.value.account
|
const account = action.value.account
|
||||||
const name = action.value.label
|
const name = action.value.label
|
||||||
const id = {}
|
const id = {}
|
||||||
id[account] = Object.assign({}, metamaskState.identities[account], { name })
|
id[account] = Object.assign({}, metamaskState.identities[account], { name })
|
||||||
const identities = Object.assign({}, metamaskState.identities, id)
|
const identities = Object.assign({}, metamaskState.identities, id)
|
||||||
return Object.assign(metamaskState, { identities })
|
return Object.assign(metamaskState, { identities })
|
||||||
|
}
|
||||||
|
|
||||||
case actionConstants.SET_CURRENT_FIAT:
|
case actionConstants.SET_CURRENT_FIAT:
|
||||||
return Object.assign(metamaskState, {
|
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 = {
|
const newSend = {
|
||||||
...metamaskState.send,
|
...metamaskState.send,
|
||||||
token: action.value,
|
token: action.value,
|
||||||
@ -225,6 +226,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
return Object.assign(metamaskState, {
|
return Object.assign(metamaskState, {
|
||||||
send: newSend,
|
send: newSend,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
case actionConstants.UPDATE_SEND_ENS_RESOLUTION:
|
case actionConstants.UPDATE_SEND_ENS_RESOLUTION:
|
||||||
return {
|
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
|
const { id: txId, value } = action
|
||||||
let { currentNetworkTxList } = metamaskState
|
let { currentNetworkTxList } = metamaskState
|
||||||
currentNetworkTxList = currentNetworkTxList.map((tx) => {
|
currentNetworkTxList = currentNetworkTxList.map((tx) => {
|
||||||
@ -281,6 +283,7 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
...metamaskState,
|
...metamaskState,
|
||||||
currentNetworkTxList,
|
currentNetworkTxList,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case actionConstants.SET_PARTICIPATE_IN_METAMETRICS:
|
case actionConstants.SET_PARTICIPATE_IN_METAMETRICS:
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user