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

ESLint fixes (#5775)

* eslint . --fix

* Upgrade all ESLint warnings to errors
This commit is contained in:
Whymarrh Whitby 2018-11-16 21:24:55 -03:30 committed by Frankie
parent ce147bf6d8
commit 1988e1e96b
15 changed files with 37 additions and 37 deletions

View File

@ -55,13 +55,13 @@
"constructor-super": 2, "constructor-super": 2,
"curly": [2, "multi-line"], "curly": [2, "multi-line"],
"dot-location": [2, "property"], "dot-location": [2, "property"],
"eol-last": 1, "eol-last": 2,
"eqeqeq": [2, "allow-null"], "eqeqeq": [2, "allow-null"],
"generator-star-spacing": [2, { "before": true, "after": true }], "generator-star-spacing": [2, { "before": true, "after": true }],
"handle-callback-err": [1, "^(err|error)$" ], "handle-callback-err": [2, "^(err|error)$" ],
"indent": "off", "indent": "off",
"jsx-quotes": [2, "prefer-double"], "jsx-quotes": [2, "prefer-double"],
"key-spacing": 1, "key-spacing": 2,
"keyword-spacing": [2, { "before": true, "after": true }], "keyword-spacing": [2, { "before": true, "after": true }],
"new-cap": [2, { "newIsCap": true, "capIsNew": false }], "new-cap": [2, { "newIsCap": true, "capIsNew": false }],
"new-parens": 2, "new-parens": 2,
@ -100,7 +100,7 @@
"no-mixed-spaces-and-tabs": 2, "no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2, "no-multi-spaces": 2,
"no-multi-str": 2, "no-multi-str": 2,
"no-multiple-empty-lines": [1, { "max": 2 }], "no-multiple-empty-lines": [2, { "max": 2 }],
"no-native-reassign": 2, "no-native-reassign": 2,
"no-negated-in-lhs": 2, "no-negated-in-lhs": 2,
"no-new": 2, "no-new": 2,
@ -112,7 +112,7 @@
"no-obj-calls": 2, "no-obj-calls": 2,
"no-octal": 2, "no-octal": 2,
"no-octal-escape": 2, "no-octal-escape": 2,
"no-path-concat": 1, "no-path-concat": 2,
"no-proto": 2, "no-proto": 2,
"no-redeclare": 2, "no-redeclare": 2,
"no-regex-spaces": 2, "no-regex-spaces": 2,
@ -125,7 +125,7 @@
"no-sparse-arrays": 2, "no-sparse-arrays": 2,
"no-this-before-super": 2, "no-this-before-super": 2,
"no-throw-literal": 2, "no-throw-literal": 2,
"no-trailing-spaces": 1, "no-trailing-spaces": 2,
"no-undef": 2, "no-undef": 2,
"no-undef-init": 2, "no-undef-init": 2,
"no-unexpected-multiline": 2, "no-unexpected-multiline": 2,
@ -141,15 +141,15 @@
"no-whitespace-before-property": 2, "no-whitespace-before-property": 2,
"no-with": 2, "no-with": 2,
"one-var": [2, { "initialized": "never" }], "one-var": [2, { "initialized": "never" }],
"operator-linebreak": [1, "after", { "overrides": { "?": "ignore", ":": "ignore" } }], "operator-linebreak": [2, "after", { "overrides": { "?": "ignore", ":": "ignore" } }],
"padded-blocks": "off", "padded-blocks": "off",
"quotes": [2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}], "quotes": [2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}],
"react/no-deprecated": 0, "react/no-deprecated": 0,
"semi": [2, "never"], "semi": [2, "never"],
"semi-spacing": [2, { "before": false, "after": true }], "semi-spacing": [2, { "before": false, "after": true }],
"space-before-blocks": [1, "always"], "space-before-blocks": [2, "always"],
"space-before-function-paren": [1, "always"], "space-before-function-paren": [2, "always"],
"space-in-parens": [1, "never"], "space-in-parens": [2, "never"],
"space-infix-ops": 2, "space-infix-ops": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }], "space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","], "exceptions": ["=", "-"] } ], "spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","], "exceptions": ["=", "-"] } ],
@ -160,7 +160,7 @@
"wrap-iife": [2, "any"], "wrap-iife": [2, "any"],
"yield-star-spacing": [2, "both"], "yield-star-spacing": [2, "both"],
"yoda": [2, "never"], "yoda": [2, "never"],
"prefer-const": 1, "prefer-const": 2,
"mocha/no-exclusive-tests": "error" "mocha/no-exclusive-tests": "error"
} }
} }

