[no-floating-promises] Rule proposal: Add ignore for typescript types or specific methods #4791
Labels
duplicate
This issue or pull request already exists
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Description
Some of the functions I have in my code do return a promise, where I'm fine having them "floating around". They usually are functions whose promise already is handled in a different way, and I don't want to add
.catch(() => {})
to all of them.One example I have at hand is the package
@vue/apollo-composable
which lets me run a query to a GraphQL server. This function returns properties (result, error, loading) which are objects which will get the value as they arrive (vue calls it reactive). The functionrefetch()
now returns a promise which contains the result when it arrives, but I don't need it because the reactive properties will reflect the values.My idea was now if it would be possible to ignore those calls but not all promises ... Maybe by type (
Promise<ApolloQueryResult<TResult>>
) or maybe by the name of the function returning the promise.As you see, I myself am not yet that sure about how the extra feature to the rule
no-floating-promises
could be implemented, but am rather open to discuss it to find a good option. If you see it not being feasible, it would be nice to know a bit more about the implementation here, to wrap my head around what would be possible instead.Fail
Pass
The text was updated successfully, but these errors were encountered: