Skip to content

Commit 21576f2

Browse files
refactor: fix lint
1 parent 5f45f70 commit 21576f2

File tree

6 files changed

+26
-29
lines changed

6 files changed

+26
-29
lines changed

eslint-warning-thresholds.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
2-
"@typescript-eslint/consistent-type-exports": 19,
2+
"@typescript-eslint/consistent-type-exports": 18,
33
"@typescript-eslint/no-base-to-string": 3,
44
"@typescript-eslint/no-duplicate-enum-values": 2,
55
"@typescript-eslint/no-unsafe-enum-comparison": 34,
6-
"@typescript-eslint/no-unused-vars": 41,
6+
"@typescript-eslint/no-unused-vars": 40,
77
"@typescript-eslint/prefer-promise-reject-errors": 33,
8-
"@typescript-eslint/prefer-readonly": 147,
8+
"@typescript-eslint/prefer-readonly": 137,
99
"import-x/namespace": 189,
1010
"import-x/no-named-as-default": 1,
1111
"import-x/no-named-as-default-member": 8,
12-
"import-x/order": 211,
12+
"import-x/order": 208,
1313
"jest/no-conditional-in-test": 113,
1414
"jest/prefer-lowercase-title": 2,
1515
"jest/prefer-strict-equal": 2,
16-
"jsdoc/check-tag-names": 375,
16+
"jsdoc/check-tag-names": 374,
1717
"jsdoc/require-returns": 25,
18-
"jsdoc/tag-lines": 335,
18+
"jsdoc/tag-lines": 334,
1919
"n/no-unsupported-features/node-builtins": 4,
2020
"n/prefer-global/text-encoder": 4,
2121
"n/prefer-global/text-decoder": 4,

packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import * as OnChainNotifications from './services/onchain-notifications';
4747
import type { INotification } from './types';
4848
import type { UserStorage } from './types/user-storage/user-storage';
4949
import * as Utils from './utils/utils';
50-
import { NotificationServicesPushControllerGetStateAction } from '../NotificationServicesPushController';
50+
import type { NotificationServicesPushControllerGetStateAction } from '../NotificationServicesPushController';
5151

5252
// Mock type used for testing purposes
5353
// eslint-disable-next-line @typescript-eslint/no-explicit-any

packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ export default class NotificationServicesController extends BaseController<
307307
#isPushNotificationsSetup = false;
308308

309309
#isUnlocked = false;
310-
#keyringController = {
310+
311+
readonly #keyringController = {
311312
setupLockedStateSubscriptions: (onUnlock: () => Promise<void>) => {
312313
const { isUnlocked } = this.messagingSystem.call(
313314
'KeyringController:getState',
@@ -328,7 +329,7 @@ export default class NotificationServicesController extends BaseController<
328329
},
329330
};
330331

331-
#auth = {
332+
readonly #auth = {
332333
getBearerToken: async () => {
333334
return await this.messagingSystem.call(
334335
'AuthenticationController:getBearerToken',
@@ -339,7 +340,7 @@ export default class NotificationServicesController extends BaseController<
339340
},
340341
};
341342

342-
#storage = {
343+
readonly #storage = {
343344
enableProfileSyncing: async () => {
344345
return await this.messagingSystem.call(
345346
'UserStorageController:enableProfileSyncing',
@@ -363,7 +364,7 @@ export default class NotificationServicesController extends BaseController<
363364
},
364365
};
365366

366-
#pushNotifications = {
367+
readonly #pushNotifications = {
367368
isEnabled: () =>
368369
this.messagingSystem.call('NotificationServicesPushController:getState')
369370
?.isPushEnabled ?? false,
@@ -382,7 +383,6 @@ export default class NotificationServicesController extends BaseController<
382383
// Push notifications were disabled
383384
if (prevVal === true && newVal === false) {
384385
this.#isPushNotificationsSetup = false;
385-
return;
386386
}
387387
} catch {
388388
// Do nothing, silently fail push notifications
@@ -473,7 +473,7 @@ export default class NotificationServicesController extends BaseController<
473473
},
474474
};
475475

