Skip to content

Commit

Permalink
eslint: fix no-useless-concat (#2100)
Browse files Browse the repository at this point in the history
manual fixes
  • Loading branch information
NovemLinguae authored Dec 8, 2024
1 parent b20e3a8 commit 69de130
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"no-underscore-dangle": "warn",
"no-unused-expressions": "warn",
"no-use-before-define": "warn",
"no-useless-concat": "warn",
"no-var": "warn",
"unicorn/prefer-string-slice": "warn"
}
Expand Down
10 changes: 5 additions & 5 deletions modules/twinklearv.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,19 +921,19 @@ Twinkle.arv.processAN3 = function(params) {
ret += sub.reverse().map((v) => (sub.length >= 2 ? '#' : '') + '# {{diff2|' + v.revid + '|' + new Morebits.Date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n');
return ret;
}).reverse().join('\n');
const warningtext = params.warnings.reverse().map((v) => '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.Date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n');
let resolvetext = params.resolves.reverse().map((v) => '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.Date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n');
const warningtext = params.warnings.reverse().map((v) => '# {{diff2|' + v.revid + '|' + new Morebits.Date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n');
let resolvetext = params.resolves.reverse().map((v) => '# {{diff2|' + v.revid + '|' + new Morebits.Date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n');

if (params.free_resolves) {
const page = params.free_resolves;
if (page.compare) {
resolvetext += '\n# ' + ' {{diff|oldid=' + page.compare.fromrevid + '|diff=' + page.compare.torevid + '|label=Consecutive edits on ' + page.compare.totitle + '}}';
resolvetext += '\n# {{diff|oldid=' + page.compare.fromrevid + '|diff=' + page.compare.torevid + '|label=Consecutive edits on ' + page.compare.totitle + '}}';
} else if (page.revisions) {
const revCount = page.revisions.length;
let rev;
if (revCount < 3) { // diff=prev or next
rev = revCount === 1 ? page.revisions[0] : page.revisions[1];
resolvetext += '\n# ' + ' {{diff2|' + rev.revid + '|' + new Morebits.Date(rev.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) on ' + page.title + '}} ' + hasHiddenComment(rev);
resolvetext += '\n# {{diff2|' + rev.revid + '|' + new Morebits.Date(rev.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) on ' + page.title + '}} ' + hasHiddenComment(rev);
} else { // diff and oldid are nonconsecutive
rev = page.revisions[0];
const revLatest = page.revisions[revCount - 1];
Expand All @@ -949,7 +949,7 @@ Twinkle.arv.processAN3 = function(params) {
comment += ' ~~~~';
}

const text = '\n\n' + '{{subst:AN3 report|diffs=' + difftext + '|warnings=' + warningtext + '|resolves=' + resolvetext + '|pagename=' + params.page + '|orig=' + origtext + '|comment=' + comment + '|uid=' + params.uid + '}}';
const text = '\n\n{{subst:AN3 report|diffs=' + difftext + '|warnings=' + warningtext + '|resolves=' + resolvetext + '|pagename=' + params.page + '|orig=' + origtext + '|comment=' + comment + '|uid=' + params.uid + '}}';

const reportpage = 'Wikipedia:Administrators\' noticeboard/Edit warring';

Expand Down
2 changes: 1 addition & 1 deletion modules/twinkleblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ Twinkle.block.callback.change_expiry = function twinkleblockCallbackChangeExpiry
Twinkle.block.seeAlsos = [];
Twinkle.block.callback.toggle_see_alsos = function twinkleblockCallbackToggleSeeAlso() {
const reason = this.form.reason.value.replace(
new RegExp('( <!--|;) ' + 'see also ' + Twinkle.block.seeAlsos.join(' and ') + '( -->)?'), ''
new RegExp('( <!--|;) see also ' + Twinkle.block.seeAlsos.join(' and ') + '( -->)?'), ''
);

Twinkle.block.seeAlsos = Twinkle.block.seeAlsos.filter((el) => el !== this.value);
Expand Down
2 changes: 2 additions & 0 deletions modules/twinkleconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -1697,13 +1697,15 @@ Twinkle.config.writePrefs = function twinkleconfigWritePrefs(pageobj) {
'// changing the configuration parameters in a valid-JavaScript way) will be\n' +
'// overwritten the next time you click "save" in the Twinkle preferences\n' +
'// panel. If modifying this file, make sure to use correct JavaScript.\n' +
// eslint-disable-next-line no-useless-concat
'// <no' + 'wiki>\n' +
'\n' +
'window.Twinkle.prefs = ';
text += JSON.stringify(newConfig, null, 2);
text +=
';\n' +
'\n' +
// eslint-disable-next-line no-useless-concat
'// </no' + 'wiki>\n' +
'// End of twinkleoptions.js\n';

Expand Down
2 changes: 1 addition & 1 deletion modules/twinklerollback.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ Twinkle.rollback.addLinks = {
const warnFromTalk = function(xtitle) {
const $talkLink = $('#mw-diff-' + xtitle + '2 .mw-usertoollinks a').first();
if ($talkLink.length) {
let extraParams = 'vanarticle=' + mw.util.rawurlencode(Morebits.pageNameNorm) + '&' + 'noautowarn=true';
let extraParams = 'vanarticle=' + mw.util.rawurlencode(Morebits.pageNameNorm) + '&noautowarn=true';
// diffIDs for vanarticlerevid
extraParams += '&vanarticlerevid=';
extraParams += xtitle === 'otitle' ? mw.config.get('wgDiffOldId') : mw.config.get('wgDiffNewId');
Expand Down
2 changes: 1 addition & 1 deletion modules/twinkletalkback.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Twinkle.talkback.noticeboards = {
},
hd: {
label: 'WP:HD (Help desk)',
text: '== Your question at the Help desk ==\n' + '{{helpdeskreply|1=$SECTION|ts=~~~~~}}',
text: '== Your question at the Help desk ==\n{{helpdeskreply|1=$SECTION|ts=~~~~~}}',
editSummary: 'You have replies at the [[Wikipedia:Help desk|Wikipedia help desk]]'
},
norn: {
Expand Down
2 changes: 2 additions & 0 deletions morebits.js
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,7 @@ Morebits.ip = {
}
ipv6 = Morebits.ip.sanitizeIPv6(ipv6);
const ip_re = /^((?:[0-9A-F]{1,4}:){4})(?:[0-9A-F]{1,4}:){3}[0-9A-F]{1,4}(?:\/\d{1,3})?$/;
// eslint-disable-next-line no-useless-concat
return ipv6.replace(ip_re, '$1' + '0:0:0:0/64');
}
};
Expand Down Expand Up @@ -1501,6 +1502,7 @@ Morebits.string = {
formatReasonText: function(str, addSig) {
let reason = (str || '').toString().trim();
const unbinder = new Morebits.unbinder(reason);
// eslint-disable-next-line no-useless-concat
unbinder.unbind('<no' + 'wiki>', '</no' + 'wiki>');
unbinder.content = unbinder.content.replace(/\|/g, '{{subst:!}}');
reason = unbinder.rebind();
Expand Down

0 comments on commit 69de130

Please sign in to comment.