Skip to content

no-callback-in-promise misses callback passed as argument #167

Closed
@gabegorelick

Description

@gabegorelick

Description

The no-callback-in-promise rule only checks for CallExpressions. It does not check if a callback is passed to a third-party like setTimeout(callback). I think any time a callback is passed to another function, the assumption should be that the callback will be called.

Steps to Reproduce

function wait (callback) {
  return Promise.resolve()
    .then(() => {
      setTimeout(() => callback()); // this fails
      setTimeout(callback); // this does not fail
    }); 
}

Expected behavior: no-callback-in-promise flags error

Actual behavior: no-callback-in-promise rule does not flag error

Versions

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

Additional Information

Potential implementation: in https://github.com/xjamundx/eslint-plugin-promise/blob/5b935bdd3c3760a2e58eea9b89c86b6d3243e321/rules/lib/is-callback.js, you can potentially check if any of the CallExpressions's arguments is a named callback.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions