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

line breaks after assignment instead of between parentheses / around parameters #15208

Closed
fisker opened this issue Aug 5, 2023 Discussed in #15196 · 1 comment · Fixed by #15204
Closed

line breaks after assignment instead of between parentheses / around parameters #15208

fisker opened this issue Aug 5, 2023 Discussed in #15196 · 1 comment · Fixed by #15204
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@fisker
Copy link
Member

fisker commented Aug 5, 2023

Discussed in #15196

Originally posted by macgyver August 1, 2023
Just wondering if anybody can explain the formatting philosophy of converting a line like

  const { section, rubric, authors, tags } = await utils.upsertCommonData(mainData);

into this:

  const { section, rubric, authors, tags } = await utils.upsertCommonData(
    mainData
  );

vs. this:

  const { section, rubric, authors, tags } =
    await utils.upsertCommonData(mainData);

or even

  const { section, rubric, authors, tags }
    = await utils.upsertCommonData(mainData);

(though I recognize that putting operators at the start of a line is controversial)

it seems like keeping the code on two lines vs. three is more parsimonious in terms of vertical space, and groups the concepts better by dividing the code neatly into variable names, and assigned values. Having mainData dangling by itself at the end there just doesn't read that well (to me at least).

What do other folks think? Is there a bigger concept at play here that prevents this from being the behavior? Thanks for your time and insights.

My guess is that Prettier is trying to produce the longest line it can without exceeding the maximum line length, but in cases like this my feeling is that balancing the length of the lines it produces or trying to reduce the total number of lines produced would be a prettier result.

@fisker
Copy link
Member Author

fisker commented Aug 5, 2023

#15196 (comment)

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Nov 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 23, 2023
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant