Skip to content

bug(linter): incorrect fix for no-single-promise-in-promise-methods #4093

@DonIsaac

Description

@DonIsaac

This happens in cases where the awaited Promise.all is assigned to a variable.

Example 1: array unpacking

const [x] = await Promise.all([getSomeData()])

// turns into
const [x] = await getSomeData()

// but should be
const x = await getSomeData()

Example 2: simple assignment targets

const arr = await Promise.all([getSomeData()])
console.log('waited for ', arr.length, 'fetch requests')

// turns into
const arr = getSomeData()
console.log('waited for ', arr.length, 'fetch requests') // not an array anymore, has incorrect semantics

// we should not auto-fix this case.

Metadata

Metadata

Assignees

Labels

A-linterArea - LinterC-bugCategory - Bug

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions