Skip to content

[no-floating-promises] Finally callback reports as false positive for unhanded promises #1603

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

Closed
CoderCoco opened this issue Feb 13, 2020 · 0 comments · Fixed by #1620
Closed
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@CoderCoco
Copy link

Repro

{
  "rules": {
    "@typescript-eslint/no-floating-promises": ["error"]
  }
}
const demoFunction: (input: boolean) => Promise<string> = (input: boolean) => {
  if (input) {
    return Promise.resolve('hello world');
  } else {
    return Promise.reject('input was false');
  }
}

// Call 1
demoFunction(true).then(() => {
  console.log('Entered then');
}).catch(() => {
  console.log('Entered catch');
});

// Call 2
demoFunction(true).then(() => {
  console.log('Entered then');
}).catch(() => {
  console.log('Entered catch');
}).finally(() => {
  console.log('Entered finally');
});

Expected Result

Both Call 1 and Call 2 should pass the floating promises check.

Actual Result

Call 1 passes but Call 2 fails.

Versions

package version
@typescript-eslint/eslint-plugin 2.19.2
@typescript-eslint/parser 2.19.2
TypeScript 3.5.3
ESLint 6.8.0
node 12.14.0
npm 6.13.4
@CoderCoco CoderCoco added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Feb 13, 2020
@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for team members to take a look labels Feb 13, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants