From b78030337d873b9ed024cd28754179b824e3bb18 Mon Sep 17 00:00:00 2001 From: NovemLinguae Date: Thu, 21 Nov 2024 01:51:20 -0800 Subject: [PATCH] arrow-body-style --- modules/twinklearv.js | 32 ++++++---------------- modules/twinklebatchdelete.js | 40 +++++++-------------------- modules/twinklebatchprotect.js | 18 +++++-------- modules/twinklebatchundelete.js | 12 +++------ modules/twinkleblock.js | 32 ++++++---------------- modules/twinkledeprod.js | 4 +-- modules/twinkleprotect.js | 38 ++++++++++++-------------- modules/twinklespeedy.js | 36 +++++++------------------ modules/twinkletag.js | 20 ++++---------- modules/twinklewarn.js | 4 +-- modules/twinklewelcome.js | 6 ++--- morebits.js | 48 +++++++++------------------------ 12 files changed, 83 insertions(+), 207 deletions(-) diff --git a/modules/twinklearv.js b/modules/twinklearv.js index 6dbdc266b..9c62fa7ea 100644 --- a/modules/twinklearv.js +++ b/modules/twinklearv.js @@ -669,9 +669,7 @@ Twinkle.arv.callback.evaluate = function(e) { } sockParameters.uid = puppetReport ? form.sockmaster.value.trim() : uid; - sockParameters.sockpuppets = puppetReport ? [uid] : Morebits.array.uniq($.map($('input:text[name=sockpuppet]', form), (o) => { - return $(o).val() || null; - })); + sockParameters.sockpuppets = puppetReport ? [uid] : Morebits.array.uniq($.map($('input:text[name=sockpuppet]', form), (o) => $(o).val() || null)); Morebits.simpleWindow.setButtonsEnabled(false); Morebits.status.init(form); @@ -679,25 +677,19 @@ Twinkle.arv.callback.evaluate = function(e) { break; case 'an3': - var diffs = $.map($('input:checkbox[name=s_diffs]:checked', form), (o) => { - return $(o).data('revinfo'); - }); + var diffs = $.map($('input:checkbox[name=s_diffs]:checked', form), (o) => $(o).data('revinfo')); if (diffs.length < 3 && !confirm('You have selected fewer than three offending edits. Do you wish to make the report anyway?')) { return; } - var warnings = $.map($('input:checkbox[name=s_warnings]:checked', form), (o) => { - return $(o).data('revinfo'); - }); + var warnings = $.map($('input:checkbox[name=s_warnings]:checked', form), (o) => $(o).data('revinfo')); if (!warnings.length && !confirm('You have not selected any edits where you warned the offender. Do you wish to make the report anyway?')) { return; } - var resolves = $.map($('input:checkbox[name=s_resolves]:checked', form), (o) => { - return $(o).data('revinfo'); - }); + var resolves = $.map($('input:checkbox[name=s_resolves]:checked', form), (o) => $(o).data('revinfo')); var free_resolves = $('input[name=s_resolves_free]').val(); var an3_next = function(free_resolves) { @@ -817,9 +809,7 @@ Twinkle.arv.processSock = function(params) { // prepare the SPI report let text = '\n{{subst:SPI report|' + - params.sockpuppets.map((sock, index) => { - return (index + 1) + '=' + sock; - }).join('|') + '\n|evidence=' + params.evidence + ' \n'; + params.sockpuppets.map((sock, index) => (index + 1) + '=' + sock).join('|') + '\n|evidence=' + params.evidence + ' \n'; if (params.checkuser) { text += '|checkuser=yes'; @@ -914,17 +904,11 @@ Twinkle.arv.processAN3 = function(params) { const label = 'Consecutive edits made from ' + new Morebits.date(first.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) to ' + new Morebits.date(last.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)'; ret = '# {{diff|oldid=' + first.parentid + '|diff=' + last.revid + '|label=' + label + '}}\n'; } - ret += sub.reverse().map((v) => { - return (sub.length >= 2 ? '#' : '') + '# {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v); - }).join('\n'); + ret += sub.reverse().map((v) => (sub.length >= 2 ? '#' : '') + '# {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n'); return ret; }).reverse().join('\n'); - const warningtext = params.warnings.reverse().map((v) => { - return '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v); - }).join('\n'); - let resolvetext = params.resolves.reverse().map((v) => { - return '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v); - }).join('\n'); + const warningtext = params.warnings.reverse().map((v) => '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n'); + let resolvetext = params.resolves.reverse().map((v) => '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n'); if (params.free_resolves) { const page = params.free_resolves; diff --git a/modules/twinklebatchdelete.js b/modules/twinklebatchdelete.js index 3eec0be3d..659fba7fc 100644 --- a/modules/twinklebatchdelete.js +++ b/modules/twinklebatchdelete.js @@ -169,9 +169,7 @@ Twinkle.batchdelete.callback = function twinklebatchdeleteCallback() { const wikipedia_api = new Morebits.wiki.api('loading...', query, ((apiobj) => { const response = apiobj.getResponse(); let pages = (response.query && response.query.pages) || []; - pages = pages.filter((page) => { - return !page.missing && page.imagerepository !== 'shared'; - }); + pages = pages.filter((page) => !page.missing && page.imagerepository !== 'shared'); pages.sort(Twinkle.sortByNamespace); pages.forEach((page) => { const metadata = []; @@ -179,9 +177,7 @@ Twinkle.batchdelete.callback = function twinklebatchdeleteCallback() { metadata.push('redirect'); } - const editProt = page.protection.filter((pr) => { - return pr.type === 'edit' && pr.level === 'sysop'; - }).pop(); + const editProt = page.protection.filter((pr) => pr.type === 'edit' && pr.level === 'sysop').pop(); if (editProt) { metadata.push('fully protected' + (editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + new Morebits.date(editProt.expiry).calendar('utc') + ' (UTC)')); @@ -231,9 +227,7 @@ Twinkle.batchdelete.callback = function twinklebatchdeleteCallback() { name: 'pages', id: 'tw-dbatch-pages', shiftClickSupport: true, - list: $.map(Twinkle.batchdelete.pages, (e) => { - return e; - }) + list: $.map(Twinkle.batchdelete.pages, (e) => e) }); form.append({ type: 'submit' }); @@ -265,9 +259,7 @@ Twinkle.batchdelete.generateNewPageList = function(form) { name: 'pages', id: 'tw-dbatch-pages', shiftClickSupport: true, - list: $.map(Twinkle.batchdelete.pages, (e) => { - return e; - }) + list: $.map(Twinkle.batchdelete.pages, (e) => e) }).render(); }; @@ -306,9 +298,7 @@ Twinkle.batchdelete.callback.toggleSubpages = function twDbatchToggleSubpages(e) const loadingText = 'Loading... '; $(e.target).after(loadingText); - const pages = $(form.pages).map((i, el) => { - return el.value; - }).get(); + const pages = $(form.pages).map((i, el) => el.value).get(); const subpageLister = new Morebits.batchOperation(); subpageLister.setOption('chunkSize', Twinkle.getPref('batchChunks')); @@ -343,9 +333,7 @@ Twinkle.batchdelete.callback.toggleSubpages = function twDbatchToggleSubpages(e) metadata.push('redirect'); } - const editProt = page.protection.filter((pr) => { - return pr.type === 'edit' && pr.level === 'sysop'; - }).pop(); + const editProt = page.protection.filter((pr) => pr.type === 'edit' && pr.level === 'sysop').pop(); if (editProt) { metadata.push('fully protected' + (editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + new Morebits.date(editProt.expiry).calendar('utc') + ' (UTC)')); @@ -422,9 +410,7 @@ Twinkle.batchdelete.callback.evaluate = function twinklebatchdeleteCallbackEvalu const form = event.target; - const numProtected = $(Morebits.quickForm.getElements(form, 'pages')).filter((index, element) => { - return element.checked && element.nextElementSibling.style.color === 'red'; - }).length; + const numProtected = $(Morebits.quickForm.getElements(form, 'pages')).filter((index, element) => element.checked && element.nextElementSibling.style.color === 'red').length; if (numProtected > 0 && !confirm('You are about to delete ' + mw.language.convertNumber(numProtected) + ' fully protected page(s). Are you sure?')) { return; } @@ -572,9 +558,7 @@ Twinkle.batchdelete.callbacks = { deleteRedirectsMain: function(apiobj) { const response = apiobj.getResponse(); let pages = response.query.pages[0].redirects || []; - pages = pages.map((redirect) => { - return redirect.title; - }); + pages = pages.map((redirect) => redirect.title); if (!pages.length) { return; } @@ -605,9 +589,7 @@ Twinkle.batchdelete.callbacks = { unlinkBacklinksMain: function(apiobj) { const response = apiobj.getResponse(); let pages = response.query.backlinks || []; - pages = pages.map((page) => { - return page.title; - }); + pages = pages.map((page) => page.title); if (!pages.length) { return; } @@ -658,9 +640,7 @@ Twinkle.batchdelete.callbacks = { unlinkImageInstancesMain: function(apiobj) { const response = apiobj.getResponse(); let pages = response.query.imageusage || []; - pages = pages.map((page) => { - return page.title; - }); + pages = pages.map((page) => page.title); if (!pages.length) { return; } diff --git a/modules/twinklebatchprotect.js b/modules/twinklebatchprotect.js index b8630f473..b69072e8a 100644 --- a/modules/twinklebatchprotect.js +++ b/modules/twinklebatchprotect.js @@ -82,10 +82,10 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() { name: 'movelevel', label: 'Move protection:', event: Twinkle.protect.formevents.movelevel, - list: Twinkle.protect.protectionLevels.filter((level) => { + list: Twinkle.protect.protectionLevels.filter((level) => // Autoconfirmed is required for a move, redundant - return level.value !== 'autoconfirmed'; - }) + level.value !== 'autoconfirmed' + ) }); form.append({ type: 'select', @@ -189,9 +189,7 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() { if (missing) { metadata.push('page does not exist'); - editProt = page.protection.filter((pr) => { - return pr.type === 'create' && pr.level === 'sysop'; - }).pop(); + editProt = page.protection.filter((pr) => pr.type === 'create' && pr.level === 'sysop').pop(); } else { if (page.redirect) { metadata.push('redirect'); @@ -204,9 +202,7 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() { metadata.push(mw.language.convertNumber(page.revisions[0].size) + ' bytes'); } - editProt = page.protection.filter((pr) => { - return pr.type === 'edit' && pr.level === 'sysop'; - }).pop(); + editProt = page.protection.filter((pr) => pr.type === 'edit' && pr.level === 'sysop').pop(); } if (editProt) { metadata.push('fully' + (missing ? ' create' : '') + ' protected' + @@ -261,9 +257,7 @@ Twinkle.batchprotect.callback.evaluate = function twinklebatchprotectCallbackEva const form = event.target; - const numProtected = $(Morebits.quickForm.getElements(form, 'pages')).filter((index, element) => { - return element.checked && element.nextElementSibling.style.color === 'red'; - }).length; + const numProtected = $(Morebits.quickForm.getElements(form, 'pages')).filter((index, element) => element.checked && element.nextElementSibling.style.color === 'red').length; if (numProtected > 0 && !confirm('You are about to act on ' + mw.language.convertNumber(numProtected) + ' fully protected page(s). Are you sure?')) { return; } diff --git a/modules/twinklebatchundelete.js b/modules/twinklebatchundelete.js index 5f79bc75d..d157f2430 100644 --- a/modules/twinklebatchundelete.js +++ b/modules/twinklebatchundelete.js @@ -67,15 +67,11 @@ Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() { const wikipedia_api = new Morebits.wiki.api('loading...', query, ((apiobj) => { const response = apiobj.getResponse(); let pages = (response.query && response.query.pages) || []; - pages = pages.filter((page) => { - return page.missing; - }); + pages = pages.filter((page) => page.missing); const list = []; pages.sort(Twinkle.sortByNamespace); pages.forEach((page) => { - const editProt = page.protection.filter((pr) => { - return pr.type === 'create' && pr.level === 'sysop'; - }).pop(); + const editProt = page.protection.filter((pr) => pr.type === 'create' && pr.level === 'sysop').pop(); const title = page.title; list.push({ @@ -122,9 +118,7 @@ Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() { Twinkle.batchundelete.callback.evaluate = function(event) { Morebits.wiki.actionCompleted.notice = 'Batch undeletion is now complete'; - const numProtected = Morebits.quickForm.getElements(event.target, 'pages').filter((element) => { - return element.checked && element.nextElementSibling.style.color === 'red'; - }).length; + const numProtected = Morebits.quickForm.getElements(event.target, 'pages').filter((element) => element.checked && element.nextElementSibling.style.color === 'red').length; if (numProtected > 0 && !confirm('You are about to undelete ' + numProtected + ' fully create protected page(s). Are you sure?')) { return; } diff --git a/modules/twinkleblock.js b/modules/twinkleblock.js index 82f67036b..dba077be5 100644 --- a/modules/twinkleblock.js +++ b/modules/twinkleblock.js @@ -170,9 +170,7 @@ Twinkle.block.processUserInfo = function twinkleblockProcessUserInfo(data, fn) { Twinkle.block.isRegistered = !!userinfo.userid; if (Twinkle.block.isRegistered) { - Twinkle.block.userIsBot = !!userinfo.groupmemberships && userinfo.groupmemberships.map((e) => { - return e.group; - }).indexOf('bot') !== -1; + Twinkle.block.userIsBot = !!userinfo.groupmemberships && userinfo.groupmemberships.map((e) => e.group).indexOf('bot') !== -1; } else { Twinkle.block.userIsBot = false; } @@ -315,9 +313,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction prior.list = [{ label: 'Prior block settings', value: 'prior', selected: true }]; // Arrays of objects are annoying to check - if (!blockGroup.some((bg) => { - return bg.label === prior.label; - })) { + if (!blockGroup.some((bg) => bg.label === prior.label)) { blockGroup.push(prior); } @@ -333,9 +329,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction } } else { // But first remove any prior prior - blockGroup = blockGroup.filter((bg) => { - return bg.label !== prior.label; - }); + blockGroup = blockGroup.filter((bg) => bg.label !== prior.label); } // Can be in preset or template field, so the old one in the template @@ -521,9 +515,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction Twinkle.block.dsinfo.then((dsinfo) => { const $select = $('[name="dstopic"]'); - const $options = $.map(dsinfo, (value, key) => { - return $('