Skip to content

Enhancement: [no-floating-promises] need a configuration that would allow to exclude an object from this rule #5844

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
4 tasks done
budarin opened this issue Oct 18, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@budarin
Copy link

budarin commented Oct 18, 2022

Before You File a Proposal Please Confirm You Have Done The Following...

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the rule's documentation

https://typescript-eslint.io/rules/no-floating-promises/

Description

Fastify.reply object has then method, but reply is not a Promise and its methods are not asynchronous

typescript-eslint marks each method of the reply object as asynchronous and requires it to be preceded by an await call

Fail

import { FastifyReply, FastifyRequest } from 'fastify';

function setNotFound(req: FastifyRequest, res: FastifyReply, done: HookHandlerDoneFunction): void {
    res.status(404);
    res.send('Not found');

    done();
}

image

Pass

import { FastifyReply, FastifyRequest } from 'fastify';

function setNotFound(req: FastifyRequest, res: FastifyReply, done: HookHandlerDoneFunction): void {
    void res.status(404);
    void res.send('Not found');

    done();
}

Additional Info

The plugin should look at what the object's method returns, and not just whether the object has a then method.

Or it is necessary to configure the rule to be able to exclude this object/methods from consideration by this rule

@budarin budarin added enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Oct 18, 2022
@budarin budarin changed the title Enhancement: [no-floating-promises] need a configuration that would allow you to exclude an object from this rule Enhancement: [no-floating-promises] need a configuration that would allow to exclude an object from this rule Oct 18, 2022
@bradzacher
Copy link
Member

duplicate of #2640

@bradzacher bradzacher added duplicate This issue or pull request already exists and removed triage Waiting for team members to take a look enhancement: plugin rule option New rule option for an existing eslint-plugin rule labels Oct 19, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2022
@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

3 participants