From db0bcb7dd6bcf0351c950bf2fd93766e416e0fb1 Mon Sep 17 00:00:00 2001 From: NovemLinguae <79697282+NovemLinguae@users.noreply.github.com> Date: Sat, 7 Dec 2024 13:58:48 -0800 Subject: [PATCH 1/2] eslint: revert $.extend autofixes (#2107) Manual revert. Partial revert. There's an upstream bug in the autofix ( https://github.com/wikimedia/eslint-plugin-no-jquery/issues/343 ). I don't want to take any chances. Fixes #2106 --- .eslintrc.json | 1 + modules/twinklebatchdelete.js | 4 ++-- modules/twinklebatchprotect.js | 2 +- modules/twinkleblock.js | 4 ++-- modules/twinkleimage.js | 2 +- modules/twinklespeedy.js | 4 ++-- modules/twinkleunlink.js | 2 +- modules/twinklewarn.js | 6 +++--- modules/twinklexfd.js | 2 +- morebits.js | 6 +++--- twinkle.js | 2 +- 11 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 086f4739c..bbcacf8ee 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -47,6 +47,7 @@ "new-cap": "warn", "no-jquery/no-constructor-attributes": "warn", "no-jquery/no-each-util": "warn", + "no-jquery/no-extend": "warn", "no-jquery/no-grep": "warn", "no-jquery/no-in-array": "warn", "no-jquery/no-map-util": "warn", diff --git a/modules/twinklebatchdelete.js b/modules/twinklebatchdelete.js index 2bb2446af..257c6097c 100644 --- a/modules/twinklebatchdelete.js +++ b/modules/twinklebatchdelete.js @@ -597,7 +597,7 @@ Twinkle.batchdelete.callbacks = { unlinker.setPageList(pages); unlinker.run((pageName) => { const wikipedia_page = new Morebits.wiki.Page(pageName, 'Unlinking on ' + pageName); - const params = Object.assign({}, apiobj.params); + const params = $.extend({}, apiobj.params); params.title = pageName; params.unlinker = unlinker; wikipedia_page.setCallbackParameters(params); @@ -648,7 +648,7 @@ Twinkle.batchdelete.callbacks = { unlinker.setPageList(pages); unlinker.run((pageName) => { const wikipedia_page = new Morebits.wiki.Page(pageName, 'Removing file usages on ' + pageName); - const params = Object.assign({}, apiobj.params); + const params = $.extend({}, apiobj.params); params.title = pageName; params.unlinker = unlinker; wikipedia_page.setCallbackParameters(params); diff --git a/modules/twinklebatchprotect.js b/modules/twinklebatchprotect.js index bb0b3412f..6f745f26d 100644 --- a/modules/twinklebatchprotect.js +++ b/modules/twinklebatchprotect.js @@ -288,7 +288,7 @@ Twinkle.batchprotect.callback.evaluate = function twinklebatchprotectCallbackEva }; const wikipedia_api = new Morebits.wiki.Api('Checking if page ' + pageName + ' exists', query, Twinkle.batchprotect.callbacks.main, null, batchOperation.workerFailure); - wikipedia_api.params = Object.assign({ + wikipedia_api.params = $.extend({ page: pageName, batchOperation: batchOperation }, input); diff --git a/modules/twinkleblock.js b/modules/twinkleblock.js index 7980ae853..16c39050c 100644 --- a/modules/twinkleblock.js +++ b/modules/twinkleblock.js @@ -3,7 +3,7 @@ (function() { let api = new mw.Api(), relevantUserName, blockedUserName; -const menuFormattedNamespaces = Object.assign({}, mw.config.get('wgFormattedNamespaces')); +const menuFormattedNamespaces = $.extend({}, mw.config.get('wgFormattedNamespaces')); menuFormattedNamespaces[0] = '(Article)'; /* @@ -1899,7 +1899,7 @@ Twinkle.block.callback.issue_template = function twinkleblockCallbackIssueTempla // "talk page" of an IP range (which does not exist) const userTalkPage = 'User_talk:' + mw.config.get('wgRelevantUserName'); - const params = Object.assign(formData || {}, { + const params = $.extend(formData, { messageData: Twinkle.block.blockPresetsInfo[formData.template], reason: Twinkle.block.field_template_options.block_reason, disabletalk: Twinkle.block.field_template_options.notalk, diff --git a/modules/twinkleimage.js b/modules/twinkleimage.js index f0ffa79cc..593370098 100644 --- a/modules/twinkleimage.js +++ b/modules/twinkleimage.js @@ -212,7 +212,7 @@ Twinkle.image.callback.evaluate = function twinkleimageCallbackEvaluate(event) { const lognomination = Twinkle.getPref('logSpeedyNominations') && Twinkle.getPref('noLogOnSpeedyNomination').indexOf(csdcrit.toLowerCase()) === -1; const templatename = input.derivative ? 'dw ' + input.type : input.type; - const params = Object.assign({ + const params = $.extend({ templatename: templatename, normalized: csdcrit, lognomination: lognomination diff --git a/modules/twinklespeedy.js b/modules/twinklespeedy.js index d8d46952d..1d2a681b1 100644 --- a/modules/twinklespeedy.js +++ b/modules/twinklespeedy.js @@ -400,7 +400,7 @@ Twinkle.speedy.generateCsdList = function twinklespeedyGenerateCsdList(list, mod }; return $.map(list, (critElement) => { - const criterion = Object.assign({}, critElement); + const criterion = $.extend({}, critElement); if (mode.isMultiple) { if (criterion.hideWhenMultiple) { @@ -1068,7 +1068,7 @@ Twinkle.speedy.callbacks = { code += '|' + i + '=' + parameters[i]; } } - Object.assign(params.utparams, Twinkle.speedy.getUserTalkParameters(norm, parameters)); + $.extend(params.utparams, Twinkle.speedy.getUserTalkParameters(norm, parameters)); }); code += '}}'; } else { diff --git a/modules/twinkleunlink.js b/modules/twinkleunlink.js index c27c316db..a7a547398 100644 --- a/modules/twinkleunlink.js +++ b/modules/twinkleunlink.js @@ -121,7 +121,7 @@ Twinkle.unlink.callback.evaluate = function twinkleunlinkCallbackEvaluate(event) unlinker.run((pageName) => { const wikipedia_page = new Morebits.wiki.Page(pageName, 'Unlinking in page "' + pageName + '"'); wikipedia_page.setBotEdit(true); // unlink considered a floody operation - wikipedia_page.setCallbackParameters(Object.assign({ + wikipedia_page.setCallbackParameters($.extend({ doBacklinks: input.backlinks.indexOf(pageName) !== -1, doImageusage: input.imageusage.indexOf(pageName) !== -1 }, params)); diff --git a/modules/twinklewarn.js b/modules/twinklewarn.js index 1cef93c2c..cf0724fbd 100644 --- a/modules/twinklewarn.js +++ b/modules/twinklewarn.js @@ -1363,7 +1363,7 @@ Twinkle.warn.getTemplateProperty = function(templates, templateName, propertyNam const level = isNumberedTemplate[0]; const numberedWarnings = {}; $.each(templates.levels, (key, val) => { - Object.assign(numberedWarnings, val); + $.extend(numberedWarnings, val); }); $.each(numberedWarnings, (key) => { if (key === unNumberedTemplateName) { @@ -1376,7 +1376,7 @@ Twinkle.warn.getTemplateProperty = function(templates, templateName, propertyNam const otherWarnings = {}; $.each(templates, (key, val) => { if (key !== 'levels') { - Object.assign(otherWarnings, val); + $.extend(otherWarnings, val); } }); $.each(otherWarnings, (key) => { @@ -1469,7 +1469,7 @@ Twinkle.warn.callback.change_category = function twinklewarnCallbackChangeCatego createEntries(Twinkle.warn.messages[value], sub_group, true); break; case 'singlecombined': - var unSortedSinglets = Object.assign({}, Twinkle.warn.messages.singlenotice, Twinkle.warn.messages.singlewarn); + var unSortedSinglets = $.extend({}, Twinkle.warn.messages.singlenotice, Twinkle.warn.messages.singlewarn); var sortedSingletMessages = {}; Object.keys(unSortedSinglets).sort().forEach((key) => { sortedSingletMessages[key] = unSortedSinglets[key]; diff --git a/modules/twinklexfd.js b/modules/twinklexfd.js index 903eb4d11..59034ac58 100644 --- a/modules/twinklexfd.js +++ b/modules/twinklexfd.js @@ -1320,7 +1320,7 @@ Twinkle.xfd.callbacks = { // Tag other template/module wikipedia_otherpage.setFollowRedirect(true); - const otherParams = Object.assign({}, params); + const otherParams = $.extend({}, params); otherParams.otherTemplateName = Morebits.pageNameNorm; wikipedia_otherpage.setCallbackParameters(otherParams); wikipedia_otherpage.load(Twinkle.xfd.callbacks.tfd.taggingTemplateForMerge); diff --git a/morebits.js b/morebits.js index 206cfec32..c015ac77a 100644 --- a/morebits.js +++ b/morebits.js @@ -601,7 +601,7 @@ Morebits.quickForm.element.prototype.compute = function QuickFormElementCompute( id: id + '_' + i + '_subgroup' }); $.each(tmpgroup, (idx, el) => { - const newEl = Object.assign({}, el); + const newEl = $.extend({}, el); if (!newEl.type) { newEl.type = data.type; } @@ -758,7 +758,7 @@ Morebits.quickForm.element.prototype.compute = function QuickFormElementCompute( node = document.createElement('div'); data.inputs.forEach((subdata) => { - const cell = new Morebits.quickForm.element(Object.assign(subdata || {}, { type: '_dyninput_cell' })); + const cell = new Morebits.quickForm.element($.extend(subdata, { type: '_dyninput_cell' })); node.appendChild(cell.render()); }); if (data.remove) { @@ -2363,7 +2363,7 @@ Morebits.wiki.api.prototype = { }).join('&').replace(/^(.*?)(\btoken=[^&]*)&(.*)/, '$1$3&$2'); // token should always be the last item in the query string (bug TW-B-0013) - const ajaxparams = Object.assign({}, { + const ajaxparams = $.extend({}, { context: this, type: this.query.action === 'query' ? 'GET' : 'POST', url: mw.util.wikiScript('api'), diff --git a/twinkle.js b/twinkle.js index 4e5a4e48b..1ba4ae3c0 100644 --- a/twinkle.js +++ b/twinkle.js @@ -337,7 +337,7 @@ $.ajax({ const options = JSON.parse(optionsText); if (options) { if (options.twinkle || options.friendly) { // Old preferences format - Twinkle.prefs = Object.assign(options.twinkle || {}, options.friendly); + Twinkle.prefs = $.extend(options.twinkle, options.friendly); } else { Twinkle.prefs = options; } From 51527505fbd233a880915b7d629a9c11800b046c Mon Sep 17 00:00:00 2001 From: NovemLinguae <79697282+NovemLinguae@users.noreply.github.com> Date: Sat, 7 Dec 2024 14:11:41 -0800 Subject: [PATCH 2/2] eslint: switch camelcase and underscore dangle from off to warn (#2108) in preparation for fixing them keep the camelcase warnings off for object keys. these could be API keys or something. needs further investigation before refactoring them --- .eslintrc.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index bbcacf8ee..5f5867080 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,7 +12,6 @@ }, "rules": { "array-bracket-spacing": "off", - "camelcase": "off", "computed-property-spacing": "off", "indent": "off", "jsdoc/require-param": "off", @@ -22,7 +21,6 @@ "no-jquery/no-class-state": "off", "no-jquery/no-global-selector": "off", "no-shadow": "off", - "no-underscore-dangle": "off", "object-curly-spacing": "off", "space-before-function-paren": "off", "space-in-parens": "off", @@ -41,6 +39,7 @@ } ], + "camelcase": ["warn", {"properties": "never"}], "es-x/no-array-prototype-includes": "warn", "es-x/no-object-values": "warn", "mediawiki/class-doc": "warn", @@ -58,6 +57,7 @@ "no-return-assign": "warn", "no-script-url": "warn", "no-throw-literal": "warn", + "no-underscore-dangle": "warn", "no-unused-expressions": "warn", "no-use-before-define": "warn", "no-useless-concat": "warn",