Skip to content

Commit

Permalink
Merge branch 'master' into no-throw-literal
Browse files Browse the repository at this point in the history
  • Loading branch information
NovemLinguae authored Dec 8, 2024
2 parents 8f1796d + 69de130 commit ec7019d
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 72 deletions.
7 changes: 3 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
},
"rules": {
"array-bracket-spacing": "off",
"camelcase": "off",
"computed-property-spacing": "off",
"indent": "off",
"jsdoc/require-param": "off",
Expand All @@ -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",
Expand All @@ -41,12 +39,14 @@
}
],

"camelcase": ["warn", {"properties": "never"}],
"es-x/no-array-prototype-includes": "warn",
"es-x/no-object-values": "warn",
"mediawiki/class-doc": "warn",
"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",
Expand All @@ -56,11 +56,10 @@
"no-new": "warn",
"no-return-assign": "warn",
"no-script-url": "warn",
"no-underscore-dangle": "warn",
"no-unused-expressions": "warn",
"no-use-before-define": "warn",
"no-useless-concat": "warn",
"no-var": "warn",
"prefer-const": "warn",
"unicorn/prefer-string-slice": "warn"
}
}
10 changes: 5 additions & 5 deletions modules/twinklearv.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,19 +921,19 @@ Twinkle.arv.processAN3 = function(params) {
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) => '# ' + ' {{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');
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;
if (page.compare) {
resolvetext += '\n# ' + ' {{diff|oldid=' + page.compare.fromrevid + '|diff=' + page.compare.torevid + '|label=Consecutive edits on ' + page.compare.totitle + '}}';
resolvetext += '\n# {{diff|oldid=' + page.compare.fromrevid + '|diff=' + page.compare.torevid + '|label=Consecutive edits on ' + page.compare.totitle + '}}';
} else if (page.revisions) {
const revCount = page.revisions.length;
let rev;
if (revCount < 3) { // diff=prev or next
rev = revCount === 1 ? page.revisions[0] : page.revisions[1];
resolvetext += '\n# ' + ' {{diff2|' + rev.revid + '|' + new Morebits.Date(rev.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) on ' + page.title + '}} ' + hasHiddenComment(rev);
resolvetext += '\n# {{diff2|' + rev.revid + '|' + new Morebits.Date(rev.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) on ' + page.title + '}} ' + hasHiddenComment(rev);
} else { // diff and oldid are nonconsecutive
rev = page.revisions[0];
const revLatest = page.revisions[revCount - 1];
Expand All @@ -949,7 +949,7 @@ Twinkle.arv.processAN3 = function(params) {
comment += ' ~~~~';
}

const text = '\n\n' + '{{subst:AN3 report|diffs=' + difftext + '|warnings=' + warningtext + '|resolves=' + resolvetext + '|pagename=' + params.page + '|orig=' + origtext + '|comment=' + comment + '|uid=' + params.uid + '}}';
const text = '\n\n{{subst:AN3 report|diffs=' + difftext + '|warnings=' + warningtext + '|resolves=' + resolvetext + '|pagename=' + params.page + '|orig=' + origtext + '|comment=' + comment + '|uid=' + params.uid + '}}';

const reportpage = 'Wikipedia:Administrators\' noticeboard/Edit warring';

Expand Down
4 changes: 2 additions & 2 deletions modules/twinklebatchdelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions modules/twinklebatchprotect.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() {
pages.sort(Twinkle.sortByNamespace);
pages.forEach((page) => {
const metadata = [];
let missing = !!page.missing, editProt;
const missing = !!page.missing;
let editProt;

if (missing) {
metadata.push('page does not exist');
Expand Down Expand Up @@ -288,7 +289,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);
Expand Down
37 changes: 21 additions & 16 deletions modules/twinkleblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

(function() {

let api = new mw.Api(), relevantUserName, blockedUserName;
const menuFormattedNamespaces = Object.assign({}, mw.config.get('wgFormattedNamespaces'));
const api = new mw.Api();
let relevantUserName, blockedUserName;
const menuFormattedNamespaces = $.extend({}, mw.config.get('wgFormattedNamespaces'));
menuFormattedNamespaces[0] = '(Article)';

/*
Expand Down Expand Up @@ -156,8 +157,8 @@ Twinkle.block.fetchedData = {};
// Processes the data from a a query response, separated from
// Twinkle.block.fetchUserInfo to allow reprocessing of already-fetched data
Twinkle.block.processUserInfo = function twinkleblockProcessUserInfo(data, fn) {
let blockinfo = data.query.blocks[0],
userinfo = data.query.users[0];
let blockinfo = data.query.blocks[0];
const userinfo = data.query.users[0];
// If an IP is blocked *and* rangeblocked, the above finds
// whichever block is more recent, not necessarily correct.
// Three seems... unlikely
Expand Down Expand Up @@ -296,7 +297,8 @@ Twinkle.block.callback.change_block64 = function twinkleblockCallbackChangeBlock
};

Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction(e) {
let field_preset, field_template_options, field_block_options, $form = $(e.target.form);
let field_preset, field_template_options, field_block_options;
const $form = $(e.target.form);
// Make ifs shorter
const blockBox = $form.find('[name=actiontype][value=block]').is(':checked');
const templateBox = $form.find('[name=actiontype][value=template]').is(':checked');
Expand Down Expand Up @@ -1534,7 +1536,7 @@ Twinkle.block.callback.change_expiry = function twinkleblockCallbackChangeExpiry
Twinkle.block.seeAlsos = [];
Twinkle.block.callback.toggle_see_alsos = function twinkleblockCallbackToggleSeeAlso() {
const reason = this.form.reason.value.replace(
new RegExp('( <!--|;) ' + 'see also ' + Twinkle.block.seeAlsos.join(' and ') + '( -->)?'), ''
new RegExp('( <!--|;) see also ' + Twinkle.block.seeAlsos.join(' and ') + '( -->)?'), ''
);

Twinkle.block.seeAlsos = Twinkle.block.seeAlsos.filter((el) => el !== this.value);
Expand Down Expand Up @@ -1572,7 +1574,8 @@ Twinkle.block.callback.toggle_ds_reason = function twinkleblockCallbackToggleDSR
};

Twinkle.block.callback.update_form = function twinkleblockCallbackUpdateForm(e, data) {
let form = e.target.form, expiry = data.expiry;
const form = e.target.form;
let expiry = data.expiry;

// don't override original expiry if useInitialOptions is set
if (!data.useInitialOptions) {
Expand Down Expand Up @@ -1723,11 +1726,11 @@ Twinkle.block.callback.preview = function twinkleblockcallbackPreview(form) {
};

Twinkle.block.callback.evaluate = function twinkleblockCallbackEvaluate(e) {
let $form = $(e.target),
const $form = $(e.target),
toBlock = $form.find('[name=actiontype][value=block]').is(':checked'),
toWarn = $form.find('[name=actiontype][value=template]').is(':checked'),
toPartial = $form.find('[name=actiontype][value=partial]').is(':checked'),
blockoptions = {}, templateoptions = {};
toPartial = $form.find('[name=actiontype][value=partial]').is(':checked');
let blockoptions = {}, templateoptions = {};

Twinkle.block.callback.saveFieldset($form.find('[name=field_block_options]'));
Twinkle.block.callback.saveFieldset($form.find('[name=field_template_options]'));
Expand Down Expand Up @@ -1899,7 +1902,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,
Expand All @@ -1916,7 +1919,8 @@ Twinkle.block.callback.issue_template = function twinkleblockCallbackIssueTempla
};

Twinkle.block.callback.getBlockNoticeWikitext = function(params) {
let text = '{{', settings = Twinkle.block.blockPresetsInfo[params.template];
let text = '{{';
const settings = Twinkle.block.blockPresetsInfo[params.template];
if (!settings.nonstandard) {
text += 'subst:' + params.template;
if (params.article && settings.pageParam) {
Expand Down Expand Up @@ -1990,10 +1994,10 @@ Twinkle.block.callback.getBlockNoticeWikitext = function(params) {
};

Twinkle.block.callback.main = function twinkleblockcallbackMain(pageobj) {
let params = pageobj.getCallbackParameters(),
const params = pageobj.getCallbackParameters(),
date = new Morebits.Date(pageobj.getLoadTime()),
messageData = params.messageData,
text;
messageData = params.messageData;
let text;

params.indefinite = Morebits.string.isInfinity(params.expiry);

Expand All @@ -2003,7 +2007,8 @@ Twinkle.block.callback.main = function twinkleblockcallbackMain(pageobj) {
} else {
text = pageobj.getPageText();

let dateHeaderRegex = date.monthHeaderRegex(), dateHeaderRegexLast, dateHeaderRegexResult;
const dateHeaderRegex = date.monthHeaderRegex();
let dateHeaderRegexLast, dateHeaderRegexResult;
while ((dateHeaderRegexLast = dateHeaderRegex.exec(text)) !== null) {
dateHeaderRegexResult = dateHeaderRegexLast;
}
Expand Down
13 changes: 9 additions & 4 deletions modules/twinkleconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,8 @@ Twinkle.config.init = function twinkleconfigInit() {
}
cell = document.createElement('td');

let label, input, gotPref = Twinkle.getPref(pref.name);
let label, input;
const gotPref = Twinkle.getPref(pref.name);
switch (pref.type) {

case 'boolean': // create a checkbox
Expand Down Expand Up @@ -1295,9 +1296,11 @@ Twinkle.config.init = function twinkleconfigInit() {
// Styled in twinkle.css
box.setAttribute('id', 'twinkle-config-headerbox');

let link,
scriptPageName = mw.config.get('wgPageName').slice(mw.config.get('wgPageName').lastIndexOf('/') + 1,
mw.config.get('wgPageName').lastIndexOf('.js'));
let link;
const scriptPageName = mw.config.get('wgPageName').slice(
mw.config.get('wgPageName').lastIndexOf('/') + 1,
mw.config.get('wgPageName').lastIndexOf('.js')
);

if (scriptPageName === 'twinkleoptions') {
// place "why not try the preference panel" notice
Expand Down Expand Up @@ -1694,13 +1697,15 @@ Twinkle.config.writePrefs = function twinkleconfigWritePrefs(pageobj) {
'// changing the configuration parameters in a valid-JavaScript way) will be\n' +
'// overwritten the next time you click "save" in the Twinkle preferences\n' +
'// panel. If modifying this file, make sure to use correct JavaScript.\n' +
// eslint-disable-next-line no-useless-concat
'// <no' + 'wiki>\n' +
'\n' +
'window.Twinkle.prefs = ';
text += JSON.stringify(newConfig, null, 2);
text +=
';\n' +
'\n' +
// eslint-disable-next-line no-useless-concat
'// </no' + 'wiki>\n' +
'// End of twinkleoptions.js\n';

Expand Down
2 changes: 1 addition & 1 deletion modules/twinkleimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion modules/twinkleprotect.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ Twinkle.protect.fetchProtectionLevel = function twinkleprotectFetchProtectionLev

const pageid = protectData[0].query.pageids[0];
const page = protectData[0].query.pages[pageid];
let current = {}, adminEditDeferred;
const current = {};
let adminEditDeferred;

// Save requested page's watched status for later in case needed when filing request
Twinkle.protect.watched = page.watchlistexpiry || page.watched === '';
Expand Down
2 changes: 1 addition & 1 deletion modules/twinklerollback.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ Twinkle.rollback.addLinks = {
const warnFromTalk = function(xtitle) {
const $talkLink = $('#mw-diff-' + xtitle + '2 .mw-usertoollinks a').first();
if ($talkLink.length) {
let extraParams = 'vanarticle=' + mw.util.rawurlencode(Morebits.pageNameNorm) + '&' + 'noautowarn=true';
let extraParams = 'vanarticle=' + mw.util.rawurlencode(Morebits.pageNameNorm) + '&noautowarn=true';
// diffIDs for vanarticlerevid
extraParams += '&vanarticlerevid=';
extraParams += xtitle === 'otitle' ? mw.config.get('wgDiffOldId') : mw.config.get('wgDiffNewId');
Expand Down
15 changes: 7 additions & 8 deletions modules/twinklespeedy.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ Twinkle.speedy.hasCSD = !!$('#delete-reason').length;

// Prepares the speedy deletion dialog and displays it
Twinkle.speedy.initDialog = function twinklespeedyInitDialog(callbackfunc) {
let dialog;
Twinkle.speedy.dialog = new Morebits.SimpleWindow(Twinkle.getPref('speedyWindowWidth'), Twinkle.getPref('speedyWindowHeight'));
dialog = Twinkle.speedy.dialog;
const dialog = Twinkle.speedy.dialog;
dialog.setTitle('Choose criteria for speedy deletion');
dialog.setScriptName('Twinkle');
dialog.addFooterLink('Speedy deletion policy', 'WP:CSD');
Expand Down Expand Up @@ -400,7 +399,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) {
Expand Down Expand Up @@ -1068,7 +1067,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 {
Expand Down Expand Up @@ -1140,8 +1139,8 @@ Twinkle.speedy.callbacks = {
}

if (initialContrib) {
let usertalkpage = new Morebits.wiki.Page('User talk:' + initialContrib, 'Notifying initial contributor (' + initialContrib + ')'),
notifytext, i, editsummary;
const usertalkpage = new Morebits.wiki.Page('User talk:' + initialContrib, 'Notifying initial contributor (' + initialContrib + ')');
let notifytext, i, editsummary;

// special cases: "db" and "db-multiple"
if (params.normalizeds.length > 1) {
Expand Down Expand Up @@ -1367,8 +1366,8 @@ Twinkle.speedy.callbacks = {

// given the params, builds the template and also adds the user talk page parameters to the params that were passed in
// returns => [<string> wikitext, <object> utparams]
let buildData = Twinkle.speedy.callbacks.getTemplateCodeAndParams(params),
code = buildData[0];
const buildData = Twinkle.speedy.callbacks.getTemplateCodeAndParams(params);
let code = buildData[0];
params.utparams = buildData[1];

// Set the correct value for |ts= parameter in {{db-g13}}
Expand Down
14 changes: 8 additions & 6 deletions modules/twinkletag.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ Twinkle.tag.callback = function twinkletagCallback() {
const evt = document.createEvent('Event');
evt.initEvent('change', true, true);
result.sortorder.dispatchEvent(evt);

} else {
// Redirects and files: Add a link to each template's description page
Morebits.QuickForm.getElements(result, 'tags').forEach(generateLinks);
Expand Down Expand Up @@ -1589,7 +1588,8 @@ Twinkle.tag.callbacks = {
return;
}

let tagRe, tagText = '', tags = [], groupableTags = [], groupableExistingTags = [];
let tagRe, tagText = '', tags = [];
const groupableTags = [], groupableExistingTags = [];
// Executes first: addition of selected tags

/**
Expand Down Expand Up @@ -1806,10 +1806,12 @@ Twinkle.tag.callbacks = {
},

redirect: function redirect(pageobj) {
let params = pageobj.getCallbackParameters(),
pageText = pageobj.getPageText(),
tagRe, tagText = '', summaryText = 'Added',
tags = [], i;
const params = pageobj.getCallbackParameters(),
tags = [];
let pageText = pageobj.getPageText(),
tagRe, tagText = '',
summaryText = 'Added',
i;

for (i = 0; i < params.tags.length; i++) {
tagRe = new RegExp('(\\{\\{' + params.tags[i] + '(\\||\\}\\}))', 'im');
Expand Down
2 changes: 1 addition & 1 deletion modules/twinkletalkback.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Twinkle.talkback.noticeboards = {
},
hd: {
label: 'WP:HD (Help desk)',
text: '== Your question at the Help desk ==\n' + '{{helpdeskreply|1=$SECTION|ts=~~~~~}}',
text: '== Your question at the Help desk ==\n{{helpdeskreply|1=$SECTION|ts=~~~~~}}',
editSummary: 'You have replies at the [[Wikipedia:Help desk|Wikipedia help desk]]'
},
norn: {
Expand Down
2 changes: 1 addition & 1 deletion modules/twinkleunlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading

0 comments on commit ec7019d

Please sign in to comment.