Skip to content

Commit a840490

Browse files
authored
Chore/w3a controllers linting (#7455)
## Explanation <!-- 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 changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> Fixed or suppressed linting for the following controllers ~ - `@metamask/subscription-controller` - `@metamask/shield-controller` - `@metamask/claims-controller` - `@metamask/seedless-onboarding-controller` ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> Fixes Shield-Controller: #7392 Fixes Subscription-Controller: #7395 Fixes Claims-Controller: #7349 Fixes Seedless-Onboarding-Controller: #7390 ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs) - [x] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds explicit TypeScript return types, minor refactors, and small correctness tweaks across multiple controllers with corresponding test and fixture updates. > > - **Seedless Onboarding Controller**: > - Add explicit return types across public/private APIs, helpers, and tests; tighten generics and nullish coalescing. > - Refactor `SecretMetadata.fromBatch` param names; type getters; minor branch tweak in `#changeEncryptionKey` to use vault data when `latestKeyIndex` is present. > - Improve token-refresh wrapper typing; add ESLint suppressions for test env crypto. > - **Shield Controller**: > - Add return types and JSDoc; rename internal `#getCoverageStatus` to `#getCoverageShownStatus` and use it in logging. > - Type-safe polling and backend helpers; refine error message fallback and latency metrics typing. > - **Subscription Controller/Service**: > - Define precise return types (e.g., `getSubscriptions(): Subscription[]`, `cancel/unCancel: Promise<void>`), rename params for clarity, and tighten validations. > - Service: typed helpers, query handling, and safer defaults (`assignedCohort ?? null`). > - Update tests/mocks to match new types. > - **Claims**: > - Add explicit return types in tests; enum members annotated to match API format. > - **Lint**: > - Reduce/adjust ESLint suppressions to reflect fixed rules across the touched packages. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 41d9596. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 3ca081c commit a840490

28 files changed

+357
-380
lines changed

eslint-suppressions.json

Lines changed: 0 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -963,21 +963,6 @@
963963
"count": 2
964964
}
965965
},
966-
"packages/claims-controller/src/ClaimsController.test.ts": {
967-
"@typescript-eslint/explicit-function-return-type": {
968-
"count": 1
969-
}
970-
},
971-
"packages/claims-controller/src/ClaimsService.test.ts": {
972-
"@typescript-eslint/explicit-function-return-type": {
973-
"count": 1
974-
}
975-
},
976-
"packages/claims-controller/src/constants.ts": {
977-
"@typescript-eslint/naming-convention": {
978-
"count": 2
979-
}
980-
},
981966
"packages/composable-controller/src/ComposableController.test.ts": {
982967
"@typescript-eslint/explicit-function-return-type": {
983968
"count": 2
@@ -3011,97 +2996,6 @@
30112996
"count": 1
30122997
}
30132998
},
3014-
"packages/seedless-onboarding-controller/jest.environment.js": {
3015-
"n/no-unsupported-features/node-builtins": {
3016-
"count": 1
3017-
}
3018-
},
3019-
"packages/seedless-onboarding-controller/src/SecretMetadata.ts": {
3020-
"@typescript-eslint/explicit-function-return-type": {
3021-
"count": 3
3022-
},
3023-
"id-length": {
3024-
"count": 1
3025-
}
3026-
},
3027-
"packages/seedless-onboarding-controller/src/SeedlessOnboardingController.test.ts": {
3028-
"@typescript-eslint/explicit-function-return-type": {
3029-
"count": 14
3030-
},
3031-
"@typescript-eslint/naming-convention": {
3032-
"count": 1
3033-
},
3034-
"id-length": {
3035-
"count": 1
3036-
},
3037-
"jest/unbound-method": {
3038-
"count": 1
3039-
},
3040-
"no-new": {
3041-
"count": 1
3042-
}
3043-
},
3044-
"packages/seedless-onboarding-controller/src/SeedlessOnboardingController.ts": {
3045-
"@typescript-eslint/explicit-function-return-type": {
3046-
"count": 23
3047-
},
3048-
"@typescript-eslint/naming-convention": {
3049-
"count": 1
3050-
},
3051-
"@typescript-eslint/prefer-nullish-coalescing": {
3052-
"count": 3
3053-
},
3054-
"no-negated-condition": {
3055-
"count": 1
3056-
}
3057-
},
3058-
"packages/seedless-onboarding-controller/src/assertions.test.ts": {
3059-
"@typescript-eslint/explicit-function-return-type": {
3060-
"count": 1
3061-
}
3062-
},
3063-
"packages/seedless-onboarding-controller/src/types.ts": {
3064-
"@typescript-eslint/naming-convention": {
3065-
"count": 4
3066-
}
3067-
},
3068-
"packages/seedless-onboarding-controller/tests/__fixtures__/mockMessenger.ts": {
3069-
"@typescript-eslint/explicit-function-return-type": {
3070-
"count": 2
3071-
}
3072-
},
3073-
"packages/seedless-onboarding-controller/tests/__fixtures__/topfClient.ts": {
3074-
"@typescript-eslint/explicit-function-return-type": {
3075-
"count": 7
3076-
}
3077-
},
3078-
"packages/seedless-onboarding-controller/tests/mocks/toprf.ts": {
3079-
"@typescript-eslint/explicit-function-return-type": {
3080-
"count": 1
3081-
},
3082-
"@typescript-eslint/naming-convention": {
3083-
"count": 1
3084-
},
3085-
"@typescript-eslint/prefer-nullish-coalescing": {
3086-
"count": 1
3087-
}
3088-
},
3089-
"packages/seedless-onboarding-controller/tests/mocks/toprfEncryptor.ts": {
3090-
"@typescript-eslint/naming-convention": {
3091-
"count": 3
3092-
}
3093-
},
3094-
"packages/seedless-onboarding-controller/tests/mocks/vaultEncryptor.ts": {
3095-
"@typescript-eslint/explicit-function-return-type": {
3096-
"count": 5
3097-
},
3098-
"@typescript-eslint/naming-convention": {
3099-
"count": 2
3100-
},
3101-
"@typescript-eslint/prefer-nullish-coalescing": {
3102-
"count": 2
3103-
}
3104-
},
31052999
"packages/selected-network-controller/src/SelectedNetworkController.ts": {
31063000
"@typescript-eslint/explicit-function-return-type": {
31073001
"count": 4
@@ -3117,52 +3011,6 @@
31173011
"count": 4
31183012
}
31193013
},
3120-
"packages/shield-controller/src/ShieldController.test.ts": {
3121-
"@typescript-eslint/explicit-function-return-type": {
3122-
"count": 3
3123-
}
3124-
},
3125-
"packages/shield-controller/src/ShieldController.ts": {
3126-
"@typescript-eslint/explicit-function-return-type": {
3127-
"count": 8
3128-
}
3129-
},
3130-
"packages/shield-controller/src/backend.test.ts": {
3131-
"@typescript-eslint/explicit-function-return-type": {
3132-
"count": 1
3133-
}
3134-
},
3135-
"packages/shield-controller/src/backend.ts": {
3136-
"@typescript-eslint/explicit-function-return-type": {
3137-
"count": 3
3138-
},
3139-
"@typescript-eslint/prefer-nullish-coalescing": {
3140-
"count": 1
3141-
}
3142-
},
3143-
"packages/shield-controller/src/polling-with-policy.test.ts": {
3144-
"@typescript-eslint/explicit-function-return-type": {
3145-
"count": 1
3146-
}
3147-
},
3148-
"packages/shield-controller/src/polling-with-policy.ts": {
3149-
"@typescript-eslint/explicit-function-return-type": {
3150-
"count": 4
3151-
},
3152-
"@typescript-eslint/unbound-method": {
3153-
"count": 1
3154-
}
3155-
},
3156-
"packages/shield-controller/tests/mocks/backend.ts": {
3157-
"@typescript-eslint/explicit-function-return-type": {
3158-
"count": 1
3159-
}
3160-
},
3161-
"packages/shield-controller/tests/utils.ts": {
3162-
"@typescript-eslint/explicit-function-return-type": {
3163-
"count": 2
3164-
}
3165-
},
31663014
"packages/signature-controller/src/SignatureController.test.ts": {
31673015
"@typescript-eslint/explicit-function-return-type": {
31683016
"count": 5
@@ -3222,38 +3070,6 @@
32223070
"count": 2
32233071
}
32243072
},
3225-
"packages/subscription-controller/src/SubscriptionController.test.ts": {
3226-
"@typescript-eslint/explicit-function-return-type": {
3227-
"count": 4
3228-
}
3229-
},
3230-
"packages/subscription-controller/src/SubscriptionController.ts": {
3231-
"@typescript-eslint/explicit-function-return-type": {
3232-
"count": 14
3233-
},
3234-
"id-length": {
3235-
"count": 13
3236-
}
3237-
},
3238-
"packages/subscription-controller/src/SubscriptionService.test.ts": {
3239-
"@typescript-eslint/explicit-function-return-type": {
3240-
"count": 3
3241-
}
3242-
},
3243-
"packages/subscription-controller/src/SubscriptionService.ts": {
3244-
"@typescript-eslint/explicit-function-return-type": {
3245-
"count": 2
3246-
},
3247-
"@typescript-eslint/naming-convention": {
3248-
"count": 1
3249-
},
3250-
"@typescript-eslint/prefer-nullish-coalescing": {
3251-
"count": 1
3252-
},
3253-
"id-length": {
3254-
"count": 1
3255-
}
3256-
},
32573073
"packages/token-search-discovery-controller/src/token-discovery-api-service/token-discovery-api-service.ts": {
32583074
"@typescript-eslint/explicit-function-return-type": {
32593075
"count": 1

packages/claims-controller/src/ClaimsController.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const mockClaimsServiceFetchClaimsConfigurations = jest.fn();
2525
*/
2626
async function withController<ReturnValue>(
2727
...args: WithControllerArgs<ReturnValue>
28-
) {
28+
): Promise<ReturnValue> {
2929
const [{ ...rest }, fn] = args.length === 2 ? args : [{}, args[0]];
3030
const { messenger, rootMessenger } = createMockClaimsControllerMessenger({
3131
mockClaimServiceRequestHeaders,

packages/claims-controller/src/ClaimsService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const mockFetchFunction = jest.fn();
2121
* @param env - The environment to use for the mock claims service. Defaults to Env.DEV.
2222
* @returns A mock claims service.
2323
*/
24-
function createMockClaimsService(env: Env = Env.DEV) {
24+
function createMockClaimsService(env: Env = Env.DEV): ClaimsService {
2525
const { messenger } = createMockClaimsServiceMessenger(
2626
mockAuthenticationControllerGetBearerToken,
2727
);

packages/claims-controller/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ export enum ClaimStatusEnum {
1616
// submitted to Intercom
1717
SUBMITTED = 'submitted',
1818
// in progress by Intercom
19+
// eslint-disable-next-line @typescript-eslint/naming-convention -- to match the API response format
1920
IN_PROGRESS = 'in_progress',
2021
// waiting for customer reply
22+
// eslint-disable-next-line @typescript-eslint/naming-convention -- to match the API response format
2123
WAITING_FOR_CUSTOMER = 'waiting_for_customer',
2224
// approved by Intercom
2325
APPROVED = 'approved',

packages/seedless-onboarding-controller/jest.environment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class CustomTestEnvironment extends NodeEnvironment {
88
async setup() {
99
await super.setup();
1010
if (typeof this.global.crypto === 'undefined') {
11+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- this is a test environment
1112
this.global.crypto = require('crypto').webcrypto;
1213
}
1314
}

packages/seedless-onboarding-controller/src/SecretMetadata.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,26 +75,26 @@ export class SecretMetadata<DataType extends SecretDataType = Uint8Array>
7575
* so that the first secret backup will have the oldest timestamp
7676
* and the last secret backup will have the newest timestamp.
7777
*
78-
* @param data - The data to add metadata to.
79-
* @param data.value - The SeedPhrase/PrivateKey to add metadata to.
80-
* @param data.options - The options for the seed phrase metadata.
78+
* @param batchData - The data to add metadata to.
79+
* @param batchData.value - The SeedPhrase/PrivateKey to add metadata to.
80+
* @param batchData.options - The options for the seed phrase metadata.
8181
* @returns The SecretMetadata instances.
8282
*/
8383
static fromBatch<DataType extends SecretDataType = Uint8Array>(
84-
data: {
84+
batchData: {
8585
value: DataType;
8686
options?: Partial<SecretMetadataOptions>;
8787
}[],
8888
): SecretMetadata<DataType>[] {
8989
const timestamp = Date.now();
90-
return data.map((d, index) => {
90+
return batchData.map((data, index) => {
9191
// To respect the order of the seed phrases, we add the index to the timestamp
9292
// so that the first seed phrase backup will have the oldest timestamp
9393
// and the last seed phrase backup will have the newest timestamp
94-
const backupCreatedAt = d.options?.timestamp ?? timestamp + index * 5;
95-
return new SecretMetadata(d.value, {
94+
const backupCreatedAt = data.options?.timestamp ?? timestamp + index * 5;
95+
return new SecretMetadata(data.value, {
9696
timestamp: backupCreatedAt,
97-
type: d.options?.type,
97+
type: data.options?.type,
9898
});
9999
});
100100
}
@@ -206,15 +206,15 @@ export class SecretMetadata<DataType extends SecretDataType = Uint8Array>
206206
return this.#data;
207207
}
208208

209-
get timestamp() {
209+
get timestamp(): number {
210210
return this.#timestamp;
211211
}
212212

213-
get type() {
213+
get type(): SecretType {
214214
return this.#type;
215215
}
216216

217-
get version() {
217+
get version(): SecretMetadataVersion {
218218
return this.#version;
219219
}
220220

0 commit comments

Comments
 (0)