Skip to content

Commit

Permalink
eslint: apply autofixes 3 (#2079)
Browse files Browse the repository at this point in the history
- apply all remaining autofixes with `npx eslint --fix .`
- turn off jsdoc/require-param because I didn't like the autofix. would just add params without any types or descriptions
- turn off jsdoc/require-returns for now. lots of docblocks that are just being used as comments, which is fine
  • Loading branch information
NovemLinguae authored Nov 26, 2024
1 parent b0a8d38 commit ed4296f
Show file tree
Hide file tree
Showing 17 changed files with 235 additions and 225 deletions.
8 changes: 3 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"array-bracket-spacing": "off",
"camelcase": "off",
"computed-property-spacing": "off",
"indent": "off",
"jsdoc/require-param": "off",
"jsdoc/require-returns": "off",
"max-len": "off",
"no-alert": "off",
"no-jquery/no-class-state": "off",
Expand Down Expand Up @@ -41,13 +44,10 @@

"es-x/no-array-prototype-includes": "warn",
"es-x/no-object-values": "warn",
"indent": "off",
"jsdoc/require-asterisk-prefix": "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 @@ -60,12 +60,10 @@
"no-script-url": "warn",
"no-sequences": "warn",
"no-throw-literal": "warn",
"no-unneeded-ternary": "warn",
"no-unused-expressions": "warn",
"no-use-before-define": "warn",
"no-useless-concat": "warn",
"no-var": "warn",
"operator-linebreak": "warn",
"prefer-const": "warn"
}
}
34 changes: 17 additions & 17 deletions modules/twinklearv.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,10 @@ Twinkle.arv.callback.changeCategory = function (e) {
} else {
for (let i = 0; i < page.revisions.length; ++i) {
const rev = page.revisions[i];
const $entry = $('<div/>', {
const $entry = $('<div>', {
class: 'entry'
});
const $input = $('<input/>', {
const $input = $('<input>', {
type: 'checkbox',
name: 's_' + field,
value: rev.revid
Expand All @@ -397,15 +397,15 @@ Twinkle.arv.callback.changeCategory = function (e) {

// add free form input for resolves
if (field === 'resolves') {
const $free_entry = $('<div/>', {
const $free_entry = $('<div>', {
class: 'entry'
});
const $free_input = $('<input/>', {
const $free_input = $('<input>', {
type: 'text',
name: 's_resolves_free'
});

const $free_label = $('<label/>', {
const $free_label = $('<label>', {
for: 's_resolves_free',
html: 'URL link of diff with additional discussions: '
});
Expand Down Expand Up @@ -468,11 +468,11 @@ Twinkle.arv.callback.changeCategory = function (e) {
};

Twinkle.arv.callback.evaluate = function(e) {
var form = e.target;
var reason = '';
var input = Morebits.quickForm.getInputData(form);
const form = e.target;
let reason = '';
const input = Morebits.quickForm.getInputData(form);

var uid = form.uid.value;
const uid = form.uid.value;

switch (input.category) {

Expand Down Expand Up @@ -725,8 +725,8 @@ Twinkle.arv.callback.evaluate = function(e) {
};

Twinkle.arv.callback.getAivReasonWikitext = function(input) {
var text = '';
var type = input.arvtype;
let text = '';
let type = input.arvtype;

if (!type.length && input.reason === '') {
return null;
Expand Down Expand Up @@ -763,15 +763,15 @@ Twinkle.arv.callback.getAivReasonWikitext = function(input) {
}

if (input.reason !== '') {
var textEndsInPunctuationOrBlank = /([.?!;:]|^)$/.test(text);
const textEndsInPunctuationOrBlank = /([.?!;:]|^)$/.test(text);
text += textEndsInPunctuationOrBlank ? '' : '.';
var textIsBlank = text === '';
const textIsBlank = text === '';
text += textIsBlank ? '' : ' ';
text += input.reason;
}

text = text.trim();
var textEndsInPunctuation = /[.?!;]$/.test(text);
const textEndsInPunctuation = /[.?!;]$/.test(text);
if (!textEndsInPunctuation) {
text += '.';
}
Expand All @@ -795,18 +795,18 @@ Twinkle.arv.callback.getUsernameReportWikitext = function(input) {
}

// a or an?
var adjective = 'a';
let adjective = 'a';
if (/[aeiouwyh]/.test(input.arvtype[0] || '')) { // non 100% correct, but whatever, including 'h' for Cockney
adjective = 'an';
}

var text = '*{{user-uaa|1=' + input.uid + '}} &ndash; ';
let text = '*{{user-uaa|1=' + input.uid + '}} &ndash; ';
if (input.arvtype.length) {
text += 'Violation of the username policy as ' + adjective + ' ' + input.arvtype + ' username. ';
}
if (input.reason !== '') {
text += Morebits.string.toUpperCaseFirstChar(input.reason);
var endsInPeriod = /\.$/.test(input.reason);
const endsInPeriod = /\.$/.test(input.reason);
if (!endsInPeriod) {
text += '.';
}
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 = $.extend({}, apiobj.params);
const params = Object.assign({}, 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 = $.extend({}, apiobj.params);
const params = Object.assign({}, apiobj.params);
params.title = pageName;
params.unlinker = unlinker;
wikipedia_page.setCallbackParameters(params);
Expand Down
2 changes: 1 addition & 1 deletion modules/twinklebatchprotect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $.extend({
wikipedia_api.params = Object.assign({
page: pageName,
batchOperation: batchOperation
}, input);
Expand Down
4 changes: 2 additions & 2 deletions modules/twinkleblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(function($) {

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

/*
Expand Down Expand Up @@ -1897,7 +1897,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 = $.extend(formData, {
const params = Object.assign(formData, {
messageData: Twinkle.block.blockPresetsInfo[formData.template],
reason: Twinkle.block.field_template_options.block_reason,
disabletalk: Twinkle.block.field_template_options.notalk,
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 = $.extend({
const params = Object.assign({
templatename: templatename,
normalized: csdcrit,
lognomination: lognomination
Expand Down
10 changes: 5 additions & 5 deletions modules/twinklerollback.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

/**
Twinklerollback revert and antivandalism utility
* Twinklerollback revert and antivandalism utility
*/

Twinkle.rollback = function twinklerollback() {
Expand Down Expand Up @@ -118,12 +118,12 @@ Twinkle.rollback.linkBuilder = {
normLink.style.fontWeight = 'bold';
vandLink.style.fontWeight = 'bold';

$(normLink).click((e) => {
$(normLink).on('click', (e) => {
e.preventDefault();
Twinkle.rollback.revert('norm', vandal, rev, page);
Twinkle.rollback.disableLinks(revNode);
});
$(vandLink).click((e) => {
$(vandLink).on('click', (e) => {
e.preventDefault();
Twinkle.rollback.revert('vand', vandal, rev, page);
Twinkle.rollback.disableLinks(revNode);
Expand All @@ -141,7 +141,7 @@ Twinkle.rollback.linkBuilder = {
if (!inline) {
const agfNode = document.createElement('span');
const agfLink = Twinkle.rollback.linkBuilder.buildLink('DarkOliveGreen', 'rollback (AGF)');
$(agfLink).click((e) => {
$(agfLink).on('click', (e) => {
e.preventDefault();
Twinkle.rollback.revert('agf', vandal, rev, page);
// Twinkle.rollback.disableLinks(revNode); // rollbackInPlace not relevant for any inline situations
Expand Down Expand Up @@ -170,7 +170,7 @@ Twinkle.rollback.linkBuilder = {
revertToRevisionNode.style.fontWeight = 'bold';

const revertToRevisionLink = Twinkle.rollback.linkBuilder.buildLink('SaddleBrown', 'restore this version');
$(revertToRevisionLink).click((e) => {
$(revertToRevisionLink).on('click', (e) => {
e.preventDefault();
Twinkle.rollback.revertToRevision(revisionRef);
});
Expand Down
4 changes: 2 additions & 2 deletions modules/twinkleshared.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Twinkle.shared.callback = function twinklesharedCallback() {
);

const previewlink = document.createElement('a');
$(previewlink).click(() => {
$(previewlink).on('click', () => {
Twinkle.shared.preview(result);
});
previewlink.style.cursor = 'pointer';
Expand Down Expand Up @@ -187,7 +187,7 @@ Twinkle.shared.preview = function(form) {

previewDialog.display();

$(submit).click(() => {
$(submit).on('click', () => {
previewDialog.close();
});
}
Expand Down
14 changes: 7 additions & 7 deletions modules/twinklespeedy.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ Twinkle.speedy.generateCsdList = function twinklespeedyGenerateCsdList(list, mod
};

return $.map(list, (critElement) => {
const criterion = $.extend({}, critElement);
const criterion = Object.assign({}, critElement);

if (mode.isMultiple) {
if (criterion.hideWhenMultiple) {
Expand Down Expand Up @@ -1068,7 +1068,7 @@ Twinkle.speedy.callbacks = {
code += '|' + i + '=' + parameters[i];
}
}
$.extend(params.utparams, Twinkle.speedy.getUserTalkParameters(norm, parameters));
Object.assign(params.utparams, Twinkle.speedy.getUserTalkParameters(norm, parameters));
});
code += '}}';
} else {
Expand Down Expand Up @@ -1285,7 +1285,7 @@ Twinkle.speedy.callbacks = {
// promote Unlink tool
let $link, $bigtext;
if (mw.config.get('wgNamespaceNumber') === 6 && params.normalized !== 'f8') {
$link = $('<a/>', {
$link = $('<a>', {
href: '#',
text: 'click here to go to the Unlink tool',
css: { fontSize: '130%', fontWeight: 'bold' },
Expand All @@ -1295,13 +1295,13 @@ Twinkle.speedy.callbacks = {
Twinkle.unlink.callback('Removing usages of and/or links to deleted file ' + Morebits.pageNameNorm);
}
});
$bigtext = $('<span/>', {
$bigtext = $('<span>', {
text: 'To orphan backlinks and remove instances of file usage',
css: { fontSize: '130%', fontWeight: 'bold' }
});
Morebits.status.info($bigtext[0], $link[0]);
} else if (params.normalized !== 'f8') {
$link = $('<a/>', {
$link = $('<a>', {
href: '#',
text: 'click here to go to the Unlink tool',
css: { fontSize: '130%', fontWeight: 'bold' },
Expand All @@ -1311,7 +1311,7 @@ Twinkle.speedy.callbacks = {
Twinkle.unlink.callback('Removing links to deleted page ' + Morebits.pageNameNorm);
}
});
$bigtext = $('<span/>', {
$bigtext = $('<span>', {
text: 'To orphan backlinks',
css: { fontSize: '130%', fontWeight: 'bold' }
});
Expand Down Expand Up @@ -1862,7 +1862,7 @@ Twinkle.speedy.getUserTalkParameters = function twinklespeedyGetUserTalkParamete

/**
* @param {Event} e
* @returns {Array}
* @return {Array}
*/
Twinkle.speedy.resolveCsdValues = function twinklespeedyResolveCsdValues(e) {
const values = (e.target.form ? e.target.form : e.target).getChecked('csd');
Expand Down
4 changes: 3 additions & 1 deletion modules/twinkletag.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ Twinkle.tag.updateSortOrder = function(e) {

// tally tags added/removed, update statusNode text
const statusNode = document.getElementById('tw-tag-status');
$('[name=tags], [name=existingTags]').click(function() {
$('[name=tags], [name=existingTags]').on('click', function() {
if (this.name === 'tags') {
Twinkle.tag.status.numAdded += this.checked ? 1 : -1;
} else if (this.name === 'existingTags') {
Expand All @@ -505,6 +505,7 @@ Twinkle.tag.updateSortOrder = function(e) {

/**
* Adds a link to each template's description page
*
* @param {Morebits.quickForm.element} checkbox associated with the template
*/
var generateLinks = function(checkbox) {
Expand Down Expand Up @@ -1593,6 +1594,7 @@ Twinkle.tag.callbacks = {

/**
* Updates `tagText` with the syntax of `tagName` template with its parameters
*
* @param {number} tagIndex
* @param {string} tagName
*/
Expand Down
2 changes: 1 addition & 1 deletion modules/twinkletalkback.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Twinkle.talkback.callback = function() {
});

const previewlink = document.createElement('a');
$(previewlink).click(() => {
$(previewlink).on('click', () => {
Twinkle.talkback.callbacks.preview(result); // |result| is defined below
});
previewlink.style.cursor = 'pointer';
Expand Down
4 changes: 2 additions & 2 deletions modules/twinkleunlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Twinkle.unlink.callback = function(presetReason) {
type: 'input',
name: 'reason',
label: 'Reason:',
value: presetReason ? presetReason : '',
value: presetReason || '',
size: 60
});

Expand Down 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($.extend({
wikipedia_page.setCallbackParameters(Object.assign({
doBacklinks: input.backlinks.indexOf(pageName) !== -1,
doImageusage: input.imageusage.indexOf(pageName) !== -1
}, params));
Expand Down
Loading

0 comments on commit ed4296f

Please sign in to comment.