Commit 4507871
chore: Notification controller eslint cleanup (#7484)
## Explanation
This PR addresses and removes ESLint suppressions in three files within
`packages/notification-services-controller/src/NotificationServicesPushController`.
The goal is to improve code quality and consistency by adhering to
established linting rules.
The changes include:
* **Adding explicit return types** to functions to satisfy
`@typescript-eslint/explicit-function-return-type`.
* **Using the nullish coalescing operator (`??`)** to fix
`@typescript-eslint/prefer-nullish-coalescing`.
* **Renaming short, non-descriptive identifiers** (e.g., `num` to
`numericValue`, `t` to `translate`, `n` to `notification`) to resolve
`id-denylist` and `id-length` violations.
* **Refactoring generic type parameters** (e.g., `N` to `TNotification`,
`K` to `TriggerType`/`TKey`) for better clarity and to fix
`@typescript-eslint/naming-convention`.
* **Adding an `eslint-disable` comment** with an explanation for the
`registration_token` property in `services.ts`. Its `snake_case` naming
is dictated by an external API contract, making a code change
impractical.
* **Removing all corresponding entries** from
`eslint-suppressions.json`.
## References
* Fixes ASSETS-2100
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
(Functional tests pass, coverage thresholds are a separate issue)
- [x] 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
---
<a
href="https://cursor.com/background-agent?bcId=bc-9abd1f11-e0c0-4df0-bb89-cfd2727b98b5"><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-9abd1f11-e0c0-4df0-bb89-cfd2727b98b5"><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]
> Tightens TypeScript types and naming in
NotificationServicesPushController utilities/services, adds a justified
snake_case exception for `registration_token`, and removes related
ESLint suppressions.
>
> - **Notification Services (push)**:
> - `utils/get-notification-data.ts`:
> - Add explicit return types (`calcTokenAmount: BigNumber`,
`getLeadingZeroCount: number`, `formatAmount: string`, `getAmount:
string`).
> - Use nullish coalescing in parsing; type `handleShouldEllipse` and
options.
> - Rename params/vars for clarity (e.g., `num` → `numericValue`).
> - `utils/get-notification-message.ts`:
> - Strengthen generics and parameter names (`N/K` →
`TNotification/TKey`, `n` → `notification`, `t` → `translate`).
> - Add explicit return types across helpers and message creators; type
`getChainSymbol`.
> - `services/services.ts`:
> - Document API contract and add ESLint naming exception for
`registration_token` in `PushTokenRequest`.
> - **Lint**:
> - Remove corresponding entries from `eslint-suppressions.json` for the
updated files.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
8dfbc12. 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 6410b13 commit 4507871
File tree
4 files changed
+133
-126
lines changed- packages/notification-services-controller/src/NotificationServicesPushController
- services
- utils
4 files changed
+133
-126
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1578 | 1578 | | |
1579 | 1579 | | |
1580 | 1580 | | |
1581 | | - | |
1582 | | - | |
1583 | | - | |
1584 | | - | |
1585 | | - | |
1586 | | - | |
1587 | | - | |
1588 | | - | |
1589 | | - | |
1590 | | - | |
1591 | | - | |
1592 | | - | |
1593 | | - | |
1594 | | - | |
1595 | | - | |
1596 | | - | |
1597 | | - | |
1598 | | - | |
1599 | | - | |
1600 | | - | |
1601 | | - | |
1602 | | - | |
1603 | | - | |
1604 | | - | |
1605 | | - | |
1606 | | - | |
1607 | | - | |
1608 | 1581 | | |
1609 | 1582 | | |
1610 | 1583 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
Lines changed: 11 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
61 | | - | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
90 | | - | |
| 93 | + | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| |||
0 commit comments