From abb92b2138a97a720e35ec1734f513e3f9f356bd Mon Sep 17 00:00:00 2001 From: Dariusz L Date: Sun, 2 Aug 2026 04:20:44 +0200 Subject: [PATCH] refactor(frontend): clean unused catches and regex escapes --- web/log_system/log_funcs.js | 2 +- web/log_system/logger.js | 6 +-- web/resolver/actions/queue_methods.js | 52 +++++++++---------- web/resolver/model_resolver.js | 4 +- .../search/download_target_methods.js | 16 +++--- web/resolver/search/search_panel.js | 10 ++-- web/resolver/shell/dialog_shell_methods.js | 10 ++-- web/resolver/shell/lifecycle_graph_methods.js | 2 +- web/resolver/shell/workflow_state_methods.js | 2 +- web/resolver/utils/html_utils.js | 2 +- web/resolver/utils/render_format_methods.js | 4 +- web/resolver/utils/url_utils.js | 2 +- web/resolver/views/missing_browser_methods.js | 18 +++---- web/resolver/views/model_info_methods.js | 12 ++--- web/resolver/views/options_methods.js | 12 ++--- web/utils/notification_utils.js | 4 +- 16 files changed, 79 insertions(+), 79 deletions(-) diff --git a/web/log_system/log_funcs.js b/web/log_system/log_funcs.js index ce54493..6716988 100644 --- a/web/log_system/log_funcs.js +++ b/web/log_system/log_funcs.js @@ -31,7 +31,7 @@ export function createModuleLogger(moduleName) { */ export function createAutoLogger() { const stack = new Error().stack; - const match = stack?.match(/\/([^\/]+)\.js/); + const match = stack?.match(/\/([^/]+)\.js/); const moduleName = match ? match[1] : 'Unknown'; return createModuleLogger(moduleName); } diff --git a/web/log_system/logger.js b/web/log_system/logger.js index 0e7af78..c64f8ab 100644 --- a/web/log_system/logger.js +++ b/web/log_system/logger.js @@ -303,7 +303,7 @@ class Logger { try { return JSON.stringify(arg); } - catch (e) { + catch (_e) { return String(arg); } } @@ -526,7 +526,7 @@ class Logger { try { return JSON.parse(trimmed); } - catch (e) { + catch (_e) { return null; } } @@ -551,7 +551,7 @@ class Logger { try { return JSON.parse(JSON.stringify(arg)); } - catch (e) { + catch (_e) { return String(arg); } } diff --git a/web/resolver/actions/queue_methods.js b/web/resolver/actions/queue_methods.js index 906dc7e..e88ec6e 100644 --- a/web/resolver/actions/queue_methods.js +++ b/web/resolver/actions/queue_methods.js @@ -44,13 +44,13 @@ export const queueMethods = { this.queueElement.style.flexShrink = '0'; } } - } catch (e) { } + } catch (_e) { } try { const onSplitMouseDown = (e) => this.startSplitDrag(e); this.splitterElement.addEventListener(typeof PointerEvent === 'function' ? 'pointerdown' : 'mousedown', onSplitMouseDown); this._splitterMouseDown = onSplitMouseDown; - } catch (e) { } + } catch (_e) { } // Toggle icon always visible try { @@ -66,13 +66,13 @@ export const queueMethods = { ); body.appendChild(this.queueToggleIcon); this.updateQueueToggleIcon(); - } catch (e) { } + } catch (_e) { } // Restore queue collapsed state try { const col = localStorage.getItem('model_resolver_queue_collapsed'); if (col === '1') this.setQueueCollapsed(true, { persist: false, updatePanel: false }); - } catch (e) { } + } catch (_e) { } return body; }, @@ -213,7 +213,7 @@ export const queueMethods = { this._queueCollapsedPersistTimer = null; try { localStorage.setItem('model_resolver_queue_collapsed', collapsed ? '1' : '0'); - } catch (e) { } + } catch (_e) { } }; const delay = Math.max(0, Number(delayMs) || 0); if (delay > 0) { @@ -234,7 +234,7 @@ export const queueMethods = { this._queueSplitPersistTimer = null; try { localStorage.setItem('model_resolver_split_w', String(nextWidth)); - } catch (e) { } + } catch (_e) { } }; const delay = Math.max(0, Number(delayMs) || 0); if (delay > 0) { @@ -306,7 +306,7 @@ export const queueMethods = { const decodeLabel = (value = '') => { try { return decodeURIComponent(String(value || '').replace(/\+/g, ' ')); - } catch (error) { + } catch (_error) { return String(value || ''); } }; @@ -329,7 +329,7 @@ export const queueMethods = { ]; const found = candidates.map(cleanRoutePart).find(Boolean); if (found) return found; - } catch (error) { /* fall through to manual route parsing */ } + } catch (_error) { /* fall through to manual route parsing */ } try { const hash = rawRoute.startsWith('#') ? rawRoute.slice(1) : rawRoute; @@ -349,7 +349,7 @@ export const queueMethods = { ]; const found = candidates.map(cleanRoutePart).find(Boolean); if (found) return found; - } catch (error) { /* fall through to readable route */ } + } catch (_error) { /* fall through to readable route */ } const withoutQuery = rawRoute.split('?')[0].split('&')[0]; const parts = withoutQuery @@ -499,7 +499,7 @@ export const queueMethods = { let elements; try { elements = Array.from(document.querySelectorAll(selector)); - } catch (error) { + } catch (_error) { continue; } @@ -552,7 +552,7 @@ export const queueMethods = { activeWorkflow?.workflow?.name, activeWorkflow?.workflow?.title ); - } catch (error) { /* ignore unavailable Comfy internals */ } + } catch (_error) { /* ignore unavailable Comfy internals */ } for (const candidate of candidates) { const label = this.cleanWorkflowLabel(candidate); @@ -600,7 +600,7 @@ export const queueMethods = { || app?.ui?.workflow?.activeWorkflow || app?.canvas?.workflow; return this.getWorkflowIdFromWorkflow?.(activeWorkflow) || ''; - } catch (error) { + } catch (_error) { return ''; } }, @@ -662,7 +662,7 @@ export const queueMethods = { const url = new URL(String(routeKey || ''), base); const routeWorkflowId = url.searchParams.get('workflowId') || url.searchParams.get('workflow_id') || url.searchParams.get('id'); if (routeWorkflowId) return routeWorkflowId.trim(); - } catch (error) { /* fall through to uuid extraction */ } + } catch (_error) { /* fall through to uuid extraction */ } const routeUuid = String(routeKey || '').match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i)?.[0] || ''; if (routeUuid) return routeUuid; @@ -843,7 +843,7 @@ export const queueMethods = { context_scope: 'download_queue', download_id: downloadId, open_folder_label: folderContext ? 'Open Download Folder' : '', - name: folderContext?.name || progress?.filename || info?.filename || missing?.original_path?.split(/[\/\\]/).pop() || 'Download', + name: folderContext?.name || progress?.filename || info?.filename || missing?.original_path?.split(/[/\\]/).pop() || 'Download', workflow_id: info.workflowId || info.workflow_id || this.getWorkflowContextId(info) || '', workflow_label: label, workflow_route_key: info.workflowRouteKey || this.getWorkflowContextRouteKey(info) || '', @@ -904,7 +904,7 @@ export const queueMethods = { let elements; try { elements = Array.from(document.querySelectorAll(selector)); - } catch (error) { + } catch (_error) { continue; } @@ -1074,7 +1074,7 @@ export const queueMethods = { const filename = progress.filename || info.filename || missing.download_source?.filename - || missing.original_path?.split(/[\/\\]/).pop() + || missing.original_path?.split(/[/\\]/).pop() || ''; if (!filename) return null; @@ -1123,7 +1123,7 @@ export const queueMethods = { hour: '2-digit', minute: '2-digit' }); - } catch (error) { + } catch (_error) { return ''; } }, @@ -1342,7 +1342,7 @@ export const queueMethods = { const filename = progress.filename || info.filename || info.missing?.download_source?.filename - || info.missing?.original_path?.split(/[\/\\]/).pop() + || info.missing?.original_path?.split(/[/\\]/).pop() || 'model'; const category = this.getCategoryDisplayName?.(info.category || info.missing?.category || '') || info.category || ''; const nodeLabel = info.missing?.subgraph_name || info.missing?.node_type || (info.missing?.subgraph_id ? 'Subgraph' : 'Node'); @@ -1363,7 +1363,7 @@ export const queueMethods = { ? `Finalizing file: ${logicalDownloaded} / ${logicalTotal}` : (total ? `${downloaded} / ${total}` : downloaded); const targetPath = progress.directory || info.downloadDirectory || info.downloadPath || ''; - const targetLabel = targetPath ? targetPath.split(/[\/\\]/).filter(Boolean).pop() || targetPath : ''; + const targetLabel = targetPath ? targetPath.split(/[/\\]/).filter(Boolean).pop() || targetPath : ''; const workflowLabel = this.getDownloadWorkflowLabel?.(info) || 'Unknown workflow'; const contextModel = this.getDownloadQueueContext?.(progress, info, workflowLabel, downloadId); const hasFolderAction = Boolean(contextModel?.folder_path || contextModel?.download_directory || contextModel?.directory || contextModel?.path || contextModel?.resolved_path); @@ -1424,7 +1424,7 @@ export const queueMethods = { ? `${entry.nodeLabel || 'Node'} #${entry.nodeId}` : (entry.nodeLabel || ''); const targetPath = entry.directory || entry.path || ''; - const targetLabel = targetPath ? targetPath.split(/[\/\\]/).filter(Boolean).pop() || targetPath : ''; + const targetLabel = targetPath ? targetPath.split(/[/\\]/).filter(Boolean).pop() || targetPath : ''; const timeLabel = this.formatDownloadHistoryTime(entry.completedAt); const sizeLabel = entry.totalSize ? this.formatBytes(entry.totalSize) : ''; const statusLabel = entry.statusLabel || (entry.status === 'already_exists' ? 'Already downloaded' : 'Downloaded'); @@ -1516,7 +1516,7 @@ export const queueMethods = { this.refreshMissingModelsBrowserFromCache?.(); try { document.querySelectorAll('.model-resolver-selected').forEach(el => { el.style.display = 'none'; el.innerHTML = ''; }); - } catch (e) { /* ignore */ } + } catch (_e) { /* ignore */ } }, // Update selected bar for a specific missing model slot @@ -1837,7 +1837,7 @@ export const queueMethods = { this._queueSplitFallbackContainerWidth = Number(window.innerWidth || 720); if (this._queueSplitResizeObserver) { - try { this._queueSplitResizeObserver.disconnect(); } catch (e) { } + try { this._queueSplitResizeObserver.disconnect(); } catch (_e) { } this._queueSplitResizeObserver = null; } @@ -2093,7 +2093,7 @@ export const queueMethods = { this.queueElement.style.display = ''; if (this.splitterElement) this.splitterElement.style.display = ''; this.persistQueueSplitWidth(restoreWidth, 500); - } catch (err) { } + } catch (_err) { } this.queueCollapsed = false; this.persistQueueCollapsedState(false, 500); this.updateQueueVisibility(); @@ -2119,7 +2119,7 @@ export const queueMethods = { }); this.queueElement.style.display = ''; this.persistQueueSplitWidth(restoreWidth); - } catch (err) { } + } catch (_err) { } this._pendingSplitWidth = null; this._appliedSplitWidth = null; this._splitPreviewCollapsed = false; @@ -2138,7 +2138,7 @@ export const queueMethods = { || Number.parseInt(String(this.queueElement.style.width || ''), 10) || this.getQueuePaneWidth(this.queueElement); this.persistQueueSplitWidth(width); - } catch (err) { } + } catch (_err) { } this._pendingSplitWidth = null; this._appliedSplitWidth = null; this._splitPreviewCollapsed = false; @@ -2149,7 +2149,7 @@ export const queueMethods = { this._splitInteraction = null; } }); - } catch (err) { /* ignore */ } + } catch (_err) { /* ignore */ } }, diff --git a/web/resolver/model_resolver.js b/web/resolver/model_resolver.js index 66f5e11..c3fd978 100644 --- a/web/resolver/model_resolver.js +++ b/web/resolver/model_resolver.js @@ -47,7 +47,7 @@ function getKeybindingSetting(id) { try { const value = app.ui?.settings?.getSettingValue?.(id); return Array.isArray(value) ? value : []; - } catch (error) { + } catch (_error) { return []; } } @@ -786,7 +786,7 @@ export class ModelResolver { // Insert before settings group in the menu app.menu?.settingsGroup.element.before(this.buttonGroup.element); - } catch (e) { + } catch (_e) { // Fallback for older ComfyUI versions without the new button system log.debug('Model Resolver: New button system not available, using floating button fallback.'); this.createFloatingButton(); diff --git a/web/resolver/search/download_target_methods.js b/web/resolver/search/download_target_methods.js index a293e44..7a0747e 100644 --- a/web/resolver/search/download_target_methods.js +++ b/web/resolver/search/download_target_methods.js @@ -95,7 +95,7 @@ export const downloadTargetMethods = { const token = String(category || '') .trim() .toLowerCase() - .replace(/[\/\\\s-]+/g, '_') + .replace(/[/\\\s-]+/g, '_') .replace(/_+/g, '_') .replace(/^_|_$/g, ''); const categoryMap = { @@ -1006,16 +1006,16 @@ export const downloadTargetMethods = { joinLocalPath(basePath = '', relativePath = '') { const rawBase = String(basePath || ''); - const relative = String(relativePath || '').replace(/^[\/\\]+/, ''); + const relative = String(relativePath || '').replace(/^[/\\]+/, ''); const usesBackslash = /^[A-Za-z]:\\/.test(rawBase) || /^\\\\/.test(rawBase) || (!rawBase.includes('/') && rawBase.includes('\\')); const separator = usesBackslash ? '\\' : '/'; - const base = rawBase.replace(usesBackslash ? /[\/\\]+$/ : /\/+$/, '') + const base = rawBase.replace(usesBackslash ? /[/\\]+$/ : /\/+$/, '') || (usesBackslash ? (/^\\+$/.test(rawBase) ? '\\' : '') : (/^\/+$/.test(rawBase) ? '/' : '')); if (!base) return this.normalizePathToForward(relative); if (!relative) return base; - const normalizedRelative = relative.replace(/[\/\\]+/g, separator); + const normalizedRelative = relative.replace(/[/\\]+/g, separator); const joiner = base.endsWith(separator) ? '' : separator; return `${base}${joiner}${normalizedRelative}`; }, @@ -1776,14 +1776,14 @@ export const downloadTargetMethods = { normalizeFolderToken(value = '') { return String(value || '') .toLowerCase() - .replace(/[\/\\]+/g, ' ') + .replace(/[/\\]+/g, ' ') .replace(/[^a-z0-9]+/g, ''); }, getFolderSuggestionEntries(folders = []) { return folders.map(folder => { const value = this.getSubfolderOptionValue(folder); - const segments = value.split(/[\/\\]/).filter(Boolean); + const segments = value.split(/[/\\]/).filter(Boolean); return { value, label: this.getSubfolderOptionLabel(folder), @@ -1939,7 +1939,7 @@ export const downloadTargetMethods = { for (const value of rawValues) { const text = String(value || '').trim(); if (!text) continue; - const pathParts = text.split(/[\/\\]/).filter(Boolean); + const pathParts = text.split(/[/\\]/).filter(Boolean); if (pathParts.length > 1) { pathParts.slice(0, -1).forEach(addCandidate); addCandidate(pathParts.slice(0, -1).join('/')); @@ -3103,7 +3103,7 @@ export const downloadTargetMethods = { for (const controller of job.sourceControllers?.values?.() || []) { try { controller.abort(); - } catch (error) { /* ignore abort cleanup failures */ } + } catch (_error) { /* ignore abort cleanup failures */ } } } this.backgroundSearchJobs?.clear(); diff --git a/web/resolver/search/search_panel.js b/web/resolver/search/search_panel.js index a431e9f..86a2a71 100644 --- a/web/resolver/search/search_panel.js +++ b/web/resolver/search/search_panel.js @@ -1318,7 +1318,7 @@ export const searchPanelMethods = { }, missing, { workflowKey }); this.persistSearchStateForWorkflow(workflowKey, missing, state); this.refreshSearchUiForMissing(missing, state, { workflowKey }); - } catch (error) { + } catch (_error) { this.clearBackendSearchProgressTimer(runId, source); } finally { timerRecord.inFlight = false; @@ -2475,7 +2475,7 @@ export const searchPanelMethods = { ...(extra && typeof extra === 'object' ? extra : {}) }; const resolvedPath = merged.path || merged.resolved_path || ''; - const filename = merged.filename || fallbackName || resolvedPath.split(/[\/\\]/).pop() || ''; + const filename = merged.filename || fallbackName || resolvedPath.split(/[/\\]/).pop() || ''; return { ...merged, name: merged.name || filename, @@ -2552,7 +2552,7 @@ export const searchPanelMethods = { ]; for (const candidate of candidates) { const raw = String(candidate || '').trim(); - if (!raw || /[\/\\]/.test(raw) || /^[a-z]:/i.test(raw)) continue; + if (!raw || /[/\\]/.test(raw) || /^[a-z]:/i.test(raw)) continue; const normalized = this.normalizeDownloadCategory?.(raw) || raw; if (normalized && normalized !== 'unknown') return normalized; } @@ -2775,7 +2775,7 @@ export const searchPanelMethods = { try { this.localMatchAlternativesCollapsed = localStorage.getItem(this.localMatchAlternativesCollapsedStorageKey) === '1'; - } catch (e) { + } catch (_e) { this.localMatchAlternativesCollapsed = false; } @@ -2789,7 +2789,7 @@ export const searchPanelMethods = { this.localMatchAlternativesCollapsedStorageKey, this.localMatchAlternativesCollapsed ? '1' : '0' ); - } catch (e) {} + } catch (_e) {} }, renderLocalMatchesContent(missing, missingIndex = 0) { diff --git a/web/resolver/shell/dialog_shell_methods.js b/web/resolver/shell/dialog_shell_methods.js index 04bf9b7..94f7ae1 100644 --- a/web/resolver/shell/dialog_shell_methods.js +++ b/web/resolver/shell/dialog_shell_methods.js @@ -468,7 +468,7 @@ export const dialogShellMethods = { try { if (!(property in target)) return false; return Reflect.set(target, property, value); - } catch (error) { + } catch (_error) { return false; } }, @@ -504,7 +504,7 @@ export const dialogShellMethods = { if (this.trySetSidebarStateProperty(candidate, 'activeSidebarTabId', this.sidebarTabId)) { opened = true; } - } catch (error) { + } catch (_error) { // Sidebar internals differ between ComfyUI versions; unsupported state APIs are ignored. } } @@ -602,7 +602,7 @@ export const dialogShellMethods = { ) { closed = true; } - } catch (error) { + } catch (_error) { // Sidebar internals differ between ComfyUI versions; unsupported state APIs are ignored. } } @@ -656,7 +656,7 @@ export const dialogShellMethods = { el.style.resize = 'both'; // Restore saved pre-FS size if available let wh = null; - try { wh = JSON.parse(safeStorage.getItem('model_resolver_modal_size_before_fs') || 'null'); } catch (e) {} + try { wh = JSON.parse(safeStorage.getItem('model_resolver_modal_size_before_fs') || 'null'); } catch (_e) {} if (wh && wh.w && wh.h) { el.style.width = `${wh.w}px`; el.style.height = `${wh.h}px`; @@ -1023,7 +1023,7 @@ export const dialogShellMethods = { this._onMouseUp = () => this.endDrag(); document.addEventListener('mousemove', this._onMouseMove); document.addEventListener('mouseup', this._onMouseUp, { once: true }); - } catch (err) { /* ignore */ } + } catch (_err) { /* ignore */ } }, onDrag(e) { diff --git a/web/resolver/shell/lifecycle_graph_methods.js b/web/resolver/shell/lifecycle_graph_methods.js index 5979b41..531beb8 100644 --- a/web/resolver/shell/lifecycle_graph_methods.js +++ b/web/resolver/shell/lifecycle_graph_methods.js @@ -956,7 +956,7 @@ export const lifecycleGraphMethods = { const key = this.getMissingModelKey(missing); try { return btoa(key).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, ''); - } catch (e) { + } catch (_e) { return key.replace(/[^A-Za-z0-9_-]/g, char => `_${char.charCodeAt(0).toString(16)}_`); } } diff --git a/web/resolver/shell/workflow_state_methods.js b/web/resolver/shell/workflow_state_methods.js index ab10bb2..880f36c 100644 --- a/web/resolver/shell/workflow_state_methods.js +++ b/web/resolver/shell/workflow_state_methods.js @@ -358,7 +358,7 @@ export const workflowStateMethods = { getActiveWorkflowRouteKey() { try { return window.location?.hash || ''; - } catch (error) { + } catch (_error) { return ''; } }, diff --git a/web/resolver/utils/html_utils.js b/web/resolver/utils/html_utils.js index c59b238..5c60b74 100644 --- a/web/resolver/utils/html_utils.js +++ b/web/resolver/utils/html_utils.js @@ -291,7 +291,7 @@ export async function copyTextWithFeedback(text, button, options = {}) { */ export function getFilenameFromPath(path) { if (!path) return ''; - return path.split(/[\/\\]/).pop() || path; + return path.split(/[/\\]/).pop() || path; } diff --git a/web/resolver/utils/render_format_methods.js b/web/resolver/utils/render_format_methods.js index 2a18fb1..6ec1bbe 100644 --- a/web/resolver/utils/render_format_methods.js +++ b/web/resolver/utils/render_format_methods.js @@ -369,9 +369,9 @@ export const renderFormatMethods = { }, getBaseDirectoryLabel(baseDirectory = '') { - const clean = String(baseDirectory || '').replace(/[\\\/]+$/, ''); + const clean = String(baseDirectory || '').replace(/[\\/]+$/, ''); if (!clean) return 'Default root'; - return clean.split(/[\\\/]+/).filter(Boolean).pop() || clean; + return clean.split(/[\\/]+/).filter(Boolean).pop() || clean; }, estimateTextWidth(value, charPx = 6, minPx = 40, maxPx = 180) { diff --git a/web/resolver/utils/url_utils.js b/web/resolver/utils/url_utils.js index 354ebd7..41267f2 100644 --- a/web/resolver/utils/url_utils.js +++ b/web/resolver/utils/url_utils.js @@ -59,7 +59,7 @@ export function getModelCardUrl(downloadUrl) { return `https://huggingface.co/${file.repo}/blob/${encodedRevision}/${encodedPath}`; } - const match = downloadUrl.match(/huggingface\.co\/([^\/]+\/[^\/]+)/); + const match = downloadUrl.match(/huggingface\.co\/([^/]+\/[^/]+)/); if (match) { return `https://huggingface.co/${match[1]}`; } diff --git a/web/resolver/views/missing_browser_methods.js b/web/resolver/views/missing_browser_methods.js index 8805b04..6aaf181 100644 --- a/web/resolver/views/missing_browser_methods.js +++ b/web/resolver/views/missing_browser_methods.js @@ -964,7 +964,7 @@ export const missingBrowserMethods = { this.showResolvedModels = Boolean(showResolvedToggle.checked); try { safeStorage.setItem(this.showResolvedModelsStorageKey, this.showResolvedModels ? '1' : '0'); - } catch (e) {} + } catch (_e) {} this.displayMissingModels(container, data, { preserveBrowser: true }); }); } @@ -976,7 +976,7 @@ export const missingBrowserMethods = { this.showAutoDownloadModels = Boolean(showAutoDownloadToggle.checked); try { safeStorage.setItem(this.showAutoDownloadModelsStorageKey, this.showAutoDownloadModels ? '1' : '0'); - } catch (e) {} + } catch (_e) {} this.displayMissingModels(container, data, { preserveBrowser: true }); }); } @@ -1108,7 +1108,7 @@ export const missingBrowserMethods = { this.cancelMissingBrowserSplitWidthPersist(); try { safeStorage.removeItem(this.missingBrowserSplitStorageKey); - } catch (e) {} + } catch (_e) {} }); splitter.addEventListener('keydown', (event) => { @@ -1214,7 +1214,7 @@ export const missingBrowserMethods = { try { const storedWidth = parseInt(safeStorage.getItem(this.missingBrowserSplitStorageKey) || '', 10); savedWidth = Number.isFinite(storedWidth) && storedWidth > 0 ? storedWidth : null; - } catch (e) {} + } catch (_e) {} this._missingBrowserStoredSplitWidth = savedWidth; this._missingBrowserStoredSplitWidthLoaded = true; @@ -1532,7 +1532,7 @@ export const missingBrowserMethods = { if (this._missingBrowserSplitPersistIdle && typeof cancelIdleCallback === 'function') { try { cancelIdleCallback(this._missingBrowserSplitPersistIdle); - } catch (e) {} + } catch (_e) {} } if (this._missingBrowserSplitPersistTimer) { clearTimeout(this._missingBrowserSplitPersistTimer); @@ -1555,7 +1555,7 @@ export const missingBrowserMethods = { this._missingBrowserSplitPersistTimer = null; try { safeStorage.setItem(this.missingBrowserSplitStorageKey, String(nextWidth)); - } catch (e) {} + } catch (_e) {} }; const writeDelay = Math.max(0, Number(delay) || 0); @@ -1722,17 +1722,17 @@ export const missingBrowserMethods = { return this.joinLocalPath(basePath, relativePath); } const rawBase = String(basePath || ''); - const relative = String(relativePath || '').replace(/^[\/\\]+/, ''); + const relative = String(relativePath || '').replace(/^[/\\]+/, ''); const usesBackslash = /^[A-Za-z]:\\/.test(rawBase) || /^\\\\/.test(rawBase) || (!rawBase.includes('/') && rawBase.includes('\\')); const separator = usesBackslash ? '\\' : '/'; - const base = rawBase.replace(usesBackslash ? /[\/\\]+$/ : /\/+$/, '') + const base = rawBase.replace(usesBackslash ? /[/\\]+$/ : /\/+$/, '') || (usesBackslash ? (/^\\+$/.test(rawBase) ? '\\' : '') : (/^\/+$/.test(rawBase) ? '/' : '')); if (!base) return relative; if (!relative) return base; const joiner = base.endsWith(separator) ? '' : separator; - return `${base}${joiner}${relative.replace(/[\/\\]+/g, separator)}`; + return `${base}${joiner}${relative.replace(/[/\\]+/g, separator)}`; }; const buildLocalFolderContext = (folderPath = '', name = 'Folder', category = '') => { const path = String(folderPath || '').trim(); diff --git a/web/resolver/views/model_info_methods.js b/web/resolver/views/model_info_methods.js index 6979e2b..d13111f 100644 --- a/web/resolver/views/model_info_methods.js +++ b/web/resolver/views/model_info_methods.js @@ -216,7 +216,7 @@ export const modelInfoMethods = { if (host === 'huggingface.co' || host.endsWith('.huggingface.co')) return 'huggingface'; if (host === 'civarchive.com' || host.endsWith('.civarchive.com')) return 'civarchive'; if (host === 'civitai.com' || host.endsWith('.civitai.com') || host === 'civitai.red' || host.endsWith('.civitai.red')) return 'civitai'; - } catch (error) { + } catch (_error) { return this.getContextMenuSourceKeyFromText(url); } @@ -1098,7 +1098,7 @@ export const modelInfoMethods = { method: 'POST', body: JSON.stringify({ path }) }, 'Open containing folder'); - } catch (error) { + } catch (_error) { // Already logged and notified inside fetchJson } }, @@ -1601,7 +1601,7 @@ export const modelInfoMethods = { { method: 'POST', silent: true }, 'Cancel model hash calculation' ); - } catch (error) { + } catch (_error) { // Keep the UI in stopping state; polling will surface the final state if possible. } } @@ -1931,7 +1931,7 @@ export const modelInfoMethods = { const localData = { ...fallbackData, ...data, civitai_checked: false }; this.rememberContextMenuSourceMetadata(localData); this.updateInfoDialogWithData(dialog, localData); - } catch (e) { + } catch (_e) { if (dialog._localInfoRequestId !== requestId || dialog._infoDialogCivitaiFetchStarted) { return; } @@ -3002,7 +3002,7 @@ export const modelInfoMethods = { if (host !== 'civitai.com' && host !== 'civitai.red') return ''; url.hostname = 'civitai.com'; return url.toString(); - } catch (error) { + } catch (_error) { return /civitai\.(?:com|red)\//i.test(value) ? value.replace('civitai.red', 'civitai.com') : ''; @@ -3367,7 +3367,7 @@ export const modelInfoMethods = { getSourceModelMirrorHost(url = '') { try { return new URL(url).hostname.replace(/^www\./, ''); - } catch (error) { + } catch (_error) { return ''; } }, diff --git a/web/resolver/views/options_methods.js b/web/resolver/views/options_methods.js index f98d1fe..e38a2af 100644 --- a/web/resolver/views/options_methods.js +++ b/web/resolver/views/options_methods.js @@ -1088,7 +1088,7 @@ export const optionsMethods = { if (utf8Match?.[1]) { try { return decodeURIComponent(utf8Match[1].trim().replace(/^"|"$/g, '')); - } catch (error) { + } catch (_error) { return utf8Match[1].trim().replace(/^"|"$/g, '') || fallback; } } @@ -1238,7 +1238,7 @@ export const optionsMethods = { if (typeof this.metadataSizeControlsCollapsed !== 'boolean') { try { this.metadataSizeControlsCollapsed = safeStorage.getItem(this.metadataSizeControlsCollapsedStorageKey) === '1'; - } catch (error) { + } catch (_error) { this.metadataSizeControlsCollapsed = false; } } @@ -1447,7 +1447,7 @@ export const optionsMethods = { if (typeof this.metadataBuildControlsCollapsed !== 'boolean') { try { this.metadataBuildControlsCollapsed = safeStorage.getItem(this.metadataBuildControlsCollapsedStorageKey) === '1'; - } catch (error) { + } catch (_error) { this.metadataBuildControlsCollapsed = false; } } @@ -1460,7 +1460,7 @@ export const optionsMethods = { panel.setAttribute('aria-hidden', hidden ? 'true' : 'false'); try { panel.inert = hidden; - } catch (error) { + } catch (_error) { panel.toggleAttribute('inert', hidden); } }; @@ -1575,7 +1575,7 @@ export const optionsMethods = { 'Load metadata build capabilities' ); renderMetadataBuildCapabilities(data); - } catch (error) { + } catch (_error) { renderMetadataBuildCapabilities({ cpu_count: navigator.hardwareConcurrency || 1, default_worker_count: Math.min(navigator.hardwareConcurrency || 1, 4), @@ -3585,7 +3585,7 @@ export const optionsMethods = { } else if (opt.type === 'json') { try { tokens[opt.serverKey] = raw ? JSON.parse(raw) : opt.default; - } catch (e) { + } catch (_e) { tokens[opt.serverKey] = opt.default; } } else if (opt.type === 'backend') { diff --git a/web/utils/notification_utils.js b/web/utils/notification_utils.js index b373a75..96ad873 100644 --- a/web/utils/notification_utils.js +++ b/web/utils/notification_utils.js @@ -39,7 +39,7 @@ try { if (typeof createModuleLogger === 'function') { log = createModuleLogger(CONFIG.LOGGER_NAME); } -} catch (e) { +} catch (_e) { // Fallback if import fails or is commented out } @@ -70,7 +70,7 @@ const activeNotifications = new Map(); */ export function showNotification(message, typeOrBgColor = "info", durationOrOptions = 3000, typeArg = "info", deduplicateArg = false) { // Clean any prefix matching the project name (e.g. "[Model Resolver]") - const escapeRegex = (str) => str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + const escapeRegex = (str) => str.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'); const prefixRegex = new RegExp(`^\\[\\s*${escapeRegex(CONFIG.PROJECT_NAME)}\\s*\\]\\s*`, 'i'); message = message.replace(prefixRegex, "");