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

Allow curly on line following multi-line conditional? #747

Open
thejohnfreeman opened this issue Jan 14, 2017 · 3 comments

Comments

@thejohnfreeman
Copy link

commented Jan 14, 2017

Right now, long conditionals broken over multiple lines must be formatted like this:

if (long_condition_1 ||
    long_condition_2 ||
    long_condition_3) {
  body();
}

In these circumstances, if I want the condition visually distinguished from the body, then I have to indent it differently (e.g. 4 spaces). I would prefer to put the curly on its own line:

if (long_condition_1 ||
  long_condition_2 ||
  long_condition_3)
{
  body();
}

I searched and didn't find this issue discussed here, so wanted to bring it up (please point me to the original if this is a duplicate). I also don't see a customization of the eslint curly rule that would permit this. Is there a popular alternative, e.g. do people really break long conditionals into separate variables? Or can we get this format in standard?

@dcousens dcousens added the question label Jan 14, 2017

@LinusU

This comment has been minimized.

Copy link
Member

commented Jan 15, 2017

I personally prefer writing it like so:

if (
  long_condition_1 ||
  long_condition_2 ||
  long_condition_3
) {
  body()
}

Whatever the preferred way, I would love it if standard would enforce it :)

@feross

This comment has been minimized.

Copy link
Member

commented Jan 16, 2017

@LinusU Yes, that is my preferred form for multiline if-statements as well.

@stale

This comment has been minimized.

Copy link

commented May 10, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label May 10, 2018

@feross feross added the enhancement label May 11, 2018

@stale stale bot removed the stale label May 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.