Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

promise/catch-or-return should report unhandled Promise.resolve/reject #55

Open
epoberezkin opened this issue Jan 23, 2017 · 1 comment

Comments

@epoberezkin
Copy link

This innocently looking assignment:

const FAIL = Promise.reject();

causes UnhandledPromiseRejectionWarning if FAIL is not used...

@macklinu
Copy link
Contributor

macklinu commented Mar 8, 2018

I believe an unhandled Promise.resolve() is valid, but opening up a Node 8 REPL shows the following:

❯ node
> const FAIL = Promise.reject()
undefined
> (node:99089) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): undefined
(node:99089) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I think warning for usages of Promise.reject() that aren't returned in a function would be a good addition. For example, assigning Promise.reject() to a variable in your example would be invalid.

I'm not 100% sure if it belongs in the promise/catch-or-return rule or if it should be part of another rule. I think that is worth discussing a little bit.

Discussion and PRs are welcome (even to discuss an initial implementation - we can always move it into another rule at the PR stage).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants