Skip to content

Wraps returned function execution of arrow functions in parentheses. #7976

@Hawmex

Description

@Hawmex

It looks like that prettier wraps the function execution in the return value of the arrow function below, in parentheses. Plus it breaks line in the return value while it's unnecessary.
Note: This behavior also breaks syntax highlighting in VSCode.

Prettier 2.0.4
Playground link

--parser babel

Input:

const a = (b) => ({
  c: () => "d"
}[c] || (() => b))();

Output:

const a = (b) =>
  ((
    {
      c: () => "d",
    }[c] || (() => b)
  )());

Expected behavior:

const a = (b) => ({
  c: () => "d"
}[c] || (() => b))();

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions