Skip to content
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

JSHint thinks awaiting a grouped ternary has unnecessary grouping (W126) #3579

Open
Abrifq opened this issue Nov 4, 2021 · 1 comment
Open
Labels

Comments

@Abrifq
Copy link

Abrifq commented Nov 4, 2021

Info

JSHint version: 2.13.1
OS: Linux
NodeJS version: v17.0.1

Expected:

The grouping in the code below to not give W124 as removing the grouping awaits the condition part instead of the condition's result.

Actual:

The grouping in the code below is tagged unnecessary.

async function wait_ok(){
  console.log( await ( true ? Promise.resolve(true) : Promise.resolve("Won't reach here")) );
  //Result: true
}

async function wait_err(){
  console.log( await true ? Promise.resolve(true) : Promise.resolve("Won't reach here") );
  //Result: Promise<true>
}
@jugglinmike
Copy link
Member

Confirmed. Good find!

If anyone needs to work around this erroneous warning before it's fixed, know that (just like with any warning) you can disable it on a line-by-line basis.

Thanks for taking the time to write a report :)

@jugglinmike jugglinmike added the P2 label Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants