Commit 2a3a2eb
chore: Notification services eslint cleanup (#7485)
## Explanation
This PR addresses and resolves several ESLint rule violations across
three files within `packages/notification-services-controller`, allowing
for the removal of their corresponding suppressions from
`eslint-suppressions.json`.
* **Current state and why change?**
ESLint suppressions were present in `eslint-suppressions.json` for rules
such as `@typescript-eslint/explicit-function-return-type`,
`@typescript-eslint/naming-convention`,
`@typescript-eslint/prefer-nullish-coalescing`, and `id-length`. These
suppressions indicated areas where the code did not conform to
established linting standards. The goal is to improve code quality and
maintainability by fixing these violations and removing the
suppressions.
* **What is the solution your changes offer and how does it work?**
* **`feature-announcements.ts`**:
* Explicit return types were added to `getFeatureAnnouncementUrl` and
`findIncludedItem`.
* `prefer-nullish-coalescing` was applied by replacing `||` with `??`.
* `id-length` violations were resolved by renaming short,
non-descriptive variables (`r`, `i`, `n`) to more explicit names
(`response`, `entry`/`asset`, `item`/`rawNotification`).
* `@typescript-eslint/naming-convention` suppressions were added with
explanations for `Entry` and `Asset` properties within the
`ContentfulResult` type, as their casing is dictated by the external
Contentful API response structure.
* **`notification-config-cache.ts`**:
* The private field `#TTL` was renamed to `#ttl` to conform to camelCase
naming conventions for private class members.
* **`perp-notifications.test.ts`**:
* An explicit return type was added to the `arrangeMocks` test helper
function.
* All corresponding entries for these files were removed from
`eslint-suppressions.json`.
* **Are there any changes whose purpose might not be obvious?**
The `eslint-disable-next-line @typescript-eslint/naming-convention`
comments in `feature-announcements.ts` for `Entry` and `Asset`
properties are intentional. These properties directly reflect the
structure of responses from the Contentful API, and renaming them would
break compatibility or require complex mapping.
## 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
- [ ] 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-f2af14fa-6392-4945-9c74-67168ae9e6e0"><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-f2af14fa-6392-4945-9c74-67168ae9e6e0"><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]
> Fixes ESLint violations in feature announcements, notification config
cache, and perps test, and removes their suppressions.
>
> - **Notification Services Controller**:
> - `services/feature-announcements.ts`:
> - Add explicit return types to `getFeatureAnnouncementUrl` and
`findIncludedItem`.
> - Replace `||` with `??` and improve variable names (`response`,
`entry`/`asset`, `item`, `rawNotification`).
> - Add targeted `@typescript-eslint/naming-convention` disables for
`includes.Entry` and `includes.Asset` to match Contentful schema.
> - Minor refactors: safer optional access, typed mappings, and
consistent `createdAt` source.
> - `services/notification-config-cache.ts`:
> - Rename private field `#TTL` to `#ttl` and update references.
> - `services/perp-notifications.test.ts`:
> - Add explicit return type to `arrangeMocks` helper.
> - **ESLint suppressions**:
> - Remove entries for `feature-announcements.ts`,
`notification-config-cache.ts`, and `perp-notifications.test.ts` from
`eslint-suppressions.json`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e6f1d91. 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 32dd105 commit 2a3a2eb
File tree
4 files changed
+43
-45
lines changed- packages/notification-services-controller/src/NotificationServicesController/services
4 files changed
+43
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1575 | 1575 | | |
1576 | 1576 | | |
1577 | 1577 | | |
1578 | | - | |
1579 | | - | |
1580 | | - | |
1581 | | - | |
1582 | | - | |
1583 | | - | |
1584 | | - | |
1585 | | - | |
1586 | | - | |
1587 | | - | |
1588 | | - | |
1589 | | - | |
1590 | | - | |
1591 | | - | |
1592 | | - | |
1593 | | - | |
1594 | | - | |
1595 | | - | |
1596 | | - | |
1597 | | - | |
1598 | | - | |
1599 | | - | |
1600 | | - | |
1601 | | - | |
1602 | 1578 | | |
1603 | 1579 | | |
1604 | 1580 | | |
| |||
Lines changed: 38 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
46 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
52 | | - | |
| 58 | + | |
53 | 59 | | |
54 | 60 | | |
55 | 61 | | |
| |||
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
65 | | - | |
| 71 | + | |
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
71 | 77 | | |
72 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
73 | 87 | | |
74 | 88 | | |
75 | 89 | | |
| |||
78 | 92 | | |
79 | 93 | | |
80 | 94 | | |
81 | | - | |
82 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
83 | 101 | | |
84 | 102 | | |
85 | 103 | | |
86 | 104 | | |
87 | 105 | | |
88 | | - | |
89 | | - | |
| 106 | + | |
| 107 | + | |
90 | 108 | | |
91 | 109 | | |
92 | 110 | | |
| |||
114 | 132 | | |
115 | 133 | | |
116 | 134 | | |
117 | | - | |
| 135 | + | |
118 | 136 | | |
119 | 137 | | |
120 | 138 | | |
| |||
163 | 181 | | |
164 | 182 | | |
165 | 183 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
175 | 195 | | |
176 | 196 | | |
177 | 197 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
0 commit comments