-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Simple expressions in template literals #3315
Comments
See #3299 |
Thanks for the report! We have changed the behavior for identifiers, so it should stop breaking. It will continue to break on member expressions (even |
That's great news. Thank you @duailibe. I'd vote for never breaking on member expressions if the left part is an identifier and the expression
Breaking on such simple expressions looks as unnatural as on identifiers. |
@thorn0 Thanks for the suggestion. The thing about template literals is without breaking between const str1 = `text text text ${foo.
bar} text text`;
const str2 = `text text text ${foo[
bar
]} text text`; because Then we could special case printing those differently when inside a template literal. |
Closing as duplicate of #3280 (comment) and OP's |
Prettier 1.8.2
Playground link
Input:
Output:
Expected behavior:
Is the output indeed prettier than the input? To me, it looks simply strange. Why did
foo
get its own line whilebar
didn't? I'd love to have a switch to disable formatting like this. Having a line longer thanprint-width
seems to be a lesser evil in this case. It should be okay though, even when the switch is on, to break lines when embedded expressions are more complex thanfoo
ordata.id
.The text was updated successfully, but these errors were encountered: