Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 713 Bytes

no-await-expression-member.md

File metadata and controls

42 lines (30 loc) · 713 Bytes

Forbid member access from await expression

When accessing a member from an await expression, the await expression has to be parenthesized, which is not readable.

This rule is fixable for simple member access.

Fail

const foo = (await import('./foo.js')).default;
const secondElement = (await getArray())[1];
const property = (await getObject()).property;
const data = await (await fetch('/foo')).json();

Pass

const {default: foo} = await import('./foo.js');
const [, secondElement] = await getArray();
const {property} = await getObject();
const response = await fetch('/foo');
const data = await response.json();