Skip to content

Latest commit

Β 

History

History
49 lines (34 loc) Β· 1.27 KB

File metadata and controls

49 lines (34 loc) Β· 1.27 KB

no-await-expression-member

πŸ“ Disallow member access from await expression.

πŸ’ΌπŸš« This rule is enabled in the βœ… recommended config. This rule is disabled in the β˜‘οΈ unopinionated config.

πŸ”§ This rule is automatically fixable by the --fix CLI option.

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.

Examples

// ❌
const foo = (await import('./foo.js')).default;

// βœ…
const {default: foo} = await import('./foo.js');
// ❌
const secondElement = (await getArray())[1];

// βœ…
const [, secondElement] = await getArray();
// ❌
const property = (await getObject()).property;

// βœ…
const {property} = await getObject();
// ❌
const data = await (await fetch('/foo')).json();

// βœ…
const response = await fetch('/foo');
const data = await response.json();