Skip to content

Bug: [no-floating-promises] doesn't detect nested arrays to Promise.all() #11257

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
libre-man opened this issue May 30, 2025 · 3 comments
Closed
4 tasks done
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look

Comments

@libre-man
Copy link

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.8.2&fileType=.tsx&code=IYZwngdgxgBAZgV2gFwJYHsI2ACgJQwDeAUDNgO7CrIwAKATugLaogCmAdMADbc4DapGPwbNWnemxDpuANzb4AugBohivMQC%2BxIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUFs%2B5AAgC4CeADigMbQCWphAtCvNQHaED0LA9vQGbxcAhoVYBzeqWhcAttWQp0URNCnRI4MAF8QmoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

async function a() {
  await Promise.all([
    [Promise.resolve()],
  ])
}

ESLint Config

{
  "rules": {
            "@typescript-eslint/no-floating-promises": "error"
  }
}

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

I would expect this code to be flagged, as Promise.all([[promise]]) doesn't await promise.

Actual Result

There was no issue detected.

Additional Info

This is quite a subtle bug and it would be great if typescript-eslint could catch it.

@libre-man libre-man added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels May 30, 2025
@kirkwaiblinger
Copy link
Member

kirkwaiblinger commented May 30, 2025

Hi @libre-man!

Note that #1804 is related and also solves this specific case, by different logic.

The trouble with detecting this case in no-floating-promises is that we're only looking for statements whose type is Promise<T> or (since #7897) Promise<T>[]. The statement in this issue has type Promise<T>[][]... While that's clearly an error in this particular case, I'm not sure we can generalize that (and if so, what's an appropriate bound to this generalization - e.g. what about Promise<T>[][][]?). Unless there's a compelling answer to that, I'm tentatively leaning towards closing this in favor of #1804. WDYT?

@kirkwaiblinger kirkwaiblinger changed the title Bug: no-floating-promises doesn't detected nested arrays to Promise.all Bug: [no-floating-promises] doesn't detected nested arrays to Promise.all May 30, 2025
@bradzacher
Copy link
Member

I would agree that #1804 would cover this.

@kirkwaiblinger kirkwaiblinger changed the title Bug: [no-floating-promises] doesn't detected nested arrays to Promise.all Bug: [no-floating-promises] doesn't detected nested arrays to Promise.all() Jun 1, 2025
@kirkwaiblinger kirkwaiblinger changed the title Bug: [no-floating-promises] doesn't detected nested arrays to Promise.all() Bug: [no-floating-promises] doesn't detect nested arrays to Promise.all() Jun 1, 2025
@libre-man
Copy link
Author

I guess indeed that #1804 is basically the same ticket indeed. Closing it in favor of that one seems fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look
Projects
None yet
Development

No branches or pull requests

3 participants