Skip to content

arrow functions "glue" long lines at badly split places #4303

@hyperknot

Description

@hyperknot

Prettier 1.11.1
Playground link

--print-width 100
--no-semi
--single-quote
--trailing-comma es5

Input:

overlayStore.showText(
  "Error: Not logged in", 
  "Please reload the page and log in.", 
  () => callback(null, res.body.error)
);

overlayStore.showText(
  "Error: Not authorized", 
  "Please reload the page and log in with the right user.", 
  () => callback(null, res.body.error)
);

Output:

overlayStore.showText('Error: Not logged in', 'Please reload the page and log in.', () =>
  callback(null, res.body.error)
)

overlayStore.showText(
  'Error: Not authorized',
  'Please reload the page and log in with the right user.',
  () => callback(null, res.body.error)
)

Expected behavior:
Short version: I'd really like to keep those 3 parameters in 3 separate lines. At least to make sure that I'm not making a new line in the middle of a parameter.

Having the arrow of an arrow function on separate line can be quite confusing. In this example, I'd really like to have both functions be organised the same way, to make sure that I can visually check that all of them are in an arrow function and not called directly. Right now, prettier makes such organisation impossible.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions