Skip to content

Commit abce3d3

Browse files
chore: get rid of '@typescript-eslint/no-unused-vars': 'off', and enforce it everywhere
1 parent e8a0be7 commit abce3d3

File tree

56 files changed

+80
-77
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+80
-77
lines changed

.eslintrc.js

-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ module.exports = {
361361
rules: {
362362
'@typescript-eslint/no-shadow': 'off',
363363
'import/no-default-export': 'off',
364-
'@typescript-eslint/no-unused-vars': 'off',
365364
'no-console': 'off',
366365
'react/jsx-no-undef': 'off',
367366
'no-catch-shadow': 'off',

packages/blockchain-link/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const initWorker = async (settings: BlockchainSettings) => {
5050
worker.onerror = null;
5151
try {
5252
worker.terminate();
53-
} catch (error) {
53+
} catch {
5454
// empty
5555
}
5656

packages/blockchain-link/src/workers/baseWebsocket.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export abstract class BaseWebsocket<T extends EventMap> extends TypedEmitter<T &
4242
private connectPromise?: Promise<void>;
4343

4444
protected abstract ping(): Promise<unknown>;
45+
4546
protected abstract createWebsocket(): WebSocket;
4647

4748
constructor(options: Options) {
@@ -79,7 +80,7 @@ export abstract class BaseWebsocket<T extends EventMap> extends TypedEmitter<T &
7980
} else {
8081
this.ws.close();
8182
}
82-
} catch (error) {
83+
} catch {
8384
// empty
8485
}
8586
}
@@ -123,7 +124,7 @@ export abstract class BaseWebsocket<T extends EventMap> extends TypedEmitter<T &
123124
subs.callback(data);
124125
}
125126
}
126-
} catch (error) {
127+
} catch {
127128
// empty
128129
}
129130

@@ -168,7 +169,7 @@ export abstract class BaseWebsocket<T extends EventMap> extends TypedEmitter<T &
168169
try {
169170
ws.once('error', () => {}); // hack; ws throws uncaughtably when there's no error listener
170171
ws.close();
171-
} catch (error) {
172+
} catch {
172173
// empty
173174
}
174175
},

packages/blockchain-link/src/workers/electrum/devrun.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
12
// @ts-nocheck
23
/// <reference path="../../../../suite/global.d.ts" />
34

