From c43194796f218a30dd415e978e6c70ef04839993 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Thu, 15 Jan 2026 15:28:54 +0100 Subject: [PATCH 1/7] Revert "fix: remove `@typescript-eslint/no-redundant-type-constituents` directives (#407)" This reverts commit 6133e50669abf089a2aa0dae2e4832927d885d8e. --- jest.config.packages.js | 2 -- packages/keyring-api/src/api/keyring.ts | 3 +++ .../src/api/v2/wrapper/keyring-account-registry.ts | 2 ++ packages/keyring-api/src/events.ts | 3 +++ packages/keyring-internal-api/src/eth/EthKeyring.ts | 2 ++ packages/keyring-internal-api/src/types.ts | 5 +++++ packages/keyring-snap-bridge/src/SnapKeyring.ts | 4 ++++ packages/keyring-snap-bridge/src/account.ts | 1 + packages/keyring-snap-bridge/src/migrations/v1.ts | 1 + packages/keyring-snap-client/src/KeyringClient.ts | 2 ++ tsconfig.packages.json | 6 +----- 11 files changed, 24 insertions(+), 7 deletions(-) diff --git a/jest.config.packages.js b/jest.config.packages.js index 5153694e0..87280d8d1 100644 --- a/jest.config.packages.js +++ b/jest.config.packages.js @@ -88,8 +88,6 @@ module.exports = { moduleNameMapper: { '^@metamask/(.+)$': [ '/../$1/src', - // While still unclear why, adding the line below seems to fix the @typescript-eslint/no-redundant-type-constituents errors throughout the monorepo - '/packages/$1/src', // Some @metamask/* packages we are referencing aren't in this monorepo, // so in that case use their published versions '/../../node_modules/@metamask/$1', diff --git a/packages/keyring-api/src/api/keyring.ts b/packages/keyring-api/src/api/keyring.ts index 4276fca25..a5bac3686 100644 --- a/packages/keyring-api/src/api/keyring.ts +++ b/packages/keyring-api/src/api/keyring.ts @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ +// This rule seems to be triggering a false positive on the `KeyringAccount`. + import type { AccountId, JsonRpcRequest } from '@metamask/keyring-utils'; import type { Json } from '@metamask/utils'; diff --git a/packages/keyring-api/src/api/v2/wrapper/keyring-account-registry.ts b/packages/keyring-api/src/api/v2/wrapper/keyring-account-registry.ts index 8737494d4..92abcb961 100644 --- a/packages/keyring-api/src/api/v2/wrapper/keyring-account-registry.ts +++ b/packages/keyring-api/src/api/v2/wrapper/keyring-account-registry.ts @@ -22,6 +22,7 @@ export class KeyringAccountRegistry< * @param accountId - The account ID to look up. * @returns The KeyringAccount, or undefined if not found. */ + // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents get(accountId: AccountId): KeyringAccountType | undefined { return this.#accountById.get(accountId); } @@ -42,6 +43,7 @@ export class KeyringAccountRegistry< * @param address - The address to look up. * @returns The account ID, or undefined if not found. */ + // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents getAccountId(address: string): AccountId | undefined { return this.#idByAddress.get(address); } diff --git a/packages/keyring-api/src/events.ts b/packages/keyring-api/src/events.ts index cb864d371..b14671797 100644 --- a/packages/keyring-api/src/events.ts +++ b/packages/keyring-api/src/events.ts @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ +// FIXME: This rule seems to be triggering a false positive on the `KeyringEvents`. + import { exactOptional, object, diff --git a/packages/keyring-internal-api/src/eth/EthKeyring.ts b/packages/keyring-internal-api/src/eth/EthKeyring.ts index 5c7d9b30c..746fe4468 100644 --- a/packages/keyring-internal-api/src/eth/EthKeyring.ts +++ b/packages/keyring-internal-api/src/eth/EthKeyring.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ + import type { KeyringExecutionContext, EthBaseTransaction, diff --git a/packages/keyring-internal-api/src/types.ts b/packages/keyring-internal-api/src/types.ts index 3f4d3a435..5a5cfdd6c 100644 --- a/packages/keyring-internal-api/src/types.ts +++ b/packages/keyring-internal-api/src/types.ts @@ -1,3 +1,8 @@ +/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ +/* eslint-disable @typescript-eslint/no-duplicate-type-constituents */ +// FIXME: Those rules seem to be triggering a false positive on the `InternalAccountStructs` +// and `InternalAccountTypes`. + import { BtcAccountType, EthAccountType, diff --git a/packages/keyring-snap-bridge/src/SnapKeyring.ts b/packages/keyring-snap-bridge/src/SnapKeyring.ts index 986c84554..74cd759d5 100644 --- a/packages/keyring-snap-bridge/src/SnapKeyring.ts +++ b/packages/keyring-snap-bridge/src/SnapKeyring.ts @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ +// This rule seems to be triggering a false positive. Possibly eslint is not +// inferring the `EthMethod`, `BtcMethod`, and `InternalAccount` types correctly. + import type { TypedTransaction } from '@ethereumjs/tx'; import { TransactionFactory } from '@ethereumjs/tx'; import type { TypedDataV1, TypedMessage } from '@metamask/eth-sig-util'; diff --git a/packages/keyring-snap-bridge/src/account.ts b/packages/keyring-snap-bridge/src/account.ts index 8a6809da1..5d44f7973 100644 --- a/packages/keyring-snap-bridge/src/account.ts +++ b/packages/keyring-snap-bridge/src/account.ts @@ -91,6 +91,7 @@ export function assertKeyringAccount< * @returns A valid transformed `KeyringAccount`. */ export function transformAccount( + // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents accountToTransform: KeyringAccountV1 | KeyringAccount, ): KeyringAccount { // To keep the retro-compatibility with older keyring-api versions, we identify the account's diff --git a/packages/keyring-snap-bridge/src/migrations/v1.ts b/packages/keyring-snap-bridge/src/migrations/v1.ts index e3812e18b..349a8fe98 100644 --- a/packages/keyring-snap-bridge/src/migrations/v1.ts +++ b/packages/keyring-snap-bridge/src/migrations/v1.ts @@ -25,6 +25,7 @@ import { * @returns True if the account is v1, false otherwise. */ export function isAccountV1( + // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents account: KeyringAccountV1 | KeyringAccount, ): boolean { return is(account, KeyringAccountV1Struct); diff --git a/packages/keyring-snap-client/src/KeyringClient.ts b/packages/keyring-snap-client/src/KeyringClient.ts index f603091bc..e7cf5b3c2 100644 --- a/packages/keyring-snap-client/src/KeyringClient.ts +++ b/packages/keyring-snap-client/src/KeyringClient.ts @@ -157,6 +157,8 @@ export class KeyringClient implements Keyring { async resolveAccountAddress( scope: CaipChainId, request: JsonRpcRequest, + // FIXME: eslint is complaning about `ResolvedAccountAddress` being `any`, so disable this for now: + // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents ): Promise { return strictMask( await this.send({ diff --git a/tsconfig.packages.json b/tsconfig.packages.json index ec34c3fef..847976f51 100644 --- a/tsconfig.packages.json +++ b/tsconfig.packages.json @@ -28,11 +28,7 @@ * `jest.config.packages.js`. */ "paths": { - "@metamask/*": [ - "../*/src", - // While still unclear why, adding "./packages/*/src" seems to fix the @typescript-eslint/no-redundant-type-constituents errors throughout the monorepo - "./packages/*/src" - ] + "@metamask/*": ["../*/src"] } } } From b099693f6840794d05035d8c797304b48e198e2c Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Fri, 16 Jan 2026 11:41:09 +0100 Subject: [PATCH 2/7] refactor: re-adapt some eslint constraint --- packages/keyring-api/src/api/keyring.ts | 3 --- .../src/api/v2/wrapper/keyring-account-registry.ts | 2 -- packages/keyring-api/src/events.ts | 3 --- packages/keyring-eth-trezor/src/trezor-keyring-v2.ts | 2 ++ packages/keyring-internal-api/src/eth/EthKeyring.ts | 2 -- packages/keyring-internal-api/src/types.ts | 5 ++--- packages/keyring-snap-bridge/src/SnapKeyring.ts | 6 ++---- packages/keyring-snap-bridge/src/account.ts | 1 + packages/keyring-snap-bridge/src/migrations/v1.ts | 1 + 9 files changed, 8 insertions(+), 17 deletions(-) diff --git a/packages/keyring-api/src/api/keyring.ts b/packages/keyring-api/src/api/keyring.ts index a5bac3686..4276fca25 100644 --- a/packages/keyring-api/src/api/keyring.ts +++ b/packages/keyring-api/src/api/keyring.ts @@ -1,6 +1,3 @@ -/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ -// This rule seems to be triggering a false positive on the `KeyringAccount`. - import type { AccountId, JsonRpcRequest } from '@metamask/keyring-utils'; import type { Json } from '@metamask/utils'; diff --git a/packages/keyring-api/src/api/v2/wrapper/keyring-account-registry.ts b/packages/keyring-api/src/api/v2/wrapper/keyring-account-registry.ts index 92abcb961..8737494d4 100644 --- a/packages/keyring-api/src/api/v2/wrapper/keyring-account-registry.ts +++ b/packages/keyring-api/src/api/v2/wrapper/keyring-account-registry.ts @@ -22,7 +22,6 @@ export class KeyringAccountRegistry< * @param accountId - The account ID to look up. * @returns The KeyringAccount, or undefined if not found. */ - // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents get(accountId: AccountId): KeyringAccountType | undefined { return this.#accountById.get(accountId); } @@ -43,7 +42,6 @@ export class KeyringAccountRegistry< * @param address - The address to look up. * @returns The account ID, or undefined if not found. */ - // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents getAccountId(address: string): AccountId | undefined { return this.#idByAddress.get(address); } diff --git a/packages/keyring-api/src/events.ts b/packages/keyring-api/src/events.ts index b14671797..cb864d371 100644 --- a/packages/keyring-api/src/events.ts +++ b/packages/keyring-api/src/events.ts @@ -1,6 +1,3 @@ -/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ -// FIXME: This rule seems to be triggering a false positive on the `KeyringEvents`. - import { exactOptional, object, diff --git a/packages/keyring-eth-trezor/src/trezor-keyring-v2.ts b/packages/keyring-eth-trezor/src/trezor-keyring-v2.ts index 5e3f31a56..6cde2e4fd 100644 --- a/packages/keyring-eth-trezor/src/trezor-keyring-v2.ts +++ b/packages/keyring-eth-trezor/src/trezor-keyring-v2.ts @@ -89,6 +89,8 @@ const DERIVATION_PATH_PATTERN = /^(m\/44'\/(?:60'|1')(?:\/\d+'?)*)\/(\d+)$/u; export type TrezorKeyringV2Options = { legacyKeyring: TrezorKeyring; entropySource: EntropySourceId; + // FIXME: eslint is complaning about `Trezor` and `OneKey` being `any`, so disable this for now: + // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents type?: KeyringType.Trezor | KeyringType.OneKey; }; diff --git a/packages/keyring-internal-api/src/eth/EthKeyring.ts b/packages/keyring-internal-api/src/eth/EthKeyring.ts index 746fe4468..5c7d9b30c 100644 --- a/packages/keyring-internal-api/src/eth/EthKeyring.ts +++ b/packages/keyring-internal-api/src/eth/EthKeyring.ts @@ -1,5 +1,3 @@ -/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ - import type { KeyringExecutionContext, EthBaseTransaction, diff --git a/packages/keyring-internal-api/src/types.ts b/packages/keyring-internal-api/src/types.ts index 5a5cfdd6c..f604e3f75 100644 --- a/packages/keyring-internal-api/src/types.ts +++ b/packages/keyring-internal-api/src/types.ts @@ -1,7 +1,6 @@ -/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ +// FIXME: eslint is complaning about some unions here, so disable this for now: /* eslint-disable @typescript-eslint/no-duplicate-type-constituents */ -// FIXME: Those rules seem to be triggering a false positive on the `InternalAccountStructs` -// and `InternalAccountTypes`. +/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ import { BtcAccountType, diff --git a/packages/keyring-snap-bridge/src/SnapKeyring.ts b/packages/keyring-snap-bridge/src/SnapKeyring.ts index 74cd759d5..04b9ed279 100644 --- a/packages/keyring-snap-bridge/src/SnapKeyring.ts +++ b/packages/keyring-snap-bridge/src/SnapKeyring.ts @@ -1,7 +1,3 @@ -/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ -// This rule seems to be triggering a false positive. Possibly eslint is not -// inferring the `EthMethod`, `BtcMethod`, and `InternalAccount` types correctly. - import type { TypedTransaction } from '@ethereumjs/tx'; import { TransactionFactory } from '@ethereumjs/tx'; import type { TypedDataV1, TypedMessage } from '@metamask/eth-sig-util'; @@ -918,6 +914,8 @@ export class SnapKeyring { snapId: SnapId, scope: CaipChainId, request: JsonRpcRequest, + // FIXME: eslint is complaning about `ResolvedAccountAddress` being `any`, so disable this for now: + // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents ): Promise { // We do check that the incoming Snap ID is known by the keyring. if (!this.hasSnapId(snapId)) { diff --git a/packages/keyring-snap-bridge/src/account.ts b/packages/keyring-snap-bridge/src/account.ts index 5d44f7973..33f53354f 100644 --- a/packages/keyring-snap-bridge/src/account.ts +++ b/packages/keyring-snap-bridge/src/account.ts @@ -91,6 +91,7 @@ export function assertKeyringAccount< * @returns A valid transformed `KeyringAccount`. */ export function transformAccount( + // FIXME: eslint is complaning about `Infer` (from `KeyringAccount`) being `any`, so disable this for now: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents accountToTransform: KeyringAccountV1 | KeyringAccount, ): KeyringAccount { diff --git a/packages/keyring-snap-bridge/src/migrations/v1.ts b/packages/keyring-snap-bridge/src/migrations/v1.ts index 349a8fe98..adaee61c1 100644 --- a/packages/keyring-snap-bridge/src/migrations/v1.ts +++ b/packages/keyring-snap-bridge/src/migrations/v1.ts @@ -25,6 +25,7 @@ import { * @returns True if the account is v1, false otherwise. */ export function isAccountV1( + // FIXME: eslint is complaning about `Infer` (used for `KeyringAccount`) being `any`, so disable this for now: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents account: KeyringAccountV1 | KeyringAccount, ): boolean { From 4c70cde32429458688eceb3ac4910313a7dc2fcb Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Fri, 16 Jan 2026 11:42:00 +0100 Subject: [PATCH 3/7] refactor: remove some more warnings --- .../keyring-eth-ledger-bridge/src/ledger-keyring-v2.test.ts | 4 ++-- packages/keyring-eth-trezor/src/trezor-keyring-v2.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/keyring-eth-ledger-bridge/src/ledger-keyring-v2.test.ts b/packages/keyring-eth-ledger-bridge/src/ledger-keyring-v2.test.ts index e4bb20fed..025c280be 100644 --- a/packages/keyring-eth-ledger-bridge/src/ledger-keyring-v2.test.ts +++ b/packages/keyring-eth-ledger-bridge/src/ledger-keyring-v2.test.ts @@ -59,7 +59,7 @@ function getFirstAccount(accounts: LedgerAccount[]): LedgerAccount { if (accounts.length === 0) { throw new Error('Expected at least one account'); } - return accounts[0] as LedgerAccount; + return accounts[0]; } /** @@ -73,7 +73,7 @@ function getAccountAt(accounts: LedgerAccount[], index: number): LedgerAccount { if (accounts.length <= index) { throw new Error(`Expected account at index ${index}`); } - return accounts[index] as LedgerAccount; + return accounts[index]; } /** diff --git a/packages/keyring-eth-trezor/src/trezor-keyring-v2.test.ts b/packages/keyring-eth-trezor/src/trezor-keyring-v2.test.ts index d020d26f8..d7d05f72e 100644 --- a/packages/keyring-eth-trezor/src/trezor-keyring-v2.test.ts +++ b/packages/keyring-eth-trezor/src/trezor-keyring-v2.test.ts @@ -64,7 +64,7 @@ function getFirstAccount(accounts: TrezorAccount[]): TrezorAccount { if (accounts.length === 0) { throw new Error('Expected at least one account'); } - return accounts[0] as TrezorAccount; + return accounts[0]; } /** @@ -78,7 +78,7 @@ function getAccountAt(accounts: TrezorAccount[], index: number): TrezorAccount { if (accounts.length <= index) { throw new Error(`Expected account at index ${index}`); } - return accounts[index] as TrezorAccount; + return accounts[index]; } /** From 3beb27afdce13ba06548e13f973381e85e418228 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Fri, 16 Jan 2026 13:15:42 +0100 Subject: [PATCH 4/7] fix: disable some eslint rule globally --- .eslintrc.js | 20 +++++++++++++++++++ .../src/trezor-keyring-v2.ts | 2 -- packages/keyring-internal-api/src/types.ts | 4 ++-- .../keyring-snap-bridge/src/SnapKeyring.ts | 2 -- packages/keyring-snap-bridge/src/account.ts | 2 -- .../keyring-snap-bridge/src/migrations/v1.ts | 2 -- .../keyring-snap-client/src/KeyringClient.ts | 2 -- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c03165604..617c22706 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -58,6 +58,10 @@ module.exports = { rules: { // Enable rules that are disabled in `@metamask/eslint-config-typescript` '@typescript-eslint/no-explicit-any': 'error', + + // This rule triggers false positives and doesn't add real type-safety value. + // See: https://typescript-eslint.io/rules/no-redundant-type-constituents/#when-not-to-use-it + '@typescript-eslint/no-redundant-type-constituents': 'off', }, }, { @@ -97,6 +101,10 @@ module.exports = { // works on the original repository, so there might be some side-effects now that // we are building in a monorepo) '@typescript-eslint/restrict-template-expressions': 'off', + + // This rule triggers false positives and doesn't add real type-safety value. + // See: https://typescript-eslint.io/rules/no-redundant-type-constituents/#when-not-to-use-it + '@typescript-eslint/no-redundant-type-constituents': 'off', }, }, // @metamask/keyring-eth-hd @@ -175,6 +183,10 @@ module.exports = { 'jsdoc/tag-lines': 'off', 'n/no-callback-literal': 'off', 'promise/no-multiple-resolved': 'off', + + // This rule triggers false positives and doesn't add real type-safety value. + // See: https://typescript-eslint.io/rules/no-redundant-type-constituents/#when-not-to-use-it + '@typescript-eslint/no-redundant-type-constituents': 'off', }, }, // @metamask/keyring-snap-bridge @@ -189,6 +201,10 @@ module.exports = { // works on the original repository, so there might be some side-effects now that // we are building in a monorepo) '@typescript-eslint/restrict-template-expressions': 'off', + + // This rule triggers false positives and doesn't add real type-safety value. + // See: https://typescript-eslint.io/rules/no-redundant-type-constituents/#when-not-to-use-it + '@typescript-eslint/no-redundant-type-constituents': 'off', }, }, // @metamask/keyring-snap-sdk @@ -215,6 +231,10 @@ module.exports = { // works on the original repository, so there might be some side-effects now that // we are building in a monorepo) '@typescript-eslint/restrict-template-expressions': 'off', + + // This rule triggers false positives and doesn't add real type-safety value. + // See: https://typescript-eslint.io/rules/no-redundant-type-constituents/#when-not-to-use-it + '@typescript-eslint/no-redundant-type-constituents': 'off', }, }, ], diff --git a/packages/keyring-eth-trezor/src/trezor-keyring-v2.ts b/packages/keyring-eth-trezor/src/trezor-keyring-v2.ts index 6cde2e4fd..5e3f31a56 100644 --- a/packages/keyring-eth-trezor/src/trezor-keyring-v2.ts +++ b/packages/keyring-eth-trezor/src/trezor-keyring-v2.ts @@ -89,8 +89,6 @@ const DERIVATION_PATH_PATTERN = /^(m\/44'\/(?:60'|1')(?:\/\d+'?)*)\/(\d+)$/u; export type TrezorKeyringV2Options = { legacyKeyring: TrezorKeyring; entropySource: EntropySourceId; - // FIXME: eslint is complaning about `Trezor` and `OneKey` being `any`, so disable this for now: - // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents type?: KeyringType.Trezor | KeyringType.OneKey; }; diff --git a/packages/keyring-internal-api/src/types.ts b/packages/keyring-internal-api/src/types.ts index f604e3f75..619ca0b7f 100644 --- a/packages/keyring-internal-api/src/types.ts +++ b/packages/keyring-internal-api/src/types.ts @@ -1,6 +1,6 @@ -// FIXME: eslint is complaning about some unions here, so disable this for now: +// FIXME: eslint is complaning about our account union even if those accounts +// types should all be different, so we disable this for now: /* eslint-disable @typescript-eslint/no-duplicate-type-constituents */ -/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ import { BtcAccountType, diff --git a/packages/keyring-snap-bridge/src/SnapKeyring.ts b/packages/keyring-snap-bridge/src/SnapKeyring.ts index 04b9ed279..986c84554 100644 --- a/packages/keyring-snap-bridge/src/SnapKeyring.ts +++ b/packages/keyring-snap-bridge/src/SnapKeyring.ts @@ -914,8 +914,6 @@ export class SnapKeyring { snapId: SnapId, scope: CaipChainId, request: JsonRpcRequest, - // FIXME: eslint is complaning about `ResolvedAccountAddress` being `any`, so disable this for now: - // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents ): Promise { // We do check that the incoming Snap ID is known by the keyring. if (!this.hasSnapId(snapId)) { diff --git a/packages/keyring-snap-bridge/src/account.ts b/packages/keyring-snap-bridge/src/account.ts index 33f53354f..8a6809da1 100644 --- a/packages/keyring-snap-bridge/src/account.ts +++ b/packages/keyring-snap-bridge/src/account.ts @@ -91,8 +91,6 @@ export function assertKeyringAccount< * @returns A valid transformed `KeyringAccount`. */ export function transformAccount( - // FIXME: eslint is complaning about `Infer` (from `KeyringAccount`) being `any`, so disable this for now: - // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents accountToTransform: KeyringAccountV1 | KeyringAccount, ): KeyringAccount { // To keep the retro-compatibility with older keyring-api versions, we identify the account's diff --git a/packages/keyring-snap-bridge/src/migrations/v1.ts b/packages/keyring-snap-bridge/src/migrations/v1.ts index adaee61c1..e3812e18b 100644 --- a/packages/keyring-snap-bridge/src/migrations/v1.ts +++ b/packages/keyring-snap-bridge/src/migrations/v1.ts @@ -25,8 +25,6 @@ import { * @returns True if the account is v1, false otherwise. */ export function isAccountV1( - // FIXME: eslint is complaning about `Infer` (used for `KeyringAccount`) being `any`, so disable this for now: - // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents account: KeyringAccountV1 | KeyringAccount, ): boolean { return is(account, KeyringAccountV1Struct); diff --git a/packages/keyring-snap-client/src/KeyringClient.ts b/packages/keyring-snap-client/src/KeyringClient.ts index e7cf5b3c2..f603091bc 100644 --- a/packages/keyring-snap-client/src/KeyringClient.ts +++ b/packages/keyring-snap-client/src/KeyringClient.ts @@ -157,8 +157,6 @@ export class KeyringClient implements Keyring { async resolveAccountAddress( scope: CaipChainId, request: JsonRpcRequest, - // FIXME: eslint is complaning about `ResolvedAccountAddress` being `any`, so disable this for now: - // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents ): Promise { return strictMask( await this.send({ From 0c91022c8453febeba7a03d65584181edaa80515 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Fri, 16 Jan 2026 13:41:49 +0100 Subject: [PATCH 5/7] chore: refactor eslintrc --- .eslintrc.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 617c22706..364751a5e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,6 +5,12 @@ const parserOptions = { sourceType: 'module', }; +const tsCommonRules = { + // This rule triggers false positives and doesn't add real type-safety value. + // See: https://typescript-eslint.io/rules/no-redundant-type-constituents/#when-not-to-use-it + '@typescript-eslint/no-redundant-type-constituents': 'off', +}; + module.exports = { root: true, extends: ['@metamask/eslint-config', '@metamask/eslint-config-nodejs'], @@ -56,12 +62,10 @@ module.exports = { extends: ['@metamask/eslint-config-typescript'], parserOptions, rules: { + ...tsCommonRules, + // Enable rules that are disabled in `@metamask/eslint-config-typescript` '@typescript-eslint/no-explicit-any': 'error', - - // This rule triggers false positives and doesn't add real type-safety value. - // See: https://typescript-eslint.io/rules/no-redundant-type-constituents/#when-not-to-use-it - '@typescript-eslint/no-redundant-type-constituents': 'off', }, }, { @@ -76,6 +80,8 @@ module.exports = { extends: ['@metamask/eslint-config-typescript'], parserOptions, rules: { + ...tsCommonRules, + // TODO: re-lint everything once the migration is done '@typescript-eslint/no-explicit-any': 'off', }, @@ -86,6 +92,8 @@ module.exports = { extends: ['@metamask/eslint-config-typescript'], parserOptions, rules: { + ...tsCommonRules, + // TODO: re-lint everything once the migration is done 'import/order': 'off', 'jsdoc/newline-after-description': 'off', @@ -97,14 +105,12 @@ module.exports = { extends: ['@metamask/eslint-config-typescript'], parserOptions, rules: { + ...tsCommonRules, + // FIXME: for some reason, it seems eslint is not able to infere those (this // works on the original repository, so there might be some side-effects now that // we are building in a monorepo) '@typescript-eslint/restrict-template-expressions': 'off', - - // This rule triggers false positives and doesn't add real type-safety value. - // See: https://typescript-eslint.io/rules/no-redundant-type-constituents/#when-not-to-use-it - '@typescript-eslint/no-redundant-type-constituents': 'off', }, }, // @metamask/keyring-eth-hd @@ -164,6 +170,8 @@ module.exports = { extends: ['@metamask/eslint-config-typescript'], parserOptions, rules: { + ...tsCommonRules, + // TODO: re-lint everything once the migration is done '@typescript-eslint/consistent-type-definitions': 'off', '@typescript-eslint/consistent-type-imports': 'off', @@ -183,10 +191,6 @@ module.exports = { 'jsdoc/tag-lines': 'off', 'n/no-callback-literal': 'off', 'promise/no-multiple-resolved': 'off', - - // This rule triggers false positives and doesn't add real type-safety value. - // See: https://typescript-eslint.io/rules/no-redundant-type-constituents/#when-not-to-use-it - '@typescript-eslint/no-redundant-type-constituents': 'off', }, }, // @metamask/keyring-snap-bridge @@ -195,16 +199,14 @@ module.exports = { extends: ['@metamask/eslint-config-typescript'], parserOptions, rules: { + ...tsCommonRules, + // TODO: re-lint everything once the migration is done '@typescript-eslint/no-explicit-any': 'off', // FIXME: for some reason, it seems eslint is not able to infere those (this // works on the original repository, so there might be some side-effects now that // we are building in a monorepo) '@typescript-eslint/restrict-template-expressions': 'off', - - // This rule triggers false positives and doesn't add real type-safety value. - // See: https://typescript-eslint.io/rules/no-redundant-type-constituents/#when-not-to-use-it - '@typescript-eslint/no-redundant-type-constituents': 'off', }, }, // @metamask/keyring-snap-sdk @@ -225,16 +227,14 @@ module.exports = { extends: ['@metamask/eslint-config-typescript'], parserOptions, rules: { + ...tsCommonRules, + // TODO: re-lint everything once the migration is done '@typescript-eslint/no-explicit-any': 'off', // FIXME: for some reason, it seems eslint is not able to infere those (this // works on the original repository, so there might be some side-effects now that // we are building in a monorepo) '@typescript-eslint/restrict-template-expressions': 'off', - - // This rule triggers false positives and doesn't add real type-safety value. - // See: https://typescript-eslint.io/rules/no-redundant-type-constituents/#when-not-to-use-it - '@typescript-eslint/no-redundant-type-constituents': 'off', }, }, ], From 4fe5bfbbe842c66667111c14be2f4eeb264663f7 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Fri, 16 Jan 2026 14:01:16 +0100 Subject: [PATCH 6/7] fix: add missing common rule --- .eslintrc.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index 364751a5e..2390c486c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -146,6 +146,8 @@ module.exports = { extends: ['@metamask/eslint-config-typescript'], parserOptions, rules: { + ...tsCommonRules, + // TODO: re-lint everything once the migration is done '@typescript-eslint/consistent-type-imports': 'off', '@typescript-eslint/naming-convention': 'off', From 056615ad12a2042a39ea083005a3d389d2ce55af Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Fri, 16 Jan 2026 14:32:51 +0100 Subject: [PATCH 7/7] refactor: refactor to avoid type casts --- .../src/ledger-keyring-v2.test.ts | 10 ++++++---- .../keyring-eth-trezor/src/trezor-keyring-v2.test.ts | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/keyring-eth-ledger-bridge/src/ledger-keyring-v2.test.ts b/packages/keyring-eth-ledger-bridge/src/ledger-keyring-v2.test.ts index 025c280be..f65636527 100644 --- a/packages/keyring-eth-ledger-bridge/src/ledger-keyring-v2.test.ts +++ b/packages/keyring-eth-ledger-bridge/src/ledger-keyring-v2.test.ts @@ -56,10 +56,11 @@ const EXPECTED_METHODS = [ * @returns The first account. */ function getFirstAccount(accounts: LedgerAccount[]): LedgerAccount { - if (accounts.length === 0) { + const [account] = accounts; + if (!account) { throw new Error('Expected at least one account'); } - return accounts[0]; + return account; } /** @@ -70,10 +71,11 @@ function getFirstAccount(accounts: LedgerAccount[]): LedgerAccount { * @returns The account at the index. */ function getAccountAt(accounts: LedgerAccount[], index: number): LedgerAccount { - if (accounts.length <= index) { + const account = accounts[index]; + if (!account) { throw new Error(`Expected account at index ${index}`); } - return accounts[index]; + return account; } /** diff --git a/packages/keyring-eth-trezor/src/trezor-keyring-v2.test.ts b/packages/keyring-eth-trezor/src/trezor-keyring-v2.test.ts index d7d05f72e..2b48d623b 100644 --- a/packages/keyring-eth-trezor/src/trezor-keyring-v2.test.ts +++ b/packages/keyring-eth-trezor/src/trezor-keyring-v2.test.ts @@ -61,10 +61,11 @@ const EXPECTED_METHODS = [ * @returns The first account. */ function getFirstAccount(accounts: TrezorAccount[]): TrezorAccount { - if (accounts.length === 0) { + const [account] = accounts; + if (!account) { throw new Error('Expected at least one account'); } - return accounts[0]; + return account; } /** @@ -75,10 +76,11 @@ function getFirstAccount(accounts: TrezorAccount[]): TrezorAccount { * @returns The account at the index. */ function getAccountAt(accounts: TrezorAccount[], index: number): TrezorAccount { - if (accounts.length <= index) { + const account = accounts[index]; + if (!account) { throw new Error(`Expected account at index ${index}`); } - return accounts[index]; + return account; } /**