require-await Potential pitfall if used. Doc update maybe? #9540
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
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 theasync
does here is guarantee aPromise
. So the following code will returngot
.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 withawait
, you are ok again asawait
will check if it's aPromise
, 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.
The text was updated successfully, but these errors were encountered: