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

Keep bracket of jsx expression in a single new line #577

Open
otakustay opened this issue Nov 9, 2023 · 3 comments
Open

Keep bracket of jsx expression in a single new line #577

otakustay opened this issue Nov 9, 2023 · 3 comments

Comments

@otakustay
Copy link

If we have a code like:

function Ok() {
    return (
        <div>
            {
                isThisConditionOk
                    ? (
                        <p><strong>Yes</strong></p>
                    )
                    : (
                        <p><strong>No</strong></p>
                    )
            }
            </div>
    );
}

We expect it to be unchanged, actually it is formatted like:

function Ok() {
  return (
    <div>
      {isThisConditionOk
        ? (
          <p>
            <strong>Yes</strong>
          </p>
        )
        : (
          <p>
            <strong>No</strong>
          </p>
        )}
    </div>
  );
}

Line breaks after { and before } are deleted, this cause unpaired indentation and hard-to-read )}.

Expression in jsx attribute has the same behavior:

function Ok() {
    return (
        <div
            render={
                work(
                    nice,
                    to,
                    have
                )
            }
        />
    );
}

is unexpectedly formatted to:

function Ok() {
  return (
    <div
      render={work(
        nice,
        to,
        have,
      )}
    />
  );
}

Meybe we can have a new option to force { and } in a standalone new line

@Bessonov
Copy link

Don't forget to vote on this issue. I am looking for exactly the same.

@John-Paul-R
Copy link

John-Paul-R commented Mar 17, 2024

I am willing to implement this feature if we can get confirmation (from a maintainer) that it is desired.

This is currently one of the few formatting idiosyncrasies (compared to prettier/biomejs) that are keeping my team from switching to dprint's formatter.

@John-Paul-R
Copy link

@dsherret Would you be willing to accept such a contribution?

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

3 participants