question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule proposal: `no-nested-await`

See original GitHub issue

Nesting await inside a statement often gets messy. It’s better to split the line using an intermediate variable.

This is potentially autofixable. The only issue is that this would need to generate a name for an intermediate variable.

Fail

const filtered = (await Promise.all(promises)).filter(Boolean);

Pass

const unfiltered = await Promise.all(promises);
const filtered = unfiltered.filter(Boolean);

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
fiskercommented, Aug 16, 2021

We can start with property access and call expression, maybe add more cases in future.

2reactions
remcohaszingcommented, Aug 16, 2021

I think we need to determine which cases should be reported. Typically I think the ones wrapped inside parentheses should be reported.

// Function
console.log(await promise);
(await import('foo')).default;

The following may be acceptable due to the lack of a better alternative:

const foo = (await promise) as string;

The following look ok to me:

const { default: foo } = await import('foo');

console.log({
  foo: await fs.readFile('foo'),
  bar: await fs.readFile('bar'),
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Proposed rule: Order Competition Rule - SEC.gov
proposed rule would prohibit a restricted competition trading center from internally executing certain orders of individual investors at a ...
Read more >
Proposed Rules - GovInfo
Commission has requested comment on a release proposing amendments to its rules under the Securities Act and. Exchange Act that would require.
Read more >
The Most Curious Rule Proposal in Securities and Exchange ...
The Proposed Rules are of three categories: Disclosure Rules, Audit Rules, and Prohibited Activity Rules. These comments relate solely to the ...
Read more >
sallai-dissertation.pdf - Institutional Repository Home
As a rule, the higher the level of abstraction that a ... Several virtual machines have been proposed for wireless sensor nodes. VM*...
Read more >
Proposed Rules - Regulations.gov
Proposed Rules. Federal Register. 29059. Vol. 87, No. 92. Thursday, May 12, 2022. SECURITIES AND EXCHANGE. COMMISSION. 17 CFR 210, 229, 232, 239,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found