From 6f05e3bf03de4b9096fd20e30ec854b7827e88a8 Mon Sep 17 00:00:00 2001 From: alexsparkes Date: Mon, 27 Oct 2025 23:27:13 +0000 Subject: [PATCH] Fix all ESLint errors: case declarations, empty blocks, display names, keys, and more --- src/components/Elements/Button/Button.jsx | 2 ++ src/features/background/Background.jsx | 21 ++++++++++++------- .../background/components/Favourite.jsx | 10 ++++++--- .../components/PhotoInformation.jsx | 8 +++++-- .../background/options/CustomURLModal.jsx | 1 - .../greeting/options/GreetingOptions.jsx | 7 ++++--- src/features/marketplace/views/Added.jsx | 4 +++- src/features/marketplace/views/Browse.jsx | 4 +++- src/features/misc/sections/About.jsx | 6 ++++-- src/features/misc/sections/Overview.jsx | 2 +- .../sections/overview_skeletons/Quote.jsx | 2 +- src/features/navbar/Navbar.jsx | 4 +++- src/features/navbar/components/Apps.jsx | 4 +++- src/features/navbar/components/Notes.jsx | 4 +++- src/features/navbar/components/Todo.jsx | 8 ++++--- .../quicklinks/options/QuickLinksOptions.jsx | 6 +++++- src/features/quote/Quote.jsx | 18 +++++++++------- src/features/quote/options/QuoteOptions.jsx | 2 +- src/features/search/Search.jsx | 2 +- src/features/time/Clock.jsx | 3 ++- .../Elements/ProgressBar/ProgressBar.jsx | 2 ++ src/utils/experimental.js | 5 ++++- src/utils/marketplace/install.js | 9 +++++--- src/utils/marketplace/uninstall.js | 3 ++- 24 files changed, 92 insertions(+), 45 deletions(-) diff --git a/src/components/Elements/Button/Button.jsx b/src/components/Elements/Button/Button.jsx index 057a05d8..0db67600 100644 --- a/src/components/Elements/Button/Button.jsx +++ b/src/components/Elements/Button/Button.jsx @@ -90,4 +90,6 @@ const Button = forwardRef( }, ); +Button.displayName = 'Button'; + export { Button as default, Button }; diff --git a/src/features/background/Background.jsx b/src/features/background/Background.jsx index 11b43d86..a87d67b1 100644 --- a/src/features/background/Background.jsx +++ b/src/features/background/Background.jsx @@ -98,7 +98,7 @@ export default class Background extends PureComponent { switch (backgroundAPI) { case 'unsplash': - case 'pexels': + case 'pexels': { const collection = localStorage.getItem('unsplashCollections'); if (collection) { requestURL = `${variables.constants.API_URL}/images/unsplash?collections=${collection}&quality=${apiQuality}`; @@ -106,6 +106,7 @@ export default class Background extends PureComponent { requestURL = `${variables.constants.API_URL}/images/unsplash?categories=${apiCategories || ''}&quality=${apiQuality}`; } break; + } // Defaults to Mue default: requestURL = `${variables.constants.API_URL}/images/random?categories=${apiCategories || ''}&quality=${apiQuality}&excludes=${backgroundExclude}`; @@ -115,7 +116,7 @@ export default class Background extends PureComponent { const accept = 'application/json, ' + ((await supportsAVIF()) ? 'image/avif' : 'image/webp'); try { data = await (await fetch(requestURL, { headers: { accept } })).json(); - } catch (e) { + } catch { // if requesting to the API fails, we get an offline image this.setState(getOfflineImage('api')); return null; @@ -188,7 +189,7 @@ export default class Background extends PureComponent { const type = localStorage.getItem('backgroundType'); switch (type) { - case 'api': + case 'api': { if (offline) { return this.setState(getOfflineImage('api')); } @@ -205,8 +206,9 @@ export default class Background extends PureComponent { ); // pre-fetch data about the next image } break; + } - case 'colour': + case 'colour': { let customBackgroundColour = localStorage.getItem('customBackgroundColour'); // check if its a json object if (customBackgroundColour && customBackgroundColour.startsWith('{')) { @@ -215,7 +217,7 @@ export default class Background extends PureComponent { try { localStorage.setItem('customBackgroundColour', customBackground.gradient[0].colour); customBackgroundColour = customBackground.gradient.colour; - } catch (e) { + } catch { // give up customBackgroundColour = 'rgb(0,0,0)'; } @@ -225,17 +227,18 @@ export default class Background extends PureComponent { style: `background: ${customBackgroundColour || 'rgb(0,0,0)'}`, }); break; + } case 'random_colour': case 'random_gradient': this.setState(randomColourStyleBuilder(type)); break; - case 'custom': + case 'custom': { let customBackground = []; const customSaved = localStorage.getItem('customBackground'); try { customBackground = JSON.parse(customSaved); - } catch (e) { + } catch { if (customSaved !== '') { // move to new format customBackground = [customSaved]; @@ -270,8 +273,9 @@ export default class Background extends PureComponent { localStorage.setItem('currentBackground', JSON.stringify(object)); } break; + } - case 'photo_pack': + case 'photo_pack': { if (offline) { return this.setState(getOfflineImage('photo_pack')); } @@ -347,6 +351,7 @@ export default class Background extends PureComponent { } } break; + } default: break; } diff --git a/src/features/background/components/Favourite.jsx b/src/features/background/components/Favourite.jsx index ec345e3d..af8d79ef 100644 --- a/src/features/background/components/Favourite.jsx +++ b/src/features/background/components/Favourite.jsx @@ -41,7 +41,7 @@ class Favourite extends PureComponent { }), ); break; - default: + default: { let url = document .getElementById('backgroundImage') .style.backgroundImage.replace('url("', '') @@ -53,9 +53,11 @@ class Favourite extends PureComponent { if (url.startsWith('blob:')) { const reader = new FileReader(); - url = await new Promise(async (resolve) => { + url = await new Promise((resolve) => { reader.onloadend = () => resolve(reader.result); - reader.readAsDataURL(await (await fetch(url)).blob()); + fetch(url) + .then((res) => res.blob()) + .then((blob) => reader.readAsDataURL(blob)); }); } @@ -86,6 +88,8 @@ class Favourite extends PureComponent { }), ); } + break; + } } this.setState({ diff --git a/src/features/background/components/PhotoInformation.jsx b/src/features/background/components/PhotoInformation.jsx index 76360b7e..c66d99c4 100644 --- a/src/features/background/components/PhotoInformation.jsx +++ b/src/features/background/components/PhotoInformation.jsx @@ -262,9 +262,13 @@ function PhotoInformation({ info, url, api }) { try { setPhotoMap(true); setMapIcon(false); - } catch (e) {} + } catch { + // Ignore errors + } }; - } catch (e) {} + } catch { + // Element not found + } const widgetStyle = localStorage.getItem('widgetStyle'); diff --git a/src/features/background/options/CustomURLModal.jsx b/src/features/background/options/CustomURLModal.jsx index 14b910f6..842cd7d5 100644 --- a/src/features/background/options/CustomURLModal.jsx +++ b/src/features/background/options/CustomURLModal.jsx @@ -24,7 +24,6 @@ function CustomURLModal({ modalClose, urlError, modalCloseOnly }) { type="text" value={url} onChange={(e) => setURL(e.target.value.replace(/(\r\n|\n|\r)/gm, ''))} - varient="outlined" /> {urlError}
diff --git a/src/features/greeting/options/GreetingOptions.jsx b/src/features/greeting/options/GreetingOptions.jsx index eb377dbf..a55ede5b 100644 --- a/src/features/greeting/options/GreetingOptions.jsx +++ b/src/features/greeting/options/GreetingOptions.jsx @@ -24,9 +24,10 @@ const GreetingOptions = () => { ); const [events, setEvents] = useState(false); - const [birthday, setBirthday] = useState( - new Date(localStorage.getItem('birthday')) || new Date(), - ); + const [birthday, setBirthday] = useState(() => { + const stored = localStorage.getItem('birthday'); + return stored ? new Date(stored) : new Date(); + }); const [enableBirthday, setEnableBirthday] = useState( localStorage.getItem('birthdayenabled') === 'true' ? 'preferences' : 'preferencesInactive', diff --git a/src/features/marketplace/views/Added.jsx b/src/features/marketplace/views/Added.jsx index c22b8ff4..626fa195 100644 --- a/src/features/marketplace/views/Added.jsx +++ b/src/features/marketplace/views/Added.jsx @@ -193,7 +193,9 @@ export default class Added extends PureComponent { this.state.installed.forEach((item) => { uninstall(item.type, item.name); }); - } catch (e) {} + } catch { + // Ignore errors during bulk uninstall + } localStorage.setItem('installed', JSON.stringify([])); diff --git a/src/features/marketplace/views/Browse.jsx b/src/features/marketplace/views/Browse.jsx index bbd62be8..dae5fea3 100644 --- a/src/features/marketplace/views/Browse.jsx +++ b/src/features/marketplace/views/Browse.jsx @@ -224,7 +224,7 @@ class Marketplace extends PureComponent { } switch (value) { - case 'a-z': + case 'a-z': { // sort by name key alphabetically const sorted = items.sort((a, b) => { if (a.display_name < b.display_name) { @@ -237,6 +237,7 @@ class Marketplace extends PureComponent { }); items = sorted; break; + } case 'z-a': items.sort(); items.reverse(); @@ -427,6 +428,7 @@ class Marketplace extends PureComponent { this.state.items.map((item) => !item.news ? (
{ if (handle === 'empty') { return ( -

{variables.getMessage('modals.main.settings.sections.about.no_supporters')}

+

+ {variables.getMessage('modals.main.settings.sections.about.no_supporters')} +

); } diff --git a/src/features/misc/sections/Overview.jsx b/src/features/misc/sections/Overview.jsx index b67dcf21..e1b0c16f 100644 --- a/src/features/misc/sections/Overview.jsx +++ b/src/features/misc/sections/Overview.jsx @@ -175,7 +175,7 @@ const Overview = () => { return null; } return ( -
+
{getTab(value)}
); diff --git a/src/features/misc/sections/overview_skeletons/Quote.jsx b/src/features/misc/sections/overview_skeletons/Quote.jsx index 2b3dcf2c..10fb3d8b 100644 --- a/src/features/misc/sections/overview_skeletons/Quote.jsx +++ b/src/features/misc/sections/overview_skeletons/Quote.jsx @@ -4,7 +4,7 @@ import { MdPerson } from 'react-icons/md'; function QuoteSkeleton() { return (
- "Never gonna give you up" + “Never gonna give you up”
diff --git a/src/features/navbar/Navbar.jsx b/src/features/navbar/Navbar.jsx index ae87f188..d997e15c 100644 --- a/src/features/navbar/Navbar.jsx +++ b/src/features/navbar/Navbar.jsx @@ -69,7 +69,9 @@ class Navbar extends PureComponent { try { this.updateRefreshText(); this.setZoom(); - } catch (e) {} + } catch { + // Ignore errors + } } }); diff --git a/src/features/navbar/components/Apps.jsx b/src/features/navbar/components/Apps.jsx index dbfcce27..c27c1e96 100644 --- a/src/features/navbar/components/Apps.jsx +++ b/src/features/navbar/components/Apps.jsx @@ -31,7 +31,9 @@ class Apps extends PureComponent { this.forceUpdate(); try { this.setZoom(); - } catch (e) {} + } catch { + // Ignore errors + } } }); diff --git a/src/features/navbar/components/Notes.jsx b/src/features/navbar/components/Notes.jsx index 83e4efe1..1b1cc369 100644 --- a/src/features/navbar/components/Notes.jsx +++ b/src/features/navbar/components/Notes.jsx @@ -32,7 +32,9 @@ class Notes extends PureComponent { this.forceUpdate(); try { this.setZoom(); - } catch (e) {} + } catch { + // Ignore errors + } } }); diff --git a/src/features/navbar/components/Todo.jsx b/src/features/navbar/components/Todo.jsx index ff7d00e7..2f43c92f 100644 --- a/src/features/navbar/components/Todo.jsx +++ b/src/features/navbar/components/Todo.jsx @@ -32,8 +32,8 @@ import { import { CSS } from '@dnd-kit/utilities'; import EventBus from 'utils/eventbus'; -const DragHandle = () => ( -
+const DragHandle = (props) => ( +
); @@ -88,7 +88,9 @@ class Todo extends PureComponent { this.forceUpdate(); try { this.setZoom(); - } catch (e) {} + } catch { + // Ignore errors + } } }); diff --git a/src/features/quicklinks/options/QuickLinksOptions.jsx b/src/features/quicklinks/options/QuickLinksOptions.jsx index 692f3d79..6c3efd52 100644 --- a/src/features/quicklinks/options/QuickLinksOptions.jsx +++ b/src/features/quicklinks/options/QuickLinksOptions.jsx @@ -310,7 +310,11 @@ class QuickLinksOptions extends PureComponent { if (this.handleRefresh) { EventBus.off('refresh', this.handleRefresh); } else { - try { EventBus.off('refresh'); } catch (e) {} + try { + EventBus.off('refresh'); + } catch { + // Ignore errors + } } } render() { diff --git a/src/features/quote/Quote.jsx b/src/features/quote/Quote.jsx index f8412f49..5a3ec2b4 100644 --- a/src/features/quote/Quote.jsx +++ b/src/features/quote/Quote.jsx @@ -82,7 +82,7 @@ class Quote extends PureComponent { this.quote = createRef(); this.quotediv = createRef(); this.quoteauthor = createRef(); - this.authorDetails = (localStorage.getItem('authorDetails') === 'true' || true) ? true : false; + this.authorDetails = localStorage.getItem('authorDetails') === 'true'; } useFavourite() { @@ -208,11 +208,11 @@ class Quote extends PureComponent { } switch (this.state.type) { - case 'custom': + case 'custom': { let customQuote; try { customQuote = JSON.parse(localStorage.getItem('customQuote')); - } catch (e) { + } catch { // move to new format customQuote = [ { @@ -242,7 +242,8 @@ class Quote extends PureComponent { }); } break; - case 'quote_pack': + } + case 'quote_pack': { if (offline) { return this.doOffline(); } @@ -268,9 +269,11 @@ class Quote extends PureComponent { authorimg: data.fallbackauthorimg, }); } else { - return this.doOffline(); + this.doOffline(); } - case 'api': + break; + } + case 'api': { if (offline) { return this.doOffline(); } @@ -307,11 +310,12 @@ class Quote extends PureComponent { } else { this.doOffline(); } - } catch (e) { + } catch { // ...and if that fails we load one locally this.doOffline(); } break; + } default: break; } diff --git a/src/features/quote/options/QuoteOptions.jsx b/src/features/quote/options/QuoteOptions.jsx index 763664ce..917a4395 100644 --- a/src/features/quote/options/QuoteOptions.jsx +++ b/src/features/quote/options/QuoteOptions.jsx @@ -188,7 +188,7 @@ class QuoteOptions extends PureComponent { {this.state.customQuote.length !== 0 ? (
{this.state.customQuote.map((_url, index) => ( -
+
diff --git a/src/features/search/Search.jsx b/src/features/search/Search.jsx index 980dec7e..5822d8cd 100644 --- a/src/features/search/Search.jsx +++ b/src/features/search/Search.jsx @@ -41,7 +41,7 @@ function Search() { return () => { EventBus.off('refresh'); }; - }, []); + }, [init]); const micIcon = createRef(); diff --git a/src/features/time/Clock.jsx b/src/features/time/Clock.jsx index 7437bf94..67281288 100644 --- a/src/features/time/Clock.jsx +++ b/src/features/time/Clock.jsx @@ -50,7 +50,7 @@ export default class Clock extends PureComponent { time: now, }); break; - default: + default: { // Default clock let time, sec = ''; @@ -112,6 +112,7 @@ export default class Clock extends PureComponent { }); } break; + } } this.startTime(); diff --git a/src/features/welcome/components/Elements/ProgressBar/ProgressBar.jsx b/src/features/welcome/components/Elements/ProgressBar/ProgressBar.jsx index b7cb1720..5a24e928 100644 --- a/src/features/welcome/components/Elements/ProgressBar/ProgressBar.jsx +++ b/src/features/welcome/components/Elements/ProgressBar/ProgressBar.jsx @@ -10,6 +10,8 @@ const Step = memo(({ isActive, index, onClick }) => { ); }); +Step.displayName = 'Step'; + function ProgressBar({ numberOfTabs, currentTab, switchTab }) { return (
diff --git a/src/utils/experimental.js b/src/utils/experimental.js index dcae1bdd..05469100 100644 --- a/src/utils/experimental.js +++ b/src/utils/experimental.js @@ -10,17 +10,20 @@ export default function ExperimentalInit() { const code = e.which || e.keyCode; switch (code) { - case 222: + case 222: { const timeout = localStorage.getItem('debugtimeout'); if (timeout !== '0') { setTimeout(() => { + // eslint-disable-next-line no-debugger debugger; }, timeout); } else { + // eslint-disable-next-line no-debugger debugger; } break; + } default: break; } diff --git a/src/utils/marketplace/install.js b/src/utils/marketplace/install.js index 11d50a02..c2fb7ce7 100644 --- a/src/utils/marketplace/install.js +++ b/src/utils/marketplace/install.js @@ -12,7 +12,7 @@ function showReminder() { export function install(type, input, sideload, collection) { switch (type) { - case 'settings': + case 'settings': { localStorage.removeItem('backup_settings'); const oldSettings = []; @@ -29,8 +29,9 @@ export function install(type, input, sideload, collection) { }); showReminder(); break; + } - case 'photos': + case 'photos': { const currentPhotos = JSON.parse(localStorage.getItem('photo_packs')) || []; input.photos.forEach((photo) => { currentPhotos.push(photo); @@ -49,8 +50,9 @@ export function install(type, input, sideload, collection) { window.location.reload(); } break; + } - case 'quotes': + case 'quotes': { const currentQuotes = JSON.parse(localStorage.getItem('quote_packs')) || []; input.quotes.forEach((quote) => { currentQuotes.push(quote); @@ -64,6 +66,7 @@ export function install(type, input, sideload, collection) { localStorage.removeItem('quotechange'); EventBus.emit('refresh', 'quote'); break; + } default: break; diff --git a/src/utils/marketplace/uninstall.js b/src/utils/marketplace/uninstall.js index 8fc9b904..f1a1ae08 100644 --- a/src/utils/marketplace/uninstall.js +++ b/src/utils/marketplace/uninstall.js @@ -9,7 +9,7 @@ function showReminder() { export function uninstall(type, name) { let installedContents, packContents; switch (type) { - case 'settings': + case 'settings': { const oldSettings = JSON.parse(localStorage.getItem('backup_settings')); localStorage.clear(); oldSettings.forEach((item) => { @@ -17,6 +17,7 @@ export function uninstall(type, name) { }); showReminder(); break; + } case 'quotes': installedContents = JSON.parse(localStorage.getItem('quote_packs'));