You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Long line-length require statements are awkwardly formatted. #303
locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:needs discussionIssues needing discussion and a decision to be made before action can be taken
It seems that there's no concept of keeping require statements and its params as one unit. It's not very often that you'll get an extremely long string to pass in to the require() parens. There should be a preference for keeping the require('./something') as one unit.
I'd say this is the expected behavior for "normal" expressions. Trying to figure out which one is bigger could possibly done, but we need to be really careful how many combinations of styles we try to detect before performance becomes a serious issue.
Also, I'd prefer for the format to be as consistent as possible. The above case, even if it's slightly awkward in rare cases, is consistent.
What we could do is specialize the require pattern specifically. This is what I talked about in Respecting Patterns. It's a very common pattern to destructure a large amount of imported properties, so we could specifically break it differently.
Reacted by Christopher Chedeau, Brian Ng and Adrian Li
Although, I'm actually a little confused. The destructuring param exists before the assigned expression... It should break first no matter what. Did we specifically break the right expression first?
locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:needs discussionIssues needing discussion and a decision to be made before action can be taken
Activity
vjeux commentedon Jan 18, 2017
This is tricky
outputs
It is unclear if we should prioritize breaking on the first part of the expression or on the second one.
If I were to throw an heuristic in this case, it would be to break in the place where there's the biggest amount of code first.
https://jlongster.github.io/prettier/#%7B%22content%22%3A%22const%20%7B%20one%2C%20two%2C%20thee%2C%20four%2C%20five%2C%20six%2C%20seven%2C%20eight%2C%20nine%2C%20ten%20%7D%20%3D%20require('.%2Fmy-utils')%3B%5Cnconst%20%7B%20one%2C%20two%2C%20thee%2C%20four%2C%20five%2C%20six%2C%20seven%2C%20eight%2C%20nine%2C%20ten%2C%20eleven%20%7D%20%3D%20require('.%2Fmy-utils')%3B%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%7D%7D
jlongster commentedon Jan 18, 2017
I'd say this is the expected behavior for "normal" expressions. Trying to figure out which one is bigger could possibly done, but we need to be really careful how many combinations of styles we try to detect before performance becomes a serious issue.
Also, I'd prefer for the format to be as consistent as possible. The above case, even if it's slightly awkward in rare cases, is consistent.
What we could do is specialize the
requirepattern specifically. This is what I talked about in Respecting Patterns. It's a very common pattern to destructure a large amount of imported properties, so we could specifically break it differently.jlongster commentedon Jan 18, 2017
Although, I'm actually a little confused. The destructuring param exists before the assigned expression... It should break first no matter what. Did we specifically break the right expression first?
Do not break require calls
Do not break require calls
vjeux commentedon Mar 1, 2017
#841 fixes it.
adrianmcli commentedon Mar 1, 2017
Awesome! Can't wait to see it merged in.
Do not break require calls (#841)