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

no-callback-in-promise flags promisification callbacks #166

Open
gabegorelick opened this issue Sep 5, 2019 · 0 comments
Open

no-callback-in-promise flags promisification callbacks #166

gabegorelick opened this issue Sep 5, 2019 · 0 comments

Comments

@gabegorelick
Copy link

gabegorelick commented Sep 5, 2019

Description

Promisification utilities like Bluebird.fromCallback are useful to interface with Node-style APIs. Unfortunately, no-callback-in-promise isn't smart enough to realize that these are legitimate uses for calling a callback inside a promise.

Workaround is to rename the name of the callback. But often times you want to shadow an outer callback and so that's not always feasible.

Steps to Reproduce

return Promise.resolve()
    .then(() => {
        return Bluebird.fromCallback(callback => {
           callback(); // this will fail
        });
    });

Expected behavior: does not fail no-callback-in-promise

Actual behavior: fails no-callback-in-promise

Versions

  • Node version: 8
  • ESLint version: 4.19.1
  • eslint-plugin-promise version: 4.2.1

Additional Information

I understand if this is hard to detect and not worth doing. But I think the heuristic to use is if the callback originates from inside the promise, then it's safe to call.

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

No branches or pull requests

1 participant