476-
#accounts = {
476+
readonly #accounts = {
477477
/**
478478
* Used to get list of addresses from keyring (wallet addresses)
479479
*
@@ -555,7 +555,7 @@ export default class NotificationServicesController extends BaseController<
555555
},
556556
};
557557

558-
#featureAnnouncementEnv: FeatureAnnouncementEnv;
558+
readonly #featureAnnouncementEnv: FeatureAnnouncementEnv;
559559

560560
/**
561561
* Creates a NotificationServicesController instance.
@@ -565,7 +565,6 @@ export default class NotificationServicesController extends BaseController<
565565
* @param args.state - Initial state to set on this controller.
566566
* @param args.env - environment variables for a given controller.
567567
* @param args.env.featureAnnouncements - env variables for feature announcements.
568-
* @param args.env.isPushIntegrated - toggle push notifications on/off if client has integrated them.
569568
*/
570569
constructor({
571570
messenger,
@@ -658,14 +657,14 @@ export default class NotificationServicesController extends BaseController<
658657
return { bearerToken, storageKey };
659658
}
660659

661-
#performEnableProfileSyncing = async () => {
660+
async #performEnableProfileSyncing() {
662661
try {
663662
await this.#storage.enableProfileSyncing();
664663
} catch (e) {
665664
log.error('Failed to enable profile syncing', e);
666665
throw new Error('Failed to enable profile syncing');
667666
}
668-
};
667+
}
669668

670669
#assertUserStorage(
671670
storage: UserStorage | null,

packages/notification-services-controller/src/NotificationServicesPushController/NotificationServicesPushController.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import { BaseController } from '@metamask/base-controller';
88
import type { AuthenticationController } from '@metamask/profile-sync-controller';
99
import log from 'loglevel';
1010

11-
import type { Types } from '../NotificationServicesController';
1211
import {
1312
activatePushNotifications,
1413
deactivatePushNotifications,
1514
updateTriggerPushNotifications,
1615
} from './services/services';
1716
import type { PushNotificationEnv } from './types';
1817
import type { PushService } from './types/push-service-interface';
18+
import type { Types } from '../NotificationServicesController';
1919

2020
const controllerName = 'NotificationServicesPushController';
2121

@@ -143,8 +143,6 @@ export type ControllerConfig = {
143143
* It is responsible for registering and unregistering the service worker that listens for push notifications,
144144
* managing the FCM token, and communicating with the server to register or unregister the device for push notifications.
145145
* Additionally, it provides functionality to update the server with new UUIDs that should trigger push notifications.
146-
*
147-
* @augments {BaseController<typeof controllerName, NotificationServicesPushControllerState, NotificationServicesPushControllerMessenger>}
148146
*/
149147
export default class NotificationServicesPushController extends BaseController<
150148
typeof controllerName,
@@ -153,9 +151,9 @@ export default class NotificationServicesPushController extends BaseController<
153151
> {
154152
#pushListenerUnsubscribe: (() => void) | undefined = undefined;
155153

156-
#env: PushNotificationEnv;
154+
readonly #env: PushNotificationEnv;
157155

158-
#config: ControllerConfig;
156+
readonly #config: ControllerConfig;
159157

160158
constructor({
161159
messenger,
@@ -232,7 +230,7 @@ export default class NotificationServicesPushController extends BaseController<
232230
(await this.#config.pushService.subscribeToPushNotifications(
233231
this.#env,
234232
)) ?? undefined;
235-
} catch (e) {
233+
} catch {
236234
// Do nothing, we are silently failing if push notification registration fails
237235
}
238236
}
@@ -301,11 +299,9 @@ export default class NotificationServicesPushController extends BaseController<
301299
}
302300

303301
const bearerToken = await this.#getAndAssertBearerToken();
304-
let isPushNotificationsDisabled: boolean;
305-
306302
try {
307303
// Send a request to the server to unregister the token/device
308-
isPushNotificationsDisabled = await deactivatePushNotifications({
304+
await deactivatePushNotifications({
309305
bearerToken,
310306
triggers: UUIDs,
311307
env: this.#env,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './firebase';
2-
export * from './push-service-interface';
1+
export type * from './firebase';
2+
export type * from './push-service-interface';

packages/notification-services-controller/src/NotificationServicesPushController/web/push-helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,14 @@ export async function deleteRegToken(
102102

103103
await deleteToken(messaging);
104104
return true;
105-
} catch (error) {
105+
} catch {
106106
return false;
107107
}
108108
}
109109

110110
/**
111111
* Service Worker Listener for when push notifications are received.
112+
*
112113
* @param env - push notification environment
113114
* @param handler - handler to actually showing notification, MUST BE PROVIDED
114115
* @returns unsubscribe handler
@@ -178,6 +179,7 @@ function listenToPushNotificationsClicked(
178179
* 1. Creates subscriptions for receiving and clicking notifications
179180
* 2. Creates click events when a notification is clicked
180181
* 3. Publishes controller messenger events
182+
*
181183
* @param props - props for this creator function.
182184
* @param props.onReceivedHandler - allows the developer to handle showing a notification
183185
* @param props.onClickHandler - allows the developer to handle clicking the notification

0 commit comments

Comments
 (0)