Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint: fix no-jquery/no-constructor-attributes #2098

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"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-grep": "warn",
"no-jquery/no-in-array": "warn",
Expand Down
44 changes: 22 additions & 22 deletions modules/twinklearv.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,18 +369,19 @@ Twinkle.arv.callback.changeCategory = function (e) {
const pageid = data.query.pageids[0];
const page = data.query.pages[pageid];
if (!page.revisions) {
$('<span class="entry">None found</span>').appendTo($field);
$('<span>')
.addClass('entry')
.html('None found')
.appendTo($field);
} else {
for (let i = 0; i < page.revisions.length; ++i) {
const rev = page.revisions[i];
const $entry = $('<div>', {
class: 'entry'
});
const $input = $('<input>', {
type: 'checkbox',
name: 's_' + field,
value: rev.revid
});
const $entry = $('<div>')
.addClass('entry');
const $input = $('<input>')
.attr('type', 'checkbox')
.attr('name', 's_' + field)
.attr('value', rev.revid);
Comment on lines +381 to +384
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also possible to use the .attr({ field1: val1, field2: val2 }) form to be more concise.

Fine either way though.

$input.data('revinfo', rev);
$input.appendTo($entry);
let comment = '<span>';
Expand All @@ -397,22 +398,21 @@ Twinkle.arv.callback.changeCategory = function (e) {

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

const $free_label = $('<label>', {
for: 's_resolves_free',
html: 'URL link of diff with additional discussions: '
});
const $free_entry = $('<div>')
.addClass('entry');
const $free_input = $('<input>')
.attr('type', 'text')
.attr('name', 's_resolves_free');
const $free_label = $('<label>')
.attr('for', 's_resolves_free')
.html('URL link of diff with additional discussions: ');
$free_entry.append($free_label).append($free_input).appendTo($field);
}
}).fail(() => {
$('<span class="entry">API failure, reload page and try again</span>').appendTo($field);
$('<span>')
.addClass('entry')
.html('API failure, reload page and try again')
.appendTo($field);
});
};

Expand Down
44 changes: 22 additions & 22 deletions modules/twinklespeedy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1285,36 +1285,36 @@ Twinkle.speedy.callbacks = {
// promote Unlink tool
let $link, $bigtext;
if (mw.config.get('wgNamespaceNumber') === 6 && params.normalized !== 'f8') {
$link = $('<a>', {
href: '#',
text: 'click here to go to the Unlink tool',
css: { fontSize: '130%', fontWeight: 'bold' },
click: function() {
$link = $('<a>')
.attr('href', '#')
.text('click here to go to the Unlink tool')
.css('fontSize', '130%')
.css('fontWeight', 'bold')
.on('click', () => {
Morebits.wiki.actionCompleted.redirect = null;
Twinkle.speedy.dialog.close();
Twinkle.unlink.callback('Removing usages of and/or links to deleted file ' + Morebits.pageNameNorm);
}
});
$bigtext = $('<span>', {
text: 'To orphan backlinks and remove instances of file usage',
css: { fontSize: '130%', fontWeight: 'bold' }
});
});
$bigtext = $('<span>')
.text('To orphan backlinks and remove instances of file usage')
.css('fontSize', '130%')
.css('fontWeight', 'bold');
Morebits.Status.info($bigtext[0], $link[0]);
} else if (params.normalized !== 'f8') {
$link = $('<a>', {
href: '#',
text: 'click here to go to the Unlink tool',
css: { fontSize: '130%', fontWeight: 'bold' },
click: function() {
$link = $('<a>')
.attr('href', '#')
.text('click here to go to the Unlink tool')
.css('fontSize', '130%')
.css('fontWeight', 'bold')
.on('click', () => {
Morebits.wiki.actionCompleted.redirect = null;
Twinkle.speedy.dialog.close();
Twinkle.unlink.callback('Removing links to deleted page ' + Morebits.pageNameNorm);
}
});
$bigtext = $('<span>', {
text: 'To orphan backlinks',
css: { fontSize: '130%', fontWeight: 'bold' }
});
} );
$bigtext = $('<span>')
.text('To orphan backlinks')
.css('fontSize', '130%')
.css('fontWeight', 'bold');
Morebits.Status.info($bigtext[0], $link[0]);
}
},
Expand Down
32 changes: 15 additions & 17 deletions modules/twinklewarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -1534,11 +1534,10 @@ Twinkle.warn.callback.change_category = function twinklewarnCallbackChangeCatego
// Catch and warn if the talkpage can't load,
// most likely because it's a cross-namespace redirect
// Supersedes the typical $autolevelMessage added in autolevelParseWikitext
const $noTalkPageNode = $('<strong>', {
text: 'Unable to load user talk page; it might be a cross-namespace redirect. Autolevel detection will not work.',
id: 'twinkle-warn-autolevel-message',
css: {color: 'red' }
});
const $noTalkPageNode = $('<strong>')
.text('Unable to load user talk page; it might be a cross-namespace redirect. Autolevel detection will not work.')
.attr('id', 'twinkle-warn-autolevel-message')
.css('color', 'red');
$noTalkPageNode.insertBefore($('#twinkle-warn-warning-messages'));
// If a preview was opened while in a different mode, close it
// Should nullify the need to catch the error in preview callback
Expand Down Expand Up @@ -1808,7 +1807,8 @@ Twinkle.warn.callbacks = {
}
}

const $autolevelMessage = $('<div>', {id: 'twinkle-warn-autolevel-message'});
const $autolevelMessage = $('<div>')
.attr('id', 'twinkle-warn-autolevel-message');

if (isNaN(level)) { // No prior warnings found, this is the first
level = 1;
Expand All @@ -1829,22 +1829,20 @@ Twinkle.warn.callbacks = {
// Basically indicates whether we're in the final Main evaluation or not,
// and thus whether we can continue or need to display the warning and link
if (!statelem) {
const $link = $('<a>', {
href: '#',
text: 'click here to open the ARV tool.',
css: { fontWeight: 'bold' },
click: function() {
const $link = $('<a>')
.attr('href', '#')
.text('click here to open the ARV tool.')
.css('fontWeight', 'bold')
.on('click', () => {
Morebits.wiki.actionCompleted.redirect = null;
Twinkle.warn.dialog.close();
Twinkle.arv.callback(mw.config.get('wgRelevantUserName'));
$('input[name=page]').val(params.article); // Target page
$('input[value=final]').prop('checked', true); // Vandalism after final
}
});
const $statusNode = $('<div>', {
text: mw.config.get('wgRelevantUserName') + ' recently received a level 4 warning (' + latest.type + ') so it might be better to report them instead; ',
css: {color: 'red' }
});
});
const $statusNode = $('<div>')
.text(mw.config.get('wgRelevantUserName') + ' recently received a level 4 warning (' + latest.type + ') so it might be better to report them instead; ')
.css('color', 'red');
$statusNode.append($link[0]);
$autolevelMessage.append($statusNode);
}
Expand Down
Loading