Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leave empty blocks on the same line #170

Closed
dsherret opened this issue Jan 30, 2020 · 2 comments
Closed

Leave empty blocks on the same line #170

dsherret opened this issue Jan 30, 2020 · 2 comments

Comments

@dsherret
Copy link
Member

For example:

function test() {}
@dsherret dsherret changed the title Leave empty blocks alone Leave empty blocks on the same line Jan 30, 2020
@nayeemrmn
Copy link

@dsherret
Input:

try {} catch {}

dprint output:

try {
} catch {
}

Prettier output:

try {
} catch {}

I know this seems arbitrary 😅, designing a formatter must be hard. I think Prettier's logic is add a new line for blocks which have no reason to be empty (if, else, try) and allow empty blocks for everything else (while, for, catch, functions).

Using options:

dprint::ConfigurationBuilder::new()
  .line_width(80)
  .indent_width(2)
  .next_control_flow_position(dprint::NextControlFlowPosition::SameLine)
  .binary_expression_operator_position(dprint::OperatorPosition::SameLine)
  .build()

@dsherret
Copy link
Member Author

dsherret commented Feb 1, 2020

@nayeemrmn Thanks again! Opened dprint/dprint#77

@dsherret dsherret transferred this issue from dprint/dprint Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants