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

Possibly keep code on a single line when an if statement has no braces and the statement after the if fits on the same line. #1472

Open
belav opened this issue Feb 6, 2025 · 1 comment

Comments

@belav
Copy link
Owner

belav commented Feb 6, 2025

Given

if (value is null) return Result.NotFound($"Value with ID {request.ValueId} not found.");

if (value is null) return;

CSharpier will always break after the if condition.

if (value is null)
    return Result.NotFound($"Value with ID {request.ValueId} not found.");

if (value is null)
    return;

Prettier keeps things on the same line if they fit.

Look into how common it is in the csharpier-repos to break after the if condition vs keeping things on the same line. If it seems to be more common I think we should not break after condition.

If it is a somewhat even split, I think it is worth possibly not breaking "simple" statements. The bare return above would be simple. The other example is possibly simple.

@IcyFoxe
Copy link

IcyFoxe commented Feb 21, 2025

Yeah, I was expecting that behavior too. Since csharpier is based on prettier, it should follow the same rules. I would appreciate if there was at least a configuration for this.

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