Skip to content

Commit 53b8f6b

Browse files
authored
chore: resolve most the lint issues using static analysis; supress irrelevant issues (#998)
1 parent 5393446 commit 53b8f6b

8 files changed

Lines changed: 25 additions & 78 deletions

batch-add-recording-relationships.user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ function batch_recording_rels(gm_info) {
730730
);
731731
}
732732

733-
let $reload = style_buttons($('<button>Reload</button>'))
733+
style_buttons($('<button>Reload</button>'))
734734
.click(function () {
735735
$button_cell.css('display', 'none');
736736
$msg.text(`Loading works for ${name}...`);

lib/logger.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Logger
33
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
44

5+
// eslint-disable-next-line no-unused-vars
56
const LOGGER = (function () {
67
let LOG_LEVEL = 'info';
78

lib/mbimport.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
*
6363
*/
6464

65+
// eslint-disable-next-line no-unused-vars
6566
const MBImport = (function () {
6667
// --------------------------------------- publics ----------------------------------------- //
6768

lib/mbimportstyle.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ function _add_css(css) {
22
document.head.insertAdjacentHTML('beforeend', `<style>${css.replace(/\s+/g, ' ')}</style>`);
33
}
44

5+
// eslint-disable-next-line no-unused-vars
56
function MBImportStyle() {
67
let css_import_button = `
78
#mb_buttons {
@@ -42,6 +43,7 @@ function MBImportStyle() {
4243
_add_css(css_import_button);
4344
}
4445

46+
// eslint-disable-next-line no-unused-vars
4547
function MBSearchItStyle() {
4648
let css_search_it = `
4749
.mb_valign {

lib/mblinks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// user_cache_key = textual key used to store cached data in local storage
1717
// version = optionnal version, to force creation of a cache (ie. when format of keys changes)
1818
// expiration = time in minutes before an entry is refreshed, value <= 0 disables cache reads, if undefined or false, use defaults
19+
// eslint-disable-next-line no-unused-vars
1920
const MBLinks = function (user_cache_key, version, expiration) {
2021
/**
2122
* Processes a URL match from the MusicBrainz API response: updates cache and inserts
@@ -71,7 +72,7 @@ const MBLinks = function (user_cache_key, version, expiration) {
7172
this.supports_local_storage = (function () {
7273
try {
7374
return !!localStorage.getItem;
74-
} catch (e) {
75+
} catch {
7576
return false;
7677
}
7778
})();

mb_discids_detector.user.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// @require lib/logger.js
1313
// ==/UserScript==
1414

15+
/* eslint-disable */
16+
1517
console.warn(
1618
'[Musicbrainz DiscIds Detector]: ⚠️ This userscript has been rewritten in TypeScript and is now hosted at a new URL. It should auto-update to use the TS version automatically, but if it didn’t and you’re seeing this message, please upgrade it manually from https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/dist/mb_discids_detector.user.js.',
1719
);

qobuz_importer.user.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const OPEN_QOBUZ_BASE = 'https://open.qobuz.com';
3131

3232
let is_classical = false; // release detected as classical
3333
let album_artist_data = {}; // for switching album artists on classical
34-
let raw_release_data;
3534

3635
function getOpenQobuzArtistUrl(artistId) {
3736
return `${OPEN_QOBUZ_BASE}/artist/${artistId}`;

takealot_importer.user.js

Lines changed: 16 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ if (DEBUG) {
3636

3737
// promise to ensure all api calls are done before we parse the release
3838
const tracks_deferred = $.Deferred();
39-
const retrieve_tracks_promise = tracks_deferred.promise();
39+
tracks_deferred.promise();
4040

4141
// object to store all global attributes collected for the release
4242
const release_attributes = {}; // albumid, total_pages, artist_name, label
4343

4444
// arrays to store the data retrieved from API to parse for MB release
4545
const album_api_array = []; // album information [0]
46-
const tracks_api_array = []; // track information [0,1,2,..] one element for each pagination in FMA tracks API
4746

4847
$(document).ready(function () {
4948
LOGGER.info('Document Ready & Takealot Userscript Executing');
@@ -65,9 +64,8 @@ $(document).ready(function () {
6564
$.when(retrieve_album_detail).done(function () {
6665
LOGGER.info('All the AJAX API calls are done continue to build the release object ...');
6766
LOGGER.debug(`ALBUM Object > ${album_api_array[0]}`);
68-
// LOGGER.debug("TRACK Object > " + tracks_api_array);
6967

70-
let FreeMusicArchiveRelease = new Parsefmarelease(album_api_array[0], tracks_api_array);
68+
let FreeMusicArchiveRelease = new Parsefmarelease(album_api_array[0]);
7169
insertMBSection(FreeMusicArchiveRelease);
7270

7371
let album_link = window.location.href;
@@ -143,7 +141,7 @@ const updateAPISection = {
143141
},
144142
ApiKey: function (apikey) {
145143
this.apikey = apikey;
146-
$('#lbut-lt-fma-api-key-id').text(FMA_API);
144+
$('#lbut-lt-fma-api-key-id').text(`FMA_API: ${this.apikey}`);
147145
return 'complete';
148146
},
149147
AlbumAjaxStatus: function (ajaxstatus) {
@@ -301,45 +299,6 @@ function insertMBSection(release) {
301299
mbUI.slideDown();
302300
}
303301

304-
// Insert MusicBrainz API section on FMA page to enter API Key
305-
function insertAPIKEYSection() {
306-
LOGGER.debug('FMA insertAPIKEYSection Function Executing');
307-
308-
let mbUI = $(
309-
'<div id="musicbrainz_apikey" class="section musicbrainz"><h4 class="wlinepad"><span class="hd">Import FMA API KEY for MusicBrainz</span></h4></div>',
310-
).hide();
311-
if (DEBUG)
312-
mbUI.css({
313-
border: '1px dotted red',
314-
});
315-
316-
let mbContentBlock = $('<div class="section_content"></div>');
317-
mbUI.append(mbContentBlock);
318-
319-
// Build section
320-
let innerHTML =
321-
'<span class="mhd-nosep">Please enter API Key found <a class="donate" href="https://freemusicarchive.org/member/api_key" target="_blank">here</a></span>';
322-
innerHTML = `${innerHTML}<div id="mb_buttons"><input id="apikey_input" type="text" name="apikey_input" value=""><br><input id="api_key_submit" type="submit" value="Import API KEY"></div>`;
323-
mbContentBlock.append(innerHTML);
324-
325-
insertMbUI(mbUI); // Insert the MusicBrainzUI
326-
327-
$('#musicbrainz_apikey').css({
328-
display: 'block',
329-
float: 'right',
330-
height: '120px',
331-
width: '49%',
332-
});
333-
334-
$('#mb_buttons').css({
335-
display: 'inline-block',
336-
float: 'right',
337-
height: '80px',
338-
});
339-
340-
mbUI.slideDown();
341-
}
342-
343302
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
344303
// Retrieve data from TAL API //
345304
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -389,23 +348,23 @@ function parseFMApage() {
389348

390349
if (typeof $('#idProduct').attr('value') === 'undefined' && $('div.cell:nth-child(3) > a:nth-child(1)').length) {
391350
LOGGER.debug('Uhm I think the idProduct is missing folks and comments left ...');
392-
let FMAEmbedCode = $('div.cell:nth-child(3) > a:nth-child(1)').attr('href');
351+
const FMAEmbedCode = $('div.cell:nth-child(3) > a:nth-child(1)').attr('href');
393352
LOGGER.debug('The album id for API: ', FMAEmbedCode);
394-
FMAEmbedCodeRegex = /product_id=(\d*)/;
395-
let FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
353+
const FMAEmbedCodeRegex = /product_id=(\d*)/;
354+
const FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
396355
release_attributes.albumid = FMAAlbumIdMatch[1]; // assign the ID to a variable
397356
} else if (typeof $('#idProduct').attr('value') === 'undefined' && $('.reviews > a:nth-child(1)').length) {
398357
LOGGER.debug('Uhm I think the idProduct is missing folks ...');
399-
let FMAEmbedCode = $('.reviews > a:nth-child(1)').attr('href');
358+
const FMAEmbedCode = $('.reviews > a:nth-child(1)').attr('href');
400359
LOGGER.debug('The album id for API: ', FMAEmbedCode);
401-
FMAEmbedCodeRegex = /product_id=(\d*)/;
402-
let FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
360+
const FMAEmbedCodeRegex = /product_id=(\d*)/;
361+
const FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
403362
release_attributes.albumid = FMAAlbumIdMatch[1]; // assign the ID to a variable
404363
} else {
405364
LOGGER.debug('Aha got that idProduct value, Jipeeeee ...');
406-
let FMAEmbedCode = $('#idProduct').attr('value');
407-
FMAEmbedCodeRegex = /\d{8}/; // regex to match the value from the idProduct object
408-
let FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
365+
const FMAEmbedCode = $('#idProduct').attr('value');
366+
const FMAEmbedCodeRegex = /\d{8}/; // regex to match the value from the idProduct object
367+
const FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id
409368
release_attributes.albumid = FMAAlbumIdMatch[0]; // assign the ID to a variable
410369
}
411370

@@ -440,23 +399,6 @@ function parseFMApage() {
440399
// Analyze FMA data and return a release object //
441400
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
442401

443-
// Parse the date string and set object properties day, month, year
444-
function parse_MM_DD_YYYY(date, obj) {
445-
if (!date) return;
446-
let m = date.split(/\D+/, 3).map(function (e) {
447-
return parseInt(e, 10);
448-
});
449-
if (m[0] !== undefined) {
450-
obj.month = m[0];
451-
if (m[1] !== undefined) {
452-
obj.day = m[1];
453-
if (m[2] !== undefined) {
454-
obj.year = m[2];
455-
}
456-
}
457-
}
458-
}
459-
460402
function parse_YYYY_MM_DD(date, obj) {
461403
if (!date) return;
462404
let m = date.split(/\D+/, 3).map(function (e) {
@@ -474,7 +416,7 @@ function parse_YYYY_MM_DD(date, obj) {
474416
}
475417

476418
// parse the release from the album and track objects
477-
function Parsefmarelease(albumobject, trackobject) {
419+
function Parsefmarelease(albumobject) {
478420
if (albumobject === undefined) {
479421
albumobject = [];
480422
}
@@ -704,7 +646,7 @@ function Parsefmarelease(albumobject, trackobject) {
704646
//var lines = alltracklist.val().split('\n');
705647
let lines = alltracklist.split(/\r?\n/);
706648

707-
takealot_format = 'v2_type1';
649+
const takealot_format = 'v2_type1';
708650

709651
// Tracks
710652
let tracklistarray = new Array(); // create the track list array
@@ -718,15 +660,14 @@ function Parsefmarelease(albumobject, trackobject) {
718660
//let trackdetails = lines[j];
719661
// sample: [ Disc 01 Track 01 ] What Do You Mean? - Justin Bieber
720662
// do this up in regex tester now...
721-
//disctracktitleregex = /\[ Disc (\d{2}) Track.(\b\d{2}) \] (.*) - (.*)/;
722-
//let disctracktitle = trackdetails.match(disctracktitleregex);
663+
const disctracktitleregex = /\[ Disc (\d{2}) Track.(\b\d{2}) \] (.*) - (.*)/;
664+
const disctracktitle = lines[j].match(disctracktitleregex);
723665

724666
let currentdiscnumber = 1;
725667
lastdiscnumber = 1;
726668

727669
if (currentdiscnumber == 1) {
728670
let track = {};
729-
let track_artist_credit = [];
730671

731672
track.number = j + 1;
732673
track.title = lines[j];

0 commit comments

Comments
 (0)