View File

@ -28,7 +28,7 @@ function createInfuraClient ({ network }) {
return { networkMiddleware, blockTracker } return { networkMiddleware, blockTracker }
} }
function createNetworkAndChainIdMiddleware({ network }) { function createNetworkAndChainIdMiddleware ({ network }) {
let chainId let chainId
let netId let netId

View File

@ -86,7 +86,7 @@ class TransactionStateManager extends EventEmitter {
@returns {array} the tx list whos status is approved if no address is provide @returns {array} the tx list whos status is approved if no address is provide
returns all txMetas who's status is approved for the current network returns all txMetas who's status is approved for the current network
*/ */
getApprovedTransactions(address) { getApprovedTransactions (address) {
const opts = { status: 'approved' } const opts = { status: 'approved' }
if (address) opts.from = address if (address) opts.from = address
return this.getFilteredTxList(opts) return this.getFilteredTxList(opts)

View File

@ -29,7 +29,7 @@ console.warn('ATTENTION: In an effort to improve user privacy, MetaMask ' +
* @param {Function} handler - event handler * @param {Function} handler - event handler
* @param {boolean} remove - removes this handler after being triggered * @param {boolean} remove - removes this handler after being triggered
*/ */
function onMessage(messageType, handler, remove) { function onMessage (messageType, handler, remove) {
window.addEventListener('message', function ({ data }) { window.addEventListener('message', function ({ data }) {
if (!data || data.type !== messageType) { return } if (!data || data.type !== messageType) { return }
remove && window.removeEventListener('message', handler) remove && window.removeEventListener('message', handler)
@ -104,7 +104,7 @@ inpageProvider._metamask = new Proxy({
* *
* @returns {Promise<boolean>} - Promise resolving to true if this domain has been previously approved * @returns {Promise<boolean>} - Promise resolving to true if this domain has been previously approved
*/ */
isApproved: function() { isApproved: function () {
return new Promise((resolve) => { return new Promise((resolve) => {
isApprovedHandle = ({ data: { caching, isApproved } }) => { isApprovedHandle = ({ data: { caching, isApproved } }) => {
if (caching) { if (caching) {
@ -133,7 +133,7 @@ inpageProvider._metamask = new Proxy({
}) })
}, },
}, { }, {
get: function(obj, prop) { get: function (obj, prop) {
!warned && console.warn('Heads up! ethereum._metamask exposes methods that have ' + !warned && console.warn('Heads up! ethereum._metamask exposes methods that have ' +
'not been standardized yet. This means that these methods may not be implemented ' + 'not been standardized yet. This means that these methods may not be implemented ' +
'in other dapp browsers and may be removed from MetaMask in the future.') 'in other dapp browsers and may be removed from MetaMask in the future.')
@ -153,7 +153,7 @@ const proxiedInpageProvider = new Proxy(inpageProvider, {
window.ethereum = proxiedInpageProvider window.ethereum = proxiedInpageProvider
// detect eth_requestAccounts and pipe to enable for now // detect eth_requestAccounts and pipe to enable for now
function detectAccountRequest(method) { function detectAccountRequest (method) {
const originalMethod = inpageProvider[method] const originalMethod = inpageProvider[method]
inpageProvider[method] = function ({ method }) { inpageProvider[method] = function ({ method }) {
if (method === 'eth_requestAccounts') { if (method === 'eth_requestAccounts') {

View File

@ -38,7 +38,7 @@ async function resolveEnsToIpfsContentId ({ provider, name }) {
return contentId return contentId
} }
function hexValueIsEmpty(value) { function hexValueIsEmpty (value) {
return [undefined, null, '0x', '0x0', '0x0000000000000000000000000000000000000000000000000000000000000000'].includes(value) return [undefined, null, '0x', '0x0', '0x0000000000000000000000000000000000000000000000000000000000000000'].includes(value)
} }

View File

@ -6,7 +6,7 @@ const supportedTopLevelDomains = ['eth']
module.exports = setupEnsIpfsResolver module.exports = setupEnsIpfsResolver
function setupEnsIpfsResolver({ provider }) { function setupEnsIpfsResolver ({ provider }) {
// install listener // install listener
const urlPatterns = supportedTopLevelDomains.map(tld => `*://*.${tld}/*`) const urlPatterns = supportedTopLevelDomains.map(tld => `*://*.${tld}/*`)
@ -35,11 +35,11 @@ function setupEnsIpfsResolver({ provider }) {
attemptResolve({ tabId, name, path, search }) attemptResolve({ tabId, name, path, search })
} }
async function attemptResolve({ tabId, name, path, search }) { async function attemptResolve ({ tabId, name, path, search }) {
extension.tabs.update(tabId, { url: `loading.html` }) extension.tabs.update(tabId, { url: `loading.html` })
try { try {
const ipfsContentId = await resolveEnsToIpfsContentId({ provider, name }) const ipfsContentId = await resolveEnsToIpfsContentId({ provider, name })
let url = `https://gateway.ipfs.io/ipfs/${ipfsContentId}${path}${search || ''}` const url = `https://gateway.ipfs.io/ipfs/${ipfsContentId}${path}${search || ''}`
try { try {
// check if ipfs gateway has result // check if ipfs gateway has result
const response = await fetch(url, { method: 'HEAD' }) const response = await fetch(url, { method: 'HEAD' })

View File

@ -6,13 +6,13 @@ module.exports = setupFetchDebugging
// https://github.com/getsentry/sentry-javascript/pull/1293 // https://github.com/getsentry/sentry-javascript/pull/1293
// //
function setupFetchDebugging() { function setupFetchDebugging () {
if (!global.fetch) return if (!global.fetch) return
const originalFetch = global.fetch const originalFetch = global.fetch
global.fetch = wrappedFetch global.fetch = wrappedFetch
async function wrappedFetch(...args) { async function wrappedFetch (...args) {
const initialStack = getCurrentStack() const initialStack = getCurrentStack()
try { try {
return await originalFetch.call(window, ...args) return await originalFetch.call(window, ...args)
@ -20,14 +20,14 @@ function setupFetchDebugging() {
if (!err.stack) { if (!err.stack) {
console.warn('FetchDebugger - fetch encountered an Error without a stack', err) console.warn('FetchDebugger - fetch encountered an Error without a stack', err)
console.warn('FetchDebugger - overriding stack to point of original call') console.warn('FetchDebugger - overriding stack to point of original call')
err.stack = initialStack err.stack = initialStack
} }
throw err throw err
} }
} }
} }
function getCurrentStack() { function getCurrentStack () {
try { try {
throw new Error('Fake error for generating stack trace') throw new Error('Fake error for generating stack trace')
} catch (err) { } catch (err) {

View File

@ -32,7 +32,7 @@ function setupSentry (opts) {
scope.setExtra('isBrave', isBrave) scope.setExtra('isBrave', isBrave)
}) })
function rewriteReport(report) { function rewriteReport (report) {
try { try {
// simplify certain complex error messages (e.g. Ethjs) // simplify certain complex error messages (e.g. Ethjs)
simplifyErrorMessages(report) simplifyErrorMessages(report)

View File

@ -200,7 +200,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.networkController.on('networkDidChange', () => { this.networkController.on('networkDidChange', () => {
this.balancesController.updateAllBalances() this.balancesController.updateAllBalances()
var currentCurrency = this.currencyController.getCurrentCurrency() var currentCurrency = this.currencyController.getCurrentCurrency()
this.setCurrentCurrency(currentCurrency, function() {}) this.setCurrentCurrency(currentCurrency, function () {})
}) })
this.balancesController.updateAllBalances() this.balancesController.updateAllBalances()
@ -1581,7 +1581,7 @@ module.exports = class MetamaskController extends EventEmitter {
/** /**
* Locks MetaMask * Locks MetaMask
*/ */
setLocked() { setLocked () {
this.providerApprovalController.setLocked() this.providerApprovalController.setLocked()
return this.keyringController.setLocked() return this.keyringController.setLocked()
} }

View File

@ -23,7 +23,7 @@ async function start () {
const release = global.platform.getVersion() const release = global.platform.getVersion()
setupSentry({ release, getState }) setupSentry({ release, getState })
// provide app state to append to error logs // provide app state to append to error logs
function getState() { function getState () {
// get app state // get app state
const state = window.getCleanAppState() const state = window.getCleanAppState()
// remove unnecessary data // remove unnecessary data

View File

@ -222,7 +222,7 @@ ConfigScreen.prototype.render = function () {
}, },
}, 'Clear privacy data'), }, 'Clear privacy data'),
]), ]),
h('hr.horizontal-line'), h('hr.horizontal-line'),
h('div', { h('div', {
@ -253,7 +253,7 @@ ConfigScreen.prototype.render = function () {
'Enable privacy mode' 'Enable privacy mode'
), ),
]), ]),
h('hr.horizontal-line'), h('hr.horizontal-line'),
h('div', { h('div', {

View File

@ -515,14 +515,14 @@ describe('preferences controller', function () {
it('should add custom RPC url to state', function () { it('should add custom RPC url to state', function () {
preferencesController.addToFrequentRpcList('rpc_url', 1) preferencesController.addToFrequentRpcList('rpc_url', 1)
preferencesController.addToFrequentRpcList('http://localhost:8545', 1) preferencesController.addToFrequentRpcList('http://localhost:8545', 1)
assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }] ) assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }])
preferencesController.addToFrequentRpcList('rpc_url', 1) preferencesController.addToFrequentRpcList('rpc_url', 1)
assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }] ) assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }])
}) })
it('should remove custom RPC url from state', function () { it('should remove custom RPC url from state', function () {
preferencesController.addToFrequentRpcList('rpc_url', 1) preferencesController.addToFrequentRpcList('rpc_url', 1)
assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }] ) assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }])
preferencesController.removeFromFrequentRpcList('other_rpc_url') preferencesController.removeFromFrequentRpcList('other_rpc_url')
preferencesController.removeFromFrequentRpcList('http://localhost:8545') preferencesController.removeFromFrequentRpcList('http://localhost:8545')
preferencesController.removeFromFrequentRpcList('rpc_url') preferencesController.removeFromFrequentRpcList('rpc_url')

View File

@ -5,7 +5,7 @@ import * as actions from '../../../../../ui/app/actions'
describe('MetaMask Reducers', () => { describe('MetaMask Reducers', () => {
it('init state', () => { it('init state', () => {
const initState = reduceMetamask({metamask:{}}, {}) const initState = reduceMetamask({metamask: {}}, {})
assert(initState) assert(initState)
}) })

View File

@ -52,7 +52,7 @@ export default class MenuBar extends PureComponent {
{ {
accountDetailsMenuOpen && ( accountDetailsMenuOpen && (
<AccountDetailsDropdown <AccountDetailsDropdown
className="menu-bar__account-details-dropdown" className="menu-bar__account-details-dropdown"
onClose={() => this.setState({ accountDetailsMenuOpen: false })} onClose={() => this.setState({ accountDetailsMenuOpen: false })}
/> />
) )

View File

@ -348,7 +348,7 @@ export default class ConfirmTransactionBase extends Component {
/> />
) )
} }
handleNextTx (txId) { handleNextTx (txId) {
const { history, clearConfirmTransaction } = this.props const { history, clearConfirmTransaction } = this.props
if (txId) { if (txId) {