Skip to content

Prettier converts blocks with a long single line from do...end to {...} #1346

Closed
@varg90

Description

@varg90

Hello!

What
Prettier converts this code

if filtered_codes.any? { |codes| codes.include?(code) || (codes.starts_with?('2') && codes.include?(code[0..-6])) }
...

into this because of the printWidth

if filtered_codes.any? { |codes| 
  codes.include?(code) || (codes.starts_with?('2') && codes.include?(code[0..-6]))
}
...

and for some reason thinks that this block is still a single-line and force {..} instead of do...end.

Expected
Either

if filtered_codes.any? { |codes| short_line }

or

if filtered_codes.any? do |codes|
  really_long_lineeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
end

Actual

if filtered_codes.any? { |codes| 
  really_long_lineeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
}

Versions
npm:
prettier (2.8.8)
@prettier/plugin-ruby (3.2.2)
gems:
prettier_print (1.2.1)
syntax_tree (6.1.1)
syntax_tree-haml (4.0.3)
syntax_tree-rbs (1.0.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions