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

Recombine split JSX lines #1583

Closed
karl opened this issue May 11, 2017 · 3 comments
Closed

Recombine split JSX lines #1583

karl opened this issue May 11, 2017 · 3 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. status:needs discussion Issues needing discussion and a decision to be made before action can be taken

Comments

@karl
Copy link
Collaborator

karl commented May 11, 2017

With #1120 we now split JSX text across multiple lines when it gets too long to fit on a single line.

It would be nice to investigate whether we could automatically recombine split lines when they can fit on a single line (as mentioned in #1120 (comment)).

For example:

const Abc = () => {
  return (
    <div>
      Please state your
      {" "}
      <b>name</b>
      {" "}
      and
      {" "}
      <b>occupation</b>
      {" "}
      for the board of directors.
    </div>
  );
};

Would become:

const Abc = () => {
  return (
    <div>
      Please state your <b>name</b> and <b>occupation</b> for the board of
      directors.
    </div>
  );
}

Doing this would be a major change from our current JSX behaviour where we always retain newlines in the source. I've opened this issue to discuss whether we want to make this change and if so how we would like it to behave.

@vjeux
Copy link
Contributor

vjeux commented May 11, 2017

Just to be clear, my idea was to only recombine lines separated by {' '}, not arbitrary lines.

The reasoning is that in the shipped version of prettier we introduced a worse output by splitting all those up. Now that we know how to inline things, it would be nice to correct this error automatically, without having users have to do it manually.

@vjeux vjeux added the status:needs discussion Issues needing discussion and a decision to be made before action can be taken label May 11, 2017
@karl karl closed this as completed May 11, 2017
@karl karl reopened this May 11, 2017
@karl
Copy link
Collaborator Author

karl commented May 11, 2017

(Accidentally pressed the close button!)

@karl
Copy link
Collaborator Author

karl commented Jun 27, 2017

This is now done in #1831 🎉

@karl karl closed this as completed Jun 27, 2017
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jul 7, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. status:needs discussion Issues needing discussion and a decision to be made before action can be taken
Projects
None yet
Development

No branches or pull requests

2 participants