Skip to content

Commit 6133e50

Browse files
mathieuartuccharly
andauthored
fix: remove @typescript-eslint/no-redundant-type-constituents directives (#407)
<!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? Are there any issues or other links reviewers should consult to understand this pull request better? For instance: * Fixes #12345 * See: #67890 --> ## Examples <!-- Are there any examples of this change being used in another repository? When considering changes to the MetaMask module template, it's strongly preferred that the change be experimented with in another repository first. This gives reviewers a better sense of how the change works, making it less likely the change will need to be reverted or adjusted later. --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Removes @typescript-eslint/no-redundant-type-constituents disables across keyring packages and updates TS/Jest path mappings to resolve @metamask/* to local package sources. > > - **Linting**: > - Remove `@typescript-eslint/no-redundant-type-constituents` disable directives in `keyring-api`, `keyring-internal-api`, `keyring-snap-bridge`, and `keyring-snap-client` sources. > - **Tooling/Config**: > - Jest: Add `'<rootDir>/packages/$1/src'` to `moduleNameMapper` for `@metamask/*` in `jest.config.packages.js`. > - TypeScript: Add `"./packages/*/src"` to `paths['@metamask/*']` in `tsconfig.packages.json` to match Jest mapping. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 21d0d8f. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Charly Chevalier <[email protected]>
1 parent d6a0c20 commit 6133e50

File tree

11 files changed

+7
-24
lines changed

11 files changed

+7
-24
lines changed

jest.config.packages.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ module.exports = {
8888
moduleNameMapper: {
8989
'^@metamask/(.+)$': [
9090
'<rootDir>/../$1/src',
91+
// While still unclear why, adding the line below seems to fix the @typescript-eslint/no-redundant-type-constituents errors throughout the monorepo
92+
'<rootDir>/packages/$1/src',
9193
// Some @metamask/* packages we are referencing aren't in this monorepo,
9294
// so in that case use their published versions
9395
'<rootDir>/../../node_modules/@metamask/$1',

packages/keyring-api/src/api/keyring.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
2-
// This rule seems to be triggering a false positive on the `KeyringAccount`.
3-
41
import type { AccountId, JsonRpcRequest } from '@metamask/keyring-utils';
52
import type { Json } from '@metamask/utils';
63

packages/keyring-api/src/api/v2/wrapper/keyring-account-registry.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export class KeyringAccountRegistry<
2222
* @param accountId - The account ID to look up.
2323
* @returns The KeyringAccount, or undefined if not found.
2424
*/
25-
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
2625
get(accountId: AccountId): KeyringAccountType | undefined {
2726
return this.#accountById.get(accountId);
2827
}
@@ -43,7 +42,6 @@ export class KeyringAccountRegistry<
4342
* @param address - The address to look up.
4443
* @returns The account ID, or undefined if not found.
4544
*/
46-
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
4745
getAccountId(address: string): AccountId | undefined {
4846
return this.#idByAddress.get(address);
4947
}

packages/keyring-api/src/events.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
2-
// FIXME: This rule seems to be triggering a false positive on the `KeyringEvents`.
3-
41
import {
52
exactOptional,
63
object,

packages/keyring-internal-api/src/eth/EthKeyring.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
2-
31
import type {
42
KeyringExecutionContext,
53
EthBaseTransaction,

packages/keyring-internal-api/src/types.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
2-
/* eslint-disable @typescript-eslint/no-duplicate-type-constituents */
3-
// FIXME: Those rules seem to be triggering a false positive on the `InternalAccountStructs`
4-
// and `InternalAccountTypes`.
5-
61
import {
72
BtcAccountType,
83
EthAccountType,

packages/keyring-snap-bridge/src/SnapKeyring.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
2-
// This rule seems to be triggering a false positive. Possibly eslint is not
3-
// inferring the `EthMethod`, `BtcMethod`, and `InternalAccount` types correctly.
4-
51
import type { TypedTransaction } from '@ethereumjs/tx';
62
import { TransactionFactory } from '@ethereumjs/tx';
73
import type { TypedDataV1, TypedMessage } from '@metamask/eth-sig-util';

packages/keyring-snap-bridge/src/account.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export function assertKeyringAccount<
9191
* @returns A valid transformed `KeyringAccount`.
9292
*/
9393
export function transformAccount(
94-
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
9594
accountToTransform: KeyringAccountV1 | KeyringAccount,
9695
): KeyringAccount {
9796
// To keep the retro-compatibility with older keyring-api versions, we identify the account's

packages/keyring-snap-bridge/src/migrations/v1.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
* @returns True if the account is v1, false otherwise.
2626
*/
2727
export function isAccountV1(
28-
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
2928
account: KeyringAccountV1 | KeyringAccount,
3029
): boolean {
3130
return is(account, KeyringAccountV1Struct);

packages/keyring-snap-client/src/KeyringClient.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ export class KeyringClient implements Keyring {
157157
async resolveAccountAddress(
158158
scope: CaipChainId,
159159
request: JsonRpcRequest,
160-
// FIXME: eslint is complaning about `ResolvedAccountAddress` being `any`, so disable this for now:
161-
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
162160
): Promise<ResolvedAccountAddress | null> {
163161
return strictMask(
164162
await this.send({

0 commit comments

Comments
 (0)