eslint-plugin-promise icon indicating copy to clipboard operation
eslint-plugin-promise copied to clipboard

no-callback-in-promise flags promisification callbacks

Open gabegorelick opened this issue 6 years ago • 0 comments
trafficstars

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.

gabegorelick avatar Sep 05 '19 23:09 gabegorelick