packages/blockchain-link/src/workers/ripple/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const getAccountInfo = async (request: Request<MessageTypes.GetAccountInfo>) =>
141141
account.availableBalance = new BigNumber(mempoolInfo.xrpBalance).minus(reserve).toString();
142142
account.misc.sequence = mempoolInfo.sequence;
143143
account.history.unconfirmed = mempoolInfo.txs;
144-
} catch (error) {
144+
} catch {
145145
// do not throw error for mempool (ledger_index: "current")
146146
// mainnet sometimes return "error": "noNetwork", "error_message": "InsufficientNetworkMode",
147147
// TODO: investigate

packages/blockchain-link/src/workers/solana/transactionConfirmation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const tryConfirmBySignatureStatus = async (
1212
const getCurrentBlockHeight = async () => {
1313
try {
1414
return await api.getBlockHeight('finalized');
15-
} catch (_) {
15+
} catch {
1616
return -1;
1717
}
1818
};

packages/blockchain-link/tests/unit/workers.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ describe('Worker', () => {
167167
return new TinyWorker(() => {
168168
self.onmessage = () => {
169169
// @ts-expect-error undefined "x"
170+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
170171
const r = 1 / x;
171172
};
172173

packages/components/src/components/animations/LottieAnimation.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const LottieAnimation = ({
4848
).json();
4949

5050
setLottieAnimationData(animation);
51-
} catch (error) {
51+
} catch {
5252
// do not need to handle error
5353
}
5454
};

packages/connect-common/src/messageChannel/abstract.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ export abstract class AbstractMessageChannel<
4848
protected messageID = 0;
4949

5050
public isConnected = false;
51+
5152
abstract connect(): void;
53+
5254
abstract disconnect(): void;
5355

5456
private readonly handshakeMaxRetries = 5;
@@ -219,7 +221,7 @@ export abstract class AbstractMessageChannel<
219221
if (!usePromise) {
220222
try {
221223
this.sendFn(message);
222-
} catch (err) {
224+
} catch {
223225
if (useQueue) {
224226
this.messagesQueue.push(message);
225227
}
@@ -234,7 +236,7 @@ export abstract class AbstractMessageChannel<
234236

235237
try {
236238
this.sendFn(message);
237-
} catch (err) {
239+
} catch {
238240
if (useQueue) {
239241
this.messagesQueue.push(message);
240242
}

packages/connect-common/src/storage.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Storage extends TypedEmitter<Events> {
7373
const newState = getNewState(getPermanentStorage());
7474
localStorage.setItem(storageName, JSON.stringify(newState));
7575
this.emit('changed', newState);
76-
} catch (err) {
76+
} catch {
7777
// memory storage is fallback of the last resort
7878
console.warn('long term storage not available');
7979
memoryStorage = getNewState(memoryStorage);
@@ -104,7 +104,7 @@ class Storage extends TypedEmitter<Events> {
104104

105105
try {
106106
return getPermanentStorage();
107-
} catch (err) {
107+
} catch {
108108
// memory storage is fallback of the last resort
109109
console.warn('long term storage not available');
110110

packages/connect-explorer/src/actions/trezorConnectActions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export const init =
123123
try {
124124
// Verify if valid by loading core.js, if this file exists we can assume the connectSrc is valid
125125
await testLoadingScript(options.connectSrc + 'js/core.js');
126-
} catch (err) {
126+
} catch {
127127
dispatch({
128128
type: ACTIONS.ON_INIT_ERROR,
129129
payload: `Invalid connectSrc: ${options.connectSrc}`,

packages/connect-explorer/src/pages/index.mdx

+1-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ import styled from 'styled-components';
88
import Link from 'next/link';
99

1010
import { spacings, spacingsPx } from '@trezor/theme';
11-
import {
12-
Button,
13-
Card as TrezorCard,
14-
CollapsibleBox,
15-
variables,
16-
Paragraph,
17-
} from '@trezor/components';
11+
import { Button, Card as TrezorCard, CollapsibleBox, variables } from '@trezor/components';
1812

1913
import IconNode from '../components/icons/IconNode';
2014
import IconWeb from '../components/icons/IconWeb';

packages/connect-iframe/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ const init = async (payload: IFrameInit['payload'], origin: string) => {
315315
// throws DOMException: The operation is insecure.
316316
_popupMessagePort = new BroadcastChannel(broadcastID);
317317
_popupMessagePort.onmessage = message => handleMessage(message);
318-
} catch (error) {
318+
} catch {
319319
// popup will use MessageChannel fallback communication
320320
}
321321
}

packages/connect-popup/e2e/tests/passphrase.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ test('passphrase mismatch', async ({ page }) => {
374374
timeout: 10000,
375375
});
376376
await popup.click('.explain.unacquired');
377-
} catch (error) {
377+
} catch {
378378
// May appear or not
379379
}
380380

packages/connect-popup/e2e/tests/popup-close.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ test(`device disconnected during device interaction`, async ({ page, context })
188188
try {
189189
log('waiting to click @connect-ui/error-close-button');
190190
await popup.click("button[data-testid='@connect-ui/error-close-button']");
191-
} catch (error) {
191+
} catch {
192192
// Sometimes this crashes with error that the page is already closed.
193193
}
194194

packages/connect-popup/e2e/tests/unchained.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const signTransaction = async (page: Page, iteration: number) => {
103103
});
104104
await TrezorUserEnvLink.send({ type: 'emulator-press-yes' });
105105
await popup.waitForTimeout(501);
106-
} catch (err) {
106+
} catch {
107107
confirmOnTrezorScreenStilVisible = false;
108108
}
109109
}

packages/connect-popup/src/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const escapeHtml = (payload: any) => {
5757
div.appendChild(document.createTextNode(JSON.stringify(payload)));
5858

5959
return JSON.parse(div.innerHTML);
60-
} catch (error) {
60+
} catch {
6161
// do nothing
6262
}
6363
};

packages/connect-popup/src/log.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const useLogWorker = (setLogs: React.Dispatch<React.SetStateAction<any[]>>) => {
103103

104104
try {
105105
logWorker = new SharedWorker('./workers/shared-logger-worker.js');
106-
} catch (error) {
106+
} catch {
107107
console.warn('Failed to initialize SharedWorker');
108108
}
109109

packages/connect-popup/src/view/common.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const getIframeElement = () => {
7979
if (frames[i].location.host === window.location.host) {
8080
iframe = frames[i];
8181
}
82-
} catch (error) {
82+
} catch {
8383
// do nothing, try next entry
8484
}
8585
}
@@ -147,7 +147,7 @@ export const initMessageChannelWithIframe = async (
147147
// otherwise close BroadcastChannel and try to use MessageChannel fallback
148148
broadcast.close();
149149
broadcast.removeEventListener('message', handler);
150-
} catch (error) {
150+
} catch {
151151
// silent error. use MessageChannel as fallback communication
152152
}
153153
}

packages/connect-web/src/iframe/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const dispose = () => {
1919
if (instance && instance.parentNode) {
2020
try {
2121
instance.parentNode.removeChild(instance);
22-
} catch (e) {
22+
} catch {
2323
// do nothing
2424
}
2525
}
@@ -109,7 +109,7 @@ export const init = async (settings: ConnectSettings) => {
109109

110110
return;
111111
}
112-
} catch (e) {
112+
} catch {
113113
// empty
114114
}
115115

packages/connect-web/src/impl/core-in-iframe.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ export class CoreInIframe implements ConnectFactoryDependencies<ConnectSettingsW
348348
try {
349349
await window.navigator.usb.requestDevice({ filters: config.webusb });
350350
iframe.postMessage({ type: TRANSPORT.REQUEST_DEVICE });
351-
} catch (_err) {
351+
} catch {
352352
// user hits cancel gets "DOMException: No device selected."
353353
// no need to log this
354354
}

packages/connect-web/src/webextension/extensionPermissions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const init = (label: string) => {
3535
await usb.requestDevice({ filters: config.webusb });
3636
sendMessage(WEBEXTENSION.USB_PERMISSIONS_CLOSE, '*');
3737
broadcastPermissionFinished();
38-
} catch (error) {
38+
} catch {
3939
// empty
4040
}
4141
}

packages/connect-web/src/webusb/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const onload = () => {
1616
if (usb) {
1717
try {
1818
await usb.requestDevice({ filters: config.webusb });
19-
} catch (error) {
19+
} catch {
2020
// empty
2121
}
2222
}

packages/connect/e2e/__wscache__/server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const createServer = () => {
3737
try {
3838
const data = fn(params, request);
3939
ws.send(JSON.stringify({ ...data, id: request.id }));
40-
} catch (e) {
40+
} catch {
4141
// empty
4242
}
4343
};

packages/connect/e2e/utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
12
let Trezor: {
23
getController: (testName?: string) => any;
34
setup: (controller: any, options: any) => any;

packages/connect/src/api/bitcoin/Fees.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class FeeLevels {
9595
Math.max(this.coinInfo.minFee, parseInt(response.feePerUnit, 10)),
9696
).toString(),
9797
};
98-
} catch (error) {
98+
} catch {
9999
// silent
100100
}
101101

@@ -147,7 +147,7 @@ export class FeeLevels {
147147
});
148148

149149
this.longTermFeeRate = findLowest(this.blocks);
150-
} catch (error) {
150+
} catch {
151151
// do not throw
152152
}
153153

packages/connect/src/api/common/paramsValidator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function validateParams<P extends Record<string, any>>(params: P, schema:
4242
validateParams(p, [{ name: field.name, type: t }]);
4343

4444
return count + 1;
45-
} catch (e) {
45+
} catch {
4646
return count;
4747
}
4848
}, 0);

packages/connect/src/api/firmware/getBinary.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const getBinary = ({ baseUrl, btcOnly, release }: GetBinaryProps) => {
1717
export const getBinaryOptional = async (props: GetBinaryProps) => {
1818
try {
1919
return await getBinary(props);
20-
} catch (error) {
20+
} catch {
2121
return null;
2222
}
2323
};

packages/connect/src/core/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ const onCallDevice = async (
718718
// (acquire > Initialize > nothing > release)
719719
try {
720720
await device.run(() => Promise.resolve(), { skipFinalReload: true });
721-
} catch (err) {
721+
} catch {
722722
// ignore. on model T, this block of code is probably not needed at all. but I am keeping it here for
723723
// backwards compatibility
724724
}

packages/connect/src/device/Device.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
800800
return await this.getCommands().typedCall('GetFirmwareHash', 'FirmwareHash', {
801801
challenge,
802802
});
803-
} catch (e) {
803+
} catch {
804804
return null;
805805
}
806806
};
@@ -1111,7 +1111,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
11111111
path: this.transportPath,
11121112
onClose: true,
11131113
});
1114-
} catch (err) {
1114+
} catch {
11151115
// empty
11161116
}
11171117
}

