From 855548f686a5fb5586285666860f5c96b9dd4a53 Mon Sep 17 00:00:00 2001 From: Peter Sanderson Date: Thu, 31 Oct 2024 16:30:15 +0100 Subject: [PATCH] chore: add 'no-case-declarations' ESLint rule --- .eslintrc.js | 1 + packages/blockchain-link/src/workers/electrum/index.ts | 4 ++-- packages/connect/src/data/analyticsInfo.ts | 3 ++- .../MultiShareBackupModal/MultiShareBackupModal.tsx | 6 ++++-- suite-common/wallet-utils/src/tokenUtils.ts | 3 ++- .../accounts/src/components/AccountSelectBottomSheet.tsx | 3 ++- suite-native/blockchain/src/blockchainMiddleware.ts | 3 ++- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 248522c29d0..673a6ca8241 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -71,6 +71,7 @@ module.exports = { allowArrowFunctions: true, }, ], + 'no-case-declarations': 'error', // Fix for TypeScript. 'react/jsx-filename-extension': [ 'error', diff --git a/packages/blockchain-link/src/workers/electrum/index.ts b/packages/blockchain-link/src/workers/electrum/index.ts index af8af2c546b..5c5ecd4950b 100644 --- a/packages/blockchain-link/src/workers/electrum/index.ts +++ b/packages/blockchain-link/src/workers/electrum/index.ts @@ -127,14 +127,14 @@ const onRequest = async ( throw new CustomError(`Subscription ${request.payload.type} not implemented`); } // @ts-expect-error this message is used in tests - case 'raw': + case 'raw': { // @ts-expect-error - const { method, params } = request.payload; return client .request(method, ...params) .then((res: any) => ({ type: method, payload: res })); + } default: throw new CustomError('worker_unknown_request', `+${request.type}`); } diff --git a/packages/connect/src/data/analyticsInfo.ts b/packages/connect/src/data/analyticsInfo.ts index a131778bec3..da59ded02ef 100644 --- a/packages/connect/src/data/analyticsInfo.ts +++ b/packages/connect/src/data/analyticsInfo.ts @@ -7,7 +7,7 @@ export const enhanceMessageWithAnalytics = ( data: { device?: Device }, ): CoreEventMessage => { switch (message.type) { - case UI_REQUEST.REQUEST_CONFIRMATION: + case UI_REQUEST.REQUEST_CONFIRMATION: { const { device } = data; return { @@ -37,6 +37,7 @@ export const enhanceMessageWithAnalytics = ( }, }, }; + } default: return message; diff --git a/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupModal.tsx b/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupModal.tsx index 3f0b1011a6d..fae960a71f4 100644 --- a/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupModal.tsx +++ b/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupModal.tsx @@ -70,7 +70,7 @@ export const MultiShareBackupModal = ({ onCancel }: MultiShareBackupModalProps) const getStepConfig = (): StepConfig => { switch (step) { - case 'first-info': + case 'first-info': { const goToStepNextStep = () => { setIsSubmitted(true); if (isChecked1 && isChecked2) { @@ -107,8 +107,9 @@ export const MultiShareBackupModal = ({ onCancel }: MultiShareBackupModalProps) isCancelable: true, hasBackdropCancel: true, }; + } - case 'second-info': + case 'second-info': { const enterBackup = async () => { setStep('verify-ownership'); @@ -160,6 +161,7 @@ export const MultiShareBackupModal = ({ onCancel }: MultiShareBackupModalProps) isCancelable: true, hasBackdropCancel: true, }; + } case 'verify-ownership': return { diff --git a/suite-common/wallet-utils/src/tokenUtils.ts b/suite-common/wallet-utils/src/tokenUtils.ts index e0f36d32c80..8551e118750 100644 --- a/suite-common/wallet-utils/src/tokenUtils.ts +++ b/suite-common/wallet-utils/src/tokenUtils.ts @@ -13,10 +13,11 @@ export const getContractAddressForNetwork = ( case 'dsol': return contractAddress; case 'ada': - case 'tada': + case 'tada': { const { policyId } = parseAsset(contractAddress); return policyId.toLowerCase(); + } default: return contractAddress.toLowerCase(); } diff --git a/suite-native/accounts/src/components/AccountSelectBottomSheet.tsx b/suite-native/accounts/src/components/AccountSelectBottomSheet.tsx index 9009b61b5de..eee47a23a70 100644 --- a/suite-native/accounts/src/components/AccountSelectBottomSheet.tsx +++ b/suite-native/accounts/src/components/AccountSelectBottomSheet.tsx @@ -66,7 +66,7 @@ export const AccountSelectBottomSheet = React.memo( }} /> ); - case 'token': + case 'token': { const { token, account } = item; return ( @@ -82,6 +82,7 @@ export const AccountSelectBottomSheet = React.memo( } /> ); + } default: return null; } diff --git a/suite-native/blockchain/src/blockchainMiddleware.ts b/suite-native/blockchain/src/blockchainMiddleware.ts index de529a78e95..4d3ea39553e 100644 --- a/suite-native/blockchain/src/blockchainMiddleware.ts +++ b/suite-native/blockchain/src/blockchainMiddleware.ts @@ -29,7 +29,7 @@ export const blockchainMiddleware = createMiddleware( dispatch(onBlockchainConnectThunk({ symbol: action.payload.coin.shortcut })); break; - case TREZOR_CONNECT_BLOCKCHAIN_ACTIONS.BLOCK: + case TREZOR_CONNECT_BLOCKCHAIN_ACTIONS.BLOCK: { const networksWithPendingTransactions = selectNetworksWithPendingTransactions(getState()); const symbol = action.payload.coin.shortcut.toLowerCase() as NetworkSymbol; @@ -39,6 +39,7 @@ export const blockchainMiddleware = createMiddleware( } break; + } case TREZOR_CONNECT_BLOCKCHAIN_ACTIONS.NOTIFICATION: dispatch(onBlockchainNotificationThunk(action.payload)); break;