Skip to content

Only accept functions in then/catch #60

Open
@friday

Description

@friday

Similar to: http://bluebirdjs.com/docs/warning-explanations.html

Examples:

Promise.resolve(1)
  .then(Promise.resolve(2)) // This is ignored, probably not what the developer intended
  .then(console.log) // 1
const errorHandler = console.warn;
Promise.reject('Catch me if you can').catch(errorHandler()) // should have been `errorHandler` without parenthesis 

It wouldn't be possible to cover this completely with static code analysis I guess (we would have to know that console.warn isn't a function that returns another function), but the first example should be detectable at least?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions