Skip to content

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

Closed
@CoderCoco

Description

@CoderCoco

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions