Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[no-floating-promises] Rule proposal: Add ignore for typescript types or specific methods #4791

Closed as not planned
Labels
duplicateThis issue or pull request already existspackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@SimonSimCity

Description

@SimonSimCity

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 ruleno-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

newPromise(()=>{});

Pass

import*asVueApolloComposablefrom"@vue/apollo-composable";importgqlfrom"graphql-tag";constquery=VueApolloComposable.useQuery<Record<string,string>,Record<string,string>>(gql`    query Test() {  test() {    result  }}`,{},{});// Returns a promise which is already resolved by the query.result-propertyquery.refetch();

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already existspackage: 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


      [8]ページ先頭

      ©2009-2025 Movatter.jp