prodypanda / MarkEnti

MarkEnti is a comprehensive e-commerce platform designed to enable users to effortlessly create and manage their online storefronts.
https://markenti.com/
Other
1 stars 0 forks source link

(JS-0111) Unnecessary `return await` function found #4

Closed prodypanda closed 4 months ago

prodypanda commented 4 months ago

Description

Returning an awaited value (like with return await f()) has two problems: - It queues an extra microtask, blocking the callstack until return is executed.

Occurrences

There is 1 occurrence of this issue in the repository.

See all occurrences on DeepSource → app.deepsource.com/gh/prodypanda/MarkEnti/issue/JS-0111/occurrences/

prodypanda commented 4 months ago

RECOMMENDED

async function getUserByName(name: string) {
// find() returns a Promise<User | null >.
return db.users.find({ userName: name })
}

// OR:

async function getUserByName(name: string) {
// If we must await the return-value in this function
// it's better to do it this way. This is more performant:
const user = await db.users.find({ userName: name })
return user;