Skip to content

Commit

Permalink
eslint: apply autofixes 2 (wikimedia-gadgets#2069)
Browse files Browse the repository at this point in the history
* turn off no-alert. lots of alerts in Twinkle

* no-multiple-empty-lines

* no-multiple-empty-lines

* no-multi-spaces

* quote-props

* dot-location

* new-parens
  • Loading branch information
NovemLinguae authored Nov 25, 2024
1 parent 93d287e commit 3aa633a
Show file tree
Hide file tree
Showing 23 changed files with 301 additions and 443 deletions.
9 changes: 2 additions & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"camelcase": "off",
"computed-property-spacing": "off",
"max-len": "off",
"no-alert": "off",
"no-jquery/no-class-state": "off",
"no-jquery/no-global-selector": "off",
"no-shadow": "off",
Expand All @@ -38,15 +39,12 @@
}
],

"dot-location": "warn",
"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",
"new-parens": "warn",
"no-alert": "warn",
"no-jquery/no-constructor-attributes": "warn",
"no-jquery/no-each-util": "warn",
"no-jquery/no-extend": "warn",
Expand All @@ -57,8 +55,6 @@
"no-jquery/no-sizzle": "warn",
"no-jquery/variable-pattern": "warn",
"no-loop-func": "warn",
"no-multi-spaces": "warn",
"no-multiple-empty-lines": "warn",
"no-new": "warn",
"no-return-assign": "warn",
"no-script-url": "warn",
Expand All @@ -70,7 +66,6 @@
"no-useless-concat": "warn",
"no-var": "warn",
"operator-linebreak": "warn",
"prefer-const": "warn",
"quote-props": "warn"
"prefer-const": "warn"
}
}
12 changes: 4 additions & 8 deletions modules/twinklearv.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// <nowiki>


