diff --git a/src/webui/www/eslint.config.mjs b/src/webui/www/eslint.config.mjs index 5d78ea107..102d04aea 100644 --- a/src/webui/www/eslint.config.mjs +++ b/src/webui/www/eslint.config.mjs @@ -36,6 +36,7 @@ export default [ "curly": ["error", "multi-or-nest", "consistent"], "eqeqeq": "error", "guard-for-in": "error", + "no-implicit-coercion": "error", "no-undef": "off", "no-unused-vars": "off", "no-var": "error", @@ -73,7 +74,10 @@ export default [ "Unicorn/no-array-for-each": "error", "Unicorn/no-for-loop": "error", "Unicorn/no-zero-fractions": "error", + "Unicorn/prefer-classlist-toggle": "error", + "Unicorn/prefer-native-coercion-functions": "error", "Unicorn/prefer-number-properties": "error", + "Unicorn/prefer-single-call": "error", "Unicorn/switch-case-braces": ["error", "avoid"] } } diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index b8e895ffb..0f69e4b1d 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -710,10 +710,8 @@ window.qBittorrent.DynamicTable ??= (() => { colElem.classList.toggle("reverse", isReverse); } const oldColElem = getCol(this.dynamicTableFixedHeaderDivId, oldColumn); - if (oldColElem !== null) { - oldColElem.classList.remove("sorted"); - oldColElem.classList.remove("reverse"); - } + if (oldColElem !== null) + oldColElem.classList.remove("sorted", "reverse"); } getSelectedRowId() { diff --git a/src/webui/www/private/scripts/search.js b/src/webui/www/private/scripts/search.js index 90c099467..b0f30cdfa 100644 --- a/src/webui/www/private/scripts/search.js +++ b/src/webui/www/private/scripts/search.js @@ -730,9 +730,7 @@ window.qBittorrent.Search ??= (() => { for (const plugin of responseJSON) searchPlugins.push(plugin); - const pluginOptions = []; - pluginOptions.push(createOption("QBT_TR(Only enabled)QBT_TR[CONTEXT=SearchEngineWidget]", "enabled")); - pluginOptions.push(createOption("QBT_TR(All plugins)QBT_TR[CONTEXT=SearchEngineWidget]", "all")); + const pluginOptions = [createOption("QBT_TR(Only enabled)QBT_TR[CONTEXT=SearchEngineWidget]", "enabled"), createOption("QBT_TR(All plugins)QBT_TR[CONTEXT=SearchEngineWidget]", "all")]; const searchPluginsEmpty = (searchPlugins.length === 0); if (!searchPluginsEmpty) { diff --git a/src/webui/www/private/views/aboutToolbar.html b/src/webui/www/private/views/aboutToolbar.html index 23a10cec1..143a1d175 100644 --- a/src/webui/www/private/views/aboutToolbar.html +++ b/src/webui/www/private/views/aboutToolbar.html @@ -17,12 +17,8 @@ MochaUI.initializeTabs("aboutTabs"); const showContent = (element) => { - for (const content of document.querySelectorAll(".aboutTabContent")) { - if (content === element) - content.classList.remove("invisible"); - else - content.classList.add("invisible"); - } + for (const content of document.querySelectorAll(".aboutTabContent")) + content.classList.toggle("invisible", (content !== element)); }; document.getElementById("aboutAboutLink").addEventListener("click", (event) => { diff --git a/src/webui/www/private/views/preferencesToolbar.html b/src/webui/www/private/views/preferencesToolbar.html index 38dfb9dce..da9dbd332 100644 --- a/src/webui/www/private/views/preferencesToolbar.html +++ b/src/webui/www/private/views/preferencesToolbar.html @@ -36,12 +36,8 @@ MochaUI.initializeTabs("preferencesTabs"); const showTab = (element) => { - for (const tab of document.querySelectorAll(".PrefTab")) { - if (tab === element) - tab.classList.remove("invisible"); - else - tab.classList.add("invisible"); - } + for (const tab of document.querySelectorAll(".PrefTab")) + tab.classList.toggle("invisible", (tab !== element)); }; document.getElementById("PrefBehaviorLink").addEventListener("click", (e) => { diff --git a/src/webui/www/private/views/rss.html b/src/webui/www/private/views/rss.html index 26e27f77d..80723924c 100644 --- a/src/webui/www/private/views/rss.html +++ b/src/webui/www/private/views/rss.html @@ -620,8 +620,8 @@ if (articlesDiffer) { // update unread count - const oldUnread = feedData[r.uid].map((art) => !art.isRead).filter((v) => v).length; - const newUnread = r.articles.map((art) => !art.isRead).filter((v) => v).length; + const oldUnread = feedData[r.uid].map((art) => !art.isRead).filter(Boolean).length; + const newUnread = r.articles.map((art) => !art.isRead).filter(Boolean).length; const unreadDifference = newUnread - oldUnread; // find all parents (and self) and add unread difference @@ -733,7 +733,7 @@ }); // calculate number of unread - const numberOfUnread = dataEntry.articles.map((art) => !art.isRead).filter((v) => v).length; + const numberOfUnread = dataEntry.articles.map((art) => !art.isRead).filter(Boolean).length; // find all items that contain this rss feed and add unread count for (const row of rssFeedTable.getRowValues()) { if (dataEntry.fullName.slice(0, row.full_data.dataPath.length) === row.full_data.dataPath)