diff --git a/biome.json b/biome.json index 977c5283c..1ac79ea95 100644 --- a/biome.json +++ b/biome.json @@ -8,6 +8,10 @@ "noBannedTypes": "off", "noForEach": "off" }, + "correctness": { + "noUnusedFunctionParameters": "error", + "noUnusedVariables": "error" + }, "performance": { "noAccumulatingSpread": "off" }, diff --git a/src/screens/Activity/ActivityDetail.tsx b/src/screens/Activity/ActivityDetail.tsx index 44bb68619..799215e61 100644 --- a/src/screens/Activity/ActivityDetail.tsx +++ b/src/screens/Activity/ActivityDetail.tsx @@ -164,7 +164,6 @@ const OnchainActivityDetail = ({ const dispatch = useAppDispatch(); const contacts = useAppSelector(contactsSelector); const tags = useAppSelector((state) => tagSelector(state, id)); - const selectedNetwork = useAppSelector(selectedNetworkSelector); const activityItems = useAppSelector(activityItemsSelector); const boostedTransactions = useAppSelector(boostedTransactionsSelector); const transfer = useAppSelector((state) => { diff --git a/src/screens/Contacts/AddContact.tsx b/src/screens/Contacts/AddContact.tsx index 2f77c8132..9aedabd8b 100644 --- a/src/screens/Contacts/AddContact.tsx +++ b/src/screens/Contacts/AddContact.tsx @@ -50,7 +50,7 @@ const AddContact = ({ try { parse(contactUrl); - } catch (e) { + } catch (_e) { setError(t('contact_error_key')); return; } @@ -60,7 +60,7 @@ const AddContact = ({ setError(t('contact_error_yourself')); return; } - } catch (e) {} + } catch (_e) {} const onError = (): void => { setError(t('contact_error_key')); diff --git a/src/screens/Contacts/ContactEdit.tsx b/src/screens/Contacts/ContactEdit.tsx index bd2d8984a..d34b0d4cb 100644 --- a/src/screens/Contacts/ContactEdit.tsx +++ b/src/screens/Contacts/ContactEdit.tsx @@ -45,7 +45,7 @@ const ContactEdit = ({ const myProfile = useMemo(() => { try { return parse(myProfileUrl).id === parse(url).id; - } catch (e) { + } catch (_e) { return false; } }, [myProfileUrl, url]); diff --git a/src/screens/Settings/ElectrumConfig/index.tsx b/src/screens/Settings/ElectrumConfig/index.tsx index 01418c97c..60f8bb6f7 100644 --- a/src/screens/Settings/ElectrumConfig/index.tsx +++ b/src/screens/Settings/ElectrumConfig/index.tsx @@ -67,7 +67,7 @@ const isValidURL = (data: string): boolean => { } return isValidDomainOrIP; - } catch (e) { + } catch (_e) { // If URL constructor fails, it's not a valid URL return false; } diff --git a/src/store/migrations/index.ts b/src/store/migrations/index.ts index fd0e09d28..0e94b9d7c 100644 --- a/src/store/migrations/index.ts +++ b/src/store/migrations/index.ts @@ -76,7 +76,7 @@ const migrations = { for (const key of keys) { mmkv.delete(key); } - } catch (e) {} + } catch (_e) {} return state; }, diff --git a/src/store/utils/settings.ts b/src/store/utils/settings.ts index 5b5a0b73e..b7366ba1c 100644 --- a/src/store/utils/settings.ts +++ b/src/store/utils/settings.ts @@ -35,7 +35,7 @@ export const wipeApp = async ({ try { const wallet = getOnChainWallet(); await wallet.stop(); - } catch (e) {} + } catch (_e) {} // Reset Redux stores & persisted storage dispatch({ type: actions.WIPE_APP }); diff --git a/src/utils/conversion.ts b/src/utils/conversion.ts index 9f8ee0c91..54f37196d 100644 --- a/src/utils/conversion.ts +++ b/src/utils/conversion.ts @@ -13,7 +13,7 @@ export const btcToSats = (balance: number): number => { .value() .toFixed(0), ); - } catch (e) { + } catch (_e) { return 0; } }; @@ -75,7 +75,7 @@ export const fiatToBitcoinUnit = ({ .toFixed(denomination === EDenomination.modern ? 0 : 8); // satoshi cannot be a fractional number return Number(value); - } catch (e) { + } catch (_e) { return 0; } }; diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 50b1d791f..eda561751 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -191,19 +191,6 @@ export const capitalize = (text: string): string => { return text.charAt(0).toUpperCase() + text.slice(1); }; -/** - * Returns the last word in a string. - * @param {string} phrase - */ -export const getLastWordInString = (phrase: string): string => { - try { - const n = phrase.split(' '); - return n[n.length - 1]; - } catch (e) { - return phrase; - } -}; - export const roundUpToTwoDecimals = (num: number): number => { return Math.ceil(num * 100) / 100; }; @@ -509,7 +496,7 @@ export const openURL = async (url: string): Promise => { export const openAppURL = async (url: string): Promise => { try { await Linking.openURL(url); - } catch (error) { + } catch (_e) { console.log('Cannot open url: ', url); } }; diff --git a/src/utils/i18n/index.ts b/src/utils/i18n/index.ts index be332e9e2..c51cdfc9c 100644 --- a/src/utils/i18n/index.ts +++ b/src/utils/i18n/index.ts @@ -54,7 +54,7 @@ i18nICU try { // @ts-ignore __setDefaultTimeZone doesn't exist in native API Intl.DateTimeFormat.__setDefaultTimeZone(timeZone); - } catch (e) { + } catch (_e) { console.log(`error settings timezone to: ${timeZone} fallback to UTC`); // @ts-ignore __setDefaultTimeZone doesn't exist in native API Intl.DateTimeFormat.__setDefaultTimeZone('UTC'); @@ -80,7 +80,7 @@ i18nICU if (Intl.RelativeTimeFormat.polyfilled) { await relativeTimeFormatPolyfills[lang]?.(); } - } catch (e) { + } catch (_e) { console.warn('Error loading polyfill for language: ', lang); } }); diff --git a/src/utils/ignoreLogs.ts b/src/utils/ignoreLogs.ts index d83c51eef..c3a1d2932 100644 --- a/src/utils/ignoreLogs.ts +++ b/src/utils/ignoreLogs.ts @@ -24,7 +24,7 @@ if (__DEV__) { let output: string; try { output = args.join(' '); - } catch (err) { + } catch (_err) { // if we can't check if the log should be ignored, just log it logger(...args); return; diff --git a/src/utils/lightning/logs.ts b/src/utils/lightning/logs.ts index 0b3884ea9..775655706 100644 --- a/src/utils/lightning/logs.ts +++ b/src/utils/lightning/logs.ts @@ -173,5 +173,5 @@ const unlinkIfExists = async (path: string): Promise => { if (await exists(path)) { await unlink(path); } - } catch (e) {} + } catch (_e) {} }; diff --git a/src/utils/wallet/transactions.ts b/src/utils/wallet/transactions.ts index ba16d49fc..79a464add 100644 --- a/src/utils/wallet/transactions.ts +++ b/src/utils/wallet/transactions.ts @@ -168,7 +168,7 @@ export const getTransactionInputValue = ({ } } return 0; - } catch (e) { + } catch (_e) { return 0; } }; diff --git a/src/utils/wallet/txdecoder.ts b/src/utils/wallet/txdecoder.ts index 4b6c0c1f3..639890ed7 100644 --- a/src/utils/wallet/txdecoder.ts +++ b/src/utils/wallet/txdecoder.ts @@ -44,7 +44,7 @@ const classifyOutputScript = (script): string => { const isOutput = (paymentFn: PaymentFn): bitcoin.Payment | undefined => { try { return paymentFn({ output: script }); - } catch (e) {} + } catch (_e) {} }; if (isOutput(bitcoin.payments.p2pk)) {