Skip to content

Commit 0853e6e

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

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
@@ -345,7 +345,6 @@ module.exports = {
345345
'@typescript-eslint/no-shadow': 'off',
346346
'import/no-default-export': 'off',
347347
'import/order': 'off',
348-
'@typescript-eslint/no-unused-vars': 'off',
349348
'no-console': 'off',
350349
'react/jsx-no-undef': 'off',
351350
'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
@@ -139,7 +139,7 @@ const getAccountInfo = async (request: Request<MessageTypes.GetAccountInfo>) =>
139139
account.availableBalance = new BigNumber(mempoolInfo.xrpBalance).minus(reserve).toString();
140140
account.misc.sequence = mempoolInfo.sequence;
141141
account.history.unconfirmed = mempoolInfo.txs;
142-
} catch (error) {
142+
} catch {
143143
// do not throw error for mempool (ledger_index: "current")
144144
// mainnet sometimes return "error": "noNetwork", "error_message": "InsufficientNetworkMode",
145145
// 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
@@ -165,6 +165,7 @@ describe('Worker', () => {
165165
return new TinyWorker(() => {
166166
self.onmessage = () => {
167167
// @ts-expect-error undefined "x"
168+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
168169
const r = 1 / x;
169170
};
170171

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const LottieAnimation = ({
4646
).json();
4747

4848
setLottieAnimationData(animation);
49-
} catch (error) {
49+
} catch {
5050
// do not need to handle error
5151
}
5252
};

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
@@ -124,7 +124,7 @@ export const init =
124124
try {
125125
// Verify if valid by loading core.js, if this file exists we can assume the connectSrc is valid
126126
await testLoadingScript(options.connectSrc + 'js/core.js');
127-
} catch (err) {
127+
} catch {
128128
dispatch({
129129
type: ACTIONS.ON_INIT_ERROR,
130130
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
@@ -314,7 +314,7 @@ const init = async (payload: IFrameInit['payload'], origin: string) => {
314314
// throws DOMException: The operation is insecure.
315315
_popupMessagePort = new BroadcastChannel(broadcastID);
316316
_popupMessagePort.onmessage = message => handleMessage(message);
317-
} catch (error) {
317+
} catch {
318318
// popup will use MessageChannel fallback communication
319319
}
320320
}

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

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

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

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

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

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

packages/connect-popup/src/index.tsx

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

6060
return JSON.parse(div.innerHTML);
61-
} catch (error) {
61+
} catch {
6262
// do nothing
6363
}
6464
};

packages/connect-popup/src/log.tsx

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

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

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

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

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const dispose = () => {
1818
if (instance && instance.parentNode) {
1919
try {
2020
instance.parentNode.removeChild(instance);
21-
} catch (e) {
21+
} catch {
2222
// do nothing
2323
}
2424
}
@@ -108,7 +108,7 @@ export const init = async (settings: ConnectSettings) => {
108108

109109
return;
110110
}
111-
} catch (e) {
111+
} catch {
112112
// empty
113113
}
114114

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
@@ -36,7 +36,7 @@ const createServer = () => {
3636
try {
3737
const data = fn(params, request);
3838
ws.send(JSON.stringify({ ...data, id: request.id }));
39-
} catch (e) {
39+
} catch {
4040
// empty
4141
}
4242
};

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
@@ -94,7 +94,7 @@ export class FeeLevels {
9494
Math.max(this.coinInfo.minFee, parseInt(response.feePerUnit, 10)),
9595
).toString(),
9696
};
97-
} catch (error) {
97+
} catch {
9898
// silent
9999
}
100100

@@ -146,7 +146,7 @@ export class FeeLevels {
146146
});
147147

148148
this.longTermFeeRate = findLowest(this.blocks);
149-
} catch (error) {
149+
} catch {
150150
// do not throw
151151
}
152152

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
@@ -709,7 +709,7 @@ const onCallDevice = async (
709709
// (acquire > Initialize > nothing > release)
710710
try {
711711
await device.run(() => Promise.resolve(), { skipFinalReload: true });
712-
} catch (err) {
712+
} catch {
713713
// ignore. on model T, this block of code is probably not needed at all. but I am keeping it here for
714714
// backwards compatibility
715715
}

packages/connect/src/device/Device.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
798798
return await this.getCommands().typedCall('GetFirmwareHash', 'FirmwareHash', {
799799
challenge,
800800
});
801-
} catch (e) {
801+
} catch {
802802
return null;
803803
}
804804
};
@@ -1109,7 +1109,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
11091109
path: this.transportPath,
11101110
onClose: true,
11111111
});
1112-
} catch (err) {
1112+
} catch {
11131113
// empty
11141114
}
11151115
}

packages/connect/src/device/DeviceCommands.ts

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

packages/connect/src/utils/addressUtils.ts

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

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

0 commit comments

Comments
 (0)