Skip to content

Commit 845352d

Browse files
authored
chore(lint): Fix suppressed ESLint errors in polling-controller package (#7435)
## Explanation This fixes all suppressed ESLint errors in the `polling-controller` package. ## 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 --> Closes #7383. ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] 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) - [ ] 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 return types and targeted ESLint-disable annotations to polling controller mixins and tests, removing related suppressions. > > - **Polling Controller**: > - **BlockTrackerPollingController** (`packages/polling-controller/src/BlockTrackerPollingController.ts`): > - Add explicit return types to `_startPolling` and `_stopPollingByPollingTokenSetId`. > - Document/annotate mixin factory and exported helpers with ESLint disables for inferred return types. > - **StaticIntervalPollingController** (`packages/polling-controller/src/StaticIntervalPollingController.ts`): > - Add explicit return types to `setIntervalLength`, `getIntervalLength`, `_startPolling`, and `_stopPollingByPollingTokenSetId`. > - Document/annotate mixin factory and exported helpers with ESLint disables for inferred return types. > - **Tests** (`packages/polling-controller/src/StaticIntervalPollingController.test.ts`): > - Rename callback param `err` to `error` in deferred promise handlers. > - **ESLint Suppressions**: > - Remove suppressions for updated polling-controller files in `eslint-suppressions.json`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 91d0c5a. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent a840490 commit 845352d

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

eslint-suppressions.json

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2652,27 +2652,6 @@
26522652
"count": 1
26532653
}
26542654
},
2655-
"packages/polling-controller/src/BlockTrackerPollingController.ts": {
2656-
"@typescript-eslint/explicit-function-return-type": {
2657-
"count": 5
2658-
},
2659-
"@typescript-eslint/naming-convention": {
2660-
"count": 1
2661-
}
2662-
},
2663-
"packages/polling-controller/src/StaticIntervalPollingController.test.ts": {
2664-
"id-denylist": {
2665-
"count": 1
2666-
}
2667-
},
2668-
"packages/polling-controller/src/StaticIntervalPollingController.ts": {
2669-
"@typescript-eslint/explicit-function-return-type": {
2670-
"count": 7
2671-
},
2672-
"@typescript-eslint/naming-convention": {
2673-
"count": 1
2674-
}
2675-
},
26762655
"packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.test.ts": {
26772656
"@typescript-eslint/explicit-function-return-type": {
26782657
"count": 5

packages/polling-controller/src/BlockTrackerPollingController.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export type BlockTrackerPollingInput = {
2626
* @param Base - The base class to mix onto.
2727
* @returns The composed class.
2828
*/
29+
// This is a function that's used as class, and the return type is inferred from
30+
// the class defined inside the function scope, so this can't be easily typed.
31+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/naming-convention
2932
function BlockTrackerPollingControllerMixin<
3033
TBase extends Constructor,
3134
PollingInput extends BlockTrackerPollingInput,
@@ -40,7 +43,7 @@ function BlockTrackerPollingControllerMixin<
4043
networkClientId: NetworkClientId,
4144
): NetworkClient | undefined;
4245

43-
_startPolling(input: PollingInput) {
46+
_startPolling(input: PollingInput): void {
4447
const key = getKey(input);
4548

4649
if (this.#activeListeners[key]) {
@@ -61,7 +64,7 @@ function BlockTrackerPollingControllerMixin<
6164
}
6265
}
6366

64-
_stopPollingByPollingTokenSetId(key: PollingTokenSetId) {
67+
_stopPollingByPollingTokenSetId(key: PollingTokenSetId): void {
6568
const { networkClientId } = JSON.parse(key);
6669
const networkClient = this._getNetworkClientById(
6770
networkClientId as NetworkClientId,
@@ -86,10 +89,16 @@ class Empty {}
8689

8790
export const BlockTrackerPollingControllerOnly = <
8891
PollingInput extends BlockTrackerPollingInput,
92+
// The return type is inferred from the class defined inside the function
93+
// scope, so this can't be easily typed.
94+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
8995
>() => BlockTrackerPollingControllerMixin<typeof Empty, PollingInput>(Empty);
9096

9197
export const BlockTrackerPollingController = <
9298
PollingInput extends BlockTrackerPollingInput,
99+
// The return type is inferred from the class defined inside the function
100+
// scope, so this can't be easily typed.
101+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
93102
>() =>
94103
BlockTrackerPollingControllerMixin<typeof BaseController, PollingInput>(
95104
BaseController,

packages/polling-controller/src/StaticIntervalPollingController.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ChildBlockTrackerPollingController extends StaticIntervalPollingController
2525
any
2626
> {
2727
executePollPromises: {
28-
reject: (err: unknown) => void;
28+
reject: (error: unknown) => void;
2929
resolve: () => void;
3030
}[] = [];
3131

packages/polling-controller/src/StaticIntervalPollingController.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import type {
1818
* @param Base - The base class to mix onto.
1919
* @returns The composed class.
2020
*/
21+
// This is a function that's used as class, and the return type is inferred from
22+
// the class defined inside the function scope, so this can't be easily typed.
23+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/naming-convention
2124
function StaticIntervalPollingControllerMixin<
2225
TBase extends Constructor,
2326
PollingInput extends Json,
@@ -30,15 +33,15 @@ function StaticIntervalPollingControllerMixin<
3033

3134
#intervalLength: number | undefined = 1000;
3235

33-
setIntervalLength(intervalLength: number) {
36+
setIntervalLength(intervalLength: number): void {
3437
this.#intervalLength = intervalLength;
3538
}
3639

37-
getIntervalLength() {
40+
getIntervalLength(): number | undefined {
3841
return this.#intervalLength;
3942
}
4043

41-
_startPolling(input: PollingInput) {
44+
_startPolling(input: PollingInput): void {
4245
if (!this.#intervalLength) {
4346
throw new Error('intervalLength must be defined and greater than 0');
4447
}
@@ -65,7 +68,7 @@ function StaticIntervalPollingControllerMixin<
6568
));
6669
}
6770

68-
_stopPollingByPollingTokenSetId(key: PollingTokenSetId) {
71+
_stopPollingByPollingTokenSetId(key: PollingTokenSetId): void {
6972
const intervalId = this.#intervalIds[key];
7073
if (intervalId) {
7174
clearTimeout(intervalId);
@@ -81,8 +84,14 @@ class Empty {}
8184

8285
export const StaticIntervalPollingControllerOnly = <
8386
PollingInput extends Json,
87+
// The return type is inferred from the class defined inside the function
88+
// scope, so this can't be easily typed.
89+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
8490
>() => StaticIntervalPollingControllerMixin<typeof Empty, PollingInput>(Empty);
8591

92+
// The return type is inferred from the class defined inside the function
93+
// scope, so this can't be easily typed.
94+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
8695
export const StaticIntervalPollingController = <PollingInput extends Json>() =>
8796
StaticIntervalPollingControllerMixin<typeof BaseController, PollingInput>(
8897
BaseController,

0 commit comments

Comments
 (0)