Skip to content

[TS / JS] line break before Array methods for inline await #6851

@felixmosh

Description

@felixmosh

Prettier 1.18.2
Playground link

--parser babel

Input:

async function HelloWorld({greeting = "hello", greeted = '"World"', silent = false, onMouseOver,}) {

  const admins = (await(db.select('*').from('admins').leftJoin('bla').where('id', 'in', [1,2,3,4]))).map(({id, name})=>({id, name}))

}

Output:

async function HelloWorld({
  greeting = "hello",
  greeted = '"World"',
  silent = false,
  onMouseOver
}) {
  const admins = (await db
    .select("*")
    .from("admins")
    .leftJoin("bla")
    .where("id", "in", [1, 2, 3, 4])).map(({ id, name }) => ({ id, name }));
}

Expected behavior:
As you can see the map method is on the same line at the end, and it looks weird.
I think that this looks much better:

async function HelloWorld() {
  const admins = (await db
        .select("*")
        .from("admins")
        .leftJoin("bla")
        .where("id", "in", [1, 2, 3, 4])
     )
     .map(({ id, name }) => ({ id, name }));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions