Skip to content

Commit 544a773

Browse files
committed
chore: fix a number of eslint issues
1 parent c362388 commit 544a773

14 files changed

+119
-127
lines changed

batch-add-recording-relationships.user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ function batch_recording_rels(gm_info) {
807807
}
808808

809809
function request_works(url, offset, count, callback) {
810-
$.get(`${url}&offset=${offset}`, function (data, textStatus, jqXHR) {
810+
$.get(`${url}&offset=${offset}`, function (data) {
811811
if (count < 0) {
812812
count = data['work-count'];
813813
}

beatport_classic_importer.user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $(document).ready(function () {
2828

2929
function retrieveReleaseInfo(release_url) {
3030
function contains_or(selector, list) {
31-
selectors = [];
31+
const selectors = [];
3232
$.each(list, function (ind, value) {
3333
selectors.push(`${selector}:contains("${value.replace('"', '\\"')}")`);
3434
});

cd1d_importer.user.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const CD1DImporter = {
3333
};
3434
});
3535
// remove "parent" formats : ie. digital when mp3 and flac are present
36-
for (var i = 0; i < formats.length; i++) {
36+
for (let i = 0; i < formats.length; i++) {
3737
for (let j = i + 1; j < formats.length; j++) {
3838
if (formats[j].id.length > 1) {
3939
if (formats[i].id[1] == formats[j].id[1]) {
@@ -48,7 +48,7 @@ const CD1DImporter = {
4848
}
4949
}
5050
let cleanformats = [];
51-
for (var i = 0; i < formats.length; i++) {
51+
for (let i = 0; i < formats.length; i++) {
5252
if (!formats[i].toremove) {
5353
cleanformats.push({
5454
id: formats[i].id.join('-'),
@@ -64,7 +64,7 @@ const CD1DImporter = {
6464
let tracklists = `div#${id} div.tracklist table.tracklist-content`;
6565
let discs = [];
6666
$(tracklists).each(function () {
67-
disc = $(this)
67+
const disc = $(this)
6868
.find('tbody tr')
6969
.map(function () {
7070
// $(this) is used more than once; cache it for performance.
@@ -225,7 +225,7 @@ const CD1DImporter = {
225225
.get();
226226

227227
// Tracks
228-
$.each(this.getTracks(format.id), function (ndisc, disc) {
228+
$.each(this.getTracks(format.id), function () {
229229
let thisdisc = {
230230
tracks: [],
231231
format: release.format,

fast-cancel-edits.user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function fastCancelScript() {
136136
}
137137
});
138138

139-
var pushRequest = (function () {
139+
const pushRequest = (function () {
140140
let queue = [],
141141
last = 0,
142142
active = false,

fma_importer.user.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function insertAPISection() {
188188
}
189189

190190
// Update FreeMusicArchive API Status section on FMA page
191-
var updateAPISection = {
191+
const updateAPISection = {
192192
AlbumId: function (albumid) {
193193
this.albumid = albumid;
194194
$('#lbut-lt-fma-api-album-id').text(this.albumid);
@@ -369,7 +369,7 @@ function insertAPIKEYSection() {
369369
function album_api() {
370370
let fmaWsUrl = `https://freemusicarchive.org/api/get/albums.json?api_key=${FMA_API}&album_id=${release_attributes.albumid}`;
371371

372-
var promise_variable = $.getJSON(fmaWsUrl, function () {
372+
const promise_variable = $.getJSON(fmaWsUrl, function () {
373373
updateAPISection.AlbumAjaxStatus('busy');
374374
LOGGER.debug(`promise_variable [state] in [getJSON] ${promise_variable.state()}`);
375375
}).done(function (albumjson) {
@@ -387,7 +387,7 @@ function album_api() {
387387
function track_api_parameters() {
388388
let fmaWsUrl = `https://freemusicarchive.org/api/get/tracks.json?api_key=${FMA_API}&album_id=${release_attributes.albumid}&limit=20`;
389389

390-
var promise_track_api_params = $.getJSON(fmaWsUrl, function () {
390+
const promise_track_api_params = $.getJSON(fmaWsUrl, function () {
391391
LOGGER.debug(`promise_track_api_params [state] in [getJSON] ${promise_track_api_params.state()}`);
392392
}).done(function (trackinfojson) {
393393
LOGGER.debug(' >> Track INFO > DONE');
@@ -404,7 +404,7 @@ function track_api(page) {
404404
release_attributes.albumid
405405
}&limit=20&page=${parseInt(page)}`;
406406

407-
var promise_track_api = $.getJSON(fmaWsUrl, function () {
407+
const promise_track_api = $.getJSON(fmaWsUrl, function () {
408408
LOGGER.debug(`promise_track_api_params [state] in [getJSON] ${promise_track_api.state()}`);
409409
}).done(function (tracksjson) {
410410
LOGGER.debug(` >> Track page ${page} > DONE `);
@@ -434,7 +434,7 @@ function parseFMApage() {
434434
if (FMAtype == 'album') {
435435
//LOGGER.debug("FMA parseFMApage Function Executing on ", FMAtype);
436436
let FMAEmbedCode = $('.inp-embed-code input').attr('value');
437-
FMAEmbedCodeRegex = /(\/embed\/album\/)(.+?(?=.xml))/; // regex to find the album id from the input object
437+
const FMAEmbedCodeRegex = /(\/embed\/album\/)(.+?(?=.xml))/; // regex to find the album id from the input object
438438
let FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
439439
release_attributes.albumid = FMAAlbumIdMatch[2].trim(); // assign the ID to a variable
440440
LOGGER.info('FreeMusicArchive Album identified as: ', release_attributes.albumid);
@@ -578,7 +578,6 @@ function Parsefmarelease(albumobject, trackobject) {
578578
name: release_attributes.label,
579579
});
580580

581-
let discarray = [];
582581
let trackarray = [];
583582

584583
// release_attributes.total_pages
@@ -610,10 +609,10 @@ function Parsefmarelease(albumobject, trackobject) {
610609
);
611610
//LOGGER.debug("Highest number disc:" + largest_disc);
612611

613-
for (var disccount = 1; disccount <= largest_disc; disccount++) {
612+
for (let disccount = 1; disccount <= largest_disc; disccount++) {
614613
// use this to map all the objects from trackarray with disc_number value of disccount to a new object
615-
let tracklist_per_disc = $.map(trackarray, function (obj, index) {
616-
if (obj.disc_number == disccount) {
614+
let tracklist_per_disc = $.map(trackarray, function (obj) {
615+
if (obj.disc_number === disccount) {
617616
return obj;
618617
}
619618
});
@@ -629,7 +628,7 @@ function Parsefmarelease(albumobject, trackobject) {
629628
// });
630629

631630
// current solution to remove disc_number
632-
for (i = tracklist_per_disc.length - 1; i >= 0; i--) {
631+
for (let i = tracklist_per_disc.length - 1; i >= 0; i--) {
633632
delete tracklist_per_disc[i].disc_number;
634633
}
635634

lib/mbimport.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -270,29 +270,27 @@ const MBImport = (function () {
270270
// re-split artists if featuring or vs
271271
artists.map(function (item) {
272272
let c = item.artist_name.replace(/\s*\b(?:feat\.?|ft\.?|featuring)\s+/gi, ' feat. ');
273-
c = c.replace(/\s*\(( feat. )([^\)]+)\)/g, '$1$2');
273+
c = c.replace(/\s*\(( feat. )([^)]+)\)/g, '$1$2');
274274
c = c.replace(/\s*\b(?:versus|vs\.?)\s+/gi, ' vs. ');
275275
c = c.replace(/\s+/g, ' ');
276276
let splitted = c.split(/( feat\. | vs\. )/);
277-
if (splitted.length == 1) {
277+
if (splitted.length === 1) {
278278
credits.push(item); // nothing to split
279279
} else {
280280
let new_items = [];
281281
let n = 0;
282-
for (let i = 0; i < splitted.length; i++) {
283-
if (n && (splitted[i] == ' feat. ' || splitted[i] == ' vs. ')) {
284-
new_items[n - 1].joinphrase = splitted[i];
282+
for (const element of splitted) {
283+
if (n && (element === ' feat. ' || element === ' vs. ')) {
284+
new_items[n - 1].joinphrase = element;
285285
} else {
286286
new_items[n++] = {
287-
artist_name: splitted[i].trim(),
287+
artist_name: element.trim(),
288288
joinphrase: '',
289289
};
290290
}
291291
}
292292
new_items[n - 1].joinphrase = item.joinphrase;
293-
new_items.map(function (newit) {
294-
credits.push(newit);
295-
});
293+
new_items.forEach(newit => credits.push(newit));
296294
}
297295
});
298296
return credits;
@@ -361,7 +359,7 @@ const MBImport = (function () {
361359
}
362360

363361
function luceneEscape(text) {
364-
let newtext = text.replace(/[-[\]{}()*+?~:\\^!"\/]/g, '\\$&');
362+
let newtext = text.replace(/[-[\]{}()*+?~:\\^!"/]/g, '\\$&');
365363
return newtext.replace('&&', '&&').replace('||', '||');
366364
}
367365

lib/mblinks.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,34 +107,29 @@ const MBLinks = function (user_cache_key, version, expiration) {
107107

108108
this.removeOldCacheVersions = function () {
109109
let to_remove = [];
110-
for (var i = 0, len = localStorage.length; i < len; ++i) {
110+
for (let i = 0, len = localStorage.length; i < len; ++i) {
111111
let key = localStorage.key(i);
112-
if (key.indexOf(this.user_cache_key) === 0) {
113-
if (key != this.cache_key) {
112+
if (key.startsWith(this.user_cache_key)) {
113+
if (key !== this.cache_key) {
114114
// we don't want to remove current cache
115115
to_remove.push(key);
116116
}
117117
}
118118
}
119119
// remove old cache keys
120-
for (var i = 0; i < to_remove.length; i++) {
121-
localStorage.removeItem(to_remove[i]);
120+
for (const element of to_remove) {
121+
localStorage.removeItem(element);
122122
}
123123
};
124124

125125
this.clearCacheExpired = function () {
126-
//var old_cache_entries = Object.keys(this.cache).length;
127-
//console.log("clearCacheExpired " + old_cache_entries);
128-
let now = new Date().getTime();
129126
let new_cache = {};
130127
let that = this;
131-
$.each(this.cache, function (key, value) {
128+
$.each(this.cache, function (key) {
132129
if (that.is_cached(key)) {
133130
new_cache[key] = that.cache[key];
134131
}
135132
});
136-
//var new_cache_entries = Object.keys(new_cache).length;
137-
//console.log("Cleared cache entries: " + old_cache_entries + ' -> ' + new_cache_entries);
138133
this.cache = new_cache;
139134
};
140135

loot_importer.user.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ function ParseLootPage() {
165165
releaseartist = AlbumName[1].innerText;
166166
if (releaseartist == 'Various Artists') {
167167
// Everything is: title(format)
168-
releaseartisttitle_regex = /(.*?)\((.*)\)/; //match external parenthesis
168+
const releaseartisttitle_regex = /(.*?)\((.*)\)/; //match external parenthesis
169169
if (AlbumName[0].innerText.match(releaseartisttitle_regex)) {
170-
releaseartisttitle = AlbumName[0].innerText.match(releaseartisttitle_regex);
170+
const releaseartisttitle = AlbumName[0].innerText.match(releaseartisttitle_regex);
171171
releasetitle = releaseartisttitle[1].trim();
172172
release_format = releaseartisttitle[2];
173173
} else {
@@ -180,10 +180,10 @@ function ParseLootPage() {
180180
}
181181
} else {
182182
// artist - title(format)
183-
releaseartisttitle_regex = /(.*) (-|) (.*?)\((.*)\)/;
183+
const releaseartisttitle_regex = /(.*) (-|) (.*?)\((.*)\)/;
184184

185185
if (AlbumName[0].innerText.match(releaseartisttitle_regex)) {
186-
releaseartisttitle = AlbumName[0].innerText.match(releaseartisttitle_regex);
186+
const releaseartisttitle = AlbumName[0].innerText.match(releaseartisttitle_regex);
187187

188188
releasetitle = releaseartisttitle[3].trim();
189189
releaseartist = releaseartisttitle[1];
@@ -262,22 +262,22 @@ function ParseLootPage() {
262262
let tracklisting = allinfolist[disciterate].getElementsByTagName('tr');
263263
LOGGER.debug(' The Table: (tracklisting)', tracklisting);
264264

265-
for (let trackiterate = 0; trackiterate < tracklisting.length; trackiterate++) {
266-
descriptiontrack = new Object();
265+
for (const element of tracklisting) {
266+
const descriptiontrack = new Object();
267267

268-
let currenttrack = tracklisting[trackiterate].querySelectorAll('td');
268+
let currenttrack = element.querySelectorAll('td');
269269
// var artisttitle_regex = /(.*) - (.*)/; // regex: artist - title
270270
var artisttitle_regex = /(.*) (-|) (.*)/; // regex: artist - title char 45 or 8211
271271

272272
// need to check if this can be replaced with single regex for now check artist-title if
273273
// not matching check just title
274274
if (currenttrack[1].innerText.match(artisttitle_regex)) {
275-
var artisttitle = currenttrack[1].innerText.match(artisttitle_regex);
275+
const artisttitle = currenttrack[1].innerText.match(artisttitle_regex);
276276
descriptiontrack.title = artisttitle[3];
277277
descriptiontrack.artist = artisttitle[1];
278278
} else {
279279
var artisttitle_regex = /(.*)/; // regex: title
280-
var artisttitle = currenttrack[1].innerText.match(artisttitle_regex);
280+
const artisttitle = currenttrack[1].innerText.match(artisttitle_regex);
281281
descriptiontrack.title = artisttitle[1];
282282
descriptiontrack.artist = releaseartist;
283283
}
@@ -315,17 +315,17 @@ function ParseLootPage() {
315315
}
316316

317317
//LOGGER.debug(disclistarray);
318-
release = new Object();
318+
const release = {};
319319

320320
// Check if anything is untoward and highlight to importer
321321
release.maybe_buggy = release_maybe_buggy;
322322

323323
// Release artist credit
324-
release.artist_credit = new Array();
324+
release.artist_credit = [];
325325

326326
let artist_name = releaseartist;
327327

328-
let various_artists = releaseartist == 'Various Artists';
328+
let various_artists = releaseartist === 'Various Artists';
329329
if (various_artists) {
330330
release.artist_credit = [MBImport.specialArtist('various_artists')];
331331
} else {
@@ -346,7 +346,7 @@ function ParseLootPage() {
346346
release.country = Countries[releasecountry];
347347
release.language = Languages[releaselanguage];
348348

349-
release.discs = new Array();
349+
release.discs = [];
350350
for (let l = 0; l < disccount.length; l++) {
351351
let disc = {
352352
position: l + 1,
@@ -359,7 +359,7 @@ function ParseLootPage() {
359359
release.labels = prodlabels;
360360

361361
// Release URL
362-
release.urls = new Array();
362+
release.urls = [];
363363
release.urls.push({
364364
url: window.location.href,
365365
link_type: MBImport.URL_TYPES.purchase_for_mail_order,

0 commit comments

Comments
 (0)