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 misses callback passed as argument #167

Open
gabegorelick opened this issue Sep 6, 2019 · 1 comment · May be fixed by #514
Open

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

gabegorelick opened this issue Sep 6, 2019 · 1 comment · May be fixed by #514
Labels

Comments

@gabegorelick
Copy link

gabegorelick commented Sep 6, 2019

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.

@brettz9
Copy link
Member

brettz9 commented Jul 21, 2024

Note that as per #220 the particular examples you cite with setTimeout are actually meant to pass. The plug-in could perhaps solve this by config which prevented even callbacks invoked by setTimeout and the like.

brettz9 added a commit to brettz9/eslint-plugin-promise that referenced this issue Jul 25, 2024
…t-community#167

Also:
- fix(`no-callback-in-promise`): ensure timeouts do not err (by default); fixes eslint-community#220
@brettz9 brettz9 linked a pull request Jul 25, 2024 that will close this issue
2 tasks
brettz9 added a commit to brettz9/eslint-plugin-promise that referenced this issue Jul 25, 2024
…t-community#167

Also:
- fix(`no-callback-in-promise`): ensure timeouts do not err (by default); fixes eslint-community#220
brettz9 added a commit to brettz9/eslint-plugin-promise that referenced this issue Jul 29, 2024
…t-community#167

Also:
- fix(`no-callback-in-promise`): ensure timeouts do not err (by default); fixes eslint-community#220
brettz9 added a commit to brettz9/eslint-plugin-promise that referenced this issue Jul 30, 2024
…t-community#167

Also:
- fix(`no-callback-in-promise`): ensure timeouts do not err (by default); fixes eslint-community#220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants