Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: get rid of '@typescript-eslint/no-unused-vars': 'off', and enforce it everywhere #15221

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ module.exports = {
rules: {
'@typescript-eslint/no-shadow': 'off',
'import/no-default-export': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'no-console': 'off',
'react/jsx-no-undef': 'off',
'no-catch-shadow': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain-link/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const initWorker = async (settings: BlockchainSettings) => {
worker.onerror = null;
try {
worker.terminate();
} catch (error) {
} catch {
// empty
}

Expand Down
7 changes: 4 additions & 3 deletions packages/blockchain-link/src/workers/baseWebsocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export abstract class BaseWebsocket<T extends EventMap> extends TypedEmitter<T &
private connectPromise?: Promise<void>;

protected abstract ping(): Promise<unknown>;

protected abstract createWebsocket(): WebSocket;

constructor(options: Options) {
Expand Down Expand Up @@ -79,7 +80,7 @@ export abstract class BaseWebsocket<T extends EventMap> extends TypedEmitter<T &
} else {
this.ws.close();
}
} catch (error) {
} catch {
// empty
}
}
Expand Down Expand Up @@ -123,7 +124,7 @@ export abstract class BaseWebsocket<T extends EventMap> extends TypedEmitter<T &
subs.callback(data);
}
}
} catch (error) {
} catch {
// empty
}

