-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unwanted single returns from arrow functions #12127
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,19 +19,17 @@ const { CAVEATS, ERRORS, PERMS, RPC_REQUESTS } = getters; | |
|
||
const { ACCOUNTS, DOMAINS, PERM_NAMES } = constants; | ||
|
||
const initPermController = () => { | ||
return new PermissionsController({ | ||
const initPermController = () => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like in cases like this, the braces can help with readability. |
||
new PermissionsController({ | ||
...getPermControllerOpts(), | ||
}); | ||
}; | ||
|
||
const createApprovalSpies = (permController) => { | ||
sinon.spy(permController.approvals, '_add'); | ||
}; | ||
|
||
const getNextApprovalId = (permController) => { | ||
return permController.approvals._approvals.keys().next().value; | ||
}; | ||
const getNextApprovalId = (permController) => | ||
permController.approvals._approvals.keys().next().value; | ||
|
||
const validatePermission = (perm, name, origin, caveats) => { | ||
assert.equal( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,9 +30,7 @@ describe('restricted methods', function () { | |
|
||
it('should handle missing identity for first account when sorting', async function () { | ||
const restrictedMethods = getRestrictedMethods({ | ||
getIdentities: () => { | ||
return { '0x7e57e2': {} }; | ||
}, | ||
getIdentities: () => ({ '0x7e57e2': {} }), | ||
getKeyringAccounts: async () => ['0x7e57e2', '0x7e57e3'], | ||
}); | ||
const ethAccountsMethod = pify(restrictedMethods.eth_accounts.method); | ||
|
@@ -49,9 +47,7 @@ describe('restricted methods', function () { | |
|
||
it('should handle missing identity for second account when sorting', async function () { | ||
const restrictedMethods = getRestrictedMethods({ | ||
getIdentities: () => { | ||
return { '0x7e57e3': {} }; | ||
}, | ||
getIdentities: () => ({ '0x7e57e3': {} }), | ||
getKeyringAccounts: async () => ['0x7e57e2', '0x7e57e3'], | ||
}); | ||
const ethAccountsMethod = pify(restrictedMethods.eth_accounts.method); | ||
|
@@ -69,12 +65,11 @@ describe('restricted methods', function () { | |
it('should return accounts in keyring order when none are selected', async function () { | ||
const keyringAccounts = ['0x7e57e2', '0x7e57e3', '0x7e57e4', '0x7e57e5']; | ||
const restrictedMethods = getRestrictedMethods({ | ||
getIdentities: () => { | ||
return keyringAccounts.reduce((identities, address) => { | ||
getIdentities: () => | ||
keyringAccounts.reduce((identities, address) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing with this. It's not impossible to know where the function begins and ends, of course, because of the indentation, but the braces help in being able to spot it more easily. |
||
identities[address] = {}; | ||
return identities; | ||
}, {}); | ||
}, | ||
}, {}), | ||
getKeyringAccounts: async () => [...keyringAccounts], | ||
}); | ||
const ethAccountsMethod = pify(restrictedMethods.eth_accounts.method); | ||
|
@@ -91,12 +86,11 @@ describe('restricted methods', function () { | |
it('should return accounts in keyring order when all have same last selected time', async function () { | ||
const keyringAccounts = ['0x7e57e2', '0x7e57e3', '0x7e57e4', '0x7e57e5']; | ||
const restrictedMethods = getRestrictedMethods({ | ||
getIdentities: () => { | ||
return keyringAccounts.reduce((identities, address) => { | ||
getIdentities: () => | ||
keyringAccounts.reduce((identities, address) => { | ||
identities[address] = { lastSelected: 1000 }; | ||
return identities; | ||
}, {}); | ||
}, | ||
}, {}), | ||
getKeyringAccounts: async () => [...keyringAccounts], | ||
}); | ||
const ethAccountsMethod = pify(restrictedMethods.eth_accounts.method); | ||
|
@@ -114,12 +108,11 @@ describe('restricted methods', function () { | |
const keyringAccounts = ['0x7e57e2', '0x7e57e3', '0x7e57e4', '0x7e57e5']; | ||
const expectedResult = keyringAccounts.slice().reverse(); | ||
const restrictedMethods = getRestrictedMethods({ | ||
getIdentities: () => { | ||
return keyringAccounts.reduce((identities, address, index) => { | ||
getIdentities: () => | ||
keyringAccounts.reduce((identities, address, index) => { | ||
identities[address] = { lastSelected: index * 1000 }; | ||
return identities; | ||
}, {}); | ||
}, | ||
}, {}), | ||
getKeyringAccounts: async () => [...keyringAccounts], | ||
}); | ||
const ethAccountsMethod = pify(restrictedMethods.eth_accounts.method); | ||
|
@@ -149,15 +142,13 @@ describe('restricted methods', function () { | |
'0x7e57e6', | ||
]; | ||
const restrictedMethods = getRestrictedMethods({ | ||
getIdentities: () => { | ||
return { | ||
'0x7e57e2': { lastSelected: 1000 }, | ||
'0x7e57e3': {}, | ||
'0x7e57e4': { lastSelected: 2000 }, | ||
'0x7e57e5': {}, | ||
'0x7e57e6': {}, | ||
}; | ||
}, | ||
getIdentities: () => ({ | ||
'0x7e57e2': { lastSelected: 1000 }, | ||
'0x7e57e3': {}, | ||
'0x7e57e4': { lastSelected: 2000 }, | ||
'0x7e57e5': {}, | ||
'0x7e57e6': {}, | ||
}), | ||
getKeyringAccounts: async () => [...keyringAccounts], | ||
}); | ||
const ethAccountsMethod = pify(restrictedMethods.eth_accounts.method); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use strings instead of numbers here? We've been trying to avoid using numbers so we don't have to remember what they mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried
'error'
but for some reason the linting bombed, requesting a number. I'll look into it, it was weird.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: We can't have nice things: MetaMask/eslint-config#205 (comment)