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

require-await Potential pitfall if used. Doc update maybe? #9540

Closed
KpjComp opened this issue Oct 30, 2017 · 7 comments
Closed

require-await Potential pitfall if used. Doc update maybe? #9540

KpjComp opened this issue Oct 30, 2017 · 7 comments
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation good first issue Good for people who haven't worked on ESLint before Hacktoberfest Recommended issue for those participating in Hacktoberfest https://hacktoberfest.digitalocean.com/ help wanted The team would welcome a contribution from the community for this issue

Comments

@KpjComp
Copy link

KpjComp commented Oct 30, 2017

Been using ESLint for a while, most rules are great.
But I would like to point out there is a major problem in enabling this rule.

The problem, take the code below.

async function test() { throw new Error("test"); }

There is no await, but what the async does here is guarantee a Promise. So the following code will return got.

test().catch(function (e) { console.log("got"); })

Take away the async and the above code is going to fail big time Now if you can guarantee you are always going to call test with await, you are ok again as await will check if it's a Promise, but if you sent this to any other other Promise based consumers you have the above issue.

I'm mainly pointing this out as the Doc's say nothing of this issue, and could potential cause hard to debug issues for people who are currently mixing Promise & async / await. So I wonder if a big warning of this potential pitfall should be put in the Doc's.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Oct 30, 2017
@not-an-aardvark not-an-aardvark added documentation Relates to ESLint's documentation and removed triage An ESLint team member will look at this issue soon labels Oct 30, 2017
@not-an-aardvark
Copy link
Member

Seems reasonable to me. There was more discussion on potential pitfalls in #6820.

@ilyavolodin ilyavolodin added accepted There is consensus among the team that this change meets the criteria for inclusion good first issue Good for people who haven't worked on ESLint before help wanted The team would welcome a contribution from the community for this issue labels Dec 23, 2017
@GCrispino
Copy link

Is there anything else that could be done about this issue?

The docs have a "When Not To Use It" section, that apparently warns the user that this rule may bring some harm to their code. So it seems to me that this is a matter of using or not using the rule.

Any more thoughts?

@santanaG
Copy link
Contributor

Given @GCrispino 's point. What should be done about this?

@dhruvdutt
Copy link

I would love to work on this. ✋ Can someone please describe the spec and point to some code?

@kaicataldo kaicataldo added the Hacktoberfest Recommended issue for those participating in Hacktoberfest https://hacktoberfest.digitalocean.com/ label Oct 15, 2018
@kaicataldo
Copy link
Member

@dhruvdutt Great! The documentation file in question is here. What do you mean by "describe the spec"?

@NYCJacob
Copy link

What if you just added a couple of sentences to the rule details explaining the danger?

@nzakas nzakas self-assigned this Nov 7, 2018
@nzakas
Copy link
Member

nzakas commented Nov 7, 2018

I'll take a stab at this.

@nzakas nzakas closed this as completed in 57f357e Nov 9, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators May 9, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label May 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation good first issue Good for people who haven't worked on ESLint before Hacktoberfest Recommended issue for those participating in Hacktoberfest https://hacktoberfest.digitalocean.com/ help wanted The team would welcome a contribution from the community for this issue
Projects
None yet
Development

No branches or pull requests

9 participants