Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into merge-changes-ups…
Browse files Browse the repository at this point in the history
…tream
  • Loading branch information
mdaniels5757 committed Dec 14, 2024
2 parents 9d763f9 + 58828bd commit 2411a78
Show file tree
Hide file tree
Showing 23 changed files with 253 additions and 200 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
scripts/
tests/
lib/
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"rules": {
"array-bracket-spacing": "off",
"computed-property-spacing": "off",
"es-x/no-array-prototype-includes": "off",
"indent": "off",
"jsdoc/require-param": "off",
"jsdoc/require-returns": "off",
Expand All @@ -38,9 +39,9 @@
"selector": "MemberExpression > Identifier[name=\"fail\"]"
}
],
"unicorn/prefer-includes": "error",

"camelcase": ["warn", {"properties": "never"}],
"es-x/no-array-prototype-includes": "warn",
"es-x/no-object-values": "warn",
"mediawiki/class-doc": "warn",
"new-cap": "warn",
Expand Down
2 changes: 1 addition & 1 deletion modules/twinklebatchdelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Twinkle.batchdelete.callback.toggleSubpages = function twDbatchToggleSubpages(e)
const pageTitle = mw.Title.newFromText(pageName);

// No need to look for subpages in main/file/mediawiki space
if ([0, 6, 8].indexOf(pageTitle.namespace) > -1) {
if ([0, 6, 8].includes(pageTitle.namespace)) {
subpageLister.workerSuccess();
return;
}
Expand Down
8 changes: 4 additions & 4 deletions modules/twinkleconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,12 +753,12 @@ Twinkle.config.init = function twinkleconfigInit() {
check.setAttribute('type', 'checkbox');
check.setAttribute('id', pref.name + '_' + itemkey);
check.setAttribute('name', pref.name + '_' + itemkey);
if (gotPref && gotPref.indexOf(itemkey) !== -1) {
if (gotPref && gotPref.includes(itemkey)) {
check.setAttribute('checked', 'checked');
}
// cater for legacy integer array values for unlinkNamespaces (this can be removed a few years down the track...)
if (pref.name === 'unlinkNamespaces') {
if (gotPref && gotPref.indexOf(parseInt(itemkey, 10)) !== -1) {
if (gotPref && gotPref.includes(parseInt(itemkey, 10))) {
check.setAttribute('checked', 'checked');
}
}
Expand Down Expand Up @@ -896,7 +896,7 @@ Twinkle.config.init = function twinkleconfigInit() {
box.appendChild(document.createTextNode(', or by editing this page.'));
$(box).insertAfter($('#contentSub'));

} else if (['monobook', 'vector', 'vector-2022', 'cologneblue', 'modern', 'timeless', 'minerva', 'common'].indexOf(scriptPageName) !== -1) {
} else if (['monobook', 'vector', 'vector-2022', 'cologneblue', 'modern', 'timeless', 'minerva', 'common'].includes(scriptPageName)) {
// place "Looking for Twinkle options?" notice
box.setAttribute('class', 'config-userskin-box');

Expand Down Expand Up @@ -1119,7 +1119,7 @@ Twinkle.config.resetPref = function twinkleconfigResetPref(pref) {
case 'set':
$.each(pref.setValues, (itemkey) => {
if (document.getElementById(pref.name + '_' + itemkey)) {
document.getElementById(pref.name + '_' + itemkey).checked = Twinkle.defaultConfig[pref.name].indexOf(itemkey) !== -1;
document.getElementById(pref.name + '_' + itemkey).checked = Twinkle.defaultConfig[pref.name].includes(itemkey);
}
});
break;
Expand Down
2 changes: 1 addition & 1 deletion modules/twinkleimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Twinkle.image.callback.evaluate = function twinkleimageCallbackEvaluate(event) {
throw new Error('Twinkle.image.callback.evaluate: unknown criterion');
}

const lognomination = Twinkle.getPref('logSpeedyNominations') && Twinkle.getPref('noLogOnSpeedyNomination').indexOf(csdcrit.toLowerCase()) === -1;
const lognomination = Twinkle.getPref('logSpeedyNominations') && !Twinkle.getPref('noLogOnSpeedyNomination').includes(csdcrit.toLowerCase());
const templatename = input.derivative ? 'dw ' + input.type : input.type;

const params = $.extend({
Expand Down
28 changes: 14 additions & 14 deletions modules/twinklerollback.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ Twinkle.rollback.addLinks = {
if (mw.config.exists('wgRelevantUserName') || isRange) {
// Get the username these contributions are for
let username = mw.config.get('wgRelevantUserName');
if (Twinkle.getPref('showRollbackLinks').indexOf('contribs') !== -1 ||
(mw.config.get('wgUserName') !== username && Twinkle.getPref('showRollbackLinks').indexOf('others') !== -1) ||
(mw.config.get('wgUserName') === username && Twinkle.getPref('showRollbackLinks').indexOf('mine') !== -1)) {
if (Twinkle.getPref('showRollbackLinks').includes('contribs') ||
(mw.config.get('wgUserName') !== username && Twinkle.getPref('showRollbackLinks').includes('others')) ||
(mw.config.get('wgUserName') === username && Twinkle.getPref('showRollbackLinks').includes('mine'))) {
const $list = $('#mw-content-text').find('ul li:has(span.mw-uctop):has(.mw-changeslist-diff)');

$list.each((key, current) => {
Expand All @@ -218,7 +218,7 @@ Twinkle.rollback.addLinks = {
},

recentchanges: function() {
if (Twinkle.getPref('showRollbackLinks').indexOf('recent') !== -1) {
if (Twinkle.getPref('showRollbackLinks').includes('recent')) {
// Latest and revertable (not page creations, logs, categorizations, etc.)
let $list = $('.mw-changeslist .mw-changeslist-last.mw-changeslist-src-mw-edit');
// Exclude top-level header if "group changes" preference is used
Expand All @@ -238,7 +238,7 @@ Twinkle.rollback.addLinks = {
},

history: function() {
if (Twinkle.getPref('showRollbackLinks').indexOf('history') !== -1) {
if (Twinkle.getPref('showRollbackLinks').includes('history')) {
// All revs
const histList = $('#pagehistory li').toArray();

Expand Down Expand Up @@ -286,7 +286,7 @@ Twinkle.rollback.addLinks = {
extraParams += xtitle === 'otitle' ? mw.config.get('wgDiffOldId') : mw.config.get('wgDiffNewId');

const href = $talkLink.attr('href');
if (href.indexOf('?') === -1) {
if (!href.includes('?')) {
$talkLink.attr('href', href + '?' + extraParams);
} else {
$talkLink.attr('href', href + '&' + extraParams);
Expand All @@ -311,7 +311,7 @@ Twinkle.rollback.addLinks = {
// Not latest revision, add [restore this revision] link to newer revision
const newTitle = document.getElementById('mw-diff-ntitle1').parentNode;
newTitle.insertBefore(Twinkle.rollback.linkBuilder.restoreThisRevisionLink('wgDiffNewId'), newTitle.firstChild);
} else if (Twinkle.getPref('showRollbackLinks').indexOf('diff') !== -1 && mw.config.get('wgDiffOldId') && (mw.config.get('wgDiffOldId') !== mw.config.get('wgDiffNewId') || document.getElementById('differences-prevlink'))) {
} else if (Twinkle.getPref('showRollbackLinks').includes('diff') && mw.config.get('wgDiffOldId') && (mw.config.get('wgDiffOldId') !== mw.config.get('wgDiffNewId') || document.getElementById('differences-prevlink'))) {
// Normally .mw-userlink is a link, but if the
// username is hidden, it will be a span with
// .history-deleted as well. When a sysop views the
Expand Down Expand Up @@ -459,11 +459,11 @@ Twinkle.rollback.callbacks = {
undoafter: revertToRevID,
basetimestamp: touched,
starttimestamp: loadtimestamp,
minor: Twinkle.getPref('markRevertedPagesAsMinor').indexOf('torev') !== -1 ? true : undefined,
minor: Twinkle.getPref('markRevertedPagesAsMinor').includes('torev') ? true : undefined,
format: 'json'
};
// Handle watching, possible expiry
if (Twinkle.getPref('watchRevertedPages').indexOf('torev') !== -1) {
if (Twinkle.getPref('watchRevertedPages').includes('torev')) {
const watchOrExpiry = Twinkle.getPref('watchRevertedExpiry');

if (!watchOrExpiry || watchOrExpiry === 'no') {
Expand Down Expand Up @@ -541,7 +541,7 @@ Twinkle.rollback.callbacks = {
} else if (params.type === 'vand' &&
// Okay to test on user since it will either fail or sysop will correctly access it
// Besides, none of the trusted bots are going to be revdel'd
Twinkle.rollback.trustedBots.indexOf(top.user) !== -1 && revs.length > 1 &&
Twinkle.rollback.trustedBots.includes(top.user) && revs.length > 1 &&
revs[1].revid === params.revid) {
Morebits.Status.info('Info', [ 'Latest revision was made by ', Morebits.htmlNode('strong', lastuser), ', a trusted bot, and the revision before was made by our vandal, so we will proceed with the revert.' ]);
index = 2;
Expand All @@ -557,7 +557,7 @@ Twinkle.rollback.callbacks = {
userNorm = params.user || Twinkle.rollback.hiddenName;
}

if (Twinkle.rollback.trustedBots.indexOf(params.user) !== -1) {
if (Twinkle.rollback.trustedBots.includes(params.user)) {
switch (params.type) {
case 'vand':
Morebits.Status.info('Info', [ 'Vandalism revert was chosen on ', Morebits.htmlNode('strong', userNorm), '. As this is a trusted bot, we assume you wanted to revert vandalism made by the previous user instead.' ]);
Expand Down Expand Up @@ -685,7 +685,7 @@ Twinkle.rollback.callbacks = {
}

// Decide whether to notify the user on success
if (!Twinkle.rollback.skipTalk && Twinkle.getPref('openTalkPage').indexOf(params.type) !== -1 &&
if (!Twinkle.rollback.skipTalk && Twinkle.getPref('openTalkPage').includes(params.type) &&
!params.userHidden && mw.config.get('wgUserName') !== params.user) {
params.notifyUser = true;
// Pass along to the warn module
Expand All @@ -712,11 +712,11 @@ Twinkle.rollback.callbacks = {
undoafter: params.goodid,
basetimestamp: touched,
starttimestamp: loadtimestamp,
minor: Twinkle.getPref('markRevertedPagesAsMinor').indexOf(params.type) !== -1 ? true : undefined,
minor: Twinkle.getPref('markRevertedPagesAsMinor').includes(params.type) ? true : undefined,
format: 'json'
};
// Handle watching, possible expiry
if (Twinkle.getPref('watchRevertedPages').indexOf(params.type) !== -1) {
if (Twinkle.getPref('watchRevertedPages').includes(params.type)) {
const watchOrExpiry = Twinkle.getPref('watchRevertedExpiry');

if (!watchOrExpiry || watchOrExpiry === 'no') {
Expand Down
32 changes: 16 additions & 16 deletions modules/twinklespeedy.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,10 @@ Twinkle.speedy.generateCsdList = function twinklespeedyGenerateCsdList(list, mod
return null;
}

if (criterion.showInNamespaces && criterion.showInNamespaces.indexOf(pageNamespace) < 0) {
if (criterion.showInNamespaces && !criterion.showInNamespaces.includes(pageNamespace)) {
return null;
}
if (criterion.hideInNamespaces && criterion.hideInNamespaces.indexOf(pageNamespace) > -1) {
if (criterion.hideInNamespaces && criterion.hideInNamespaces.includes(pageNamespace)) {
return null;
}

Expand Down Expand Up @@ -728,7 +728,7 @@ Twinkle.speedy.userList = [
tooltip:
'User requested deletion of their own user page or user-subpage. User pages that are blanked by the user may also be deleted under this criterion.',
subgroup:
mw.config.get('wgNamespaceNumber') === 3 && mw.config.get('wgTitle').indexOf('/') === -1 ? {
mw.config.get('wgNamespaceNumber') === 3 && !mw.config.get('wgTitle').includes('/') ? {
name: 'userreq_rationale',
parameter: '2',
type: 'input',
Expand Down Expand Up @@ -1283,12 +1283,12 @@ Twinkle.speedy.callbacks = {
params.utparams = buildData[1];

// Set the correct value for |ts= parameter in {{db-g13}}
if (params.normalizeds.indexOf('g13') !== -1) {
if (params.normalizeds.includes('g13')) {
code = code.replace('$TIMESTAMP', pageobj.getLastEditTime());
}

// Tag if possible, post on talk if not
if (pageobj.canEdit() && ['wikitext', 'Scribunto', 'javascript', 'css', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1 && mw.config.get('wgNamespaceNumber') !== 710 /* TimedText */) {
if (pageobj.canEdit() && ['wikitext', 'Scribunto', 'javascript', 'css', 'sanitized-css'].includes(pageobj.getContentModel()) && mw.config.get('wgNamespaceNumber') !== 710 /* TimedText */) {
let text = pageobj.getPageText();

statelem.status('Checking for tags on the page...');
Expand Down Expand Up @@ -1326,11 +1326,11 @@ Twinkle.speedy.callbacks = {
if (mw.config.get('wgPageContentModel') === 'Scribunto') {
// Scribunto isn't parsed like wikitext, so CSD templates on modules need special handling to work
let equals = '';
while (code.indexOf(']' + equals + ']') !== -1) {
while (code.includes(']' + equals + ']')) {
equals += '=';
}
code = "require('Module:Module wikitext')._addText([" + equals + '[' + code + ']' + equals + ']);';
} else if (['javascript', 'css', 'sanitized-css'].indexOf(mw.config.get('wgPageContentModel')) !== -1) {
} else if (['javascript', 'css', 'sanitized-css'].includes(mw.config.get('wgPageContentModel'))) {
// Likewise for JS/CSS pages
code = '/* ' + code + ' */';
}
Expand All @@ -1351,7 +1351,7 @@ Twinkle.speedy.callbacks = {
}

// Blank attack pages
if (params.normalizeds.indexOf('g10') !== -1) {
if (params.normalizeds.includes('g10')) {
text = code;
} else {
// Insert tag after short description or any hatnotes
Expand Down Expand Up @@ -1778,18 +1778,18 @@ Twinkle.speedy.callback.evaluateSysop = function twinklespeedyCallbackEvaluateSy
// analyse each criterion to determine whether to watch the page, prompt for summary, or notify the creator
let watchPage, promptForSummary;
normalizeds.forEach((norm) => {
if (Twinkle.getPref('watchSpeedyPages').indexOf(norm) !== -1) {
if (Twinkle.getPref('watchSpeedyPages').includes(norm)) {
watchPage = Twinkle.getPref('watchSpeedyExpiry');
}
if (Twinkle.getPref('promptForSpeedyDeletionSummary').indexOf(norm) !== -1) {
if (Twinkle.getPref('promptForSpeedyDeletionSummary').includes(norm)) {
promptForSummary = true;
}
});

const warnusertalk = form.warnusertalk.checked && normalizeds.some((norm, index) => Twinkle.getPref('warnUserOnSpeedyDelete').indexOf(norm) !== -1 &&
const warnusertalk = form.warnusertalk.checked && normalizeds.some((norm, index) => Twinkle.getPref('warnUserOnSpeedyDelete').includes(norm) &&
!(norm === 'g6' && values[index] !== 'copypaste'));

const welcomeuser = warnusertalk && normalizeds.some((norm) => Twinkle.getPref('welcomeUserOnSpeedyDeletionNotification').indexOf(norm) !== -1);
const welcomeuser = warnusertalk && normalizeds.some((norm) => Twinkle.getPref('welcomeUserOnSpeedyDeletionNotification').includes(norm));

const params = {
values: values,
Expand Down Expand Up @@ -1831,12 +1831,12 @@ Twinkle.speedy.callback.evaluateUser = function twinklespeedyCallbackEvaluateUse
const normalizeds = values.map((value) => Twinkle.speedy.normalizeHash[value]);

// analyse each criterion to determine whether to watch the page/notify the creator
const watchPage = normalizeds.some((csdCriteria) => Twinkle.getPref('watchSpeedyPages').indexOf(csdCriteria) !== -1) && Twinkle.getPref('watchSpeedyExpiry');
const watchPage = normalizeds.some((csdCriteria) => Twinkle.getPref('watchSpeedyPages').includes(csdCriteria)) && Twinkle.getPref('watchSpeedyExpiry');

const notifyuser = form.notify.checked && normalizeds.some((norm, index) => Twinkle.getPref('notifyUserOnSpeedyDeletionNomination').indexOf(norm) !== -1 &&
const notifyuser = form.notify.checked && normalizeds.some((norm, index) => Twinkle.getPref('notifyUserOnSpeedyDeletionNomination').includes(norm) &&
!(norm === 'g6' && values[index] !== 'copypaste'));
const welcomeuser = notifyuser && normalizeds.some((norm) => Twinkle.getPref('welcomeUserOnSpeedyDeletionNotification').indexOf(norm) !== -1);
const csdlog = Twinkle.getPref('logSpeedyNominations') && normalizeds.some((norm) => Twinkle.getPref('noLogOnSpeedyNomination').indexOf(norm) === -1);
const welcomeuser = notifyuser && normalizeds.some((norm) => Twinkle.getPref('welcomeUserOnSpeedyDeletionNotification').includes(norm));
const csdlog = Twinkle.getPref('logSpeedyNominations') && normalizeds.some((norm) => !Twinkle.getPref('noLogOnSpeedyNomination').includes(norm));

const params = {
values: values,
Expand Down
4 changes: 2 additions & 2 deletions modules/twinkleunlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ Twinkle.unlink.callback.evaluate = function twinkleunlinkCallbackEvaluate(event)
const wikipedia_page = new Morebits.wiki.Page(pageName, 'Unlinking in page "' + pageName + '"');
wikipedia_page.setBotEdit(true); // unlink considered a floody operation
wikipedia_page.setCallbackParameters($.extend({
doBacklinks: input.backlinks.indexOf(pageName) !== -1,
doImageusage: input.imageusage.indexOf(pageName) !== -1
doBacklinks: input.backlinks.includes(pageName),
doImageusage: input.imageusage.includes(pageName)
}, params));
wikipedia_page.load(Twinkle.unlink.callbacks.unlinkBacklinks);
});
Expand Down
Loading

0 comments on commit 2411a78

Please sign in to comment.