Commit edd3f57
authored
Follow
This rule comes from `typescript-eslint`:
https://typescript-eslint.io/rules/prefer-promise-reject-errors/
We don't have it enabled yet, but in v8 it's part of the
"recommended-type-checked" preset:
https://typescript-eslint.io/blog/announcing-typescript-eslint-v8/#updated-configuration-rules
In order to keep the upgrade to that version as small as possible, this
change pre-emptively fixes code considered incorrect by that rule. It
creates `Error` objects for instances where we have control over the
value the `Promise` is rejecting with, and disables the rule in cases
where we don't have control over this value because it comes from a
library.
Another approach would be to create our own `Error` object and include
the unknown library error using the `cause` option, but the browser
support is not good enough for that yet:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error#causeprefer-promise-reject-errors lint rule (#14693)1 parent d1b60df commit edd3f57
File tree
4 files changed
+8
-1
lines changed- dotcom-rendering/src
- client/userFeatures
- components
- YoutubeAtom
- lib/braze
4 files changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
146 | 149 | | |
147 | 150 | | |
148 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| |||
0 commit comments