Loosen promise/catch-or-return and promise/param-names rules#384
Conversation
| 'promise/catch-or-return': [ | ||
| 'error', | ||
| { | ||
| allowFinally: true, | ||
| }, | ||
| ], |
There was a problem hiding this comment.
By default, allowFinally is set to false, meaning that this is not allowed unless returned.
someFunction().catch(() => { /* ... */ }).finally(() => { /* ... */ });While this is allowed:
someFunction().catch(() => { /* ... */ });or
return someFunction().catch(() => { /* ... */ }).finally(() => { /* ... */ });After this change, the first example is allowed as well.
There was a problem hiding this comment.
That is a strange default. What does finally have to do with remembering to catch? Bizarre.
| 'promise/param-names': [ | ||
| 'error', | ||
| { | ||
| resolvePattern: '^_?resolve', | ||
| rejectPattern: '^_?reject', | ||
| }, | ||
| ], |
There was a problem hiding this comment.
resolvePattern and rejectPattern are set to ^_?resolve$ and ^_?reject$ by default respectively, meaning that the parameters passed to a Promise constructor function must be named exactly resolve, reject, or _resolve, _reject.
This change allows for an optional suffix after resolve and reject, for example resolvePromise or rejectPromise, which can be useful when promises are nested.
59545e5 to
0b4fb83
Compare
promise/catch-or-returnandpromise/param-namesare too strict by default. This changes the configuration slightly to loosen these rules. The exact reasons are explained in a comment below.