packages/connect/src/device/DeviceCommands.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const assertType = (res: DefaultPayloadMessage, resType: MessageKey | MessageKey
4646
const generateEntropy = (len: number) => {
4747
try {
4848
return randomBytes(len);
49-
} catch (err) {
49+
} catch {
5050
throw ERRORS.TypedError(
5151
'Runtime',
5252
'generateEntropy: Environment does not support crypto random',
@@ -564,7 +564,7 @@ export class DeviceCommands {
564564
await createTimeoutPromise(1);
565565
await this.device.acquire();
566566
await cancelPrompt(this.device, false);
567-
} catch (err) {
567+
} catch {
568568
// ignore whatever happens
569569
}
570570
} else {

packages/connect/src/utils/addressUtils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const isValidBase58Address = (address: string, network: BitcoinNetworkInfo['netw
1111
if (decoded.version !== network.pubKeyHash && decoded.version !== network.scriptHash) {
1212
return false;
1313
}
14-
} catch (e) {
14+
} catch {
1515
return false;
1616
}
1717

@@ -25,7 +25,7 @@ const isValidBech32Address = (address: string, network: BitcoinNetworkInfo['netw
2525
if (decoded.prefix !== network.bech32) {
2626
return false;
2727
}
28-
} catch (e) {
28+
} catch {
2929
return false;
3030
}
3131

0 commit comments

Comments
 (0)