(function($) {


/*
****************************************
*** twinklearv.js: ARV module
Expand Down Expand Up @@ -125,7 +123,6 @@ Twinkle.arv.callback = function (uid, isIP) {
}
})).post();


// We must init the
const evt = document.createEvent('Event');
evt.initEvent('change', true, true);
Expand Down Expand Up @@ -780,7 +777,7 @@ Twinkle.arv.callback.getAivReasonWikitext = function(input) {
}

text += ' ~~~~';
text = text.replace(/\r?\n/g, '\n*:'); // indent newlines
text = text.replace(/\r?\n/g, '\n*:'); // indent newlines

return text;
};
Expand Down Expand Up @@ -816,7 +813,7 @@ Twinkle.arv.callback.getUsernameReportWikitext = function(input) {
text += ' ';
}
text += '~~~~';
text = text.replace(/\r?\n/g, '\n*:'); // indent newlines
text = text.replace(/\r?\n/g, '\n*:'); // indent newlines

return text;
};
Expand Down Expand Up @@ -846,7 +843,7 @@ Twinkle.arv.processSock = function(params) {
spiPage.setWatchlist(Twinkle.getPref('spiWatchReport'));
spiPage.append();

Morebits.wiki.removeCheckpoint(); // all page updates have been started
Morebits.wiki.removeCheckpoint(); // all page updates have been started
};

Twinkle.arv.processAN3 = function(params) {
Expand Down Expand Up @@ -976,7 +973,7 @@ Twinkle.arv.processAN3 = function(params) {
talkPage.setChangeTags(Twinkle.changeTags);
talkPage.setAppendText(notifyText);
talkPage.append();
Morebits.wiki.removeCheckpoint(); // all page updates have been started
Morebits.wiki.removeCheckpoint(); // all page updates have been started
}).fail((data) => {
console.log('API failed :(', data); // eslint-disable-line no-console
});
Expand All @@ -985,5 +982,4 @@ Twinkle.arv.processAN3 = function(params) {
Twinkle.addInitCallback(Twinkle.arv, 'arv');
}(jQuery));


// </nowiki>
9 changes: 3 additions & 6 deletions modules/twinklebatchdelete.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// <nowiki>


(function($) {


/*
****************************************
*** twinklebatchdelete.js: Batch delete module (sysops only)
Expand Down Expand Up @@ -141,7 +139,7 @@ Twinkle.batchdelete.callback = function twinklebatchdeleteCallback() {
const titleSplit = pathSplit[3].split(':');
query.gapnamespace = mw.config.get('wgNamespaceIds')[titleSplit[0].toLowerCase()];
if (titleSplit.length < 2 || typeof query.gapnamespace === 'undefined') {
query.gapnamespace = 0; // article namespace
query.gapnamespace = 0; // article namespace
query.gapprefix = pathSplit.splice(3).join('/');
} else {
pathSplit = pathSplit.splice(4);
Expand All @@ -158,7 +156,7 @@ Twinkle.batchdelete.callback = function twinklebatchdeleteCallback() {
}

const statusdiv = document.createElement('div');
statusdiv.style.padding = '15px'; // just so it doesn't look broken
statusdiv.style.padding = '15px'; // just so it doesn't look broken
Window.setContent(statusdiv);
Morebits.status.init(statusdiv);
Window.display();
Expand Down Expand Up @@ -541,7 +539,7 @@ Twinkle.batchdelete.callbacks = {
if (params.delete_talk) {
const pageTitle = mw.Title.newFromText(params.page);
if (pageTitle && pageTitle.namespace % 2 === 0 && pageTitle.namespace !== 2) {
pageTitle.namespace++; // now pageTitle is the talk page title!
pageTitle.namespace++; // now pageTitle is the talk page title!
query = {
action: 'query',
titles: pageTitle.toText(),
Expand Down Expand Up @@ -694,5 +692,4 @@ Twinkle.batchdelete.callbacks = {
Twinkle.addInitCallback(Twinkle.batchdelete, 'batchdelete');
}(jQuery));


// </nowiki>
10 changes: 3 additions & 7 deletions modules/twinklebatchprotect.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// <nowiki>


(function($) {


/*
****************************************
*** twinklebatchprotect.js: Batch protect module (sysops only)
Expand All @@ -13,7 +11,6 @@
* non-existing categories; Special:PrefixIndex
*/


Twinkle.batchprotect = function twinklebatchprotect() {
if (Morebits.userIsSysop && ((mw.config.get('wgArticleId') > 0 && (mw.config.get('wgNamespaceNumber') === 2 ||
mw.config.get('wgNamespaceNumber') === 4)) || mw.config.get('wgNamespaceNumber') === 14 ||
Expand Down Expand Up @@ -135,7 +132,7 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() {

form.append({
type: 'header',
label: '' // horizontal rule
label: '' // horizontal rule
});
form.append({
type: 'input',
Expand All @@ -153,7 +150,7 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() {
format: 'json'
};

if (mw.config.get('wgNamespaceNumber') === 14) { // categories
if (mw.config.get('wgNamespaceNumber') === 14) { // categories
query.generator = 'categorymembers';
query.gcmtitle = mw.config.get('wgPageName');
query.gcmlimit = Twinkle.getPref('batchMax');
Expand All @@ -169,7 +166,7 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() {
}

const statusdiv = document.createElement('div');
statusdiv.style.padding = '15px'; // just so it doesn't look broken
statusdiv.style.padding = '15px'; // just so it doesn't look broken
Window.setContent(statusdiv);
Morebits.status.init(statusdiv);
Window.display();
Expand Down Expand Up @@ -338,5 +335,4 @@ Twinkle.batchprotect.callbacks = {
Twinkle.addInitCallback(Twinkle.batchprotect, 'batchprotect');
}(jQuery));


// </nowiki>
6 changes: 1 addition & 5 deletions modules/twinklebatchundelete.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// <nowiki>


(function($) {


/*
****************************************
*** twinklebatchundelete.js: Batch undelete module
Expand All @@ -12,7 +10,6 @@
* Active on: Existing user and project pages
*/


Twinkle.batchundelete = function twinklebatchundelete() {
if (!Morebits.userIsSysop || !mw.config.get('wgArticleId') || (
mw.config.get('wgNamespaceNumber') !== mw.config.get('wgNamespaceIds').user &&
Expand Down Expand Up @@ -49,7 +46,7 @@ Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() {
});

const statusdiv = document.createElement('div');
statusdiv.style.padding = '15px'; // just so it doesn't look broken
statusdiv.style.padding = '15px'; // just so it doesn't look broken
Window.setContent(statusdiv);
Morebits.status.init(statusdiv);
Window.display();
Expand Down Expand Up @@ -209,5 +206,4 @@ Twinkle.batchundelete.callbacks = {
Twinkle.addInitCallback(Twinkle.batchundelete, 'batchundelete');
}(jQuery));


// </nowiki>
19 changes: 7 additions & 12 deletions modules/twinkleblock.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// <nowiki>


(function($) {

let api = new mw.Api(), relevantUserName, blockedUserName;
Expand Down Expand Up @@ -639,7 +638,6 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction
oldfield.parentNode.replaceChild(field_block_options.render(), oldfield);
$form.find('fieldset[name="field_64"]').show();


$form.find('[name=pagerestrictions]').select2({
theme: 'default select2-morebits',
width: '100%',
Expand Down Expand Up @@ -754,7 +752,6 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction
statusStr += ' (expires ' + new Morebits.date(Twinkle.block.currentBlockInfo.expiry).calendar('utc') + ')';
}


let infoStr = 'This form will';
if (sameUser) {
infoStr += ' change that block';
Expand Down Expand Up @@ -831,7 +828,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction
* To disable, set 'hardblock' and 'disabletalk', respectively
*/
Twinkle.block.blockPresetsInfo = {
'anonblock': {
anonblock: {
expiry: '31 hours',
forUnregisteredOnly: true,
nocreate: true,
Expand Down Expand Up @@ -881,14 +878,14 @@ Twinkle.block.blockPresetsInfo = {
reason: '{{checkuserblock-wide}}',
sig: '~~~~'
},
'colocationwebhost': {
colocationwebhost: {
expiry: '1 year',
forUnregisteredOnly: true,
nonstandard: true,
reason: '{{colocationwebhost}}',
sig: null
},
'oversightblock': {
oversightblock: {
autoblock: true,
expiry: 'infinity',
nocreate: true,
Expand All @@ -903,28 +900,28 @@ Twinkle.block.blockPresetsInfo = {
reason: '{{school block}}',
sig: '~~~~'
},
'spamblacklistblock': {
spamblacklistblock: {
forUnregisteredOnly: true,
expiry: '1 month',
disabletalk: true,
nocreate: true,
reason: '{{spamblacklistblock}} <!-- editor only attempts to add blacklisted links, see [[Special:Log/spamblacklist]] -->'
},
'rangeblock': {
rangeblock: {
reason: '{{rangeblock}}',
nocreate: true,
nonstandard: true,
forUnregisteredOnly: true,
sig: '~~~~'
},
'tor': {
tor: {
expiry: '1 year',
forUnregisteredOnly: true,
nonstandard: true,
reason: '{{Tor}}',
sig: null
},
'webhostblock': {
webhostblock: {
expiry: '1 year',
forUnregisteredOnly: true,
nonstandard: true,
Expand Down Expand Up @@ -1442,7 +1439,6 @@ Twinkle.block.blockGroupsPartial = [
}
];


Twinkle.block.callback.filtered_block_groups = function twinkleblockCallbackFilteredBlockGroups(group, show_template) {
return $.map(group, (blockGroup) => {
const list = $.map(blockGroup.list, (blockPreset) => {
Expand Down Expand Up @@ -2045,5 +2041,4 @@ Twinkle.block.callback.main = function twinkleblockcallbackMain(pageobj) {
Twinkle.addInitCallback(Twinkle.block, 'block');
}(jQuery));


// </nowiki>
Loading

0 comments on commit 3aa633a

Please sign in to comment.