diff --git a/polygerrit-ui/app/.eslintrc.json b/polygerrit-ui/app/.eslintrc.json index 4a5920c2b9..c14b787e2e 100644 --- a/polygerrit-ui/app/.eslintrc.json +++ b/polygerrit-ui/app/.eslintrc.json @@ -21,6 +21,9 @@ "flushAsynchronousOperations": false }, "rules": { + "no-confusing-arrow": "error", + "newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 }], + "arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }], "arrow-parens": ["error", "as-needed"], "block-spacing": ["error", "always"], "brace-style": ["error", "1tbs", { "allowSingleLine": true }], diff --git a/polygerrit-ui/app/behaviors/gr-access-behavior/gr-access-behavior.html b/polygerrit-ui/app/behaviors/gr-access-behavior/gr-access-behavior.html index 9d3b1af9d7..7f017897f7 100644 --- a/polygerrit-ui/app/behaviors/gr-access-behavior/gr-access-behavior.html +++ b/polygerrit-ui/app/behaviors/gr-access-behavior/gr-access-behavior.html @@ -139,15 +139,17 @@ limitations under the License. */ toSortedArray(obj) { if (!obj) { return []; } - return Object.keys(obj).map(key => { - return { - id: key, - value: obj[key], - }; - }).sort((a, b) => { - // Since IDs are strings, use localeCompare. - return a.id.localeCompare(b.id); - }); + return Object.keys(obj) + .map(key => { + return { + id: key, + value: obj[key], + }; + }) + .sort((a, b) => + // Since IDs are strings, use localeCompare. + a.id.localeCompare(b.id) + ); }, }; diff --git a/polygerrit-ui/app/behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior.html b/polygerrit-ui/app/behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior.html index 07350b9545..49160daf25 100644 --- a/polygerrit-ui/app/behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior.html +++ b/polygerrit-ui/app/behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior.html @@ -64,12 +64,11 @@ limitations under the License. getAdminMenuLinks, opt_options)); } return getAccountCapabilities() - .then(capabilities => { - return this._filterLinks(link => { - return !link.capability || - capabilities.hasOwnProperty(link.capability); - }, getAdminMenuLinks, opt_options); - }); + .then(capabilities => this._filterLinks( + link => !link.capability + || capabilities.hasOwnProperty(link.capability), + getAdminMenuLinks, + opt_options)); }, /** @@ -92,15 +91,17 @@ limitations under the License. const isExernalLink = link => link.url[0] !== '/'; // Append top-level links that are defined by plugins. - links.push(...getAdminMenuLinks().map(link => ({ - url: link.url, - name: link.text, - capability: link.capability || null, - noBaseUrl: !isExernalLink(link), - view: null, - viewableToAll: !link.capability, - target: isExernalLink(link) ? '_blank' : null, - }))); + links.push(...getAdminMenuLinks().map(link => { + return { + url: link.url, + name: link.text, + capability: link.capability || null, + noBaseUrl: !isExernalLink(link), + view: null, + viewableToAll: !link.capability, + target: isExernalLink(link) ? '_blank' : null, + }; + })); links = links.filter(filterFn); diff --git a/polygerrit-ui/app/behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior_test.html b/polygerrit-ui/app/behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior_test.html index 25b75c8e33..d02483f3f5 100644 --- a/polygerrit-ui/app/behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior_test.html +++ b/polygerrit-ui/app/behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior_test.html @@ -95,9 +95,8 @@ limitations under the License. if (expected.pluginGeneratedLinks) { for (const link of expected.pluginGeneratedLinks) { - const linkMatch = res.links.find(l => { - return (l.url === link.url && l.name === link.text); - }); + const linkMatch = res.links + .find(l => (l.url === link.url && l.name === link.text)); assert.isTrue(!!linkMatch); // External links should open in new tab. @@ -325,7 +324,9 @@ limitations under the License. let options; const generatedLinks = [ {text: 'without capability', url: '/without'}, - {text: 'with capability', url: '/with', capability: 'pluginCapability'}, + {text: 'with capability', + url: '/with', + capability: 'pluginCapability'}, ]; menuLinkStub.returns(generatedLinks); expected = Object.assign(expected, { diff --git a/polygerrit-ui/app/behaviors/gr-change-table-behavior/gr-change-table-behavior.html b/polygerrit-ui/app/behaviors/gr-change-table-behavior/gr-change-table-behavior.html index 31b9423eae..d3cd940ac3 100644 --- a/polygerrit-ui/app/behaviors/gr-change-table-behavior/gr-change-table-behavior.html +++ b/polygerrit-ui/app/behaviors/gr-change-table-behavior/gr-change-table-behavior.html @@ -46,9 +46,7 @@ limitations under the License. * @return {!Array} */ getComplementColumns(columns) { - return this.columnNames.filter(column => { - return !columns.includes(column); - }); + return this.columnNames.filter(column => !columns.includes(column)); }, /** diff --git a/polygerrit-ui/app/behaviors/gr-patch-set-behavior/gr-patch-set-behavior.html b/polygerrit-ui/app/behaviors/gr-patch-set-behavior/gr-patch-set-behavior.html index 7b7a1bef6b..61e6b0a86b 100644 --- a/polygerrit-ui/app/behaviors/gr-patch-set-behavior/gr-patch-set-behavior.html +++ b/polygerrit-ui/app/behaviors/gr-patch-set-behavior/gr-patch-set-behavior.html @@ -124,9 +124,9 @@ limitations under the License. // Map a normal patchNum to 2 * (patchNum - 1) + 1... I.e. 1 -> 1, // 2 -> 3, 3 -> 5, etc. // Map an edit to the patchNum of parent*2... I.e. edit on 2 -> 4. - const num = r => r._number === Gerrit.PatchSetBehavior.EDIT_NAME ? + const num = r => (r._number === Gerrit.PatchSetBehavior.EDIT_NAME ? 2 * editParent : - 2 * (r._number - 1) + 1; + 2 * (r._number - 1) + 1); return revisions.sort((a, b) => num(b) - num(a)); }, @@ -150,9 +150,8 @@ limitations under the License. if (!change) { return []; } let patchNums = []; if (change.revisions && Object.keys(change.revisions).length) { - const revisions = Object.keys(change.revisions).map(sha => { - return Object.assign({sha}, change.revisions[sha]); - }); + const revisions = Object.keys(change.revisions) + .map(sha => Object.assign({sha}, change.revisions[sha])); patchNums = Gerrit.PatchSetBehavior.sortRevisions(revisions) .map(e => { diff --git a/polygerrit-ui/app/behaviors/gr-patch-set-behavior/gr-patch-set-behavior_test.html b/polygerrit-ui/app/behaviors/gr-patch-set-behavior/gr-patch-set-behavior_test.html index 5e701790ed..0e4033e04f 100644 --- a/polygerrit-ui/app/behaviors/gr-patch-set-behavior/gr-patch-set-behavior_test.html +++ b/polygerrit-ui/app/behaviors/gr-patch-set-behavior/gr-patch-set-behavior_test.html @@ -170,9 +170,7 @@ limitations under the License. messages: [], work_in_progress: initialWip, }; - const revs = Object.keys(tagsByRevision).sort((a, b) => { - return a - b; - }); + const revs = Object.keys(tagsByRevision).sort((a, b) => a - b); for (const rev of revs) { for (const tag of tagsByRevision[rev]) { change.messages.push({ @@ -190,9 +188,7 @@ limitations under the License. } const verifier = { assertWip(revision, expectedWip) { - const patchNum = patchNums.find(patchNum => { - return patchNum.num == revision; - }); + const patchNum = patchNums.find(patchNum => patchNum.num == revision); if (!patchNum) { assert.fail('revision ' + revision + ' not found'); } diff --git a/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.js b/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.js index 83390fb82d..8c17c499a2 100644 --- a/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.js +++ b/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.js @@ -146,9 +146,8 @@ allPermissions = labelOptions.concat( this.toSortedArray(this.permissionValues)); } - return allPermissions.filter(permission => { - return !this.section.value.permissions[permission.id]; - }); + return allPermissions + .filter(permission => !this.section.value.permissions[permission.id]); } _computeHideEditClass(section) { @@ -248,7 +247,8 @@ _computeSectionClass(editing, canUpload, ownerOf, editingRef, deleted) { const classList = []; - if (editing && this._isEditEnabled(canUpload, ownerOf, this.section.id)) { + if (editing + && this._isEditEnabled(canUpload, ownerOf, this.section.id)) { classList.push('editing'); } if (editingRef) { diff --git a/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list_test.html b/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list_test.html index 455b3a2e4c..51fa2e03ef 100644 --- a/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list_test.html +++ b/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list_test.html @@ -127,9 +127,10 @@ limitations under the License. suite('filter', () => { test('_paramsChanged', done => { - sandbox.stub(element.$.restAPI, 'getGroups', () => { - return Promise.resolve(groups); - }); + sandbox.stub( + element.$.restAPI, + 'getGroups', + () => Promise.resolve(groups)); const value = { filter: 'test', offset: 25, diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.html b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.html index 04bdab7492..7b0c723430 100644 --- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.html +++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.html @@ -101,13 +101,15 @@ limitations under the License. sandbox.stub(element.$.restAPI, 'getAccount').returns(Promise.resolve({ name: 'test-user', })); - sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => { - return Promise.resolve({ - createGroup: true, - createProject: true, - viewPlugins: true, - }); - }); + sandbox.stub( + element.$.restAPI, + 'getAccountCapabilities', + () => Promise.resolve({ + createGroup: true, + createProject: true, + viewPlugins: true, + }) + ); element.reload().then(() => { assert.equal(element._filteredLinks.length, 3); @@ -127,9 +129,11 @@ limitations under the License. sandbox.stub(element.$.restAPI, 'getAccount').returns(Promise.resolve({ name: 'test-user', })); - sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => { - return Promise.resolve({}); - }); + sandbox.stub( + element.$.restAPI, + 'getAccountCapabilities', + () => Promise.resolve({}) + ); element.reload().then(() => { assert.equal(element._filteredLinks.length, 2); @@ -185,13 +189,14 @@ limitations under the License. sandbox.stub(element.$.restAPI, 'getAccount').returns(Promise.resolve({ name: 'test-user', })); - sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => { - return Promise.resolve({ - createGroup: true, - createProject: true, - viewPlugins: true, - }); - }); + sandbox.stub( + element.$.restAPI, + 'getAccountCapabilities', + () => Promise.resolve({ + createGroup: true, + createProject: true, + viewPlugins: true, + })); element.reload().then(() => { flushAsynchronousOperations(); assert.equal(Polymer.dom(element.root) @@ -214,13 +219,14 @@ limitations under the License. sandbox.stub(element.$.restAPI, 'getAccount').returns(Promise.resolve({ name: 'test-user', })); - sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => { - return Promise.resolve({ - createGroup: true, - createProject: true, - viewPlugins: true, - }); - }); + sandbox.stub( + element.$.restAPI, + 'getAccountCapabilities', + () => Promise.resolve({ + createGroup: true, + createProject: true, + viewPlugins: true, + })); element.reload().then(() => { flushAsynchronousOperations(); assert.equal(element._filteredLinks.length, 3); @@ -239,16 +245,18 @@ limitations under the License. }); test('Nav is reloaded when repo changes', () => { - sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => { - return Promise.resolve({ - createGroup: true, - createProject: true, - viewPlugins: true, - }); - }); - sandbox.stub(element.$.restAPI, 'getAccount', () => { - return Promise.resolve({_id: 1}); - }); + sandbox.stub( + element.$.restAPI, + 'getAccountCapabilities', + () => Promise.resolve({ + createGroup: true, + createProject: true, + viewPlugins: true, + })); + sandbox.stub( + element.$.restAPI, + 'getAccount', + () => Promise.resolve({_id: 1})); sandbox.stub(element, 'reload'); element.params = {repo: 'Test Repo', adminView: 'gr-repo'}; assert.equal(element.reload.callCount, 1); @@ -259,16 +267,18 @@ limitations under the License. test('Nav is reloaded when group changes', () => { sandbox.stub(element, '_computeGroupName'); - sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => { - return Promise.resolve({ - createGroup: true, - createProject: true, - viewPlugins: true, - }); - }); - sandbox.stub(element.$.restAPI, 'getAccount', () => { - return Promise.resolve({_id: 1}); - }); + sandbox.stub( + element.$.restAPI, + 'getAccountCapabilities', + () => Promise.resolve({ + createGroup: true, + createProject: true, + viewPlugins: true, + })); + sandbox.stub( + element.$.restAPI, + 'getAccount', + () => Promise.resolve({_id: 1})); sandbox.stub(element, 'reload'); element.params = {groupId: '1', adminView: 'gr-group'}; assert.equal(element.reload.callCount, 1); @@ -304,7 +314,9 @@ limitations under the License. assert.isOk(element.$$('.mainHeader')); element._subsectionLinks = undefined; flushAsynchronousOperations(); - assert.equal(getComputedStyle(element.$$('.mainHeader')).display, 'none'); + assert.equal( + getComputedStyle(element.$$('.mainHeader')).display, + 'none'); }); test('Dropdown only triggers navigation on explicit select', done => { @@ -314,16 +326,18 @@ limitations under the License. view: Gerrit.Nav.View.REPO, detail: Gerrit.Nav.RepoDetailView.ACCESS, }; - sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => { - return Promise.resolve({ - createGroup: true, - createProject: true, - viewPlugins: true, - }); - }); - sandbox.stub(element.$.restAPI, 'getAccount', () => { - return Promise.resolve({_id: 1}); - }); + sandbox.stub( + element.$.restAPI, + 'getAccountCapabilities', + () => Promise.resolve({ + createGroup: true, + createProject: true, + viewPlugins: true, + })); + sandbox.stub( + element.$.restAPI, + 'getAccount', + () => Promise.resolve({_id: 1})); flushAsynchronousOperations(); const expectedFilteredLinks = [ { @@ -475,16 +489,18 @@ limitations under the License. suite('_computeSelectedClass', () => { setup(() => { - sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => { - return Promise.resolve({ - createGroup: true, - createProject: true, - viewPlugins: true, - }); - }); - sandbox.stub(element.$.restAPI, 'getAccount', () => { - return Promise.resolve({_id: 1}); - }); + sandbox.stub( + element.$.restAPI, + 'getAccountCapabilities', + () => Promise.resolve({ + createGroup: true, + createProject: true, + viewPlugins: true, + })); + sandbox.stub( + element.$.restAPI, + 'getAccount', + () => Promise.resolve({_id: 1})); return element.reload(); }); diff --git a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.html b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.html index 3367aa3d6b..67c85373fd 100644 --- a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.html +++ b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.html @@ -81,9 +81,7 @@ limitations under the License. }; const saveStub = sandbox.stub(element.$.restAPI, - 'createChange', () => { - return Promise.resolve({}); - }); + 'createChange', () => Promise.resolve({})); element.branch = 'test-branch'; element.topic = 'test-topic'; @@ -109,9 +107,7 @@ limitations under the License. configured_value: 'TRUE', inherited_value: false, }; - sandbox.stub(element, '_formatBooleanString', () => { - return Promise.resolve(true); - }); + sandbox.stub(element, '_formatBooleanString', () => Promise.resolve(true)); flushAsynchronousOperations(); const configInputObj = { @@ -123,9 +119,7 @@ limitations under the License. }; const saveStub = sandbox.stub(element.$.restAPI, - 'createChange', () => { - return Promise.resolve({}); - }); + 'createChange', () => Promise.resolve({})); element.branch = 'test-branch'; element.topic = 'test-topic'; diff --git a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.html b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.html index 41b8ecaf65..43d5fbe760 100644 --- a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.html +++ b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.html @@ -56,9 +56,10 @@ limitations under the License. }); test('branch created', done => { - sandbox.stub(element.$.restAPI, 'createRepoBranch', () => { - return Promise.resolve({}); - }); + sandbox.stub( + element.$.restAPI, + 'createRepoBranch', + () => Promise.resolve({})); assert.isFalse(element.hasNewItemName); @@ -77,9 +78,10 @@ limitations under the License. }); test('tag created', done => { - sandbox.stub(element.$.restAPI, 'createRepoTag', () => { - return Promise.resolve({}); - }); + sandbox.stub( + element.$.restAPI, + 'createRepoTag', + () => Promise.resolve({})); assert.isFalse(element.hasNewItemName); @@ -98,9 +100,10 @@ limitations under the License. }); test('tag created with annotations', done => { - sandbox.stub(element.$.restAPI, 'createRepoTag', () => { - return Promise.resolve({}); - }); + sandbox.stub( + element.$.restAPI, + 'createRepoTag', + () => Promise.resolve({})); assert.isFalse(element.hasNewItemName); diff --git a/polygerrit-ui/app/elements/admin/gr-create-repo-dialog/gr-create-repo-dialog_test.html b/polygerrit-ui/app/elements/admin/gr-create-repo-dialog/gr-create-repo-dialog_test.html index fa481c26cf..80f953bc1c 100644 --- a/polygerrit-ui/app/elements/admin/gr-create-repo-dialog/gr-create-repo-dialog_test.html +++ b/polygerrit-ui/app/elements/admin/gr-create-repo-dialog/gr-create-repo-dialog_test.html @@ -66,9 +66,7 @@ limitations under the License. }; const saveStub = sandbox.stub(element.$.restAPI, - 'createRepo', () => { - return Promise.resolve({}); - }); + 'createRepo', () => Promise.resolve({})); assert.isFalse(element.hasNewRepoName); diff --git a/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members_test.html b/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members_test.html index e90e6fd977..609a00d15a 100644 --- a/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members_test.html +++ b/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members_test.html @@ -153,9 +153,10 @@ limitations under the License. element = fixture('basic'); sandbox.stub(element, 'getBaseUrl').returns('https://test/site'); element.groupId = 1; - groupStub = sandbox.stub(element.$.restAPI, 'getGroupConfig', () => { - return Promise.resolve(groups); - }); + groupStub = sandbox.stub( + element.$.restAPI, + 'getGroupConfig', + () => Promise.resolve(groups)); return element._loadGroupDetails(); }); @@ -181,9 +182,7 @@ limitations under the License. const memberName = 'test-admin'; const saveStub = sandbox.stub(element.$.restAPI, 'saveGroupMembers', - () => { - return Promise.resolve({}); - }); + () => Promise.resolve({})); const button = element.$.saveGroupMember; @@ -208,9 +207,7 @@ limitations under the License. const includedGroupName = 'testName'; const saveIncludedGroupStub = sandbox.stub( - element.$.restAPI, 'saveIncludedGroup', () => { - return Promise.resolve({}); - }); + element.$.restAPI, 'saveIncludedGroup', () => Promise.resolve({})); const button = element.$.saveIncludedGroups; @@ -248,35 +245,31 @@ limitations under the License. }); }); - test('_getAccountSuggestions empty', () => { - return element._getAccountSuggestions('nonexistent').then(accounts => { - assert.equal(accounts.length, 0); - }); - }); + test('_getAccountSuggestions empty', () => element + ._getAccountSuggestions('nonexistent').then(accounts => { + assert.equal(accounts.length, 0); + })); - test('_getAccountSuggestions non-empty', () => { - return element._getAccountSuggestions('test-').then(accounts => { - assert.equal(accounts.length, 3); - assert.equal(accounts[0].name, - 'test-account '); - assert.equal(accounts[1].name, 'test-admin '); - assert.equal(accounts[2].name, 'test-git'); - }); - }); + test('_getAccountSuggestions non-empty', () => element + ._getAccountSuggestions('test-').then(accounts => { + assert.equal(accounts.length, 3); + assert.equal(accounts[0].name, + 'test-account '); + assert.equal(accounts[1].name, 'test-admin '); + assert.equal(accounts[2].name, 'test-git'); + })); - test('_getGroupSuggestions empty', () => { - return element._getGroupSuggestions('nonexistent').then(groups => { - assert.equal(groups.length, 0); - }); - }); + test('_getGroupSuggestions empty', () => element + ._getGroupSuggestions('nonexistent').then(groups => { + assert.equal(groups.length, 0); + })); - test('_getGroupSuggestions non-empty', () => { - return element._getGroupSuggestions('test').then(groups => { - assert.equal(groups.length, 2); - assert.equal(groups[0].name, 'test-admin'); - assert.equal(groups[1].name, 'test/Administrator (admin)'); - }); - }); + test('_getGroupSuggestions non-empty', () => element + ._getGroupSuggestions('test').then(groups => { + assert.equal(groups.length, 2); + assert.equal(groups[0].name, 'test-admin'); + assert.equal(groups[1].name, 'test/Administrator (admin)'); + })); test('_computeHideItemClass returns string for admin', () => { const admin = true; diff --git a/polygerrit-ui/app/elements/admin/gr-group/gr-group_test.html b/polygerrit-ui/app/elements/admin/gr-group/gr-group_test.html index 0d7aae2938..5534cde9a4 100644 --- a/polygerrit-ui/app/elements/admin/gr-group/gr-group_test.html +++ b/polygerrit-ui/app/elements/admin/gr-group/gr-group_test.html @@ -56,9 +56,11 @@ limitations under the License. getLoggedIn() { return Promise.resolve(true); }, }); element = fixture('basic'); - groupStub = sandbox.stub(element.$.restAPI, 'getGroupConfig', () => { - return Promise.resolve(group); - }); + groupStub = sandbox.stub( + element.$.restAPI, + 'getGroupConfig', + () => Promise.resolve(group) + ); }); teardown(() => { @@ -74,9 +76,10 @@ limitations under the License. }); test('default values are populated with internal group', done => { - sandbox.stub(element.$.restAPI, 'getIsGroupOwner', () => { - return Promise.resolve(true); - }); + sandbox.stub( + element.$.restAPI, + 'getIsGroupOwner', + () => Promise.resolve(true)); element.groupId = 1; element._loadGroup().then(() => { assert.isTrue(element._groupIsInternal); @@ -89,12 +92,14 @@ limitations under the License. const groupExternal = Object.assign({}, group); groupExternal.id = 'external-group-id'; groupStub.restore(); - groupStub = sandbox.stub(element.$.restAPI, 'getGroupConfig', () => { - return Promise.resolve(groupExternal); - }); - sandbox.stub(element.$.restAPI, 'getIsGroupOwner', () => { - return Promise.resolve(true); - }); + groupStub = sandbox.stub( + element.$.restAPI, + 'getGroupConfig', + () => Promise.resolve(groupExternal)); + sandbox.stub( + element.$.restAPI, + 'getIsGroupOwner', + () => Promise.resolve(true)); element.groupId = 1; element._loadGroup().then(() => { assert.isFalse(element._groupIsInternal); @@ -114,13 +119,15 @@ limitations under the License. element._groupName = groupName; element._groupOwner = true; - sandbox.stub(element.$.restAPI, 'getIsGroupOwner', () => { - return Promise.resolve(true); - }); + sandbox.stub( + element.$.restAPI, + 'getIsGroupOwner', + () => Promise.resolve(true)); - sandbox.stub(element.$.restAPI, 'saveGroupName', () => { - return Promise.resolve({status: 200}); - }); + sandbox.stub( + element.$.restAPI, + 'saveGroupName', + () => Promise.resolve({status: 200})); const button = element.$.inputUpdateNameBtn; @@ -154,9 +161,10 @@ limitations under the License. test('test for undefined group name', done => { groupStub.restore(); - sandbox.stub(element.$.restAPI, 'getGroupConfig', () => { - return Promise.resolve({}); - }); + sandbox.stub( + element.$.restAPI, + 'getGroupConfig', + () => Promise.resolve({})); assert.isUndefined(element.groupId); diff --git a/polygerrit-ui/app/elements/admin/gr-permission/gr-permission.js b/polygerrit-ui/app/elements/admin/gr-permission/gr-permission.js index e94b7fcf7b..040eabf3cc 100644 --- a/polygerrit-ui/app/elements/admin/gr-permission/gr-permission.js +++ b/polygerrit-ui/app/elements/admin/gr-permission/gr-permission.js @@ -209,9 +209,8 @@ _computeLabelValues(values) { const valuesArr = []; - const keys = Object.keys(values).sort((a, b) => { - return parseInt(a, 10) - parseInt(b, 10); - }); + const keys = Object.keys(values) + .sort((a, b) => parseInt(a, 10) - parseInt(b, 10)); for (const key of keys) { let text = values[key]; @@ -255,9 +254,8 @@ }); } // Does not return groups in which we already have rules for. - return groups.filter(group => { - return !this._groupsWithRules[group.value.id]; - }); + return groups + .filter(group => !this._groupsWithRules[group.value.id]); }); } @@ -268,7 +266,8 @@ _handleAddRuleItem(e) { // The group id is encoded, but have to decode in order for the access // API to work as expected. - const groupId = decodeURIComponent(e.detail.value.id).replace(/\+/g, ' '); + const groupId = decodeURIComponent(e.detail.value.id) + .replace(/\+/g, ' '); this.set(['permission', 'value', 'rules', groupId], {}); // Purposely don't recompute sorted array so that the newly added rule diff --git a/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list_test.html b/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list_test.html index 98636a8393..a80e5759e9 100644 --- a/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list_test.html +++ b/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list_test.html @@ -125,9 +125,10 @@ limitations under the License. suite('filter', () => { test('_paramsChanged', done => { - sandbox.stub(element.$.restAPI, 'getPlugins', () => { - return Promise.resolve(plugins); - }); + sandbox.stub( + element.$.restAPI, + 'getPlugins', + () => Promise.resolve(plugins)); const value = { filter: 'test', offset: 25, diff --git a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access_test.html b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access_test.html index fc7dea8720..e0e25e01cb 100644 --- a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access_test.html +++ b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access_test.html @@ -579,8 +579,9 @@ limitations under the License. remove: {}, }; - element.$$('gr-access-section').$$('gr-permission')._handleAddRuleItem( - {detail: {value: {id: 'Maintainers'}}}); + element.$$('gr-access-section').$$('gr-permission') + ._handleAddRuleItem( + {detail: {value: {id: 'Maintainers'}}}); flushAsynchronousOperations(); assert.deepEqual(element._computeAddAndRemove(), expectedInput); diff --git a/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands_test.html b/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands_test.html index 3c1917560c..fc6bd4b337 100644 --- a/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands_test.html +++ b/polygerrit-ui/app/elements/admin/gr-repo-commands/gr-repo-commands_test.html @@ -44,9 +44,10 @@ limitations under the License. setup(() => { sandbox = sinon.sandbox.create(); element = fixture('basic'); - repoStub = sandbox.stub(element.$.restAPI, 'getProjectConfig', () => { - return Promise.resolve({}); - }); + repoStub = sandbox.stub( + element.$.restAPI, + 'getProjectConfig', + () => Promise.resolve({})); }); teardown(() => { diff --git a/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.js b/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.js index f87f119fbf..00611b608c 100644 --- a/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.js +++ b/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.js @@ -54,7 +54,7 @@ // Group by ref and sort by id. const dashboards = res.concat.apply([], res).sort((a, b) => - a.id < b.id ? -1 : 1); + (a.id < b.id ? -1 : 1)); const dashboardsByRef = {}; dashboards.forEach(d => { if (!dashboardsByRef[d.ref]) { @@ -64,12 +64,13 @@ }); const dashboardBuilder = []; - Object.keys(dashboardsByRef).sort().forEach(ref => { - dashboardBuilder.push({ - section: ref, - dashboards: dashboardsByRef[ref], - }); - }); + Object.keys(dashboardsByRef).sort() + .forEach(ref => { + dashboardBuilder.push({ + section: ref, + dashboards: dashboardsByRef[ref], + }); + }); this._dashboards = dashboardBuilder; this._loading = false; diff --git a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_test.html b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_test.html index 2b175c7aea..0a99e605c2 100644 --- a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_test.html +++ b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_test.html @@ -297,9 +297,10 @@ limitations under the License. suite('filter', () => { test('_paramsChanged', done => { - sandbox.stub(element.$.restAPI, 'getRepoBranches', () => { - return Promise.resolve(branches); - }); + sandbox.stub( + element.$.restAPI, + 'getRepoBranches', + () => Promise.resolve(branches)); const params = { detail: 'branches', repo: 'test', @@ -480,9 +481,10 @@ limitations under the License. suite('filter', () => { test('_paramsChanged', done => { - sandbox.stub(element.$.restAPI, 'getRepoTags', () => { - return Promise.resolve(tags); - }); + sandbox.stub( + element.$.restAPI, + 'getRepoTags', + () => Promise.resolve(tags)); const params = { repo: 'test', detail: 'tags', diff --git a/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list_test.html b/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list_test.html index 9569e56045..aed5c77dc0 100644 --- a/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list_test.html +++ b/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list_test.html @@ -127,9 +127,7 @@ limitations under the License. }); test('_paramsChanged', done => { - sandbox.stub(element.$.restAPI, 'getRepos', () => { - return Promise.resolve(repos); - }); + sandbox.stub(element.$.restAPI, 'getRepos', () => Promise.resolve(repos)); const value = { filter: 'test', offset: 25, diff --git a/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.js b/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.js index dfcacb49a4..404f93c590 100644 --- a/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.js +++ b/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.js @@ -49,7 +49,8 @@ return []; } const {config} = dataRecord.base; - return Object.keys(config).map(_key => ({_key, info: config[_key]})); + return Object.keys(config) + .map(_key => { return {_key, info: config[_key]}; }); } _isArray(type) { diff --git a/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js b/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js index 5d24442ce5..a2097f9f09 100644 --- a/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js +++ b/polygerrit-ui/app/elements/admin/gr-repo/gr-repo.js @@ -136,7 +136,7 @@ const pluginConfig = configRecord.base; return Object.keys(pluginConfig) - .map(name => ({name, config: pluginConfig[name]})); + .map(name => { return {name, config: pluginConfig[name]}; }); } _loadRepo() { diff --git a/polygerrit-ui/app/elements/admin/gr-repo/gr-repo_test.html b/polygerrit-ui/app/elements/admin/gr-repo/gr-repo_test.html index 102a45e318..6f68525bd4 100644 --- a/polygerrit-ui/app/elements/admin/gr-repo/gr-repo_test.html +++ b/polygerrit-ui/app/elements/admin/gr-repo/gr-repo_test.html @@ -120,9 +120,10 @@ limitations under the License. }, }); element = fixture('basic'); - repoStub = sandbox.stub(element.$.restAPI, 'getProjectConfig', () => { - return Promise.resolve(repoConf); - }); + repoStub = sandbox.stub( + element.$.restAPI, + 'getProjectConfig', + () => Promise.resolve(repoConf)); }); teardown(() => { @@ -187,12 +188,11 @@ limitations under the License. test('form defaults to read only when logged in and not admin', done => { element.repo = REPO; - sandbox.stub(element, '_getLoggedIn', () => { - return Promise.resolve(true); - }); - sandbox.stub(element.$.restAPI, 'getRepoAccess', () => { - return Promise.resolve({'test-repo': {}}); - }); + sandbox.stub(element, '_getLoggedIn', () => Promise.resolve(true)); + sandbox.stub( + element.$.restAPI, + 'getRepoAccess', + () => Promise.resolve({'test-repo': {}})); element._loadRepo().then(() => { assert.isTrue(element._readOnly); done(); @@ -280,12 +280,11 @@ limitations under the License. suite('admin', () => { setup(() => { element.repo = REPO; - sandbox.stub(element, '_getLoggedIn', () => { - return Promise.resolve(true); - }); - sandbox.stub(element.$.restAPI, 'getRepoAccess', () => { - return Promise.resolve({'test-repo': {is_owner: true}}); - }); + sandbox.stub(element, '_getLoggedIn', () => Promise.resolve(true)); + sandbox.stub( + element.$.restAPI, + 'getRepoAccess', + () => Promise.resolve({'test-repo': {is_owner: true}})); }); test('all form elements are enabled', done => { @@ -308,14 +307,13 @@ limitations under the License. }); }); - test('inherited submit type value is calculated correctly', () => { - return element._loadRepo().then(() => { - const sel = element.$.submitTypeSelect; - assert.equal(sel.bindValue, 'INHERIT'); - assert.equal( - sel.nativeSelect.options[0].text, 'Inherit (Merge if necessary)'); - }); - }); + test('inherited submit type value is calculated correctly', () => element + ._loadRepo().then(() => { + const sel = element.$.submitTypeSelect; + assert.equal(sel.bindValue, 'INHERIT'); + assert.equal( + sel.nativeSelect.options[0].text, 'Inherit (Merge if necessary)'); + })); test('fields update and save correctly', () => { const configInputObj = { @@ -338,9 +336,7 @@ limitations under the License. }; const saveStub = sandbox.stub(element.$.restAPI, 'saveRepoConfig' - , () => { - return Promise.resolve({}); - }); + , () => Promise.resolve({})); const button = Polymer.dom(element.root).querySelector('gr-button'); diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js index dedf88707b..9ce5e462e2 100644 --- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js +++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.js @@ -121,7 +121,8 @@ } else { classes['u-gray-background'] = true; } - return Object.keys(classes).sort().join(' '); + return Object.keys(classes).sort() + .join(' '); } _computeLabelValue(change, labelName) { diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.js b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.js index cdd3cdb14c..4e08b5c15f 100644 --- a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.js +++ b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.js @@ -163,24 +163,26 @@ // in an async so that attachment to the DOM can take place first. this.async(() => this.fire('title-change', {title: this._query})); - this._getPreferences().then(prefs => { - this._changesPerPage = prefs.changes_per_page; - return this._getChanges(); - }).then(changes => { - changes = changes || []; - if (this._query && changes.length === 1) { - for (const query in LookupQueryPatterns) { - if (LookupQueryPatterns.hasOwnProperty(query) && + this._getPreferences() + .then(prefs => { + this._changesPerPage = prefs.changes_per_page; + return this._getChanges(); + }) + .then(changes => { + changes = changes || []; + if (this._query && changes.length === 1) { + for (const query in LookupQueryPatterns) { + if (LookupQueryPatterns.hasOwnProperty(query) && this._query.match(LookupQueryPatterns[query])) { - this._replaceCurrentLocation( - Gerrit.Nav.getUrlForChange(changes[0])); - return; + this._replaceCurrentLocation( + Gerrit.Nav.getUrlForChange(changes[0])); + return; + } + } } - } - } - this._changes = changes; - this._loading = false; - }); + this._changes = changes; + this._loading = false; + }); } _loadPreferences() { diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js index d1136ccdce..618b78f2cb 100644 --- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js +++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js @@ -234,11 +234,8 @@ _processQuery(query) { let tokens = query.split(' '); const invalidTokens = ['limit:', 'age:', '-age:']; - tokens = tokens.filter(token => { - return !invalidTokens.some(invalidToken => { - return token.startsWith(invalidToken); - }); - }); + tokens = tokens.filter(token => !invalidTokens + .some(invalidToken => token.startsWith(invalidToken))); return tokens.join(' '); } diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js index 0170b0b8c8..05f1abeba0 100644 --- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js +++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js @@ -181,12 +181,14 @@ .then(() => { this._maybeShowDraftsBanner(); this.$.reporting.dashboardDisplayed(); - }).catch(err => { + }) + .catch(err => { this.fire('title-change', { title: title || this._computeTitle(user), }); console.warn(err); - }).then(() => { this._loading = false; }); + }) + .then(() => { this._loading = false; }); } /** @@ -201,9 +203,9 @@ if (!res) { return Promise.resolve(); } const queries = res.sections - .map(section => section.suffixForDashboard ? + .map(section => (section.suffixForDashboard ? section.query + ' ' + section.suffixForDashboard : - section.query); + section.query)); if (checkForNewUser) { queries.push('owner:self limit:1'); @@ -216,13 +218,15 @@ const lastResultSet = changes.pop(); this._showNewUserHelp = lastResultSet.length == 0; } - this._results = changes.map((results, i) => ({ - name: res.sections[i].name, - countLabel: this._computeSectionCountLabel(results), - query: res.sections[i].query, - results, - isOutgoing: res.sections[i].isOutgoing, - })).filter((section, i) => i < res.sections.length && ( + this._results = changes.map((results, i) => { + return { + name: res.sections[i].name, + countLabel: this._computeSectionCountLabel(results), + query: res.sections[i].query, + results, + isOutgoing: res.sections[i].isOutgoing, + }; + }).filter((section, i) => i < res.sections.length && ( !res.sections[i].hideIfEmpty || section.results.length)); }); diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js index 53a9568a7f..1034389ed2 100644 --- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js +++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js @@ -474,16 +474,18 @@ } this._loading = true; - return this._getRevisionActions().then(revisionActions => { - if (!revisionActions) { return; } + return this._getRevisionActions() + .then(revisionActions => { + if (!revisionActions) { return; } - this.revisionActions = this._updateRebaseAction(revisionActions); - this._handleLoadingComplete(); - }).catch(err => { - this.fire('show-alert', {message: ERR_REVISION_ACTIONS}); - this._loading = false; - throw err; - }); + this.revisionActions = this._updateRebaseAction(revisionActions); + this._handleLoadingComplete(); + }) + .catch(err => { + this.fire('show-alert', {message: ERR_REVISION_ACTIONS}); + this._loading = false; + throw err; + }); } _handleLoadingComplete() { @@ -515,7 +517,8 @@ label, __type: type, __key: ADDITIONAL_ACTION_KEY_PREFIX + - Math.random().toString(36).substr(2), + Math.random().toString(36) + .substr(2), }; this.push('_additionalActions', action); return action.__key; @@ -558,9 +561,8 @@ if (type !== ActionType.CHANGE && type !== ActionType.REVISION) { throw Error(`Invalid action type given: ${type}`); } - const index = this._actionPriorityOverrides.findIndex(action => { - return action.type === type && action.key === key; - }); + const index = this._actionPriorityOverrides + .findIndex(action => action.type === type && action.key === key); const action = { type, key, @@ -723,9 +725,7 @@ } _getValuesFor(obj) { - return Object.keys(obj).map(key => { - return obj[key]; - }); + return Object.keys(obj).map(key => obj[key]); } _getLabelStatus(label) { @@ -790,9 +790,8 @@ hideQuickApproveAction() { this._topLevelSecondaryActions = - this._topLevelSecondaryActions.filter(sa => { - return sa.key !== QUICK_APPROVE_ACTION.key; - }); + this._topLevelSecondaryActions + .filter(sa => sa.key !== QUICK_APPROVE_ACTION.key); this._hideQuickApproveAction = true; } @@ -850,13 +849,13 @@ let additionalActions = (additionalActionsChangeRecord && additionalActionsChangeRecord.base) || []; - additionalActions = additionalActions.filter(a => { - return a.__type === type; - }).map(a => { - a.__primary = primaryActionKeys.includes(a.__key); - // Triggers a re-render by ensuring object inequality. - return Object.assign({}, a); - }); + additionalActions = additionalActions + .filter(a => a.__type === type) + .map(a => { + a.__primary = primaryActionKeys.includes(a.__key); + // Triggers a re-render by ensuring object inequality. + return Object.assign({}, a); + }); return result.concat(additionalActions).concat(pluginActions); } @@ -993,9 +992,7 @@ this._showActionDialog(this.$.confirmAbandonDialog); break; case QUICK_APPROVE_ACTION.key: - action = this._allActionValues.find(o => { - return o.key === key; - }); + action = this._allActionValues.find(o => o.key === key); this._fireAction( this._prependSlash(key), action, true, action.payload); break; @@ -1193,9 +1190,8 @@ } _getActionOverflowIndex(type, key) { - return this._overflowActions.findIndex(action => { - return action.type === type && action.key === key; - }); + return this._overflowActions + .findIndex(action => action.type === type && action.key === key); } _setLoadingOnButtonWithKey(type, key) { @@ -1457,9 +1453,8 @@ _getActionPriority(action) { if (action.__type && action.__key) { - const overrideAction = this._actionPriorityOverrides.find(i => { - return i.type === action.__type && i.key === action.__key; - }); + const overrideAction = this._actionPriorityOverrides + .find(i => i.type === action.__type && i.key === action.__key); if (overrideAction !== undefined) { return overrideAction.priority; diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html index 4f1bfedc3a..ec5c5a5485 100644 --- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html +++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html @@ -220,9 +220,8 @@ limitations under the License. test('delete buttons have explicit labels', done => { flush(() => { - const deleteItems = element.$.moreActions.items.filter(item => { - return item.id.startsWith('delete'); - }); + const deleteItems = element.$.moreActions.items + .filter(item => item.id.startsWith('delete')); assert.equal(deleteItems.length, 1); assert.notEqual(deleteItems[0].name); assert.equal(deleteItems[0].name, 'Delete change'); @@ -261,7 +260,7 @@ limitations under the License. sandbox.stub(element.$.restAPI, 'getFromProjectLookup') .returns(Promise.resolve('test')); sandbox.stub(element, 'fetchChangeUpdates', - () => { return Promise.resolve({isLatest: true}); }); + () => Promise.resolve({isLatest: true})); sandbox.stub(element.$.overlay, 'open').returns(Promise.resolve()); element.change = { revisions: { @@ -284,7 +283,7 @@ limitations under the License. sandbox.stub(element.$.restAPI, 'getFromProjectLookup') .returns(Promise.resolve('test')); sandbox.stub(element, 'fetchChangeUpdates', - () => { return Promise.resolve({isLatest: true}); }); + () => Promise.resolve({isLatest: true})); sandbox.stub(element.$.overlay, 'open').returns(Promise.resolve()); element.change = { revisions: { @@ -318,7 +317,7 @@ limitations under the License. test('submit change with plugin hook', done => { sandbox.stub(element, '_canSubmitChange', - () => { return false; }); + () => false); const fireActionStub = sandbox.stub(element, '_fireAction'); flush(() => { const submitButton = element.$$('gr-button[data-action-key="submit"]'); @@ -819,9 +818,9 @@ limitations under the License. }; const newRevertMsg = 'Modified revert msg'; sandbox.stub(element, '_modifyRevertMsg', - () => { return newRevertMsg; }); + () => newRevertMsg); sandbox.stub(element.$.confirmRevertDialog, 'populateRevertMessage', - () => { return 'original msg'; }); + () => 'original msg'); flush(() => { const revertButton = element.$$('gr-button[data-action-key="revert"]'); @@ -837,7 +836,7 @@ limitations under the License. current_revision: 'abc1234', }; sandbox.stub(element.$.confirmRevertDialog, 'populateRevertMessage', - () => { return 'original msg'; }); + () => 'original msg'); const revertButton = element.$$('gr-button[data-action-key="revert"]'); MockInteractions.tap(revertButton); @@ -1398,15 +1397,13 @@ limitations under the License. sandbox.stub(element, 'async', fn => fn()); }); - const makeGetChange = numTries => { - return () => { - if (numTries === 1) { - return Promise.resolve({_number: 123}); - } else { - numTries--; - return Promise.resolve(undefined); - } - }; + const makeGetChange = numTries => () => { + if (numTries === 1) { + return Promise.resolve({_number: 123}); + } else { + numTries--; + return Promise.resolve(undefined); + } }; test('succeed', () => { @@ -1457,15 +1454,14 @@ limitations under the License. 'navigateToChange').returns(Promise.resolve(true)); }); - test('change action', () => { - return element._send('DELETE', payload, '/endpoint', false, cleanup) - .then(() => { - assert.isFalse(onShowError.called); - assert.isTrue(cleanup.calledOnce); - assert.isTrue(sendStub.calledWith(42, 'DELETE', '/endpoint', - null, payload)); - }); - }); + test('change action', () => element + ._send('DELETE', payload, '/endpoint', false, cleanup) + .then(() => { + assert.isFalse(onShowError.called); + assert.isTrue(cleanup.calledOnce); + assert.isTrue(sendStub.calledWith(42, 'DELETE', '/endpoint', + null, payload)); + })); suite('show revert submission dialog', () => { setup(() => { @@ -1549,15 +1545,14 @@ limitations under the License. }); }); - test('revision action', () => { - return element._send('DELETE', payload, '/endpoint', true, cleanup) - .then(() => { - assert.isFalse(onShowError.called); - assert.isTrue(cleanup.calledOnce); - assert.isTrue(sendStub.calledWith(42, 'DELETE', '/endpoint', - 12, payload)); - }); - }); + test('revision action', () => element + ._send('DELETE', payload, '/endpoint', true, cleanup) + .then(() => { + assert.isFalse(onShowError.called); + assert.isTrue(cleanup.calledOnce); + assert.isTrue(sendStub.calledWith(42, 'DELETE', '/endpoint', + 12, payload)); + })); }); suite('failure modes', () => { diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js index 1dca9d1583..e13b4629c3 100644 --- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js +++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js @@ -376,15 +376,18 @@ _handleTopicRemoved(e) { const target = Polymer.dom(e).rootTarget; target.disabled = true; - this.$.restAPI.setChangeTopic(this.change._number, null).then(() => { - target.disabled = false; - this.set(['change', 'topic'], ''); - this.dispatchEvent( - new CustomEvent('topic-changed', {bubbles: true, composed: true})); - }).catch(err => { - target.disabled = false; - return; - }); + this.$.restAPI.setChangeTopic(this.change._number, null) + .then(() => { + target.disabled = false; + this.set(['change', 'topic'], ''); + this.dispatchEvent( + new CustomEvent('topic-changed', + {bubbles: true, composed: true})); + }) + .catch(err => { + target.disabled = false; + return; + }); } _handleHashtagRemoved(e) { @@ -396,7 +399,8 @@ .then(newHashtag => { target.disabled = false; this.set(['change', 'hashtags'], newHashtag); - }).catch(err => { + }) + .catch(err => { target.disabled = false; return; }); diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html index 09cb4cc4d3..6acf4fe333 100644 --- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html +++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html @@ -736,8 +736,8 @@ limitations under the License. Gerrit.install( p => { plugin = p; - plugin.hook('change-metadata-item').getLastAttached().then( - el => hookEl = el); + plugin.hook('change-metadata-item').getLastAttached() + .then(el => hookEl = el); }, '0.1', 'http://some/plugins/url.html'); diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js index fa84b95cf6..4d2f1dbe53 100644 --- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js +++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js @@ -362,16 +362,18 @@ this._setDiffViewMode(); }); - Gerrit.awaitPluginsLoaded().then(() => { - this._dynamicTabHeaderEndpoints = + Gerrit.awaitPluginsLoaded() + .then(() => { + this._dynamicTabHeaderEndpoints = Gerrit._endpoints.getDynamicEndpoints('change-view-tab-header'); - this._dynamicTabContentEndpoints = + this._dynamicTabContentEndpoints = Gerrit._endpoints.getDynamicEndpoints('change-view-tab-content'); - if (this._dynamicTabContentEndpoints.length !== + if (this._dynamicTabContentEndpoints.length !== this._dynamicTabHeaderEndpoints.length) { - console.warn('Different number of tab headers and tab content.'); - } - }).then(() => this._setPrimaryTab()); + console.warn('Different number of tab headers and tab content.'); + } + }) + .then(() => this._setPrimaryTab()); this.addEventListener('comment-save', this._handleCommentSave.bind(this)); this.addEventListener('comment-refresh', this._reloadDrafts.bind(this)); @@ -413,15 +415,17 @@ _setDiffViewMode(opt_reset) { if (!opt_reset && this.viewState.diffViewMode) { return; } - return this._getPreferences().then( prefs => { - if (!this.viewState.diffMode) { - this.set('viewState.diffMode', prefs.default_diff_view); - } - }).then(() => { - if (!this.viewState.diffMode) { - this.set('viewState.diffMode', 'SIDE_BY_SIDE'); - } - }); + return this._getPreferences() + .then( prefs => { + if (!this.viewState.diffMode) { + this.set('viewState.diffMode', prefs.default_diff_view); + } + }) + .then(() => { + if (!this.viewState.diffMode) { + this.set('viewState.diffMode', 'SIDE_BY_SIDE'); + } + }); } _onOpenFixPreview(e) { @@ -497,9 +501,10 @@ message); this._editingCommitMessage = false; this._reloadWindow(); - }).catch(err => { - this.$.commitMessageEditor.disabled = false; - }); + }) + .catch(err => { + this.$.commitMessageEditor.disabled = false; + }); } _reloadWindow() { @@ -603,11 +608,11 @@ } } diffDrafts[draft.path].push(draft); - diffDrafts[draft.path].sort((c1, c2) => { + diffDrafts[draft.path].sort((c1, c2) => // No line number means that it’s a file comment. Sort it above the // others. - return (c1.line || -1) - (c2.line || -1); - }); + (c1.line || -1) - (c2.line || -1) + ); this._diffDrafts = diffDrafts; } @@ -689,7 +694,8 @@ _handleMessageReply(e) { const msg = e.detail.message.message; const quoteStr = msg.split('\n').map( - line => { return '> ' + line; }).join('\n') + '\n\n'; + line => '> ' + line) + .join('\n') + '\n\n'; this.$.replyDialog.quote = quoteStr; this._openReplyDialog(this.$.replyDialog.FocusTarget.BODY); } @@ -1087,9 +1093,8 @@ } const drafts = (changeRecord && changeRecord.base) || {}; - const draftCount = Object.keys(drafts).reduce((count, file) => { - return count + drafts[file].length; - }, 0); + const draftCount = Object.keys(drafts) + .reduce((count, file) => count + drafts[file].length, 0); let label = 'Reply'; if (draftCount > 0) { @@ -1395,9 +1400,7 @@ } _reloadDraftsWithCallback(e) { - return this._reloadDrafts().then(() => { - return e.detail.resolve(); - }); + return this._reloadDrafts().then(() => e.detail.resolve()); } /** diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html index b80b51ebd4..7e776b582e 100644 --- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html +++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html @@ -91,9 +91,7 @@ limitations under the License. }); }); - getCustomCssValue = cssParam => { - return util.getComputedStyleValue(cssParam, element); - }; + getCustomCssValue = cssParam => util.getComputedStyleValue(cssParam, element); test('_handleMessageAnchorTap', () => { element._changeNum = '1'; @@ -725,10 +723,10 @@ limitations under the License. test('don’t reload entire page when patchRange changes', () => { const reloadStub = sandbox.stub(element, '_reload', - () => { return Promise.resolve(); }); + () => Promise.resolve()); const reloadPatchDependentStub = sandbox.stub(element, '_reloadPatchNumDependentResources', - () => { return Promise.resolve(); }); + () => Promise.resolve()); const relatedClearSpy = sandbox.spy(element.$.relatedChanges, 'clear'); const collapseStub = sandbox.stub(element.$.fileList, 'collapseAllDiffs'); @@ -753,7 +751,7 @@ limitations under the License. test('reload entire page when patchRange doesnt change', () => { const reloadStub = sandbox.stub(element, '_reload', - () => { return Promise.resolve(); }); + () => Promise.resolve()); const collapseStub = sandbox.stub(element.$.fileList, 'collapseAllDiffs'); const value = { view: Gerrit.Nav.View.CHANGE, @@ -769,11 +767,9 @@ limitations under the License. test('related changes are updated and new patch selected after rebase', done => { element._changeNum = '42'; - sandbox.stub(element, 'computeLatestPatchNum', () => { - return 1; - }); + sandbox.stub(element, 'computeLatestPatchNum', () => 1); sandbox.stub(element, '_reload', - () => { return Promise.resolve(); }); + () => Promise.resolve()); const e = {detail: {action: 'rebase'}}; element._handleReloadChange(e).then(() => { assert.isTrue(navigateToChangeStub.lastCall.calledWithExactly( @@ -783,7 +779,7 @@ limitations under the License. }); test('related changes are not updated after other action', done => { - sandbox.stub(element, '_reload', () => { return Promise.resolve(); }); + sandbox.stub(element, '_reload', () => Promise.resolve()); sandbox.stub(element.$.relatedChanges, 'reload'); const e = {detail: {action: 'abandon'}}; element._handleReloadChange(e).then(() => { @@ -929,14 +925,12 @@ limitations under the License. test('topic is coalesced to null', done => { sandbox.stub(element, '_changeChanged'); - sandbox.stub(element.$.restAPI, 'getChangeDetail', () => { - return Promise.resolve({ - id: '123456789', - labels: {}, - current_revision: 'foo', - revisions: {foo: {commit: {}}}, - }); - }); + sandbox.stub(element.$.restAPI, 'getChangeDetail', () => Promise.resolve({ + id: '123456789', + labels: {}, + current_revision: 'foo', + revisions: {foo: {commit: {}}}, + })); element._getChangeDetail().then(() => { assert.isNull(element._change.topic); @@ -946,14 +940,12 @@ limitations under the License. test('commit sha is populated from getChangeDetail', done => { sandbox.stub(element, '_changeChanged'); - sandbox.stub(element.$.restAPI, 'getChangeDetail', () => { - return Promise.resolve({ - id: '123456789', - labels: {}, - current_revision: 'foo', - revisions: {foo: {commit: {}}}, - }); - }); + sandbox.stub(element.$.restAPI, 'getChangeDetail', () => Promise.resolve({ + id: '123456789', + labels: {}, + current_revision: 'foo', + revisions: {foo: {commit: {}}}, + })); element._getChangeDetail().then(() => { assert.equal('foo', element._commitInfo.commit); @@ -963,20 +955,16 @@ limitations under the License. test('edit is added to change', () => { sandbox.stub(element, '_changeChanged'); - sandbox.stub(element.$.restAPI, 'getChangeDetail', () => { - return Promise.resolve({ - id: '123456789', - labels: {}, - current_revision: 'foo', - revisions: {foo: {commit: {}}}, - }); - }); - sandbox.stub(element, '_getEdit', () => { - return Promise.resolve({ - base_patch_set_number: 1, - commit: {commit: 'bar'}, - }); - }); + sandbox.stub(element.$.restAPI, 'getChangeDetail', () => Promise.resolve({ + id: '123456789', + labels: {}, + current_revision: 'foo', + revisions: {foo: {commit: {}}}, + })); + sandbox.stub(element, '_getEdit', () => Promise.resolve({ + base_patch_set_number: 1, + commit: {commit: 'bar'}, + })); element._patchRange = {}; return element._getChangeDetail().then(() => { @@ -1097,12 +1085,8 @@ limitations under the License. }); test('revert dialog opened with revert param', done => { - sandbox.stub(element.$.restAPI, 'getLoggedIn', () => { - return Promise.resolve(true); - }); - sandbox.stub(Gerrit, 'awaitPluginsLoaded', () => { - return Promise.resolve(); - }); + sandbox.stub(element.$.restAPI, 'getLoggedIn', () => Promise.resolve(true)); + sandbox.stub(Gerrit, 'awaitPluginsLoaded', () => Promise.resolve()); element._patchRange = { basePatchNum: 'PARENT', @@ -1173,7 +1157,7 @@ limitations under the License. setup(() => { sandbox.stub(element.$.replyDialog, '_draftChanged'); sandbox.stub(element.$.replyDialog, 'fetchChangeUpdates', - () => { return Promise.resolve({isLatest: true}); }); + () => Promise.resolve({isLatest: true})); element._change = {labels: {}}; }); @@ -1222,7 +1206,7 @@ limitations under the License. suite('commit message expand/collapse', () => { setup(() => { sandbox.stub(element, 'fetchChangeUpdates', - () => { return Promise.resolve({isLatest: false}); }); + () => Promise.resolve({isLatest: false})); }); test('commitCollapseToggle hidden for short commit message', () => { @@ -1260,7 +1244,7 @@ limitations under the License. sandbox.stub(element, '_getOffsetHeight', () => 50); sandbox.stub(element, '_getScrollHeight', () => 60); sandbox.stub(element, '_getLineHeight', () => 5); - sandbox.stub(window, 'matchMedia', () => ({matches: true})); + sandbox.stub(window, 'matchMedia', () => { return {matches: true}; }); element.$.relatedChanges.dispatchEvent( new CustomEvent('new-section-loaded')); assert.isTrue(element.$.relatedChangesToggle.classList @@ -1275,7 +1259,7 @@ limitations under the License. sandbox.stub(element, '_getOffsetHeight', () => 50); sandbox.stub(element, '_getScrollHeight', () => 40); sandbox.stub(element, '_getLineHeight', () => 5); - sandbox.stub(window, 'matchMedia', () => ({matches: true})); + sandbox.stub(window, 'matchMedia', () => { return {matches: true}; }); element.$.relatedChanges.dispatchEvent( new CustomEvent('new-section-loaded')); assert.isFalse(element.$.relatedChangesToggle.classList @@ -1285,7 +1269,7 @@ limitations under the License. test('relatedChangesToggle functions', () => { sandbox.stub(element, '_getOffsetHeight', () => 50); - sandbox.stub(window, 'matchMedia', () => ({matches: false})); + sandbox.stub(window, 'matchMedia', () => { return {matches: false}; }); element._relatedChangesLoading = false; assert.isTrue(element._relatedChangesCollapsed); assert.isTrue( @@ -1299,7 +1283,7 @@ limitations under the License. test('_updateRelatedChangeMaxHeight without commit toggle', () => { sandbox.stub(element, '_getOffsetHeight', () => 50); sandbox.stub(element, '_getLineHeight', () => 12); - sandbox.stub(window, 'matchMedia', () => ({matches: false})); + sandbox.stub(window, 'matchMedia', () => { return {matches: false}; }); // 50 (existing height) - 30 (extra height) = 20 (adjusted height). // 20 (max existing height) % 12 (line height) = 6 (remainder). @@ -1316,7 +1300,7 @@ limitations under the License. element._latestCommitMessage = _.times(31, String).join('\n'); sandbox.stub(element, '_getOffsetHeight', () => 50); sandbox.stub(element, '_getLineHeight', () => 12); - sandbox.stub(window, 'matchMedia', () => ({matches: false})); + sandbox.stub(window, 'matchMedia', () => { return {matches: false}; }); // 50 (existing height) % 12 (line height) = 2 (remainder). // 50 (existing height) - 2 (remainder) = 48 (max height to set). @@ -1332,7 +1316,7 @@ limitations under the License. element._latestCommitMessage = _.times(31, String).join('\n'); sandbox.stub(element, '_getOffsetHeight', () => 50); sandbox.stub(element, '_getLineHeight', () => 12); - sandbox.stub(window, 'matchMedia', () => ({matches: true})); + sandbox.stub(window, 'matchMedia', () => { return {matches: true}; }); element._updateRelatedChangeMaxHeight(); @@ -1383,7 +1367,7 @@ limitations under the License. test('_startUpdateCheckTimer up-to-date', () => { sandbox.stub(element, 'fetchChangeUpdates', - () => { return Promise.resolve({isLatest: true}); }); + () => Promise.resolve({isLatest: true})); element._serverConfig = {change: {update_delay: 12345}}; @@ -1394,7 +1378,7 @@ limitations under the License. test('_startUpdateCheckTimer out-of-date shows an alert', done => { sandbox.stub(element, 'fetchChangeUpdates', - () => { return Promise.resolve({isLatest: false}); }); + () => Promise.resolve({isLatest: false})); element.addEventListener('show-alert', e => { assert.equal(e.detail.message, 'A newer patch set has been uploaded'); @@ -1738,8 +1722,9 @@ limitations under the License. Gerrit.install( p => { plugin = p; - plugin.hook('change-view-integration').getLastAttached().then( - el => hookEl = el); + plugin.hook('change-view-integration').getLastAttached() + .then( + el => hookEl = el); }, '0.1', 'http://some/plugins/url.html'); diff --git a/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog_test.html b/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog_test.html index d8016387bf..09953cec26 100644 --- a/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog_test.html +++ b/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog_test.html @@ -153,15 +153,17 @@ limitations under the License. test('_getRecentChanges', () => { sandbox.spy(element, '_getRecentChanges'); - return element._getRecentChanges().then(() => { - assert.deepEqual(element._recentChanges, recentChanges); - assert.equal(element.$.restAPI.getChanges.callCount, 1); - // When called a second time, should not re-request recent changes. - element._getRecentChanges(); - }).then(() => { - assert.equal(element._getRecentChanges.callCount, 2); - assert.equal(element.$.restAPI.getChanges.callCount, 1); - }); + return element._getRecentChanges() + .then(() => { + assert.deepEqual(element._recentChanges, recentChanges); + assert.equal(element.$.restAPI.getChanges.callCount, 1); + // When called a second time, should not re-request recent changes. + element._getRecentChanges(); + }) + .then(() => { + assert.equal(element._getRecentChanges.callCount, 2); + assert.equal(element.$.restAPI.getChanges.callCount, 1); + }); }); test('_filterChanges', () => { diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.js b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.js index 46463d243e..a611250fbe 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.js +++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.js @@ -201,7 +201,8 @@ this.set(['change', 'revisions', sha, 'description'], desc); this._patchsetDescription = desc; } - }).catch(err => { + }) + .catch(err => { if (target) { target.disabled = false; } return; }); diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_test.html b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_test.html index 10efaff675..1b4b34db38 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_test.html +++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_test.html @@ -133,35 +133,37 @@ limitations under the License. // Simulate tapping the remove button, but call function directly so that // can determine what happens after the promise is resolved. - return element._handleDescriptionRemoved().then(() => { - // The API stub should be called with an empty string for the new - // description. - assert.equal(putDescStub.lastCall.args[2], ''); - assert.equal(element.change.revisions.rev1.description, ''); + return element._handleDescriptionRemoved() + .then(() => { + // The API stub should be called with an empty string for the new + // description. + assert.equal(putDescStub.lastCall.args[2], ''); + assert.equal(element.change.revisions.rev1.description, ''); - flushAsynchronousOperations(); - // The editable label should now be visible and the chip hidden. - label = Polymer.dom(element.root).querySelector('#descriptionLabel'); - assert.isOk(label); - assert.equal(getComputedStyle(chip).display, 'none'); - assert.notEqual(getComputedStyle(label).display, 'none'); - assert.isFalse(label.readOnly); - // Edit the label to have a new value of test2, and save. - label.editing = true; - label._inputText = 'test2'; - label._save(); - flushAsynchronousOperations(); - // The API stub should be called with an `test2` for the new - // description. - assert.equal(putDescStub.callCount, 2); - assert.equal(putDescStub.lastCall.args[2], 'test2'); - }).then(() => { - flushAsynchronousOperations(); - // The chip should be visible again, and the label hidden. - assert.equal(element.change.revisions.rev1.description, 'test2'); - assert.equal(getComputedStyle(label).display, 'none'); - assert.notEqual(getComputedStyle(chip).display, 'none'); - }); + flushAsynchronousOperations(); + // The editable label should now be visible and the chip hidden. + label = Polymer.dom(element.root).querySelector('#descriptionLabel'); + assert.isOk(label); + assert.equal(getComputedStyle(chip).display, 'none'); + assert.notEqual(getComputedStyle(label).display, 'none'); + assert.isFalse(label.readOnly); + // Edit the label to have a new value of test2, and save. + label.editing = true; + label._inputText = 'test2'; + label._save(); + flushAsynchronousOperations(); + // The API stub should be called with an `test2` for the new + // description. + assert.equal(putDescStub.callCount, 2); + assert.equal(putDescStub.lastCall.args[2], 'test2'); + }) + .then(() => { + flushAsynchronousOperations(); + // The chip should be visible again, and the label hidden. + assert.equal(element.change.revisions.rev1.description, 'test2'); + assert.equal(getComputedStyle(label).display, 'none'); + assert.notEqual(getComputedStyle(chip).display, 'none'); + }); }); test('expandAllDiffs called when expand button clicked', () => { diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js index f1277ab721..90ab96c45b 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js @@ -297,15 +297,15 @@ promises.push(this._getFiles().then(filesByPath => { this._filesByPath = filesByPath; })); - promises.push(this._getLoggedIn().then(loggedIn => { - return this._loggedIn = loggedIn; - }).then(loggedIn => { - if (!loggedIn) { return; } + promises.push(this._getLoggedIn() + .then(loggedIn => this._loggedIn = loggedIn) + .then(loggedIn => { + if (!loggedIn) { return; } - return this._getReviewedFiles().then(reviewed => { - this._reviewed = reviewed; - }); - })); + return this._getReviewedFiles().then(reviewed => { + this._reviewed = reviewed; + }); + })); promises.push(this._getDiffPreferences().then(prefs => { this.diffPrefs = prefs; @@ -1063,30 +1063,28 @@ return (new Promise(resolve => { this.fire('reload-drafts', {resolve}); - })).then(() => { - return this.asyncForeach(paths, (path, cancel) => { - this._cancelForEachDiff = cancel; + })).then(() => this.asyncForeach(paths, (path, cancel) => { + this._cancelForEachDiff = cancel; - iter++; - console.log('Expanding diff', iter, 'of', initialCount, ':', - path); - const diffElem = this._findDiffByPath(path, diffElements); - diffElem.comments = this.changeComments.getCommentsBySideForPath( - path, this.patchRange, this.projectConfig); - const promises = [diffElem.reload()]; - if (this._loggedIn && !this.diffPrefs.manual_review) { - promises.push(this._reviewFile(path, true)); - } - return Promise.all(promises); - }).then(() => { - this._cancelForEachDiff = null; - this._nextRenderParams = null; - console.log('Finished expanding', initialCount, 'diff(s)'); - this.$.reporting.timeEndWithAverage(EXPAND_ALL_TIMING_LABEL, - EXPAND_ALL_AVG_TIMING_LABEL, initialCount); - this.$.diffCursor.handleDiffUpdate(); - }); - }); + iter++; + console.log('Expanding diff', iter, 'of', initialCount, ':', + path); + const diffElem = this._findDiffByPath(path, diffElements); + diffElem.comments = this.changeComments.getCommentsBySideForPath( + path, this.patchRange, this.projectConfig); + const promises = [diffElem.reload()]; + if (this._loggedIn && !this.diffPrefs.manual_review) { + promises.push(this._reviewFile(path, true)); + } + return Promise.all(promises); + }).then(() => { + this._cancelForEachDiff = null; + this._nextRenderParams = null; + console.log('Finished expanding', initialCount, 'diff(s)'); + this.$.reporting.timeEndWithAverage(EXPAND_ALL_TIMING_LABEL, + EXPAND_ALL_AVG_TIMING_LABEL, initialCount); + this.$.diffCursor.handleDiffUpdate(); + })); } /** Cancel the rendering work of every diff in the list */ @@ -1141,9 +1139,9 @@ // comments due to use in the _handleCommentUpdate function. // The comment thread already has a side associated with it, so // set the comment's side to match. - threadEl.comments = newComments.map(c => { - return Object.assign(c, {__commentSide: threadEl.commentSide}); - }); + threadEl.comments = newComments.map(c => Object.assign( + c, {__commentSide: threadEl.commentSide} + )); Polymer.dom.flush(); return; } diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html index 0d258465ad..04da0c71e3 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html @@ -115,7 +115,7 @@ limitations under the License. patchNum: '2', }; saveStub = sandbox.stub(element, '_saveReviewedState', - () => { return Promise.resolve(); }); + () => Promise.resolve()); }); teardown(() => { @@ -686,7 +686,7 @@ limitations under the License. }); test('r key toggles reviewed flag', () => { - const reducer = (accum, file) => file.isReviewed ? ++accum : accum; + const reducer = (accum, file) => (file.isReviewed ? ++accum : accum); const getNumReviewed = () => element._files.reduce(reducer, 0); flushAsynchronousOperations(); @@ -865,7 +865,8 @@ limitations under the License. // Click inside the diff. This should result in no additional calls to // _togglePathExpanded or _reviewFile. - Polymer.dom(element.root).querySelector('gr-diff-host').click(); + Polymer.dom(element.root).querySelector('gr-diff-host') + .click(); assert.isTrue(clickSpy.calledTwice); assert.isTrue(toggleExpandSpy.calledOnce); assert.isFalse(reviewStub.called); @@ -1476,9 +1477,7 @@ limitations under the License. basePatchNum: 'PARENT', patchNum: '2', }; - sandbox.stub(window, 'fetch', () => { - return Promise.resolve(); - }); + sandbox.stub(window, 'fetch', () => Promise.resolve()); flushAsynchronousOperations(); }); diff --git a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.js b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.js index d2488e43a5..ce2a3ef729 100644 --- a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.js +++ b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.js @@ -97,12 +97,13 @@ const labelsObj = labelRecord.base; if (!labelsObj) { return []; } - return Object.keys(labelsObj).sort().map(key => { - return { - name: key, - value: this._getVoteForAccount(labelsObj, key, this.account), - }; - }); + return Object.keys(labelsObj).sort() + .map(key => { + return { + name: key, + value: this._getVoteForAccount(labelsObj, key, this.account), + }; + }); } _computeColumns(permittedLabels) { @@ -114,9 +115,7 @@ } } - const orderedValues = Object.keys(values).sort((a, b) => { - return a - b; - }); + const orderedValues = Object.keys(values).sort((a, b) => a - b); for (let i = 0; i < orderedValues.length; i++) { values[orderedValues[i]] = i; diff --git a/polygerrit-ui/app/elements/change/gr-message/gr-message.js b/polygerrit-ui/app/elements/change/gr-message/gr-message.js index 39438b5775..28348ba519 100644 --- a/polygerrit-ui/app/elements/change/gr-message/gr-message.js +++ b/polygerrit-ui/app/elements/change/gr-message/gr-message.js @@ -207,7 +207,7 @@ return scoresRaw.split(' ') .map(s => s.match(LABEL_TITLE_SCORE_PATTERN)) .filter(ms => ms && ms.length === 3) - .map(ms => ({label: ms[1], value: ms[2]})); + .map(ms => { return {label: ms[1], value: ms[2]}; }); } _computeScoreClass(score, labelExtremes) { diff --git a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js index 9afb334d05..49ff60acc5 100644 --- a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js +++ b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js @@ -324,9 +324,7 @@ } _getHumanMessages(messages) { - return messages.filter(msg => { - return !this._isAutomated(msg); - }); + return messages.filter(msg => !this._isAutomated(msg)); } _computeShowHideTextHidden(visibleMessages, messages, diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js index 4035115015..c925142f21 100644 --- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js +++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js @@ -354,7 +354,7 @@ changeRevision = rev; } } - const commits = relatedChanges.map(c => { return c.commit; }); + const commits = relatedChanges.map(c => c.commit); let pos = commits.length - 1; while (pos >= 0) { diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js index 3ce4f1a702..18288089d5 100644 --- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js +++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js @@ -474,28 +474,31 @@ this.disabled = true; const errFn = this._handle400Error.bind(this); - return this._saveReview(obj, errFn).then(response => { - if (!response) { - // Null or undefined response indicates that an error handler - // took responsibility, so just return. - return {}; - } - if (!response.ok) { - this.fire('server-error', {response}); - return {}; - } + return this._saveReview(obj, errFn) + .then(response => { + if (!response) { + // Null or undefined response indicates that an error handler + // took responsibility, so just return. + return {}; + } + if (!response.ok) { + this.fire('server-error', {response}); + return {}; + } - this.draft = ''; - this._includeComments = true; - this.fire('send', null, {bubbles: false}); - return accountAdditions; - }).then(result => { - this.disabled = false; - return result; - }).catch(err => { - this.disabled = false; - throw err; - }); + this.draft = ''; + this._includeComments = true; + this.fire('send', null, {bubbles: false}); + return accountAdditions; + }) + .then(result => { + this.disabled = false; + return result; + }) + .catch(err => { + this.disabled = false; + throw err; + }); } _focusOn(section) { diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.html b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.html index e44f669f1c..4c6c5bd18f 100644 --- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.html +++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.html @@ -136,23 +136,24 @@ limitations under the License. }); function stubSaveReview(jsonResponseProducer) { - return sandbox.stub(element, '_saveReview', review => { - return new Promise((resolve, reject) => { - try { - const result = jsonResponseProducer(review) || {}; - const resultStr = - element.$.restAPI.JSON_PREFIX + JSON.stringify(result); - resolve({ - ok: true, - text() { - return Promise.resolve(resultStr); - }, - }); - } catch (err) { - reject(err); - } - }); - }); + return sandbox.stub( + element, + '_saveReview', + review => new Promise((resolve, reject) => { + try { + const result = jsonResponseProducer(review) || {}; + const resultStr = + element.$.restAPI.JSON_PREFIX + JSON.stringify(result); + resolve({ + ok: true, + text() { + return Promise.resolve(resultStr); + }, + }); + } catch (err) { + reject(err); + } + })); } test('default to publishing drafts with reply', done => { @@ -271,7 +272,8 @@ limitations under the License. test('getlabelValue when no score is selected', done => { flush(() => { element.$$('gr-label-scores') - .$$(`gr-label-score-row[name="Code-Review"]`).setSelectedValue(-1); + .$$(`gr-label-score-row[name="Code-Review"]`) + .setSelectedValue(-1); assert.strictEqual(element.getLabelValue('Verified'), ' 0'); done(); }); @@ -372,73 +374,87 @@ limitations under the License. element._pendingConfirmationDetails); } - observer.then(() => { - assert.isTrue(isVisible(element.$.reviewerConfirmationOverlay)); - observer = overlayObserver('closed'); - const expected = 'Group name has 10 members'; - assert.notEqual( - element.$.reviewerConfirmationOverlay.innerText.indexOf(expected), - -1); - MockInteractions.tap(noButton); // close the overlay - return observer; - }).then(() => { - assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay)); + observer + .then(() => { + assert.isTrue(isVisible(element.$.reviewerConfirmationOverlay)); + observer = overlayObserver('closed'); + const expected = 'Group name has 10 members'; + assert.notEqual( + element.$.reviewerConfirmationOverlay.innerText + .indexOf(expected), + -1); + MockInteractions.tap(noButton); // close the overlay + return observer; + }).then(() => { + assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay)); - // We should be focused on account entry input. - assert.isTrue( - isFocusInsideElement(element.$.reviewers.$.entry.$.input.$.input)); + // We should be focused on account entry input. + assert.isTrue( + isFocusInsideElement( + element.$.reviewers.$.entry.$.input.$.input + ) + ); - // No reviewer/CC should have been added. - assert.equal(element.$.ccs.additions().length, 0); - assert.equal(element.$.reviewers.additions().length, 0); + // No reviewer/CC should have been added. + assert.equal(element.$.ccs.additions().length, 0); + assert.equal(element.$.reviewers.additions().length, 0); - // Reopen confirmation dialog. - observer = overlayObserver('opened'); - if (cc) { - element._ccPendingConfirmation = { - group, - count: 10, - }; - } else { - element._reviewerPendingConfirmation = { - group, - count: 10, - }; - } - return observer; - }).then(() => { - assert.isTrue(isVisible(element.$.reviewerConfirmationOverlay)); - observer = overlayObserver('closed'); - MockInteractions.tap(yesButton); // Confirm the group. - return observer; - }).then(() => { - assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay)); - const additions = cc ? - element.$.ccs.additions() : - element.$.reviewers.additions(); - assert.deepEqual( - additions, - [ - { - group: { - id: 'id', - name: 'name', - confirmed: true, - _group: true, - _pendingAdd: true, - }, - }, - ]); + // Reopen confirmation dialog. + observer = overlayObserver('opened'); + if (cc) { + element._ccPendingConfirmation = { + group, + count: 10, + }; + } else { + element._reviewerPendingConfirmation = { + group, + count: 10, + }; + } + return observer; + }) + .then(() => { + assert.isTrue(isVisible(element.$.reviewerConfirmationOverlay)); + observer = overlayObserver('closed'); + MockInteractions.tap(yesButton); // Confirm the group. + return observer; + }) + .then(() => { + assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay)); + const additions = cc ? + element.$.ccs.additions() : + element.$.reviewers.additions(); + assert.deepEqual( + additions, + [ + { + group: { + id: 'id', + name: 'name', + confirmed: true, + _group: true, + _pendingAdd: true, + }, + }, + ]); - // We should be focused on account entry input. - if (cc) { - assert.isTrue( - isFocusInsideElement(element.$.ccs.$.entry.$.input.$.input)); - } else { - assert.isTrue( - isFocusInsideElement(element.$.reviewers.$.entry.$.input.$.input)); - } - }).then(done); + // We should be focused on account entry input. + if (cc) { + assert.isTrue( + isFocusInsideElement( + element.$.ccs.$.entry.$.input.$.input + ) + ); + } else { + assert.isTrue( + isFocusInsideElement( + element.$.reviewers.$.entry.$.input.$.input + ) + ); + } + }) + .then(done); } test('cc confirmation', done => { @@ -673,7 +689,8 @@ limitations under the License. // fail. element.$$('gr-label-scores').$$( - 'gr-label-score-row[name="Verified"]').setSelectedValue(-1); + 'gr-label-score-row[name="Verified"]') + .setSelectedValue(-1); MockInteractions.tap(element.$$('.send')); }); }); @@ -967,9 +984,10 @@ limitations under the License. let startReviewStub; setup(() => { - startReviewStub = sandbox.stub(element.$.restAPI, 'startReview', () => { - return Promise.resolve(); - }); + startReviewStub = sandbox.stub( + element.$.restAPI, + 'startReview', + () => Promise.resolve()); }); test('ready property in review input on start review', () => { diff --git a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.js b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.js index 252a490bb8..7bef5dd7d5 100644 --- a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.js +++ b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.js @@ -102,10 +102,12 @@ */ _permittedLabelsToNumericScores(labels) { if (!labels) return []; - return Object.keys(labels).map(label => ({ - label, - scores: labels[label].map(v => parseInt(v, 10)), - })); + return Object.keys(labels).map(label => { + return { + label, + scores: labels[label].map(v => parseInt(v, 10)), + }; + }); } /** @@ -116,10 +118,12 @@ */ _getMaxPermittedScores(change) { return this._permittedLabelsToNumericScores(change.permitted_labels) - .map(({label, scores}) => ({ - [label]: scores - .map(v => parseInt(v, 10)) - .reduce((a, b) => Math.max(a, b))})) + .map(({label, scores}) => { + return { + [label]: scores + .map(v => parseInt(v, 10)) + .reduce((a, b) => Math.max(a, b))}; + }) .reduce((acc, i) => Object.assign(acc, i), {}); } @@ -189,9 +193,8 @@ result = result.concat(reviewers[key]); } } - this._reviewers = result.filter(reviewer => { - return reviewer._account_id != owner._account_id; - }); + this._reviewers = result + .filter(reviewer => reviewer._account_id != owner._account_id); // If there is one or two more than the max reviewers, don't show the // 'show more' button, because it takes up just as much space. @@ -249,10 +252,11 @@ } } } - }).catch(err => { - this.disabled = false; - throw err; - }); + }) + .catch(err => { + this.disabled = false; + throw err; + }); } _handleAddTap(e) { diff --git a/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.js b/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.js index 9a699ea0a6..0441129905 100644 --- a/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.js +++ b/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.js @@ -67,16 +67,18 @@ attached() { super.attached(); - this.$.restAPI.getLoggedIn().then(loggedIn => { - if (loggedIn) { - return this.$.restAPI.getPreferences(); - } - }).then(prefs => { - if (prefs) { - this._preferredDownloadCommand = prefs.download_command; - this._preferredDownloadScheme = prefs.download_scheme; - } - }); + this.$.restAPI.getLoggedIn() + .then(loggedIn => { + if (loggedIn) { + return this.$.restAPI.getPreferences(); + } + }) + .then(prefs => { + if (prefs) { + this._preferredDownloadCommand = prefs.download_command; + this._preferredDownloadScheme = prefs.download_scheme; + } + }); } _handleCloseTap(e) { diff --git a/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.js b/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.js index 6aac157c59..1cbbf3e4dd 100644 --- a/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.js +++ b/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.js @@ -102,9 +102,9 @@ } _interpolateUrl(url, replacements) { - return url.replace(INTERPOLATE_URL_PATTERN, (match, p1) => { - return replacements[p1] || ''; - }); + return url.replace( + INTERPOLATE_URL_PATTERN, + (match, p1) => replacements[p1] || ''); } _accountName(account) { diff --git a/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager_test.html b/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager_test.html index af978199f8..a0a5731b87 100644 --- a/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager_test.html +++ b/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager_test.html @@ -107,7 +107,7 @@ limitations under the License. test('show normal Error', done => { const showErrorStub = sandbox.stub(element, '_showErrorDialog'); - const textSpy = sandbox.spy(() => { return Promise.resolve('ZOMG'); }); + const textSpy = sandbox.spy(() => Promise.resolve('ZOMG')); element.fire('server-error', {response: {status: 500, text: textSpy}}); assert.isTrue(textSpy.called); @@ -129,8 +129,9 @@ limitations under the License. 'Error 409'); assert.equal(element._constructServerErrorMsg({status, url}), 'Error 409: \nEndpoint: /my/test/url'); - assert.equal(element._constructServerErrorMsg({status, statusText, url}), - 'Error 409 (Conflict): \nEndpoint: /my/test/url'); + assert.equal(element. + _constructServerErrorMsg({status, statusText, url}), + 'Error 409 (Conflict): \nEndpoint: /my/test/url'); assert.equal(element._constructServerErrorMsg({ status, statusText, @@ -142,9 +143,9 @@ limitations under the License. test('suppress TOO_MANY_FILES error', done => { const showAlertStub = sandbox.stub(element, '_showAlert'); - const textSpy = sandbox.spy(() => { - return Promise.resolve('too many files to find conflicts'); - }); + const textSpy = sandbox.spy( + () => Promise.resolve('too many files to find conflicts') + ); element.fire('server-error', {response: {status: 500, text: textSpy}}); assert.isTrue(textSpy.called); @@ -172,7 +173,7 @@ limitations under the License. // starts with authed state element.$.restAPI.getLoggedIn(); const refreshStub = sandbox.stub(element.$.restAPI, 'getAccount', - () => { return Promise.resolve({}); }); + () => Promise.resolve({})); const toastSpy = sandbox.spy(element, '_createToastAlert'); const windowOpen = sandbox.stub(window, 'open'); const responseText = Promise.resolve('Authentication required\n'); @@ -297,7 +298,10 @@ limitations under the License. test('show-error', () => { const openStub = sandbox.stub(element.$.errorOverlay, 'open'); const closeStub = sandbox.stub(element.$.errorOverlay, 'close'); - const reportStub = sandbox.stub(element.$.reporting, 'reportErrorDialog'); + const reportStub = sandbox.stub( + element.$.reporting, + 'reportErrorDialog' + ); const message = 'test message'; element.fire('show-error', {message}); @@ -317,7 +321,9 @@ limitations under the License. const accountPromise = Promise.resolve({_account_id: 1234}); sandbox.stub(element.$.restAPI, 'getAccount') .returns(accountPromise); - const requestCheckStub = sandbox.stub(element, '_requestCheckLoggedIn'); + const requestCheckStub = sandbox.stub( + element, + '_requestCheckLoggedIn'); const handleRefreshStub = sandbox.stub(element, '_handleCredentialRefreshed'); const reloadStub = sandbox.stub(element, '_reloadPage'); @@ -344,7 +350,9 @@ limitations under the License. }); test('refresh loop continues on credential fail', done => { - const requestCheckStub = sandbox.stub(element, '_requestCheckLoggedIn'); + const requestCheckStub = sandbox.stub( + element, + '_requestCheckLoggedIn'); const handleRefreshStub = sandbox.stub(element, '_handleCredentialRefreshed'); const reloadStub = sandbox.stub(element, '_reloadPage'); diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js index d009225843..07cac73e87 100644 --- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js +++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js @@ -231,10 +231,10 @@ const topMenuLinks = []; links.forEach(link => { topMenuLinks[link.title] = link.links; }); for (const m of topMenus) { - const items = m.items.map(this._fixCustomMenuItem).filter(link => { + const items = m.items.map(this._fixCustomMenuItem).filter(link => // Ignore GWT project links - return !link.url.includes('${projectName}'); - }); + !link.url.includes('${projectName}') + ); if (m.name in topMenuLinks) { items.forEach(link => { topMenuLinks[m.name].push(link); }); } else { diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.js b/polygerrit-ui/app/elements/core/gr-router/gr-router.js index e84beb6ead..1dfa973ccd 100644 --- a/polygerrit-ui/app/elements/core/gr-router/gr-router.js +++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.js @@ -634,7 +634,8 @@ * @return {!string} Everything after the first '#' ("a#b#c" -> "b#c"). */ _getHashFromCanonicalPath(canonicalPath) { - return canonicalPath.split('#').slice(1).join('#'); + return canonicalPath.split('#').slice(1) + .join('#'); } _parseLineAddress(hash) { diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html index fb7f0d62e5..656f13aaf2 100644 --- a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html +++ b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html @@ -74,7 +74,7 @@ limitations under the License. test('_getChangeWeblinks', () => { const link = {name: 'test', url: 'test/url'}; const browserLink = {name: 'browser', url: 'browser/url'}; - const mapLinksToConfig = weblinks => ({options: {weblinks}}); + const mapLinksToConfig = weblinks => { return {options: {weblinks}}; }; sandbox.stub(element, '_getBrowseCommitWeblink').returns(browserLink); assert.deepEqual( diff --git a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.js b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.js index ee44e0614f..956beea344 100644 --- a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.js +++ b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.js @@ -200,9 +200,7 @@ const trimmedInput = this._inputVal && this._inputVal.trim(); if (trimmedInput) { const predefinedOpOnlyQuery = SEARCH_OPERATORS_WITH_NEGATIONS.some( - op => { - return op.endsWith(':') && op === trimmedInput; - } + op => op.endsWith(':') && op === trimmedInput ); if (predefinedOpOnlyQuery) { return; @@ -252,7 +250,7 @@ default: return Promise.resolve(SEARCH_OPERATORS_WITH_NEGATIONS .filter(operator => operator.includes(input)) - .map(operator => ({text: operator}))); + .map(operator => { return {text: operator}; })); } } diff --git a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.html b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.html index c822b73cf0..9d60952733 100644 --- a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.html +++ b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.html @@ -59,11 +59,9 @@ limitations under the License. assert.equal(element._inputVal, 'foo'); }); - getActiveElement = () => { - return document.activeElement.shadowRoot ? - document.activeElement.shadowRoot.activeElement : - document.activeElement; - }; + getActiveElement = () => (document.activeElement.shadowRoot ? + document.activeElement.shadowRoot.activeElement : + document.activeElement); test('enter in search input fires event', done => { element.addEventListener('handle-search', () => { diff --git a/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.js b/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.js index 935352f90a..662e1b16c1 100644 --- a/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.js +++ b/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.js @@ -91,7 +91,7 @@ .then(projects => { if (!projects) { return []; } const keys = Object.keys(projects); - return keys.map(key => ({text: predicate + ':' + key})); + return keys.map(key => { return {text: predicate + ':' + key}; }); }); } @@ -113,7 +113,7 @@ .then(groups => { if (!groups) { return []; } const keys = Object.keys(groups); - return keys.map(key => ({text: predicate + ':' + key})); + return keys.map(key => { return {text: predicate + ':' + key}; }); }); } @@ -135,7 +135,8 @@ .then(accounts => { if (!accounts) { return []; } return this._mapAccountsHelper(accounts, predicate); - }).then(accounts => { + }) + .then(accounts => { // When the expression supplied is a beginning substring of 'self', // add it as an autocomplete option. if (SELF_EXPRESSION.startsWith(expression)) { @@ -150,12 +151,14 @@ } _mapAccountsHelper(accounts, predicate) { - return accounts.map(account => ({ - label: account.name || '', - text: account.email ? - `${predicate}:${account.email}` : - `${predicate}:"${this._accountOrAnon(account)}"`, - })); + return accounts.map(account => { + return { + label: account.name || '', + text: account.email ? + `${predicate}:${account.email}` : + `${predicate}:"${this._accountOrAnon(account)}"`, + }; + }); } } diff --git a/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search_test.html b/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search_test.html index 5a4e341e88..917c5504e7 100644 --- a/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search_test.html +++ b/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search_test.html @@ -71,12 +71,15 @@ limitations under the License. }, ]) ); - element._fetchAccounts('owner', 's').then(s => { - assert.deepEqual(s[0], {text: 'owner:fred@goog.co', label: 'fred'}); - assert.deepEqual(s[1], {text: 'owner:self'}); - }).then(() => element._fetchAccounts('owner', 'selfs')).then(s => { - assert.notEqual(s[0], {text: 'owner:self'}); - }); + element._fetchAccounts('owner', 's') + .then(s => { + assert.deepEqual(s[0], {text: 'owner:fred@goog.co', label: 'fred'}); + assert.deepEqual(s[1], {text: 'owner:self'}); + }) + .then(() => element._fetchAccounts('owner', 'selfs')) + .then(s => { + assert.notEqual(s[0], {text: 'owner:self'}); + }); }); test('Inserts me as option when valid', () => { @@ -88,12 +91,15 @@ limitations under the License. }, ]) ); - return element._fetchAccounts('owner', 'm').then(s => { - assert.deepEqual(s[0], {text: 'owner:fred@goog.co', label: 'fred'}); - assert.deepEqual(s[1], {text: 'owner:me'}); - }).then(() => element._fetchAccounts('owner', 'meme')).then(s => { - assert.notEqual(s[0], {text: 'owner:me'}); - }); + return element._fetchAccounts('owner', 'm') + .then(s => { + assert.deepEqual(s[0], {text: 'owner:fred@goog.co', label: 'fred'}); + assert.deepEqual(s[1], {text: 'owner:me'}); + }) + .then(() => element._fetchAccounts('owner', 'meme')) + .then(s => { + assert.notEqual(s[0], {text: 'owner:me'}); + }); }); test('Autocompletes groups', () => { diff --git a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.js b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.js index 51306209f6..7561f1bc2b 100644 --- a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.js +++ b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.js @@ -85,11 +85,13 @@ .getRobotCommentFixPreview(this.changeNum, this._patchNum, fixId) .then(res => { if (res != null) { - const previews = Object.keys(res).map(key => - ({filepath: key, preview: res[key]})); + const previews = Object.keys(res).map(key => { + return {filepath: key, preview: res[key]}; + }); this._currentPreviews = previews; } - }).catch(err => { + }) + .catch(err => { this._close(); this.dispatchEvent(new CustomEvent('show-error', { bubbles: true, @@ -175,13 +177,14 @@ this._currentFix.fix_id).then(res => { Gerrit.Nav.navigateToChange(this.change, 'edit', this._patchNum); this._close(); - }).catch(err => { - this.dispatchEvent(new CustomEvent('show-error', { - bubbles: true, - composed: true, - detail: {message: `Error applying fix suggestion: ${err}`}, - })); - }); + }) + .catch(err => { + this.dispatchEvent(new CustomEvent('show-error', { + bubbles: true, + composed: true, + detail: {message: `Error applying fix suggestion: ${err}`}, + })); + }); }, getFixDescription(currentFix) { diff --git a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api-mock.js b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api-mock.js index 4009420d3d..4abdb615ff 100644 --- a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api-mock.js +++ b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api-mock.js @@ -39,9 +39,7 @@ * file simpler by just using _reloadComments here instead. */ _reloadDraftsWithCallback(e) { - return this._reloadComments().then(() => { - return e.detail.resolve(); - }); + return this._reloadComments().then(() => e.detail.resolve()); } _reloadComments() { diff --git a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.js b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.js index ddf551e358..f2b3d903ba 100644 --- a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.js +++ b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.js @@ -362,9 +362,10 @@ }; ChangeComments.prototype._sortComments = function(comments) { - return comments.slice(0).sort((c1, c2) => { - return util.parseDate(c1.updated) - util.parseDate(c2.updated); - }); + return comments.slice(0) + .sort( + (c1, c2) => util.parseDate(c1.updated) - util.parseDate(c2.updated) + ); }; /** diff --git a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api_test.html b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api_test.html index 4261c2de26..6f96a387a6 100644 --- a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api_test.html +++ b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api_test.html @@ -131,19 +131,21 @@ limitations under the License. test('with loadAll first', done => { assert.isNotOk(element._changeComments); - element.loadAll().then(() => { - assert.isOk(element._changeComments); - assert.equal(commentStub.callCount, 1); - assert.equal(robotCommentStub.callCount, 1); - assert.equal(draftStub.callCount, 1); - return element.reloadDrafts(); - }).then(() => { - assert.isOk(element._changeComments); - assert.equal(commentStub.callCount, 1); - assert.equal(robotCommentStub.callCount, 1); - assert.equal(draftStub.callCount, 2); - done(); - }); + element.loadAll() + .then(() => { + assert.isOk(element._changeComments); + assert.equal(commentStub.callCount, 1); + assert.equal(robotCommentStub.callCount, 1); + assert.equal(draftStub.callCount, 1); + return element.reloadDrafts(); + }) + .then(() => { + assert.isOk(element._changeComments); + assert.equal(commentStub.callCount, 1); + assert.equal(robotCommentStub.callCount, 1); + assert.equal(draftStub.callCount, 2); + done(); + }); }); }); diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.js b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.js index 62b35e4a14..33cd4cbf0e 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.js +++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.js @@ -230,7 +230,7 @@ GrDiffBuilder.prototype.getSectionsByLineRange = function( startLine, endLine, opt_side) { return this.getGroupsByLineRange(startLine, endLine, opt_side).map( - group => { return group.element; }); + group => group.element); }; GrDiffBuilder.prototype._createContextControl = function(section, line) { diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder_test.html b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder_test.html index a67835d3e9..867a0674ff 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder_test.html +++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder_test.html @@ -322,7 +322,8 @@ limitations under the License. const lineNumberEl = document.createElement('td'); function slice(str, start, end) { - return Array.from(str).slice(start, end).join(''); + return Array.from(str).slice(start, end) + .join(''); } setup(() => { @@ -811,9 +812,8 @@ limitations under the License. sandbox.stub(builder, 'addColumns'); builder.buildSectionElement = function(group) { const section = document.createElement('stub'); - section.textContent = group.lines.reduce((acc, line) => { - return acc + line.text; - }, ''); + section.textContent = group.lines + .reduce((acc, line) => acc + line.text, ''); return section; }; return builder; @@ -858,7 +858,7 @@ limitations under the License. const dispatchEventStub = sandbox.stub(element, 'dispatchEvent'); element.render(keyLocations, {}).then(() => { const firedEventTypes = dispatchEventStub.getCalls() - .map(c => { return c.args[0].type; }); + .map(c => c.args[0].type); assert.include(firedEventTypes, 'render-start'); assert.include(firedEventTypes, 'render-content'); done(); diff --git a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.js b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.js index 25f8770272..591ebfec30 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.js +++ b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.js @@ -165,9 +165,7 @@ moveToNextChunk(opt_clipToTop) { this.$.cursorManager.next(this._isFirstRowOfChunk.bind(this), - target => { - return target.parentNode.scrollHeight; - }, opt_clipToTop); + target => target.parentNode.scrollHeight, opt_clipToTop); this._fixSide(); } @@ -273,9 +271,8 @@ } createCommentInPlace() { - const diffWithRangeSelected = this.diffs.find(diff => { - return diff.isRangeSelected(); - }); + const diffWithRangeSelected = this.diffs + .find(diff => diff.isRangeSelected()); if (diffWithRangeSelected) { diffWithRangeSelected.createRangeComment(); } else { @@ -404,9 +401,7 @@ _getStops() { return this.diffs.reduce( - (stops, diff) => { - return stops.concat(diff.getCursorStops()); - }, []); + (stops, diff) => stops.concat(diff.getCursorStops()), []); } _updateStops() { diff --git a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight_test.html b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight_test.html index 3de521d310..c1a696cd8a 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight_test.html +++ b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight_test.html @@ -377,7 +377,8 @@ limitations under the License. const getRangeAtStub = sandbox.stub(); getRangeAtStub .onFirstCall().returns(startRange) - .onSecondCall().returns(endRange); + .onSecondCall() + .returns(endRange); const selection = { rangeCount: 2, getRangeAt: getRangeAtStub, diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js index 7d78212e3e..300e72a8a3 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js +++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js @@ -412,7 +412,8 @@ range.side); }); }); - }).catch(err => { + }) + .catch(err => { console.warn('Loading coverage ranges failed: ', err); }); } diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.html b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.html index 1c707479e1..6d05876ab9 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.html +++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.html @@ -123,9 +123,8 @@ limitations under the License. element.comments.left.push(comment); comment.id = id; element.fire('comment-discard', {comment}); - const drafts = element.comments.left.filter(item => { - return item.__draftID === draftID; - }); + const drafts = element.comments.left + .filter(item => item.__draftID === draftID); assert.equal(drafts.length, 0); assert.isTrue(diffCommentsModifiedStub.called); }); @@ -145,9 +144,8 @@ limitations under the License. element.comments.left.push(comment); comment.id = id; element.fire('comment-save', {comment}); - const drafts = element.comments.left.filter(item => { - return item.__draftID === draftID; - }); + const drafts = element.comments.left + .filter(item => item.__draftID === draftID); assert.equal(drafts.length, 1); assert.equal(drafts[0].id, id); assert.isTrue(diffCommentsModifiedStub.called); @@ -361,12 +359,14 @@ limitations under the License. Promise.resolve({content: []})); element.patchRange = {}; let reloadComplete = false; - element.$.restAPI.getDiffPreferences().then(prefs => { - element.prefs = prefs; - return element.reload(); - }).then(() => { - reloadComplete = true; - }); + element.$.restAPI.getDiffPreferences() + .then(prefs => { + element.prefs = prefs; + return element.reload(); + }) + .then(() => { + reloadComplete = true; + }); // Multiple cascading microtasks are scheduled. setTimeout(() => { assert.isFalse(reloadComplete); @@ -506,10 +506,10 @@ limitations under the License. }; sandbox.stub(element.$.restAPI, 'getB64FileContents', - (changeId, patchNum, path, opt_parentIndex) => { - return Promise.resolve(opt_parentIndex === 1 ? mockFile1 : - mockFile2); - }); + (changeId, patchNum, path, opt_parentIndex) => Promise.resolve( + opt_parentIndex === 1 ? mockFile1 : + mockFile2) + ); element.patchRange = {basePatchNum: 'PARENT', patchNum: 1}; element.comments = { @@ -1380,7 +1380,8 @@ limitations under the License. }); test('starts syntax layer processing on render event', done => { - sandbox.stub(element.$.syntaxLayer, 'process').returns(Promise.resolve()); + sandbox.stub(element.$.syntaxLayer, 'process') + .returns(Promise.resolve()); sandbox.stub(element.$.restAPI, 'getDiff').returns( Promise.resolve({content: []})); element.reload(); diff --git a/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor_test.html b/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor_test.html index 308428f952..8eaaa4ccc8 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor_test.html +++ b/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor_test.html @@ -500,7 +500,7 @@ limitations under the License. test('breaks down shared chunks w/ whole-file', () => { const size = 120 * 2 + 5; const content = [{ - ab: _.times(size, () => { return `${Math.random()}`; }), + ab: _.times(size, () => `${Math.random()}`), }]; element.context = -1; const result = element._splitLargeChunks(content); @@ -511,7 +511,7 @@ limitations under the License. test('does not break-down common chunks w/ context', () => { const content = [{ - ab: _.times(75, () => { return `${Math.random()}`; }), + ab: _.times(75, () => `${Math.random()}`), }]; element.context = 4; const result = @@ -897,7 +897,7 @@ limitations under the License. assert.isAtMost(subResult.length, size); } const flattened = result - .reduce((a, b) => { return a.concat(b); }, []); + .reduce((a, b) => a.concat(b), []); assert.deepEqual(flattened, array); }); diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js index 23c674168e..31223709bd 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js +++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js @@ -169,7 +169,7 @@ }, _panelFloatingDisabled: { type: Boolean, - value: () => { return window.PANEL_FLOATING_DISABLED; }, + value: () => window.PANEL_FLOATING_DISABLED, }, _editMode: { type: Boolean, @@ -678,23 +678,25 @@ promises.push(this._getChangeEdit(this._changeNum)); this._loading = true; - return Promise.all(promises).then(r => { - const edit = r[4]; - if (edit) { - this.set('_change.revisions.' + edit.commit.commit, { - _number: this.EDIT_NAME, - basePatchNum: edit.base_patch_set_number, - commit: edit.commit, + return Promise.all(promises) + .then(r => { + const edit = r[4]; + if (edit) { + this.set('_change.revisions.' + edit.commit.commit, { + _number: this.EDIT_NAME, + basePatchNum: edit.base_patch_set_number, + commit: edit.commit, + }); + } + this._loading = false; + this.$.diffHost.comments = this._commentsForDiff; + return this.$.diffHost.reload(true); + }) + .then(() => { + this.$.reporting.diffViewFullyLoaded(); + // If diff view displayed has not ended yet, it ends here. + this.$.reporting.diffViewDisplayed(); }); - } - this._loading = false; - this.$.diffHost.comments = this._commentsForDiff; - return this.$.diffHost.reload(true); - }).then(() => { - this.$.reporting.diffViewFullyLoaded(); - // If diff view displayed has not ended yet, it ends here. - this.$.reporting.diffViewDisplayed(); - }); } _changeViewStateChanged(changeViewState) { diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html index 3a5c0bcb54..29cc950aba 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html +++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html @@ -281,8 +281,11 @@ limitations under the License. MockInteractions.pressAndReleaseKeyOn(element, 219, null, '['); assert.isTrue(element._loading); - assert(diffNavStub.lastCall.calledWithExactly(element._change, 'chell.go', - '10', '5'), + assert(diffNavStub.lastCall.calledWithExactly( + element._change, + 'chell.go', + '10', + '5'), 'Should navigate to /c/42/5..10/chell.go'); element._path = 'chell.go'; @@ -342,8 +345,11 @@ limitations under the License. element._path = 'glados.txt'; MockInteractions.pressAndReleaseKeyOn(element, 219, null, '['); - assert(diffNavStub.lastCall.calledWithExactly(element._change, 'chell.go', - '1', PARENT), 'Should navigate to /c/42/1/chell.go'); + assert(diffNavStub.lastCall.calledWithExactly( + element._change, + 'chell.go', + '1', + PARENT), 'Should navigate to /c/42/1/chell.go'); element._path = 'chell.go'; MockInteractions.pressAndReleaseKeyOn(element, 219, null, '['); @@ -429,12 +435,14 @@ limitations under the License. suite('url params', () => { setup(() => { - sandbox.stub(Gerrit.Nav, 'getUrlForDiff', (c, p, pn, bpn) => { - return `${c._number}-${p}-${pn}-${bpn}`; - }); - sandbox.stub(Gerrit.Nav, 'getUrlForChange', (c, pn, bpn) => { - return `${c._number}-${pn}-${bpn}`; - }); + sandbox.stub( + Gerrit.Nav, + 'getUrlForDiff', + (c, p, pn, bpn) => `${c._number}-${p}-${pn}-${bpn}`); + sandbox.stub( + Gerrit.Nav + , 'getUrlForChange', + (c, pn, bpn) => `${c._number}-${pn}-${bpn}`); }); test('_formattedFiles', () => { diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js index de23c37321..4b075e7afe 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js +++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js @@ -374,10 +374,11 @@ .map(commentRangeFromThreadEl) .filter(({range}) => range); for (const removedCommentRange of removedCommentRanges) { - const i = this._commentRanges.findIndex(commentRange => { - return commentRange.side === removedCommentRange.side && - Gerrit.rangesEqual(commentRange.range, removedCommentRange.range); - }); + const i = this._commentRanges + .findIndex( + cr => cr.side === removedCommentRange.side && + Gerrit.rangesEqual(cr.range, removedCommentRange.range) + ); this.splice('_commentRanges', i, 1); } @@ -584,7 +585,7 @@ * @param {string=} side * @param {!Object=} range */ - _createComment(lineEl, lineNum=undefined, side=undefined, range=undefined) { + _createComment(lineEl, lineNum, side, range) { const contentText = this.$.diffBuilder.getContentByLineEl(lineEl); const contentEl = contentText.parentElement; side = side || @@ -870,13 +871,12 @@ _computeDiffHeaderItems(diffInfoRecord) { const diffInfo = diffInfoRecord.base; if (!diffInfo || !diffInfo.diff_header) { return []; } - return diffInfo.diff_header.filter(item => { - return !(item.startsWith('diff --git ') || + return diffInfo.diff_header + .filter(item => !(item.startsWith('diff --git ') || item.startsWith('index ') || item.startsWith('+++ ') || item.startsWith('--- ') || - item === 'Binary files differ'); - }); + item === 'Binary files differ')); } /** @return {boolean} */ diff --git a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_test.html b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_test.html index 81897cdad7..4cb618fcac 100644 --- a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_test.html +++ b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_test.html @@ -235,10 +235,11 @@ limitations under the License. // Should be recomputed for each available patch sandbox.stub(element, '_computeBaseDropdownContent'); assert.equal(element._computeBaseDropdownContent.callCount, 0); - commentApiWrapper.loadComments().then().then(() => { - assert.equal(element._computeBaseDropdownContent.callCount, 1); - done(); - }); + commentApiWrapper.loadComments().then() + .then(() => { + assert.equal(element._computeBaseDropdownContent.callCount, 1); + done(); + }); }); test('_computePatchDropdownContent called when basePatchNum updates', () => { @@ -286,9 +287,10 @@ limitations under the License. // Should be recomputed for each available patch sandbox.stub(element, '_computePatchDropdownContent'); assert.equal(element._computePatchDropdownContent.callCount, 0); - commentApiWrapper.loadComments().then().then(() => { - done(); - }); + commentApiWrapper.loadComments().then() + .then(() => { + done(); + }); }); test('_computePatchDropdownContent', () => { diff --git a/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js b/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js index 8fc16f51f1..d9ad795a88 100644 --- a/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js +++ b/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js @@ -208,7 +208,7 @@ return range; }) // Sort the ranges so that hovering highlights are on top. - .sort((a, b) => a.hovering && !b.hovering ? 1 : 0); + .sort((a, b) => (a.hovering && !b.hovering ? 1 : 0)); } } diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js index 2e7325c6da..9a15703852 100644 --- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js +++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js @@ -271,39 +271,37 @@ const rangesCache = new Map(); this._processPromise = util.makeCancelable(this._loadHLJS() - .then(() => { - return new Promise(resolve => { - const nextStep = () => { - this._processHandle = null; - this._processNextLine(state, rangesCache); + .then(() => new Promise(resolve => { + const nextStep = () => { + this._processHandle = null; + this._processNextLine(state, rangesCache); - // Move to the next line in the section. - state.lineIndex++; + // Move to the next line in the section. + state.lineIndex++; - // If the section has been exhausted, move to the next one. - if (this._isSectionDone(state)) { - state.lineIndex = 0; - state.sectionIndex++; - } + // If the section has been exhausted, move to the next one. + if (this._isSectionDone(state)) { + state.lineIndex = 0; + state.sectionIndex++; + } - // If all sections have been exhausted, finish. - if (state.sectionIndex >= this.diff.content.length) { - resolve(); - this._notify(state); - return; - } + // If all sections have been exhausted, finish. + if (state.sectionIndex >= this.diff.content.length) { + resolve(); + this._notify(state); + return; + } - if (state.lineIndex % 100 === 0) { - this._notify(state); - this._processHandle = this.async(nextStep, ASYNC_DELAY); - } else { - nextStep.call(this); - } - }; + if (state.lineIndex % 100 === 0) { + this._notify(state); + this._processHandle = this.async(nextStep, ASYNC_DELAY); + } else { + nextStep.call(this); + } + }; - this._processHandle = this.async(nextStep, 1); - }); - })); + this._processHandle = this.async(nextStep, 1); + }))); return this._processPromise .finally(() => { this._processPromise = null; }); } diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer_test.html b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer_test.html index 926a6bc760..88fd3b9fb9 100644 --- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer_test.html +++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer_test.html @@ -194,7 +194,7 @@ limitations under the License. const mockHLJS = getMockHLJS(); const highlightSpy = sinon.spy(mockHLJS, 'highlight'); sandbox.stub(element.$.libLoader, 'getHLJS', - () => { return Promise.resolve(mockHLJS); }); + () => Promise.resolve(mockHLJS)); const processNextSpy = sandbox.spy(element, '_processNextLine'); const processPromise = element.process(); diff --git a/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search_test.html b/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search_test.html index 688a9e6ccc..d604b1fbbd 100644 --- a/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search_test.html +++ b/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search_test.html @@ -90,9 +90,10 @@ limitations under the License. }); test('_paramsChanged', done => { - sandbox.stub(element.$.restAPI, 'getDocumentationSearches', () => { - return Promise.resolve(documentationSearches); - }); + sandbox.stub( + element.$.restAPI, + 'getDocumentationSearches', + () => Promise.resolve(documentationSearches)); const value = { filter: 'test', }; diff --git a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.html b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.html index b7e52a165b..8ef561c222 100644 --- a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.html +++ b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.html @@ -336,13 +336,12 @@ suite('gr-edit-controls tests', () => { }); }); - test('openOpenDialog', () => { - return element.openOpenDialog('test/path.cpp').then(() => { - assert.isFalse(element.$.openDialog.hasAttribute('hidden')); - assert.equal(element.$.openDialog.querySelector('gr-autocomplete').text, - 'test/path.cpp'); - }); - }); + test('openOpenDialog', () => element.openOpenDialog('test/path.cpp') + .then(() => { + assert.isFalse(element.$.openDialog.hasAttribute('hidden')); + assert.equal(element.$.openDialog.querySelector('gr-autocomplete').text, + 'test/path.cpp'); + })); test('_getDialogFromEvent', () => { const spy = sandbox.spy(element, '_getDialogFromEvent'); diff --git a/polygerrit-ui/app/elements/gr-app_test.html b/polygerrit-ui/app/elements/gr-app_test.html index c069f8bd20..1014284148 100644 --- a/polygerrit-ui/app/elements/gr-app_test.html +++ b/polygerrit-ui/app/elements/gr-app_test.html @@ -82,9 +82,7 @@ limitations under the License. sandbox.restore(); }); - appElement = () => { - return element.$['app-element']; - }; + appElement = () => element.$['app-element']; test('reporting', () => { assert.isTrue(appElement().$.reporting.appStarted.calledOnce); diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js index b98833e47c..fcf4ce88d9 100644 --- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js +++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js @@ -148,14 +148,16 @@ ready() { super.ready(); Gerrit._endpoints.onNewEndpoint(this.name, this._initModule.bind(this)); - Gerrit.awaitPluginsLoaded().then(() => Promise.all( - Gerrit._endpoints.getPlugins(this.name).map( - pluginUrl => this._import(pluginUrl))) - ).then(() => - Gerrit._endpoints - .getDetails(this.name) - .forEach(this._initModule, this) - ); + Gerrit.awaitPluginsLoaded() + .then(() => Promise.all( + Gerrit._endpoints.getPlugins(this.name).map( + pluginUrl => this._import(pluginUrl))) + ) + .then(() => + Gerrit._endpoints + .getDetails(this.name) + .forEach(this._initModule, this) + ); } } diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html index 58e20749e2..ae1c92265e 100644 --- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html +++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html @@ -96,10 +96,11 @@ limitations under the License. assert.equal(module['someparam'], 'barbar'); return decorationHook.getLastAttached().then(element => { assert.strictEqual(element, module); - }).then(() => { - element.remove(); - assert.equal(decorationHook.getAllAttached().length, 0); - }); + }) + .then(() => { + element.remove(); + assert.equal(decorationHook.getAllAttached().length, 0); + }); }); test('replacement', () => { @@ -109,12 +110,14 @@ limitations under the License. element => element.nodeName === 'OTHER-MODULE'); assert.isOk(module); assert.equal(module['someparam'], 'foofoo'); - return replacementHook.getLastAttached().then(element => { - assert.strictEqual(element, module); - }).then(() => { - element.remove(); - assert.equal(replacementHook.getAllAttached().length, 0); - }); + return replacementHook.getLastAttached() + .then(element => { + assert.strictEqual(element, module); + }) + .then(() => { + element.remove(); + assert.equal(replacementHook.getAllAttached().length, 0); + }); }); test('late registration', done => { diff --git a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.html b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.html index 1f748b807b..91f151fdf0 100644 --- a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.html +++ b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.html @@ -81,7 +81,8 @@ limitations under the License. test('skip theme if preloaded', () => { sandbox.stub(Gerrit, '_isPluginPreloaded') - .withArgs('preloaded:gerrit-theme').returns(true); + .withArgs('preloaded:gerrit-theme') + .returns(true); sandbox.stub(Gerrit, '_loadPlugins'); element.config = { default_theme: '/oof', diff --git a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup_test.html b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup_test.html index 2ff2aba8a1..8eabe2aa19 100644 --- a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup_test.html +++ b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup_test.html @@ -56,11 +56,9 @@ limitations under the License. assert.isOk(element); }); - test('open uses open() from gr-overlay', () => { - return element.open().then(() => { - assert.isTrue(element.$.overlay.open.called); - }); - }); + test('open uses open() from gr-overlay', () => element.open().then(() => { + assert.isTrue(element.$.overlay.open.called); + })); test('close uses close() from gr-overlay', () => { element.close(); diff --git a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface_test.html b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface_test.html index 0be07d4156..af3d77065d 100644 --- a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface_test.html +++ b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface_test.html @@ -69,26 +69,22 @@ limitations under the License. instance = new GrPopupInterface(plugin); }); - test('open', () => { - return instance.open().then(api => { - assert.strictEqual(api, instance); - const manual = document.createElement('div'); - manual.id = 'foobar'; - manual.innerHTML = 'manual content'; - api._getElement().appendChild(manual); - flushAsynchronousOperations(); - assert.equal( - container.querySelector('#foobar').textContent, 'manual content'); - }); - }); + test('open', () => instance.open().then(api => { + assert.strictEqual(api, instance); + const manual = document.createElement('div'); + manual.id = 'foobar'; + manual.innerHTML = 'manual content'; + api._getElement().appendChild(manual); + flushAsynchronousOperations(); + assert.equal( + container.querySelector('#foobar').textContent, 'manual content'); + })); - test('close', () => { - return instance.open().then(api => { - assert.isTrue(api._getElement().node.opened); - api.close(); - assert.isFalse(api._getElement().node.opened); - }); - }); + test('close', () => instance.open().then(api => { + assert.isTrue(api._getElement().node.opened); + api.close(); + assert.isFalse(api._getElement().node.opened); + })); }); suite('components', () => { @@ -96,20 +92,16 @@ limitations under the License. instance = new GrPopupInterface(plugin, 'gr-user-test-popup'); }); - test('open', () => { - return instance.open().then(api => { - assert.isNotNull( - Polymer.dom(container).querySelector('gr-user-test-popup')); - }); - }); + test('open', () => instance.open().then(api => { + assert.isNotNull( + Polymer.dom(container).querySelector('gr-user-test-popup')); + })); - test('close', () => { - return instance.open().then(api => { - assert.isTrue(api._getElement().node.opened); - api.close(); - assert.isFalse(api._getElement().node.opened); - }); - }); + test('close', () => instance.open().then(api => { + assert.isTrue(api._getElement().node.opened); + api.close(); + assert.isFalse(api._getElement().node.opened); + })); }); }); diff --git a/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api.js b/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api.js index f8bb0046c5..5ed4c1a144 100644 --- a/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api.js +++ b/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api.js @@ -22,7 +22,8 @@ this._title = '(no title)'; // Generate default screen URL token, specific to plugin, and unique(ish). this._token = - plugin.getPluginName() + Math.random().toString(36).substr(5); + plugin.getPluginName() + Math.random().toString(36) + .substr(5); this.plugin = plugin; } diff --git a/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.js b/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.js index ca81544794..e146a90a1e 100644 --- a/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.js +++ b/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.js @@ -59,9 +59,7 @@ })); promises.push(this.$.restAPI.getAccountGroups().then(groups => { - this._groups = groups.sort((a, b) => { - return a.name.localeCompare(b.name); - }); + this._groups = groups.sort((a, b) => a.name.localeCompare(b.name)); })); promises.push(this.$.restAPI.getAccountAgreements().then(agreements => { diff --git a/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.js b/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.js index 14d7a4ca3f..d45edff309 100644 --- a/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.js +++ b/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.js @@ -96,7 +96,8 @@ this.$.newKey.disabled = false; this._newKey = ''; this.loadData(); - }).catch(() => { + }) + .catch(() => { this.$.addButton.disabled = false; this.$.newKey.disabled = false; }); diff --git a/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor_test.html b/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor_test.html index 575285bd8d..c1c0d5089b 100644 --- a/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor_test.html +++ b/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor_test.html @@ -90,7 +90,7 @@ limitations under the License. const lastKey = keys[Object.keys(keys)[1]]; const saveStub = sinon.stub(element.$.restAPI, 'deleteAccountGPGKey', - () => { return Promise.resolve(); }); + () => Promise.resolve()); assert.equal(element._keysToRemove.length, 0); assert.isFalse(element.hasUnsavedChanges); @@ -146,7 +146,7 @@ limitations under the License. }; const addStub = sinon.stub(element.$.restAPI, 'addAccountGPGKey', - () => { return Promise.resolve(newKeyObject); }); + () => Promise.resolve(newKeyObject)); element._newKey = newKeyString; @@ -171,7 +171,7 @@ limitations under the License. const newKeyString = 'not even close to valid'; const addStub = sinon.stub(element.$.restAPI, 'addAccountGPGKey', - () => { return Promise.reject(new Error('error')); }); + () => Promise.reject(new Error('error'))); element._newKey = newKeyString; diff --git a/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.js b/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.js index 87fb852fc3..6c3a448506 100644 --- a/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.js +++ b/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.js @@ -30,9 +30,7 @@ loadData() { return this.$.restAPI.getAccountGroups().then(groups => { - this._groups = groups.sort((a, b) => { - return a.name.localeCompare(b.name); - }); + this._groups = groups.sort((a, b) => a.name.localeCompare(b.name)); }); } diff --git a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password_test.html b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password_test.html index 89da7662e1..d66b231724 100644 --- a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password_test.html +++ b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password_test.html @@ -58,11 +58,9 @@ limitations under the License. const nextPassword = 'the new password'; let generateResolve; const generateStub = sinon.stub(element.$.restAPI, - 'generateAccountHttpPassword', () => { - return new Promise(resolve => { - generateResolve = resolve; - }); - }); + 'generateAccountHttpPassword', () => new Promise(resolve => { + generateResolve = resolve; + })); assert.isNotOk(element._generatedPassword); diff --git a/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor_test.html b/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor_test.html index 380e00a86b..a82b703643 100644 --- a/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor_test.html +++ b/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor_test.html @@ -40,7 +40,7 @@ limitations under the License. let menu; function assertMenuNamesEqual(element, expected) { - const names = element.menuItems.map(i => { return i.name; }); + const names = element.menuItems.map(i => i.name); assert.equal(names.length, expected.length); for (let i = 0; i < names.length; i++) { assert.equal(names[i], expected[i]); @@ -53,7 +53,8 @@ limitations under the License. const selector = 'tr:nth-child(' + (index + 1) + ') .move' + direction + 'Button'; const button = - element.$$('tbody').querySelector(selector).$$('paper-button'); + element.$$('tbody').querySelector(selector) + .$$('paper-button'); MockInteractions.tap(button); } @@ -147,14 +148,16 @@ limitations under the License. // Tap the delete button for the middle item. MockInteractions.tap(element.$$('tbody') - .querySelector('tr:nth-child(2) .remove-button').$$('paper-button')); + .querySelector('tr:nth-child(2) .remove-button') + .$$('paper-button')); assertMenuNamesEqual(element, ['first name', 'third name']); // Delete remaining items. for (let i = 0; i < 2; i++) { MockInteractions.tap(element.$$('tbody') - .querySelector('tr:first-child .remove-button').$$('paper-button')); + .querySelector('tr:first-child .remove-button') + .$$('paper-button')); } assertMenuNamesEqual(element, []); diff --git a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog_test.html b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog_test.html index a987a2645a..7f493c3d65 100644 --- a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog_test.html +++ b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog_test.html @@ -146,11 +146,13 @@ limitations under the License. assert.equal(account.email, 'email'); // Save and verify new values are committed. - save().then(() => { - assert.equal(account.name, 'new name'); - assert.equal(account.username, 'new username'); - assert.equal(account.email, 'email3'); - }).then(done); + save() + .then(() => { + assert.equal(account.name, 'new name'); + assert.equal(account.username, 'new username'); + assert.equal(account.email, 'email3'); + }) + .then(done); }); }); diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.html b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.html index 24ee69bb55..759e65b199 100644 --- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.html +++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.html @@ -70,7 +70,7 @@ limitations under the License. function stubAddAccountEmail(statusCode) { return sandbox.stub(element.$.restAPI, 'addAccountEmail', - () => { return Promise.resolve({status: statusCode}); }); + () => Promise.resolve({status: statusCode})); } setup(done => { @@ -487,9 +487,10 @@ limitations under the License. setup(() => { sandbox.stub(element.$.emailEditor, 'loadData'); - sandbox.stub(element.$.restAPI, 'confirmEmail', () => { - return new Promise(resolve => { resolveConfirm = resolve; }); - }); + sandbox.stub( + element.$.restAPI, + 'confirmEmail', + () => new Promise(resolve => { resolveConfirm = resolve; })); element.params = {emailToken: 'foo'}; element.attached(); }); diff --git a/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.js b/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.js index 6e1781788d..f8e5a5fe71 100644 --- a/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.js +++ b/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.js @@ -91,7 +91,8 @@ this.$.newKey.disabled = false; this._newKey = ''; this.push('_keys', key); - }).catch(() => { + }) + .catch(() => { this.$.addButton.disabled = false; this.$.newKey.disabled = false; }); diff --git a/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor_test.html b/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor_test.html index 912c1fd257..d7644f74c5 100644 --- a/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor_test.html +++ b/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor_test.html @@ -81,7 +81,7 @@ limitations under the License. const lastKey = keys[1]; const saveStub = sinon.stub(element.$.restAPI, 'deleteAccountSSHKey', - () => { return Promise.resolve(); }); + () => Promise.resolve()); assert.equal(element._keysToRemove.length, 0); assert.isFalse(element.hasUnsavedChanges); @@ -132,7 +132,7 @@ limitations under the License. }; const addStub = sinon.stub(element.$.restAPI, 'addAccountSSHKey', - () => { return Promise.resolve(newKeyObject); }); + () => Promise.resolve(newKeyObject)); element._newKey = newKeyString; @@ -157,7 +157,7 @@ limitations under the License. const newKeyString = 'not even close to valid'; const addStub = sinon.stub(element.$.restAPI, 'addAccountSSHKey', - () => { return Promise.reject(new Error('error')); }); + () => Promise.reject(new Error('error'))); element._newKey = newKeyString; diff --git a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.js b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.js index f96aa760da..f638a07a89 100644 --- a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.js +++ b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.js @@ -68,9 +68,7 @@ } return deletePromise - .then(() => { - return this.$.restAPI.saveWatchedProjects(this._projects); - }) + .then(() => this.$.restAPI.saveWatchedProjects(this._projects)) .then(projects => { this._projects = projects; this._projectsToRemove = []; diff --git a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor_test.html b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor_test.html index 4bdb00fe52..e28e85802b 100644 --- a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor_test.html +++ b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor_test.html @@ -88,7 +88,7 @@ limitations under the License. function getKeysOfRow(row) { const boxes = rows[row].querySelectorAll('input[checked]'); return Array.prototype.map.call(boxes, - e => { return e.getAttribute('data-key'); }); + e => e.getAttribute('data-key')); } let checkedKeys = getKeysOfRow(0); diff --git a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.js b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.js index 7a683dccfd..2f9572c600 100644 --- a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.js +++ b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.js @@ -80,9 +80,10 @@ } _getHasAvatars() { - return this.$.restAPI.getConfig().then(cfg => { - return Promise.resolve(!!(cfg && cfg.plugin && cfg.plugin.has_avatars)); - }); + return this.$.restAPI.getConfig() + .then(cfg => Promise.resolve(!!( + cfg && cfg.plugin && cfg.plugin.has_avatars + ))); } } diff --git a/polygerrit-ui/app/elements/shared/gr-account-entry/gr-account-entry_test.html b/polygerrit-ui/app/elements/shared/gr-account-entry/gr-account-entry_test.html index 0bac7e0b94..3743820803 100644 --- a/polygerrit-ui/app/elements/shared/gr-account-entry/gr-account-entry_test.html +++ b/polygerrit-ui/app/elements/shared/gr-account-entry/gr-account-entry_test.html @@ -67,13 +67,11 @@ limitations under the License. suite('stubbed values for querySuggestions', () => { setup(() => { - element.querySuggestions = input => { - return Promise.resolve([ - suggestion1, - suggestion2, - suggestion3, - ]); - }; + element.querySuggestions = input => Promise.resolve([ + suggestion1, + suggestion2, + suggestion3, + ]); }); }); diff --git a/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.js b/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.js index e60782c886..0a4100ca61 100644 --- a/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.js +++ b/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.js @@ -333,15 +333,15 @@ } additions() { - return this.accounts.filter(account => { - return account._pendingAdd; - }).map(account => { - if (account._group) { - return {group: account}; - } else { - return {account}; - } - }); + return this.accounts + .filter(account => account._pendingAdd) + .map(account => { + if (account._group) { + return {group: account}; + } else { + return {account}; + } + }); } _computeEntryHidden(maxCount, accountsRecord, readonly) { diff --git a/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list_test.html b/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list_test.html index 7fea2436bf..3eab3c78d3 100644 --- a/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list_test.html +++ b/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list_test.html @@ -197,11 +197,13 @@ limitations under the License. return suggestion._account_id === accountId; }; - element._getSuggestions().then(suggestions => { - assert.deepEqual(suggestions, - [{name: originalSuggestions[0].email, - value: originalSuggestions[0]._account_id}]); - }).then(done); + element._getSuggestions() + .then(suggestions => { + assert.deepEqual(suggestions, + [{name: originalSuggestions[0].email, + value: originalSuggestions[0]._account_id}]); + }) + .then(done); }); }); diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete_test.html b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete_test.html index 9df3cfc38b..12bc82f0dc 100644 --- a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete_test.html +++ b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete_test.html @@ -54,15 +54,13 @@ limitations under the License. test('renders', () => { let promise; - const queryStub = sandbox.spy(input => { - return promise = Promise.resolve([ - {name: input + ' 0', value: 0}, - {name: input + ' 1', value: 1}, - {name: input + ' 2', value: 2}, - {name: input + ' 3', value: 3}, - {name: input + ' 4', value: 4}, - ]); - }); + const queryStub = sandbox.spy(input => promise = Promise.resolve([ + {name: input + ' 0', value: 0}, + {name: input + ' 1', value: 1}, + {name: input + ' 2', value: 2}, + {name: input + ' 3', value: 3}, + {name: input + ' 4', value: 4}, + ])); element.query = queryStub; assert.isTrue(element.$.suggestions.isHidden); assert.equal(element.$.suggestions.$.cursor.index, -1); @@ -104,11 +102,9 @@ limitations under the License. test('esc key behavior', done => { let promise; - const queryStub = sandbox.spy(() => { - return promise = Promise.resolve([ - {name: 'blah', value: 123}, - ]); - }); + const queryStub = sandbox.spy(() => promise = Promise.resolve([ + {name: 'blah', value: 123}, + ])); element.query = queryStub; assert.isTrue(element.$.suggestions.isHidden); @@ -135,15 +131,13 @@ limitations under the License. test('emits commit and handles cursor movement', done => { let promise; - const queryStub = sandbox.spy(input => { - return promise = Promise.resolve([ - {name: input + ' 0', value: 0}, - {name: input + ' 1', value: 1}, - {name: input + ' 2', value: 2}, - {name: input + ' 3', value: 3}, - {name: input + ' 4', value: 4}, - ]); - }); + const queryStub = sandbox.spy(input => promise = Promise.resolve([ + {name: input + ' 0', value: 0}, + {name: input + ' 1', value: 1}, + {name: input + ' 2', value: 2}, + {name: input + ' 3', value: 3}, + {name: input + ' 4', value: 4}, + ])); element.query = queryStub; assert.isTrue(element.$.suggestions.isHidden); @@ -188,7 +182,8 @@ limitations under the License. test('clear-on-commit behavior (off)', done => { let promise; const queryStub = sandbox.spy(() => { - return promise = Promise.resolve([{name: 'suggestion', value: 0}]); + promise = Promise.resolve([{name: 'suggestion', value: 0}]); + return promise; }); element.query = queryStub; focusOnInput(element); @@ -210,7 +205,8 @@ limitations under the License. test('clear-on-commit behavior (on)', done => { let promise; const queryStub = sandbox.spy(() => { - return promise = Promise.resolve([{name: 'suggestion', value: 0}]); + promise = Promise.resolve([{name: 'suggestion', value: 0}]); + return promise; }); element.query = queryStub; focusOnInput(element); @@ -231,9 +227,7 @@ limitations under the License. }); test('threshold guards the query', () => { - const queryStub = sandbox.spy(() => { - return Promise.resolve([]); - }); + const queryStub = sandbox.spy(() => Promise.resolve([])); element.query = queryStub; element.threshold = 2; focusOnInput(element); @@ -244,9 +238,7 @@ limitations under the License. }); test('noDebounce=false debounces the query', () => { - const queryStub = sandbox.spy(() => { - return Promise.resolve([]); - }); + const queryStub = sandbox.spy(() => Promise.resolve([])); let callback; const debounceStub = sandbox.stub(element, 'debounce', (name, cb) => { callback = cb; }); @@ -276,7 +268,9 @@ limitations under the License. test('when focused', done => { let promise; const queryStub = sandbox.stub() - .returns(promise = Promise.resolve([{name: 'suggestion', value: 0}])); + .returns(promise = Promise.resolve([ + {name: 'suggestion', value: 0}, + ])); element.query = queryStub; element.suggestOnlyWhenFocus = true; focusOnInput(element); @@ -293,7 +287,9 @@ limitations under the License. test('when not focused', done => { let promise; const queryStub = sandbox.stub() - .returns(promise = Promise.resolve([{name: 'suggestion', value: 0}])); + .returns(promise = Promise.resolve([ + {name: 'suggestion', value: 0}, + ])); element.query = queryStub; element.suggestOnlyWhenFocus = true; element.text = 'bla'; @@ -308,7 +304,9 @@ limitations under the License. test('suggestions should not carry over', done => { let promise; const queryStub = sandbox.stub() - .returns(promise = Promise.resolve([{name: 'suggestion', value: 0}])); + .returns(promise = Promise.resolve([ + {name: 'suggestion', value: 0}, + ])); element.query = queryStub; focusOnInput(element); element.text = 'bla'; @@ -324,7 +322,9 @@ limitations under the License. test('multi completes only the last part of the query', done => { let promise; const queryStub = sandbox.stub() - .returns(promise = Promise.resolve([{name: 'suggestion', value: 0}])); + .returns(promise = Promise.resolve([ + {name: 'suggestion', value: 0}, + ])); element.query = queryStub; focusOnInput(element); element.text = 'blah blah'; @@ -449,7 +449,12 @@ limitations under the License. // Must set the value, because the MockInteraction does not. element.$.input.value = 'file:x'; assert.isTrue(keydownSpy.calledOnce); - MockInteractions.pressAndReleaseKeyOn(element.$.input, 13, null, 'enter'); + MockInteractions.pressAndReleaseKeyOn( + element.$.input, + 13, + null, + 'enter' + ); assert.isTrue(keydownSpy.calledTwice); assert.equal(element.text, 'file:x'); }); diff --git a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.html b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.html index 98a75dd4ec..4d49206bcf 100644 --- a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.html +++ b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.html @@ -105,9 +105,10 @@ limitations under the License. test('dom for existing account', () => { assert.isFalse(element.hasAttribute('hidden')); - sandbox.stub(element, '_getConfig', () => { - return Promise.resolve({plugin: {has_avatars: true}}); - }); + sandbox.stub( + element, + '_getConfig', + () => Promise.resolve({plugin: {has_avatars: true}})); element.imageSize = 64; element.account = { @@ -139,9 +140,7 @@ limitations under the License. sandbox = sinon.sandbox.create(); stub('gr-avatar', { - _getConfig: () => { - return Promise.resolve({plugin: {has_avatars: true}}); - }, + _getConfig: () => Promise.resolve({plugin: {has_avatars: true}}), }); element = fixture('basic'); @@ -176,9 +175,7 @@ limitations under the License. sandbox = sinon.sandbox.create(); stub('gr-avatar', { - _getConfig: () => { - return Promise.resolve({}); - }, + _getConfig: () => Promise.resolve({}), }); element = fixture('basic'); diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.html b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.html index ceadae125e..c8627ba564 100644 --- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.html +++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.html @@ -280,9 +280,7 @@ limitations under the License. MockInteractions.tap(replyBtn); flushAsynchronousOperations(); - const drafts = element._orderedComments.filter(c => { - return c.__draft == true; - }); + const drafts = element._orderedComments.filter(c => c.__draft == true); assert.equal(drafts.length, 1); assert.notOk(drafts[0].message, 'message should be empty'); assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215'); @@ -299,9 +297,7 @@ limitations under the License. MockInteractions.tap(quoteBtn); flushAsynchronousOperations(); - const drafts = element._orderedComments.filter(c => { - return c.__draft == true; - }); + const drafts = element._orderedComments.filter(c => c.__draft == true); assert.equal(drafts.length, 1); assert.equal(drafts[0].message, '> is this a crossover episode!?\n\n'); assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215'); @@ -330,9 +326,7 @@ limitations under the License. MockInteractions.tap(quoteBtn); flushAsynchronousOperations(); - const drafts = element._orderedComments.filter(c => { - return c.__draft == true; - }); + const drafts = element._orderedComments.filter(c => c.__draft == true); assert.equal(drafts.length, 1); assert.equal(drafts[0].message, '> is this a crossover episode!?\n> It might be!\n\n'); @@ -352,9 +346,7 @@ limitations under the License. const ackBtn = element.$.ackBtn; MockInteractions.tap(ackBtn); flush(() => { - const drafts = element.comments.filter(c => { - return c.__draft == true; - }); + const drafts = element.comments.filter(c => c.__draft == true); assert.equal(drafts.length, 1); assert.equal(drafts[0].message, 'Ack'); assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215'); @@ -375,9 +367,7 @@ limitations under the License. const doneBtn = element.$.doneBtn; MockInteractions.tap(doneBtn); flush(() => { - const drafts = element.comments.filter(c => { - return c.__draft == true; - }); + const drafts = element.comments.filter(c => c.__draft == true); assert.equal(drafts.length, 1); assert.equal(drafts[0].message, 'Done'); assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215'); @@ -415,9 +405,7 @@ limitations under the License. const commentEl = element.$$('gr-comment'); assert.ok(commentEl); commentEl.addEventListener('create-fix-comment', () => { - const drafts = element._orderedComments.filter(c => { - return c.__draft == true; - }); + const drafts = element._orderedComments.filter(c => c.__draft == true); assert.equal(drafts.length, 1); assert.equal( drafts[0].message, '> is this a crossover episode!?\n\nPlease fix.'); @@ -446,9 +434,7 @@ limitations under the License. Polymer.dom(element.root).querySelectorAll('gr-comment')[1]; assert.ok(draftEl); draftEl.addEventListener('comment-discard', () => { - const drafts = element.comments.filter(c => { - return c.__draft == true; - }); + const drafts = element.comments.filter(c => c.__draft == true); assert.equal(drafts.length, 0); assert.isTrue(saveOrDiscardStub.called); assert.equal(saveOrDiscardStub.lastCall.args[0].detail.rootId, @@ -507,9 +493,7 @@ limitations under the License. MockInteractions.tap(replyBtn); flushAsynchronousOperations(); - const editing = element._orderedComments.filter(c => { - return c.__editing == true; - }); + const editing = element._orderedComments.filter(c => c.__editing == true); assert.equal(editing.length, 1); assert.equal(!!editing[0].__otherEditing, false); }); diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js index 0c45c85035..6449416364 100644 --- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js +++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js @@ -164,7 +164,7 @@ */ _overlays: { type: Object, - value: () => ({}), + value: () => { return {}; }, }, }; } @@ -291,10 +291,11 @@ this._fireSave(); return obj; }); - }).catch(err => { - this.disabled = false; - throw err; - }); + }) + .catch(err => { + this.disabled = false; + throw err; + }); return this._xhrPromise; } @@ -324,10 +325,9 @@ _computeHasHumanReply() { if (!this.comment || !this.comments) return; // hide please fix button for robot comment that has human reply - this._hasHumanReply = this.comments.some(c => { - return c.in_reply_to && c.in_reply_to === this.comment.id && - !c.robot_id; - }); + this._hasHumanReply = this.comments + .some(c => c.in_reply_to && c.in_reply_to === this.comment.id && + !c.robot_id); } /** @@ -568,10 +568,11 @@ } this._fireDiscard(); - }).catch(err => { - this.disabled = false; - throw err; - }); + }) + .catch(err => { + this.disabled = false; + throw err; + }); return this._xhrPromise; } diff --git a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html index fffd38ea10..fe2f1102d7 100644 --- a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html +++ b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html @@ -62,7 +62,9 @@ limitations under the License. expectedTooltip, done) { // Normalize and convert the date to mimic server response. dateStr = normalizedDate(dateStr) - .toJSON().replace('T', ' ').slice(0, -1); + .toJSON() + .replace('T', ' ') + .slice(0, -1); sandbox.useFakeTimers(normalizedDate(nowStr).getTime()); element.dateStr = dateStr; flush(() => { @@ -87,15 +89,13 @@ limitations under the License. } suite('24 hours time format preference', () => { - setup(() => { - return stubRestAPI( - {time_format: 'HHMM_24', relative_date_in_change_table: false} - ).then(() => { - element = fixture('basic'); - sandbox.stub(element, '_getUtcOffsetString').returns(''); - return element._loadPreferences(); - }); - }); + setup(() => stubRestAPI( + {time_format: 'HHMM_24', relative_date_in_change_table: false} + ).then(() => { + element = fixture('basic'); + sandbox.stub(element, '_getUtcOffsetString').returns(''); + return element._loadPreferences(); + })); test('invalid dates are quietly rejected', () => { assert.notOk((new Date('foo')).valueOf()); @@ -136,16 +136,16 @@ limitations under the License. }); suite('12 hours time format preference', () => { - setup(() => { - // relative_date_in_change_table is not set when false. - return stubRestAPI( + setup(() => + // relative_date_in_change_table is not set when false. + stubRestAPI( {time_format: 'HHMM_12'} ).then(() => { element = fixture('basic'); sandbox.stub(element, '_getUtcOffsetString').returns(''); return element._loadPreferences(); - }); - }); + }) + ); test('Within 24 hours on same day', done => { testDates('2015-07-29 20:34:14.985000000', @@ -157,15 +157,13 @@ limitations under the License. }); suite('relative date preference', () => { - setup(() => { - return stubRestAPI( - {time_format: 'HHMM_12', relative_date_in_change_table: true} - ).then(() => { - element = fixture('basic'); - sandbox.stub(element, '_getUtcOffsetString').returns(''); - return element._loadPreferences(); - }); - }); + setup(() => stubRestAPI( + {time_format: 'HHMM_12', relative_date_in_change_table: true} + ).then(() => { + element = fixture('basic'); + sandbox.stub(element, '_getUtcOffsetString').returns(''); + return element._loadPreferences(); + })); test('Within 24 hours on same day', done => { testDates('2015-07-29 20:34:14.985000000', @@ -185,14 +183,12 @@ limitations under the License. }); suite('logged in', () => { - setup(() => { - return stubRestAPI( - {time_format: 'HHMM_12', relative_date_in_change_table: true} - ).then(() => { - element = fixture('basic'); - return element._loadPreferences(); - }); - }); + setup(() => stubRestAPI( + {time_format: 'HHMM_12', relative_date_in_change_table: true} + ).then(() => { + element = fixture('basic'); + return element._loadPreferences(); + })); test('Preferences are respected', () => { assert.equal(element._timeFormat, 'h:mm A'); @@ -201,12 +197,10 @@ limitations under the License. }); suite('logged out', () => { - setup(() => { - return stubRestAPI(null).then(() => { - element = fixture('basic'); - return element._loadPreferences(); - }); - }); + setup(() => stubRestAPI(null).then(() => { + element = fixture('basic'); + return element._loadPreferences(); + })); test('Default preferences are respected', () => { assert.equal(element._timeFormat, 'HH:mm'); diff --git a/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands_test.html b/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands_test.html index 7d4b341eb6..4d2bda735f 100644 --- a/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands_test.html +++ b/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands_test.html @@ -131,7 +131,7 @@ limitations under the License. test('saves scheme to preferences', () => { element._loggedIn = true; const savePrefsStub = sandbox.stub(element.$.restAPI, 'savePreferences', - () => { return Promise.resolve(); }); + () => Promise.resolve()); flushAsynchronousOperations(); diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.js b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.js index 473a0a9ca6..1fa0f1b9b8 100644 --- a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.js +++ b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.js @@ -120,9 +120,7 @@ } if (!value) { return; } - const selectedObj = items.find(item => { - return item.value + '' === value + ''; - }); + const selectedObj = items.find(item => item.value + '' === value + ''); if (!selectedObj) { return; } this.text = selectedObj.triggerText? selectedObj.triggerText : selectedObj.text; diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.js index 7e9c03dd8e..d5e65dad21 100644 --- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.js +++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.js @@ -75,24 +75,26 @@ // TODO(taoalpha): to be deprecated. function send(method, url, opt_callback, opt_payload) { - return getRestAPI().send(method, url, opt_payload).then(response => { - if (response.status < 200 || response.status >= 300) { - return response.text().then(text => { - if (text) { - return Promise.reject(new Error(text)); + return getRestAPI().send(method, url, opt_payload) + .then(response => { + if (response.status < 200 || response.status >= 300) { + return response.text().then(text => { + if (text) { + return Promise.reject(new Error(text)); + } else { + return Promise.reject(new Error(response.status)); + } + }); } else { - return Promise.reject(new Error(response.status)); + return getRestAPI().getResponseObject(response); } + }) + .then(response => { + if (opt_callback) { + opt_callback(response); + } + return response; }); - } else { - return getRestAPI().getResponseObject(response); - } - }).then(response => { - if (opt_callback) { - opt_callback(response); - } - return response; - }); } // TEST only methods / properties diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api.js index 5658245665..7c4c817fde 100644 --- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api.js +++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api.js @@ -62,9 +62,8 @@ GrChangeActionsInterface.prototype.removePrimaryActionKey = function(key) { ensureEl(this); - this._el.primaryActionKeys = this._el.primaryActionKeys.filter(k => { - return k !== key; - }); + this._el.primaryActionKeys = this._el.primaryActionKeys + .filter(k => k !== key); }; GrChangeActionsInterface.prototype.hideQuickApproveAction = function() { diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.js index 4ebbe50c83..b0fe09ea69 100644 --- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.js +++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.js @@ -109,21 +109,22 @@ Gerrit.delete = function(url, opt_callback) { console.warn('.delete() is deprecated! Use plugin.restApi().delete()'); - return getRestAPI().send('DELETE', url).then(response => { - if (response.status !== 204) { - return response.text().then(text => { - if (text) { - return Promise.reject(new Error(text)); - } else { - return Promise.reject(new Error(response.status)); + return getRestAPI().send('DELETE', url) + .then(response => { + if (response.status !== 204) { + return response.text().then(text => { + if (text) { + return Promise.reject(new Error(text)); + } else { + return Promise.reject(new Error(response.status)); + } + }); } + if (opt_callback) { + opt_callback(response); + } + return response; }); - } - if (opt_callback) { - opt_callback(response); - } - return response; - }); }; Gerrit.awaitPluginsLoaded = function() { diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html index 7912ba197e..917c0a9f7e 100644 --- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html +++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html @@ -304,11 +304,11 @@ limitations under the License. test('submitchange', () => { plugin.on(element.EventType.SUBMIT_CHANGE, throwErrFn); - plugin.on(element.EventType.SUBMIT_CHANGE, () => { return true; }); + plugin.on(element.EventType.SUBMIT_CHANGE, () => true); assert.isTrue(element.canSubmitChange()); assert.isTrue(errorStub.calledOnce); - plugin.on(element.EventType.SUBMIT_CHANGE, () => { return false; }); - plugin.on(element.EventType.SUBMIT_CHANGE, () => { return true; }); + plugin.on(element.EventType.SUBMIT_CHANGE, () => false); + plugin.on(element.EventType.SUBMIT_CHANGE, () => true); assert.isFalse(element.canSubmitChange()); assert.isTrue(errorStub.calledTwice); }); @@ -326,13 +326,12 @@ limitations under the License. test('getLoggedIn', done => { // fake fetch for authCheck - sandbox.stub(window, 'fetch', () => { - return Promise.resolve({status: 204}); - }); - plugin.restApi().getLoggedIn().then(loggedIn => { - assert.isTrue(loggedIn); - done(); - }); + sandbox.stub(window, 'fetch', () => Promise.resolve({status: 204})); + plugin.restApi().getLoggedIn() + .then(loggedIn => { + assert.isTrue(loggedIn); + done(); + }); }); test('attributeHelper', () => { diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.html index 151c3409a1..7ddb6662cb 100644 --- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.html +++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.html @@ -369,9 +369,7 @@ limitations under the License. test('relative path should honor getBaseUrl', () => { const testUrl = '/test'; - sandbox.stub(Gerrit.BaseUrlBehavior, 'getBaseUrl', () => { - return testUrl; - }); + sandbox.stub(Gerrit.BaseUrlBehavior, 'getBaseUrl', () => testUrl); Gerrit._loadPlugins([ 'foo/bar.js', diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api_test.html index c0bdb3b070..6fb0b19f1a 100644 --- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api_test.html +++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api_test.html @@ -121,10 +121,11 @@ limitations under the License. {status: 400, text() { return Promise.resolve('text'); }})); return instance.delete('/url').then(r => { throw new Error('Should not resolve'); - }).catch(err => { - assert.isTrue(sendStub.calledWith('DELETE', '/url')); - assert.equal('text', err.message); - }); + }) + .catch(err => { + assert.isTrue(sendStub.calledWith('DELETE', '/url')); + assert.equal('text', err.message); + }); }); test('getLoggedIn', () => { diff --git a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.js b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.js index 590d753979..6e5fd5b662 100644 --- a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.js +++ b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.js @@ -133,7 +133,8 @@ target.disabled = false; if (!response.ok) { return; } Gerrit.Nav.navigateToChange(this.change); - }).catch(err => { + }) + .catch(err => { target.disabled = false; return; }); diff --git a/polygerrit-ui/app/elements/shared/gr-lib-loader/gr-lib-loader.js b/polygerrit-ui/app/elements/shared/gr-lib-loader/gr-lib-loader.js index 20b239eb40..4c221bc01e 100644 --- a/polygerrit-ui/app/elements/shared/gr-lib-loader/gr-lib-loader.js +++ b/polygerrit-ui/app/elements/shared/gr-lib-loader/gr-lib-loader.js @@ -59,7 +59,8 @@ if (!this._hljsState.loading) { this._hljsState.loading = true; this._loadScript(this._getHLJSUrl()) - .then(this._onHLJSLibLoaded.bind(this)).catch(reject); + .then(this._onHLJSLibLoaded.bind(this)) + .catch(reject); } this._hljsState.callbacks.push(resolve); diff --git a/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.js b/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.js index c7afd4de5c..ea39d0ecec 100644 --- a/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.js +++ b/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.js @@ -84,10 +84,12 @@ } _repoResponseToSuggestions(res) { - return res.map(repo => ({ - name: repo.name, - value: this.singleDecodeURL(repo.id), - })); + return res.map(repo => { + return { + name: repo.name, + value: this.singleDecodeURL(repo.id), + }; + }); } _branchResponseToSuggestions(res) { diff --git a/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker_test.html b/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker_test.html index e7252d6a0b..adc4f68e5c 100644 --- a/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker_test.html +++ b/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker_test.html @@ -126,17 +126,16 @@ limitations under the License. }); }); - test('does not query when repo is unset', () => { - return element._getRepoBranchesSuggestions('') - .then(() => { - assert.isFalse(element.$.restAPI.getRepoBranches.called); - element.repo = 'gerrit'; - return element._getRepoBranchesSuggestions(''); - }) - .then(() => { - assert.isTrue(element.$.restAPI.getRepoBranches.called); - }); - }); + test('does not query when repo is unset', () => element + ._getRepoBranchesSuggestions('') + .then(() => { + assert.isFalse(element.$.restAPI.getRepoBranches.called); + element.repo = 'gerrit'; + return element._getRepoBranchesSuggestions(''); + }) + .then(() => { + assert.isTrue(element.$.restAPI.getRepoBranches.called); + })); }); }); diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-auth_test.html b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-auth_test.html index 20e8260d3b..cbaf49d566 100644 --- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-auth_test.html +++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-auth_test.html @@ -315,17 +315,21 @@ limitations under the License. sandbox.stub(auth, '_isTokenValid'); auth._isTokenValid .onFirstCall().returns(true) - .onSecondCall().returns(false) - .onThirdCall().returns(true); - auth.fetch('/url-one').then(() => { - getToken.returns(Promise.resolve(makeToken('bzzbb'))); - return auth.fetch('/url-two'); - }).then(() => { - const [[firstUrl], [secondUrl]] = fetch.args; - assert.equal(firstUrl, '/a/url-one?access_token=zbaz'); - assert.equal(secondUrl, '/a/url-two?access_token=bzzbb'); - done(); - }); + .onSecondCall() + .returns(false) + .onThirdCall() + .returns(true); + auth.fetch('/url-one') + .then(() => { + getToken.returns(Promise.resolve(makeToken('bzzbb'))); + return auth.fetch('/url-two'); + }) + .then(() => { + const [[firstUrl], [secondUrl]] = fetch.args; + assert.equal(firstUrl, '/a/url-one?access_token=zbaz'); + assert.equal(secondUrl, '/a/url-two?access_token=bzzbb'); + done(); + }); }); test('signed in token error falls back to anonymous', done => { diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js index 5f5f700ae8..0e2bef6ce7 100644 --- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js +++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js @@ -801,7 +801,7 @@ let queryString = ''; if (opt_params) { queryString = '?q=' + opt_params - .map(param => { return encodeURIComponent(param); }) + .map(param => encodeURIComponent(param)) .join('&q='); } return this._fetchSharedCacheURL({ @@ -815,15 +815,17 @@ } getIsAdmin() { - return this.getLoggedIn().then(isLoggedIn => { - if (isLoggedIn) { - return this.getAccountCapabilities(); - } else { - return Promise.resolve(); - } - }).then(capabilities => { - return capabilities && capabilities.administrateServer; - }); + return this.getLoggedIn() + .then(isLoggedIn => { + if (isLoggedIn) { + return this.getAccountCapabilities(); + } else { + return Promise.resolve(); + } + }) + .then( + capabilities => capabilities && capabilities.administrateServer + ); } getDefaultPreferences() { @@ -1642,14 +1644,12 @@ this.awaitPendingDiffDrafts(), this.getChangeActionURL(changeNum, patchNum, '/review'), ]; - return Promise.all(promises).then(([, url]) => { - return this._restApiHelper.send({ - method: 'POST', - url, - body: review, - errFn: opt_errFn, - }); - }); + return Promise.all(promises).then(([, url]) => this._restApiHelper.send({ + method: 'POST', + url, + body: review, + errFn: opt_errFn, + })); } getChangeEdit(changeNum, opt_download_commands) { @@ -2013,9 +2013,9 @@ _setRanges(comments) { comments = comments || []; - comments.sort((a, b) => { - return util.parseDate(a.updated) - util.parseDate(b.updated); - }); + comments.sort( + (a, b) => util.parseDate(a.updated) - util.parseDate(b.updated) + ); for (const comment of comments) { this._setRange(comments, comment); } @@ -2039,14 +2039,12 @@ * @param {string|number=} opt_patchNum * @return {!Promise} Diff comments response. */ - const fetchComments = opt_patchNum => { - return this._getChangeURLAndFetch({ - changeNum, - endpoint, - patchNum: opt_patchNum, - reportEndpointAsIs: true, - }); - }; + const fetchComments = opt_patchNum => this._getChangeURLAndFetch({ + changeNum, + endpoint, + patchNum: opt_patchNum, + reportEndpointAsIs: true, + }); if (!opt_basePatchNum && !opt_patchNum && !opt_path) { return fetchComments(); @@ -2087,12 +2085,10 @@ promises.push(fetchPromise); } - return Promise.all(promises).then(() => { - return Promise.resolve({ - baseComments, - comments, - }); - }); + return Promise.all(promises).then(() => Promise.resolve({ + baseComments, + comments, + })); } /** @@ -2465,9 +2461,7 @@ probePath(path) { return fetch(new Request(path, {method: 'HEAD'})) - .then(response => { - return response.ok; - }); + .then(response => response.ok); } /** @@ -2595,19 +2589,18 @@ const anonymizedEndpoint = req.reportEndpointAsIs ? req.endpoint : req.anonymizedEndpoint; - return this._changeBaseURL(req.changeNum, req.patchNum).then(url => { - return this._restApiHelper.send({ - method: req.method, - url: url + req.endpoint, - body: req.body, - errFn: req.errFn, - contentType: req.contentType, - headers: req.headers, - parseResponse: req.parseResponse, - anonymizedUrl: anonymizedEndpoint ? - (anonymizedBaseUrl + anonymizedEndpoint) : undefined, - }); - }); + return this._changeBaseURL(req.changeNum, req.patchNum) + .then(url => this._restApiHelper.send({ + method: req.method, + url: url + req.endpoint, + body: req.body, + errFn: req.errFn, + contentType: req.contentType, + headers: req.headers, + parseResponse: req.parseResponse, + anonymizedUrl: anonymizedEndpoint ? + (anonymizedBaseUrl + anonymizedEndpoint) : undefined, + })); } /** @@ -2621,16 +2614,15 @@ req.endpoint : req.anonymizedEndpoint; const anonymizedBaseUrl = req.patchNum ? ANONYMIZED_REVISION_BASE_URL : ANONYMIZED_CHANGE_BASE_URL; - return this._changeBaseURL(req.changeNum, req.patchNum).then(url => { - return this._restApiHelper.fetchJSON({ - url: url + req.endpoint, - errFn: req.errFn, - params: req.params, - fetchOptions: req.fetchOptions, - anonymizedUrl: anonymizedEndpoint ? - (anonymizedBaseUrl + anonymizedEndpoint) : undefined, - }); - }); + return this._changeBaseURL(req.changeNum, req.patchNum) + .then(url => this._restApiHelper.fetchJSON({ + url: url + req.endpoint, + errFn: req.errFn, + params: req.params, + fetchOptions: req.fetchOptions, + anonymizedUrl: anonymizedEndpoint ? + (anonymizedBaseUrl + anonymizedEndpoint) : undefined, + })); } /** diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface_test.html b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface_test.html index 586e304e1c..ca4b24672a 100644 --- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface_test.html +++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface_test.html @@ -66,22 +66,20 @@ limitations under the License. }); test('parent diff comments are properly grouped', done => { - sandbox.stub(element._restApiHelper, 'fetchJSON', () => { - return Promise.resolve({ - '/COMMIT_MSG': [], - 'sieve.go': [ - { - updated: '2017-02-03 22:32:28.000000000', - message: 'this isn’t quite right', - }, - { - side: 'PARENT', - message: 'how did this work in the first place?', - updated: '2017-02-03 22:33:28.000000000', - }, - ], - }); - }); + sandbox.stub(element._restApiHelper, 'fetchJSON', () => Promise.resolve({ + '/COMMIT_MSG': [], + 'sieve.go': [ + { + updated: '2017-02-03 22:32:28.000000000', + message: 'this isn’t quite right', + }, + { + side: 'PARENT', + message: 'how did this work in the first place?', + updated: '2017-02-03 22:33:28.000000000', + }, + ], + })); element._getDiffComments('42', '', 'PARENT', 1, 'sieve.go').then( obj => { assert.equal(obj.baseComments.length, 1); @@ -430,15 +428,12 @@ limitations under the License. }); const preferenceSetup = function(testJSON, loggedIn, smallScreen) { - sandbox.stub(element, 'getLoggedIn', () => { - return Promise.resolve(loggedIn); - }); - sandbox.stub(element, '_isNarrowScreen', () => { - return smallScreen; - }); - sandbox.stub(element._restApiHelper, 'fetchCacheURL', () => { - return Promise.resolve(testJSON); - }); + sandbox.stub(element, 'getLoggedIn', () => Promise.resolve(loggedIn)); + sandbox.stub(element, '_isNarrowScreen', () => smallScreen); + sandbox.stub( + element._restApiHelper, + 'fetchCacheURL', + () => Promise.resolve(testJSON)); }; test('getPreferences returns correctly on small screens logged in', @@ -537,9 +532,7 @@ limitations under the License. }); test('getEditPreferences returns correct defaults', done => { - sandbox.stub(element, 'getLoggedIn', () => { - return Promise.resolve(false); - }); + sandbox.stub(element, 'getLoggedIn', () => Promise.resolve(false)); element.getEditPreferences().then(obj => { assert.equal(obj.auto_close_brackets, false); @@ -650,15 +643,17 @@ limitations under the License. ['Innocuous', 'hello'], ]}, }; - element._failForCreate200(Promise.resolve(result)).then(() => { - assert.isTrue(false, 'Promise should not resolve'); - }).catch(e => { - assert.isOk(e); - assert.include(e.message, 'Saving draft resulted in HTTP 200'); - assert.include(e.message, 'hello'); - assert.notInclude(e.message, 'secret'); - done(); - }); + element._failForCreate200(Promise.resolve(result)) + .then(() => { + assert.isTrue(false, 'Promise should not resolve'); + }) + .catch(e => { + assert.isOk(e); + assert.include(e.message, 'Saving draft resulted in HTTP 200'); + assert.include(e.message, 'hello'); + assert.notInclude(e.message, 'secret'); + done(); + }); }); test('_failForCreate200 does not fail on 201', done => { @@ -667,11 +662,13 @@ limitations under the License. status: 201, headers: {entries: () => []}, }; - element._failForCreate200(Promise.resolve(result)).then(() => { - done(); - }).catch(e => { - assert.isTrue(false, 'Promise should not fail'); - }); + element._failForCreate200(Promise.resolve(result)) + .then(() => { + done(); + }) + .catch(e => { + assert.isTrue(false, 'Promise should not fail'); + }); }); }); }); @@ -978,12 +975,12 @@ limitations under the License. toHexStub = sandbox.stub(element, 'listChangesOptionsToHex', options => 'deadbeef'); sandbox.stub(element, '_getChangeDetail', - async (changeNum, options) => ({changeNum, options})); + async (changeNum, options) => { return {changeNum, options}; }); }); test('signed pushes disabled', async () => { const {PUSH_CERTIFICATES} = element.ListChangesOption; - sandbox.stub(element, 'getConfig', async () => ({})); + sandbox.stub(element, 'getConfig', async () => { return {}; }); const {changeNum, options} = await element.getChangeDetail(123); assert.strictEqual(123, changeNum); assert.strictEqual('deadbeef', options); diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper.js b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper.js index 47989fdcf4..91fef29afe 100644 --- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper.js +++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper.js @@ -180,20 +180,22 @@ fetchOptions: req.fetchOptions, anonymizedUrl: req.reportUrlAsIs ? urlWithParams : req.anonymizedUrl, }; - return this.fetch(fetchReq).then(res => { - if (req.cancelCondition && req.cancelCondition()) { - res.body.cancel(); - return; - } - return res; - }).catch(err => { - if (req.errFn) { - req.errFn.call(undefined, null, err); - } else { - this.fire('network-error', {error: err}); - } - throw err; - }); + return this.fetch(fetchReq) + .then(res => { + if (req.cancelCondition && req.cancelCondition()) { + res.body.cancel(); + return; + } + return res; + }) + .catch(err => { + if (req.errFn) { + req.errFn.call(undefined, null, err); + } else { + this.fire('network-error', {error: err}); + } + throw err; + }); } /** @@ -309,16 +311,18 @@ return Promise.resolve(this._cache.get(req.url)); } this._fetchPromisesCache.set(req.url, - this.fetchJSON(req).then(response => { - if (response !== undefined) { - this._cache.set(req.url, response); - } - this._fetchPromisesCache.set(req.url, undefined); - return response; - }).catch(err => { - this._fetchPromisesCache.set(req.url, undefined); - throw err; - }) + this.fetchJSON(req) + .then(response => { + if (response !== undefined) { + this._cache.set(req.url, response); + } + this._fetchPromisesCache.set(req.url, undefined); + return response; + }) + .catch(err => { + this._fetchPromisesCache.set(req.url, undefined); + throw err; + }) ); return this._fetchPromisesCache.get(req.url); } @@ -360,14 +364,15 @@ this.fire('server-error', {request: fetchReq, response}); } return response; - }).catch(err => { - this.fire('network-error', {error: err}); - if (req.errFn) { - return req.errFn.call(undefined, null, err); - } else { - throw err; - } - }); + }) + .catch(err => { + this.fire('network-error', {error: err}); + if (req.errFn) { + return req.errFn.call(undefined, null, err); + } else { + throw err; + } + }); if (req.parseResponse) { return xhr.then(res => this.getResponseObject(res)); diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper_test.html b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper_test.html index f4ff4df7e9..6458104b0e 100644 --- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper_test.html +++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper_test.html @@ -97,9 +97,7 @@ limitations under the License. test('cached results', done => { let n = 0; - sandbox.stub(helper, 'fetchJSON', () => { - return Promise.resolve(++n); - }); + sandbox.stub(helper, 'fetchJSON', () => Promise.resolve(++n)); const promises = []; promises.push(helper.fetchCacheURL('/foo')); promises.push(helper.fetchCacheURL('/foo')); @@ -164,7 +162,7 @@ limitations under the License. cancel() { cancelCalled = true; }, }, })); - const cancelCondition = () => { return true; }; + const cancelCondition = () => true; helper.fetchJSON({url: '/dummy/url', cancelCondition}).then( obj => { assert.isUndefined(obj); diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser.js b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser.js index 589f8dc512..1c62ca3004 100644 --- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser.js +++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser.js @@ -54,9 +54,10 @@ * are used. */ GrReviewerUpdatesParser.prototype._filterRemovedMessages = function() { - this.result.messages = this.result.messages.filter(message => { - return message.tag !== 'autogenerated:gerrit:deleteReviewer'; - }); + this.result.messages = this.result.messages + .filter( + message => message.tag !== 'autogenerated:gerrit:deleteReviewer' + ); }; /** @@ -217,7 +218,9 @@ const timestamp = util.parseDate(update.date).getTime() - GrReviewerUpdatesParser.MESSAGE_REVIEWERS_THRESHOLD_MILLIS; update.date = new Date(timestamp) - .toISOString().replace('T', ' ').replace('Z', '000000'); + .toISOString() + .replace('T', ' ') + .replace('Z', '000000'); } if (nextMessageDate && date > nextMessageDate) { break; diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser_test.html b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser_test.html index ad3e4ca38a..818bfa9e3e 100644 --- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser_test.html +++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser_test.html @@ -253,10 +253,10 @@ limitations under the License. test('_advanceUpdates', () => { const T0 = util.parseDate('2017-02-17 19:04:18.000000000').getTime(); - const tplus = delta => { - return new Date(T0 + delta) - .toISOString().replace('T', ' ').replace('Z', '000000'); - }; + const tplus = delta => new Date(T0 + delta) + .toISOString() + .replace('T', ' ') + .replace('Z', '000000'); const change = { reviewer_updates: [{ date: tplus(0), diff --git a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.js b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.js index 0c237bc621..d3119b7375 100644 --- a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.js +++ b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.js @@ -302,9 +302,9 @@ this._formatSuggestions(ALL_SUGGESTIONS); this.disableEnterKeyForSelectingEmoji = true; } else { - const matches = ALL_SUGGESTIONS.filter(suggestion => { - return suggestion.match.includes(emojiText); - }).slice(0, MAX_ITEMS_DROPDOWN); + const matches = ALL_SUGGESTIONS + .filter(suggestion => suggestion.match.includes(emojiText)) + .slice(0, MAX_ITEMS_DROPDOWN); this._formatSuggestions(matches); this.disableEnterKeyForSelectingEmoji = false; } diff --git a/polygerrit-ui/app/samples/repo-command.html b/polygerrit-ui/app/samples/repo-command.html index 526d35051c..afbc78c9fb 100644 --- a/polygerrit-ui/app/samples/repo-command.html +++ b/polygerrit-ui/app/samples/repo-command.html @@ -7,7 +7,8 @@ if (repoName !== 'All-Projects') { return false; } - }).onTap(() => { + }) + .onTap(() => { alert('Bork, bork!'); }); diff --git a/polygerrit-ui/app/scripts/gr-group-suggestions-provider/gr-group-suggestions-provider.js b/polygerrit-ui/app/scripts/gr-group-suggestions-provider/gr-group-suggestions-provider.js index a95670be9e..80166cdd73 100644 --- a/polygerrit-ui/app/scripts/gr-group-suggestions-provider/gr-group-suggestions-provider.js +++ b/polygerrit-ui/app/scripts/gr-group-suggestions-provider/gr-group-suggestions-provider.js @@ -31,9 +31,7 @@ .then(groups => { if (!groups) { return []; } const keys = Object.keys(groups); - return keys.map(key => { - return Object.assign({}, groups[key], {name: key}); - }); + return keys.map(key => Object.assign({}, groups[key], {name: key})); }); } diff --git a/polygerrit-ui/app/scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider_test.html b/polygerrit-ui/app/scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider_test.html index 6fcc4dcbc7..fc6fa1ce37 100644 --- a/polygerrit-ui/app/scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider_test.html +++ b/polygerrit-ui/app/scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider_test.html @@ -181,9 +181,7 @@ limitations under the License. }); sandbox.stub(GrDisplayNameUtils, '_accountEmail', - () => { - return ''; - }); + () => ''); suggestion = provider.makeSuggestionItem(account3); assert.deepEqual(suggestion, { @@ -193,13 +191,16 @@ limitations under the License. }); test('getSuggestions', done => { - provider.getSuggestions().then(reviewers => { - // Default is no filtering. - assert.equal(reviewers.length, 6); - assert.deepEqual(reviewers, - [redundantSuggestion1, redundantSuggestion2, - redundantSuggestion3, suggestion1, suggestion2, suggestion3]); - }).then(done); + provider.getSuggestions() + .then(reviewers => { + // Default is no filtering. + assert.equal(reviewers.length, 6); + assert.deepEqual(reviewers, + [redundantSuggestion1, redundantSuggestion2, + redundantSuggestion3, suggestion1, + suggestion2, suggestion3]); + }) + .then(done); }); test('getSuggestions short circuits when logged out', () => { diff --git a/polygerrit-ui/app/template_test_srcs/template_test.js b/polygerrit-ui/app/template_test_srcs/template_test.js index d715d7d442..5592825ad5 100644 --- a/polygerrit-ui/app/template_test_srcs/template_test.js +++ b/polygerrit-ui/app/template_test_srcs/template_test.js @@ -78,7 +78,8 @@ fs.readdir('./polygerrit-ui/temp/behaviors/', (err, data) => { if (joinedErrors) { process.exit(1); } - }).catch(e => { + }) + .catch(e => { console.error(e); process.exit(1); }); diff --git a/polygerrit-ui/app/test/functional/test.js b/polygerrit-ui/app/test/functional/test.js index d394487ae4..ae572af5ef 100644 --- a/polygerrit-ui/app/test/functional/test.js +++ b/polygerrit-ui/app/test/functional/test.js @@ -11,15 +11,11 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; describe('example ', () => { let driver; - beforeAll(() => { - return setup().then(d => driver = d); - }); + beforeAll(() => setup().then(d => driver = d)); - afterAll(() => { - return cleanup(); - }); + afterAll(() => cleanup()); - it('should update title', () => { - return driver.wait(until.titleIs('status:open · Gerrit Code Review'), 5000); - }); + it('should update title', () => driver.wait( + until.titleIs('status:open · Gerrit Code Review'), 5000 + )); });