Commit 9fb9729
chore: Notification controller eslint cleanup (#7483)
## Explanation
This PR addresses and removes ESLint suppressions from three files
within `packages/notification-services-controller` as part of a larger
cleanup effort (ASSETS-2100).
* **Current state and why it needs to change:** The identified files
contained suppressions for
`@typescript-eslint/explicit-function-return-type`,
`no-restricted-globals`, `require-atomic-updates`, and `id-length`.
These suppressions masked potential code quality issues and reduced code
clarity.
* **Solution:**
* **`push-utils.test.ts`**: Explicit return types were added to all
functions to satisfy `@typescript-eslint/explicit-function-return-type`.
For `no-restricted-globals` related to `self`, targeted
`eslint-disable-next-line` comments with explanations were added, as
`self` is required for testing service worker functionality.
* **`push-utils.ts`**: Explicit return types were added to functions to
satisfy `@typescript-eslint/explicit-function-return-type`. The
`require-atomic-updates` issue was addressed with a targeted
`eslint-disable-next-line` comment and explanation, as the race
condition for caching a boolean is acceptable.
* **`is-onchain-notification.ts`**: The `id-length` violation was fixed
by renaming the parameter `n` to `notification` for improved
readability.
* All corresponding entries for these files have been removed from
`eslint-suppressions.json`.
* **Changes whose purpose might not be obvious:** The
`eslint-disable-next-line` comments for `no-restricted-globals` and
`require-atomic-updates` are intentional and include inline explanations
in the code, detailing why these specific rules are being ignored at
those points.
## References
* Fixes ASSETS-2100
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] 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-6ab48784-58dc-44dd-b632-a564eb71d229"><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-6ab48784-58dc-44dd-b632-a564eb71d229"><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 and stricter typings to web push utils and
tests, renames a short param in on-chain notification check, and removes
related entries from eslint-suppressions.json.
>
> - **Notification Services Push (web)**:
> - **Typing/ESLint**: Add explicit return types to
`getPushAvailability`, `listenToPushNotificationsReceived`,
`listenToPushNotificationsClicked`, and
`createSubscribeToPushNotifications`; ensure handlers return
`Promise<void>`/`void`; type `unsubscribe` functions.
> - **Support caching**: Document acceptable race; add targeted
`eslint-disable-next-line require-atomic-updates`.
> - **Tests (`web/push-utils.test.ts`)**:
> - Refactor helper utilities into typed `function`s; add explicit
return types; type Jest spies; add targeted `eslint-disable-next-line
no-restricted-globals` for `self` usage; simulate `notificationclick`
via `self.dispatchEvent`.
> - **Shared**:
> - Rename `isOnChainRawNotification` param from `n` to `notification`
for clarity.
> - **Tooling**:
> - Remove corresponding entries for these files from
`eslint-suppressions.json`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ba5e91a. 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 2a3a2eb commit 9fb9729
File tree
4 files changed
+80
-60
lines changed- packages/notification-services-controller/src
- NotificationServicesPushController/web
4 files changed
+80
-60
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1638 | 1638 | | |
1639 | 1639 | | |
1640 | 1640 | | |
1641 | | - | |
1642 | | - | |
1643 | | - | |
1644 | | - | |
1645 | | - | |
1646 | | - | |
1647 | | - | |
1648 | | - | |
1649 | | - | |
1650 | | - | |
1651 | | - | |
1652 | | - | |
1653 | | - | |
1654 | | - | |
1655 | | - | |
1656 | | - | |
1657 | | - | |
1658 | | - | |
1659 | | - | |
1660 | | - | |
1661 | | - | |
1662 | 1641 | | |
1663 | 1642 | | |
1664 | 1643 | | |
| |||
Lines changed: 62 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
46 | | - | |
47 | | - | |
48 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
49 | 57 | | |
50 | 58 | | |
51 | 59 | | |
| |||
65 | 73 | | |
66 | 74 | | |
67 | 75 | | |
68 | | - | |
| 76 | + | |
69 | 77 | | |
70 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
71 | 82 | | |
72 | 83 | | |
73 | 84 | | |
| |||
77 | 88 | | |
78 | 89 | | |
79 | 90 | | |
80 | | - | |
| 91 | + | |
81 | 92 | | |
82 | 93 | | |
83 | 94 | | |
84 | 95 | | |
85 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
86 | 99 | | |
87 | 100 | | |
88 | 101 | | |
| |||
94 | 107 | | |
95 | 108 | | |
96 | 109 | | |
97 | | - | |
| 110 | + | |
98 | 111 | | |
99 | 112 | | |
100 | 113 | | |
| |||
147 | 160 | | |
148 | 161 | | |
149 | 162 | | |
150 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
151 | 166 | | |
152 | 167 | | |
153 | 168 | | |
154 | 169 | | |
155 | 170 | | |
156 | | - | |
| 171 | + | |
157 | 172 | | |
158 | 173 | | |
159 | 174 | | |
| |||
193 | 208 | | |
194 | 209 | | |
195 | 210 | | |
196 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
197 | 218 | | |
198 | 219 | | |
199 | 220 | | |
| |||
213 | 234 | | |
214 | 235 | | |
215 | 236 | | |
216 | | - | |
217 | | - | |
218 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
219 | 245 | | |
| 246 | + | |
220 | 247 | | |
221 | 248 | | |
222 | 249 | | |
223 | 250 | | |
224 | 251 | | |
225 | 252 | | |
226 | | - | |
227 | | - | |
228 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
229 | 262 | | |
230 | 263 | | |
231 | 264 | | |
| |||
238 | 271 | | |
239 | 272 | | |
240 | 273 | | |
241 | | - | |
| 274 | + | |
242 | 275 | | |
243 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
244 | 279 | | |
245 | 280 | | |
246 | 281 | | |
247 | 282 | | |
248 | 283 | | |
249 | 284 | | |
250 | 285 | | |
251 | | - | |
| 286 | + | |
252 | 287 | | |
253 | 288 | | |
254 | 289 | | |
| |||
288 | 323 | | |
289 | 324 | | |
290 | 325 | | |
291 | | - | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
292 | 329 | | |
293 | 330 | | |
294 | 331 | | |
| |||
303 | 340 | | |
304 | 341 | | |
305 | 342 | | |
306 | | - | |
| 343 | + | |
307 | 344 | | |
308 | 345 | | |
309 | 346 | | |
| |||
351 | 388 | | |
352 | 389 | | |
353 | 390 | | |
354 | | - | |
| 391 | + | |
| 392 | + | |
355 | 393 | | |
356 | 394 | | |
357 | 395 | | |
| |||
packages/notification-services-controller/src/NotificationServicesPushController/web/push-utils.ts
Lines changed: 14 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
132 | | - | |
| 135 | + | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
| |||
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
165 | | - | |
| 168 | + | |
166 | 169 | | |
167 | 170 | | |
168 | 171 | | |
| |||
174 | 177 | | |
175 | 178 | | |
176 | 179 | | |
177 | | - | |
178 | | - | |
| 180 | + | |
| 181 | + | |
179 | 182 | | |
180 | 183 | | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
184 | 187 | | |
185 | | - | |
| 188 | + | |
186 | 189 | | |
187 | 190 | | |
188 | 191 | | |
| |||
208 | 211 | | |
209 | 212 | | |
210 | 213 | | |
211 | | - | |
212 | | - | |
| 214 | + | |
| 215 | + | |
213 | 216 | | |
214 | 217 | | |
215 | | - | |
| 218 | + | |
216 | 219 | | |
217 | 220 | | |
218 | 221 | | |
| |||
221 | 224 | | |
222 | 225 | | |
223 | 226 | | |
224 | | - | |
| 227 | + | |
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
| |||
230 | 233 | | |
231 | 234 | | |
232 | 235 | | |
233 | | - | |
| 236 | + | |
234 | 237 | | |
235 | 238 | | |
236 | 239 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
0 commit comments