Commit 69dd293
chore: Notification services controller lint cleanup (#7481)
## Explanation
* **What is the current state of things and why does it need to
change?**
The `packages/notification-services-controller` contained ESLint
suppressions for `@typescript-eslint/explicit-function-return-type` and
`@typescript-eslint/prefer-nullish-coalescing`. These suppressions
indicated areas where type safety and modern JavaScript practices were
not fully enforced, leading to potential maintainability issues and
reduced code clarity.
* **What is the solution your changes offer and how does it work?**
This PR addresses these suppressions by:
1. Adding explicit return types to functions in
`NotificationServicesPushController.test.ts`,
`NotificationServicesPushController.ts`, and
`__fixtures__/mockServices.ts` to satisfy the
`@typescript-eslint/explicit-function-return-type` rule.
2. Replacing a logical OR (`||`) with the nullish coalescing operator
(`??`) in `NotificationServicesPushController.test.ts` to fix the
`@typescript-eslint/prefer-nullish-coalescing` rule.
3. Removing the corresponding entries for these files and rules from
`eslint-suppressions.json`.
* **Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?**
No, the changes are straightforward type annotations and a minor logical
operator update.
## References
* Fixes ASSETS-2100
## Checklist
- [x] 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
- [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)
- [ ] 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
---
<a
href="https://cursor.com/background-agent?bcId=bc-3ab73ae3-3c32-47f2-84e5-d8b16738a68d"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-cursor-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in
Cursor"
src="https://cursor.com/open-in-cursor.svg"></picture></a> <a
href="https://cursor.com/agents?id=bc-3ab73ae3-3c32-47f2-84e5-d8b16738a68d"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-web-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web"
src="https://cursor.com/open-in-web.svg"></picture></a>
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds explicit return types across NotificationServicesPushController
code/tests, adopts nullish coalescing in tests, and removes related
ESLint suppressions.
>
> - **Notification Services Push Controller**:
> - Add explicit return types to `#getAndAssertBearerToken`,
`#updatePushState`, `subscribeToPushNotifications`,
`enablePushNotifications`, `disablePushNotifications`, and
`updateTriggerPushNotifications` in
`NotificationServicesPushController.ts`.
> - **Tests**:
> - Add explicit return types to helpers (`mockErrorLog`,
`arrangeServicesMocks`, `arrangeMockMessenger`,
`mockAuthBearerTokenCall`) and improve Jest typings in
`NotificationServicesPushController.test.ts`.
> - Use nullish coalescing (`??`) for config defaults.
> - **Mocks**:
> - Add return type to `mockEndpointUpdatePushNotificationLinks` in
`__fixtures__/mockServices.ts`.
> - **ESLint**:
> - Remove suppressions for
`@typescript-eslint/explicit-function-return-type` and
`@typescript-eslint/prefer-nullish-coalescing` entries related to these
files in `eslint-suppressions.json`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
f5e64a1. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Cursor Agent <[email protected]>1 parent 30c8a38 commit 69dd293
File tree
4 files changed
+30
-30
lines changed- packages/notification-services-controller/src/NotificationServicesPushController
- __fixtures__
4 files changed
+30
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1593 | 1593 | | |
1594 | 1594 | | |
1595 | 1595 | | |
1596 | | - | |
1597 | | - | |
1598 | | - | |
1599 | | - | |
1600 | | - | |
1601 | | - | |
1602 | | - | |
1603 | | - | |
1604 | | - | |
1605 | | - | |
1606 | | - | |
1607 | | - | |
1608 | | - | |
1609 | | - | |
1610 | | - | |
1611 | | - | |
1612 | | - | |
1613 | | - | |
1614 | 1596 | | |
1615 | 1597 | | |
1616 | 1598 | | |
| |||
Lines changed: 21 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
| |||
359 | 364 | | |
360 | 365 | | |
361 | 366 | | |
362 | | - | |
363 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
364 | 373 | | |
365 | 374 | | |
366 | 375 | | |
| |||
403 | 412 | | |
404 | 413 | | |
405 | 414 | | |
406 | | - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
407 | 423 | | |
408 | 424 | | |
409 | 425 | | |
| |||
Lines changed: 8 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | | - | |
| 269 | + | |
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
| 299 | + | |
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
354 | | - | |
| 354 | + | |
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
398 | 400 | | |
399 | 401 | | |
400 | 402 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
0 commit comments