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 some camelcase #2111

Merged
merged 1 commit into from
Dec 10, 2024
Merged
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
56 changes: 28 additions & 28 deletions modules/twinkletag.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@
event: function twinkletagquickfilter() {
// flush the DOM of all existing underline spans
$allCheckboxDivs.find('.search-hit').each((i, e) => {
const label_element = e.parentElement;
const labelElement = e.parentElement;
// This would convert <label>Hello <span class=search-hit>wo</span>rld</label>
// to <label>Hello world</label>
label_element.innerHTML = label_element.textContent;
labelElement.innerHTML = labelElement.textContent;

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
});

if (this.value) {
Expand All @@ -100,16 +100,16 @@
const searchRegex = new RegExp(mw.util.escapeRegExp(searchString), 'i');

$allCheckboxDivs.find('label').each(function () {
const label_text = this.textContent;
const searchHit = searchRegex.exec(label_text);
const labelText = this.textContent;
const searchHit = searchRegex.exec(labelText);
if (searchHit) {
const range = document.createRange();
const textnode = this.childNodes[0];
range.selectNodeContents(textnode);
range.setStart(textnode, searchHit.index);
range.setEnd(textnode, searchHit.index + searchString.length);
const underline_span = $('<span>').addClass('search-hit').css('text-decoration', 'underline')[0];
range.surroundContents(underline_span);
const underlineSpan = $('<span>').addClass('search-hit').css('text-decoration', 'underline')[0];
range.surroundContents(underlineSpan);
this.parentElement.style.display = 'block'; // show
}
});
Expand Down Expand Up @@ -1450,7 +1450,7 @@
'Listing article at Wikipedia:Pages needing translation into English');
pntPage.setFollowRedirect(true);
pntPage.load((pageobj) => {
const old_text = pageobj.getPageText();
const oldText = pageobj.getPageText();

const lang = params.translationLanguage;
const reason = params.translationComments;
Expand All @@ -1462,18 +1462,18 @@
templateText = '{{subst:Dual fluency request|pg=' + Morebits.pageNameNorm + '|Language=' +
(lang || 'uncertain') + '|Comments=' + reason.trim() + '}} ~~~~';
// Place in section == Translated pages that could still use some cleanup ==
text = old_text + '\n\n' + templateText;
text = oldText + '\n\n' + templateText;
summary = 'Translation cleanup requested on ';
} else if (params.tags.indexOf('Not English') !== -1) {
templateText = '{{subst:Translation request|pg=' + Morebits.pageNameNorm + '|Language=' +
(lang || 'uncertain') + '|Comments=' + reason.trim() + '}} ~~~~';
// Place in section == Pages for consideration ==
text = old_text.replace(/\n+(==\s?Translated pages that could still use some cleanup\s?==)/,
text = oldText.replace(/\n+(==\s?Translated pages that could still use some cleanup\s?==)/,
'\n\n' + templateText + '\n\n$1');
summary = 'Translation' + (lang ? ' from ' + lang : '') + ' requested on ';
}

if (text === old_text) {
if (text === oldText) {
pageobj.getStatusElement().error('failed to find target spot for the discussion');
return;
}
Expand Down Expand Up @@ -1533,10 +1533,10 @@
// otherwise moves it to `getRedirectsFor` array earmarking it for
// later removal
params.tagsToRemove.forEach((tag) => {
const tag_re = new RegExp('\\{\\{' + Morebits.pageNameRegex(tag) + '\\s*(\\|[^}]+)?\\}\\}\\n?');
const tagRegex = new RegExp('\\{\\{' + Morebits.pageNameRegex(tag) + '\\s*(\\|[^}]+)?\\}\\}\\n?');

if (tag_re.test(pageText)) {
pageText = pageText.replace(tag_re, '');
if (tagRegex.test(pageText)) {
pageText = pageText.replace(tagRegex, '');
} else {
getRedirectsFor.push('Template:' + tag);
}
Expand All @@ -1563,9 +1563,9 @@
let removed = false;
page.linkshere.concat({title: page.title}).forEach((el) => {
const tag = el.title.slice(9);
const tag_re = new RegExp('\\{\\{' + Morebits.pageNameRegex(tag) + '\\s*(\\|[^}]*)?\\}\\}\\n?');
if (tag_re.test(pageText)) {
pageText = pageText.replace(tag_re, '');
const tagRegex = new RegExp('\\{\\{' + Morebits.pageNameRegex(tag) + '\\s*(\\|[^}]*)?\\}\\}\\n?');
if (tagRegex.test(pageText)) {
pageText = pageText.replace(tagRegex, '');
removed = true;
return false; // break out of $.each
}
Expand Down Expand Up @@ -1753,10 +1753,10 @@
// Reposition the tags on the page into {{multiple issues}}, if found with its
// proper name, else moves it to `getRedirectsFor` array to be handled later
groupableExistingTags.forEach((tag) => {
const tag_re = new RegExp('(\\{\\{' + Morebits.pageNameRegex(tag) + '\\s*(\\|[^}]+)?\\}\\}\\n?)');
if (tag_re.test(pageText)) {
tagText += tag_re.exec(pageText)[1];
pageText = pageText.replace(tag_re, '');
const tagRegex = new RegExp('(\\{\\{' + Morebits.pageNameRegex(tag) + '\\s*(\\|[^}]+)?\\}\\}\\n?)');
if (tagRegex.test(pageText)) {
tagText += tagRegex.exec(pageText)[1];
pageText = pageText.replace(tagRegex, '');
} else {
getRedirectsFor.push('Template:' + tag);
}
Expand All @@ -1782,10 +1782,10 @@
let found = false;
page.linkshere.forEach((el) => {
const tag = el.title.slice(9);
const tag_re = new RegExp('(\\{\\{' + Morebits.pageNameRegex(tag) + '\\s*(\\|[^}]*)?\\}\\}\\n?)');
if (tag_re.test(pageText)) {
tagText += tag_re.exec(pageText)[1];
pageText = pageText.replace(tag_re, '');
const tagRegex = new RegExp('(\\{\\{' + Morebits.pageNameRegex(tag) + '\\s*(\\|[^}]*)?\\}\\}\\n?)');
if (tagRegex.test(pageText)) {
tagText += tagRegex.exec(pageText)[1];
pageText = pageText.replace(tagRegex, '');
found = true;
return false; // break out of $.each
}
Expand Down Expand Up @@ -2178,10 +2178,10 @@
Morebits.wiki.actionCompleted.followRedirect = false;
}

const wikipedia_page = new Morebits.wiki.Page(Morebits.pageNameNorm, 'Tagging ' + Twinkle.tag.mode);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.setChangeTags(Twinkle.changeTags); // Here to apply to triage
wikipedia_page.load(Twinkle.tag.callbacks[Twinkle.tag.mode]);
const wikipediaPage = new Morebits.wiki.Page(Morebits.pageNameNorm, 'Tagging ' + Twinkle.tag.mode);
wikipediaPage.setCallbackParameters(params);
wikipediaPage.setChangeTags(Twinkle.changeTags); // Here to apply to triage
wikipediaPage.load(Twinkle.tag.callbacks[Twinkle.tag.mode]);

};

Expand Down
Loading