From 6c20ea7a21f970ddbb4ef3015c755e21e6f23e88 Mon Sep 17 00:00:00 2001 From: Raman Sinclair Date: Tue, 7 Jul 2026 18:59:34 +0200 Subject: [PATCH] chore: resolve most the lint issues using static analysis; supress irrelevant issues --- batch-add-recording-relationships.user.js | 2 +- lib/logger.js | 1 + lib/mbimport.js | 1 + lib/mbimportstyle.js | 2 + lib/mblinks.js | 3 +- mb_discids_detector.user.js | 2 + qobuz_importer.user.js | 1 - takealot_importer.user.js | 91 ++++------------------- 8 files changed, 25 insertions(+), 78 deletions(-) diff --git a/batch-add-recording-relationships.user.js b/batch-add-recording-relationships.user.js index d08889fb..26631100 100644 --- a/batch-add-recording-relationships.user.js +++ b/batch-add-recording-relationships.user.js @@ -730,7 +730,7 @@ function batch_recording_rels(gm_info) { ); } - let $reload = style_buttons($('')) + style_buttons($('')) .click(function () { $button_cell.css('display', 'none'); $msg.text(`Loading works for ${name}...`); diff --git a/lib/logger.js b/lib/logger.js index 4d3a8367..399fc421 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -2,6 +2,7 @@ // Logger /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// eslint-disable-next-line no-unused-vars const LOGGER = (function () { let LOG_LEVEL = 'info'; diff --git a/lib/mbimport.js b/lib/mbimport.js index e6234c40..e1bad46e 100644 --- a/lib/mbimport.js +++ b/lib/mbimport.js @@ -62,6 +62,7 @@ * */ +// eslint-disable-next-line no-unused-vars const MBImport = (function () { // --------------------------------------- publics ----------------------------------------- // diff --git a/lib/mbimportstyle.js b/lib/mbimportstyle.js index faeec1d2..734512cc 100644 --- a/lib/mbimportstyle.js +++ b/lib/mbimportstyle.js @@ -2,6 +2,7 @@ function _add_css(css) { document.head.insertAdjacentHTML('beforeend', ``); } +// eslint-disable-next-line no-unused-vars function MBImportStyle() { let css_import_button = ` #mb_buttons { @@ -42,6 +43,7 @@ function MBImportStyle() { _add_css(css_import_button); } +// eslint-disable-next-line no-unused-vars function MBSearchItStyle() { let css_search_it = ` .mb_valign { diff --git a/lib/mblinks.js b/lib/mblinks.js index 7b7ff447..0f5f1732 100644 --- a/lib/mblinks.js +++ b/lib/mblinks.js @@ -16,6 +16,7 @@ // user_cache_key = textual key used to store cached data in local storage // version = optionnal version, to force creation of a cache (ie. when format of keys changes) // expiration = time in minutes before an entry is refreshed, value <= 0 disables cache reads, if undefined or false, use defaults +// eslint-disable-next-line no-unused-vars const MBLinks = function (user_cache_key, version, expiration) { /** * 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) { this.supports_local_storage = (function () { try { return !!localStorage.getItem; - } catch (e) { + } catch { return false; } })(); diff --git a/mb_discids_detector.user.js b/mb_discids_detector.user.js index fc183f62..caf95db8 100644 --- a/mb_discids_detector.user.js +++ b/mb_discids_detector.user.js @@ -12,6 +12,8 @@ // @require lib/logger.js // ==/UserScript== +/* eslint-disable */ + console.warn( '[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.', ); diff --git a/qobuz_importer.user.js b/qobuz_importer.user.js index bf6602e6..48a44202 100644 --- a/qobuz_importer.user.js +++ b/qobuz_importer.user.js @@ -31,7 +31,6 @@ const OPEN_QOBUZ_BASE = 'https://open.qobuz.com'; let is_classical = false; // release detected as classical let album_artist_data = {}; // for switching album artists on classical -let raw_release_data; function getOpenQobuzArtistUrl(artistId) { return `${OPEN_QOBUZ_BASE}/artist/${artistId}`; diff --git a/takealot_importer.user.js b/takealot_importer.user.js index f7ad76dd..63222f9c 100644 --- a/takealot_importer.user.js +++ b/takealot_importer.user.js @@ -36,14 +36,13 @@ if (DEBUG) { // promise to ensure all api calls are done before we parse the release const tracks_deferred = $.Deferred(); -const retrieve_tracks_promise = tracks_deferred.promise(); +tracks_deferred.promise(); // object to store all global attributes collected for the release const release_attributes = {}; // albumid, total_pages, artist_name, label // arrays to store the data retrieved from API to parse for MB release const album_api_array = []; // album information [0] -const tracks_api_array = []; // track information [0,1,2,..] one element for each pagination in FMA tracks API $(document).ready(function () { LOGGER.info('Document Ready & Takealot Userscript Executing'); @@ -65,9 +64,8 @@ $(document).ready(function () { $.when(retrieve_album_detail).done(function () { LOGGER.info('All the AJAX API calls are done continue to build the release object ...'); LOGGER.debug(`ALBUM Object > ${album_api_array[0]}`); - // LOGGER.debug("TRACK Object > " + tracks_api_array); - let FreeMusicArchiveRelease = new Parsefmarelease(album_api_array[0], tracks_api_array); + let FreeMusicArchiveRelease = new Parsefmarelease(album_api_array[0]); insertMBSection(FreeMusicArchiveRelease); let album_link = window.location.href; @@ -143,7 +141,7 @@ const updateAPISection = { }, ApiKey: function (apikey) { this.apikey = apikey; - $('#lbut-lt-fma-api-key-id').text(FMA_API); + $('#lbut-lt-fma-api-key-id').text(`FMA_API: ${this.apikey}`); return 'complete'; }, AlbumAjaxStatus: function (ajaxstatus) { @@ -301,45 +299,6 @@ function insertMBSection(release) { mbUI.slideDown(); } -// Insert MusicBrainz API section on FMA page to enter API Key -function insertAPIKEYSection() { - LOGGER.debug('FMA insertAPIKEYSection Function Executing'); - - let mbUI = $( - '

Import FMA API KEY for MusicBrainz

', - ).hide(); - if (DEBUG) - mbUI.css({ - border: '1px dotted red', - }); - - let mbContentBlock = $('
'); - mbUI.append(mbContentBlock); - - // Build section - let innerHTML = - 'Please enter API Key found '; - innerHTML = `${innerHTML}

`; - mbContentBlock.append(innerHTML); - - insertMbUI(mbUI); // Insert the MusicBrainzUI - - $('#musicbrainz_apikey').css({ - display: 'block', - float: 'right', - height: '120px', - width: '49%', - }); - - $('#mb_buttons').css({ - display: 'inline-block', - float: 'right', - height: '80px', - }); - - mbUI.slideDown(); -} - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Retrieve data from TAL API // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -389,23 +348,23 @@ function parseFMApage() { if (typeof $('#idProduct').attr('value') === 'undefined' && $('div.cell:nth-child(3) > a:nth-child(1)').length) { LOGGER.debug('Uhm I think the idProduct is missing folks and comments left ...'); - let FMAEmbedCode = $('div.cell:nth-child(3) > a:nth-child(1)').attr('href'); + const FMAEmbedCode = $('div.cell:nth-child(3) > a:nth-child(1)').attr('href'); LOGGER.debug('The album id for API: ', FMAEmbedCode); - FMAEmbedCodeRegex = /product_id=(\d*)/; - let FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id + const FMAEmbedCodeRegex = /product_id=(\d*)/; + const FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id release_attributes.albumid = FMAAlbumIdMatch[1]; // assign the ID to a variable } else if (typeof $('#idProduct').attr('value') === 'undefined' && $('.reviews > a:nth-child(1)').length) { LOGGER.debug('Uhm I think the idProduct is missing folks ...'); - let FMAEmbedCode = $('.reviews > a:nth-child(1)').attr('href'); + const FMAEmbedCode = $('.reviews > a:nth-child(1)').attr('href'); LOGGER.debug('The album id for API: ', FMAEmbedCode); - FMAEmbedCodeRegex = /product_id=(\d*)/; - let FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id + const FMAEmbedCodeRegex = /product_id=(\d*)/; + const FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id release_attributes.albumid = FMAAlbumIdMatch[1]; // assign the ID to a variable } else { LOGGER.debug('Aha got that idProduct value, Jipeeeee ...'); - let FMAEmbedCode = $('#idProduct').attr('value'); - FMAEmbedCodeRegex = /\d{8}/; // regex to match the value from the idProduct object - let FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id + const FMAEmbedCode = $('#idProduct').attr('value'); + const FMAEmbedCodeRegex = /\d{8}/; // regex to match the value from the idProduct object + const FMAAlbumIdMatch = FMAEmbedCode.match(FMAEmbedCodeRegex); // match the Id release_attributes.albumid = FMAAlbumIdMatch[0]; // assign the ID to a variable } @@ -440,23 +399,6 @@ function parseFMApage() { // Analyze FMA data and return a release object // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Parse the date string and set object properties day, month, year -function parse_MM_DD_YYYY(date, obj) { - if (!date) return; - let m = date.split(/\D+/, 3).map(function (e) { - return parseInt(e, 10); - }); - if (m[0] !== undefined) { - obj.month = m[0]; - if (m[1] !== undefined) { - obj.day = m[1]; - if (m[2] !== undefined) { - obj.year = m[2]; - } - } - } -} - function parse_YYYY_MM_DD(date, obj) { if (!date) return; let m = date.split(/\D+/, 3).map(function (e) { @@ -474,7 +416,7 @@ function parse_YYYY_MM_DD(date, obj) { } // parse the release from the album and track objects -function Parsefmarelease(albumobject, trackobject) { +function Parsefmarelease(albumobject) { if (albumobject === undefined) { albumobject = []; } @@ -704,7 +646,7 @@ function Parsefmarelease(albumobject, trackobject) { //var lines = alltracklist.val().split('\n'); let lines = alltracklist.split(/\r?\n/); - takealot_format = 'v2_type1'; + const takealot_format = 'v2_type1'; // Tracks let tracklistarray = new Array(); // create the track list array @@ -718,15 +660,14 @@ function Parsefmarelease(albumobject, trackobject) { //let trackdetails = lines[j]; // sample: [ Disc 01 Track 01 ] What Do You Mean? - Justin Bieber // do this up in regex tester now... - //disctracktitleregex = /\[ Disc (\d{2}) Track.(\b\d{2}) \] (.*) - (.*)/; - //let disctracktitle = trackdetails.match(disctracktitleregex); + const disctracktitleregex = /\[ Disc (\d{2}) Track.(\b\d{2}) \] (.*) - (.*)/; + const disctracktitle = lines[j].match(disctracktitleregex); let currentdiscnumber = 1; lastdiscnumber = 1; if (currentdiscnumber == 1) { let track = {}; - let track_artist_credit = []; track.number = j + 1; track.title = lines[j];