Expand Down Expand Up @@ -168,7 +169,7 @@ export abstract class BaseWebsocket<T extends EventMap> extends TypedEmitter<T &
try {
ws.once('error', () => {}); // hack; ws throws uncaughtably when there's no error listener
ws.close();
} catch (error) {
} catch {
// empty
}
},
Expand Down
1 change: 1 addition & 0 deletions packages/blockchain-link/src/workers/electrum/devrun.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
// @ts-nocheck
/// <reference path="../../../../suite/global.d.ts" />

Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain-link/src/workers/ripple/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const getAccountInfo = async (request: Request<MessageTypes.GetAccountInfo>) =>
account.availableBalance = new BigNumber(mempoolInfo.xrpBalance).minus(reserve).toString();
account.misc.sequence = mempoolInfo.sequence;
account.history.unconfirmed = mempoolInfo.txs;
} catch (error) {
} catch {
// do not throw error for mempool (ledger_index: "current")
// mainnet sometimes return "error": "noNetwork", "error_message": "InsufficientNetworkMode",
// TODO: investigate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const tryConfirmBySignatureStatus = async (
const getCurrentBlockHeight = async () => {
try {
return await api.getBlockHeight('finalized');
} catch (_) {
} catch {
return -1;
}
};
Expand Down
1 change: 1 addition & 0 deletions packages/blockchain-link/tests/unit/workers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ describe('Worker', () => {
return new TinyWorker(() => {
self.onmessage = () => {
// @ts-expect-error undefined "x"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const r = 1 / x;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const LottieAnimation = ({
).json();

setLottieAnimationData(animation);
} catch (error) {
} catch {
// do not need to handle error
}
};
Expand Down
6 changes: 4 additions & 2 deletions packages/connect-common/src/messageChannel/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export abstract class AbstractMessageChannel<
protected messageID = 0;

public isConnected = false;

abstract connect(): void;

abstract disconnect(): void;

private readonly handshakeMaxRetries = 5;
Expand Down Expand Up @@ -219,7 +221,7 @@ export abstract class AbstractMessageChannel<
if (!usePromise) {
try {
this.sendFn(message);
} catch (err) {
} catch {
if (useQueue) {
this.messagesQueue.push(message);
}
Expand All @@ -234,7 +236,7 @@ export abstract class AbstractMessageChannel<

try {
this.sendFn(message);
} catch (err) {
} catch {
if (useQueue) {
this.messagesQueue.push(message);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-common/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Storage extends TypedEmitter<Events> {
const newState = getNewState(getPermanentStorage());
localStorage.setItem(storageName, JSON.stringify(newState));
this.emit('changed', newState);
} catch (err) {
} catch {
// memory storage is fallback of the last resort
console.warn('long term storage not available');
memoryStorage = getNewState(memoryStorage);
Expand Down Expand Up @@ -104,7 +104,7 @@ class Storage extends TypedEmitter<Events> {

try {
return getPermanentStorage();
} catch (err) {
} catch {
// memory storage is fallback of the last resort
console.warn('long term storage not available');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const init =
try {
// Verify if valid by loading core.js, if this file exists we can assume the connectSrc is valid
await testLoadingScript(options.connectSrc + 'js/core.js');
} catch (err) {
} catch {
dispatch({
type: ACTIONS.ON_INIT_ERROR,
payload: `Invalid connectSrc: ${options.connectSrc}`,
Expand Down
8 changes: 1 addition & 7 deletions packages/connect-explorer/src/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ import styled from 'styled-components';
import Link from 'next/link';

import { spacings, spacingsPx } from '@trezor/theme';
import {
Button,
Card as TrezorCard,
CollapsibleBox,
variables,
Paragraph,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused Paragraph, I checked with fulltext search

} from '@trezor/components';
import { Button, Card as TrezorCard, CollapsibleBox, variables } from '@trezor/components';

import IconNode from '../components/icons/IconNode';
import IconWeb from '../components/icons/IconWeb';
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-iframe/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ const init = async (payload: IFrameInit['payload'], origin: string) => {
// throws DOMException: The operation is insecure.
_popupMessagePort = new BroadcastChannel(broadcastID);
_popupMessagePort.onmessage = message => handleMessage(message);
} catch (error) {
} catch {
// popup will use MessageChannel fallback communication
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-popup/e2e/tests/passphrase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ test('passphrase mismatch', async ({ page }) => {
timeout: 10000,
});
await popup.click('.explain.unacquired');
} catch (error) {
} catch {
// May appear or not
}

Expand Down
2 changes: 1 addition & 1 deletion packages/connect-popup/e2e/tests/popup-close.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ test(`device disconnected during device interaction`, async ({ page, context })
try {
log('waiting to click @connect-ui/error-close-button');
await popup.click("button[data-testid='@connect-ui/error-close-button']");
} catch (error) {
} catch {
// Sometimes this crashes with error that the page is already closed.
}

Expand Down
2 changes: 1 addition & 1 deletion packages/connect-popup/e2e/tests/unchained.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const signTransaction = async (page: Page, iteration: number) => {
});
await TrezorUserEnvLink.send({ type: 'emulator-press-yes' });
await popup.waitForTimeout(501);
} catch (err) {
} catch {
confirmOnTrezorScreenStilVisible = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-popup/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const escapeHtml = (payload: any) => {
div.appendChild(document.createTextNode(JSON.stringify(payload)));

return JSON.parse(div.innerHTML);
} catch (error) {
} catch {
// do nothing
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-popup/src/log.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const useLogWorker = (setLogs: React.Dispatch<React.SetStateAction<any[]>>) => {

try {
logWorker = new SharedWorker('./workers/shared-logger-worker.js');
} catch (error) {
} catch {
console.warn('Failed to initialize SharedWorker');
}

Expand Down
4 changes: 2 additions & 2 deletions packages/connect-popup/src/view/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const getIframeElement = () => {
if (frames[i].location.host === window.location.host) {
iframe = frames[i];
}
} catch (error) {
} catch {
// do nothing, try next entry
}
}
Expand Down Expand Up @@ -147,7 +147,7 @@ export const initMessageChannelWithIframe = async (
// otherwise close BroadcastChannel and try to use MessageChannel fallback
broadcast.close();
broadcast.removeEventListener('message', handler);
} catch (error) {
} catch {
// silent error. use MessageChannel as fallback communication
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-web/src/iframe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const dispose = () => {
if (instance && instance.parentNode) {
try {
instance.parentNode.removeChild(instance);
} catch (e) {
} catch {
// do nothing
}
}
Expand Down Expand Up @@ -109,7 +109,7 @@ export const init = async (settings: ConnectSettings) => {

return;
}
} catch (e) {
} catch {
// empty
}

Expand Down
2 changes: 1 addition & 1 deletion packages/connect-web/src/impl/core-in-iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export class CoreInIframe implements ConnectFactoryDependencies<ConnectSettingsW
try {
await window.navigator.usb.requestDevice({ filters: config.webusb });
iframe.postMessage({ type: TRANSPORT.REQUEST_DEVICE });
} catch (_err) {
} catch {
// user hits cancel gets "DOMException: No device selected."
// no need to log this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const init = (label: string) => {
await usb.requestDevice({ filters: config.webusb });
sendMessage(WEBEXTENSION.USB_PERMISSIONS_CLOSE, '*');
broadcastPermissionFinished();
} catch (error) {
} catch {
// empty
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-web/src/webusb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const onload = () => {
if (usb) {
try {
await usb.requestDevice({ filters: config.webusb });
} catch (error) {
} catch {
// empty
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/e2e/__wscache__/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const createServer = () => {
try {
const data = fn(params, request);
ws.send(JSON.stringify({ ...data, id: request.id }));
} catch (e) {
} catch {
// empty
}
};
Expand Down
1 change: 1 addition & 0 deletions packages/connect/e2e/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let Trezor: {
getController: (testName?: string) => any;
setup: (controller: any, options: any) => any;
Expand Down
4 changes: 2 additions & 2 deletions packages/connect/src/api/bitcoin/Fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class FeeLevels {
Math.max(this.coinInfo.minFee, parseInt(response.feePerUnit, 10)),
).toString(),
};
} catch (error) {
} catch {
// silent
}

Expand Down Expand Up @@ -147,7 +147,7 @@ export class FeeLevels {
});

this.longTermFeeRate = findLowest(this.blocks);
} catch (error) {
} catch {
// do not throw
}

Expand Down
2 changes: 1 addition & 1 deletion packages/connect/src/api/common/paramsValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function validateParams<P extends Record<string, any>>(params: P, schema:
validateParams(p, [{ name: field.name, type: t }]);

return count + 1;
} catch (e) {
} catch {
return count;
}
}, 0);
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/src/api/firmware/getBinary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const getBinary = ({ baseUrl, btcOnly, release }: GetBinaryProps) => {
export const getBinaryOptional = async (props: GetBinaryProps) => {
try {
return await getBinary(props);
} catch (error) {
} catch {
return null;
}
};
2 changes: 1 addition & 1 deletion packages/connect/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ const onCallDevice = async (
// (acquire > Initialize > nothing > release)
try {
await device.run(() => Promise.resolve(), { skipFinalReload: true });
} catch (err) {
} catch {
// ignore. on model T, this block of code is probably not needed at all. but I am keeping it here for
// backwards compatibility
}
Expand Down
4 changes: 2 additions & 2 deletions packages/connect/src/device/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
return await this.getCommands().typedCall('GetFirmwareHash', 'FirmwareHash', {
challenge,
});
} catch (e) {
} catch {
return null;
}
};
Expand Down Expand Up @@ -1111,7 +1111,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
path: this.transportPath,
onClose: true,
});
} catch (err) {
} catch {
// empty
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/connect/src/device/DeviceCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const assertType = (res: DefaultPayloadMessage, resType: MessageKey | MessageKey
const generateEntropy = (len: number) => {
try {
return randomBytes(len);
} catch (err) {
} catch {
throw ERRORS.TypedError(
'Runtime',
'generateEntropy: Environment does not support crypto random',
Expand Down Expand Up @@ -564,7 +564,7 @@ export class DeviceCommands {
await createTimeoutPromise(1);
await this.device.acquire();
await cancelPrompt(this.device, false);
} catch (err) {
} catch {
// ignore whatever happens
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/connect/src/utils/addressUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const isValidBase58Address = (address: string, network: BitcoinNetworkInfo['netw
if (decoded.version !== network.pubKeyHash && decoded.version !== network.scriptHash) {
return false;
}
} catch (e) {
} catch {
return false;
}

Expand All @@ -25,7 +25,7 @@ const isValidBech32Address = (address: string, network: BitcoinNetworkInfo['netw
if (decoded.prefix !== network.bech32) {
return false;
}
} catch (e) {
} catch {
return false;
}

Expand Down
Loading
Loading