Skip to content

fix(eslint-plugin): [no-floating-promises] false negative calling .then with second argument undefined #6881

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

Merged
merged 5 commits into from
Jul 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use getTypeAtLocation correctly
  • Loading branch information
kirkwaiblinger committed Jul 14, 2023
commit 8708fc087c5d878a16b8444ef6509dcd9d8fdd06
11 changes: 5 additions & 6 deletions packages/eslint-plugin/src/rules/no-floating-promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,12 @@ export default util.createRule<Options, MessageId>({
}

function isValidRejectionHandler(rejectionHandler: TSESTree.Node): boolean {
// Note - when merged with main, getTypeAtLocation will be available as an
// instance method and these expressions can be chained.

return (
services.esTreeNodeToTSNodeMap
.get(rejectionHandler)
.getTypeAtLocation()
services.program
.getTypeChecker()
.getTypeAtLocation(
services.esTreeNodeToTSNodeMap.get(rejectionHandler),
)
.getCallSignatures().length > 0
);
}
Expand Down