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

Respect newlines in object destructuring the same as in object literals #2685

Closed
SimenB opened this issue Aug 28, 2017 · 1 comment
Closed
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@SimenB
Copy link
Contributor

SimenB commented Aug 28, 2017

I find it weird that newlines in an object literal is respected even if collapsing is less than printWidth, whilst newlines in an object destructure is not.

Input:

const someObject = { one, two, three, four, five, six, seven };
const { one, two, three, four, five, six, seven } = someObject;

const someObject = {
  one,
  two,
  three,
  four,
  five,
  six,
  seven,
};
const {
  one,
  two,
  three,
  four,
  five,
  six,
  seven
} = someObject;

Output:

const someObject = { one, two, three, four, five, six, seven };
const { one, two, three, four, five, six, seven } = someObject;

const someObject = {
  one,
  two,
  three,
  four,
  five,
  six,
  seven
};
const { one, two, three, four, five, six, seven } = someObject;

I would expect them to be treated the same - either both collapse, or both stay expanded.

(Personally I would prefer both to be expanded, combined with #2068 being a thing you'd invoke sometimes)

https://prettier.io/playground/#%7B%22content%22%3A%22const%20someObject%20%3D%20%7B%20one%2C%20two%2C%20three%2C%20four%2C%20five%2C%20six%2C%20seven%20%7D%3B%5Cnconst%20%7B%20one%2C%20two%2C%20three%2C%20four%2C%20five%2C%20six%2C%20seven%20%7D%20%3D%20someObject%3B%5Cn%5Cnconst%20someObject%20%3D%20%7B%5Cn%20%20one%2C%5Cn%20%20two%2C%5Cn%20%20three%2C%5Cn%20%20four%2C%5Cn%20%20five%2C%5Cn%20%20six%2C%5Cn%20%20seven%2C%5Cn%7D%3B%5Cnconst%20%7B%5Cn%20%20one%2C%5Cn%20%20two%2C%5Cn%20%20three%2C%5Cn%20%20four%2C%5Cn%20%20five%2C%5Cn%20%20six%2C%5Cn%20%20seven%5Cn%7D%20%3D%20someObject%3B%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3A%22none%22%2C%22bracketSpacing%22%3Atrue%2C%22jsxBracketSameLine%22%3Afalse%2C%22parser%22%3A%22babylon%22%2C%22semi%22%3Atrue%2C%22useTabs%22%3Afalse%2C%22doc%22%3Afalse%2C%22ast%22%3Afalse%7D%7D

@SimenB
Copy link
Contributor Author

SimenB commented Aug 28, 2017

This is a dupe of #2550

@SimenB SimenB closed this as completed Aug 28, 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 6, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 6, 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.
Projects
None yet
Development

No branches or pull requests

1 participant