-
-
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
Keep existing line breaks #4131
Comments
Are you looking for |
Thank you @ikatyang. Seems to do the trick. Although to be honest, I think it would be useful to have it as a configuration option so that we don't need to bloat the code with this comment |
That's a difficult thing to implement because sometimes you do want your code to remove the linebreaks so it's kind of difficult to detect when you want or don't want to preserve line breaks. |
Thank you @duailibe , I guess you're right. For now, I went for the ignore. But just wondering: isn't there a setting for something like this: when the number of arguments to a function exceeds a value (e.g., 3), then break the arguments and put each in a separate line. And maybe this setting can be applied to object destruction and other things too ... |
Should we keep this open? |
I guess not. |
I would like to see an option for this. For instance when you work with angular you have to import multiple modules with 2+ symbols. Now every single one gets a line break which bloats the header to an unnecessary number of lines. Example: Gets transformed to:
The option "// prettier-ignore" won't work here because befor and after this line are more import statements. So I would end up with a not so nice looking zebra-stripped code (comment, statement, comment, statement...). Is there any chance to implement such an option? |
I realise Prettier is "opinionated" and deliberately has few options to stop wasting time on getting to a style guide. And even though my formatting habits may differ here and there, for the most part I can see how Prettier's opinion makes sense (and is probably based on some sort of best practice). However, preserving line-breaks is one option you really should add. It's the one thing missing that still keeps me (and many others I know) from using Prettier. Just my two cents... |
@bnfrnz if there are specific cases where you think prettier's formatting is not ideal, please open a new issue. However, adding and removing line breaks is core to prettier's formatting algorithm, so preserving them isn't consistently possible. |
Hi,
I'm using the VSCode plugin, so please let me know if it's an issue with the plugin or prettier itself:
I think it is a good idea to have some configuration to tell prettier not to change existing line breaks. For example, if I intentionally break a function call arguments into separate lines, prettier shouldn't put them on a single line just because the total length will be less than (or equal to) print width
Thank you
The text was updated successfully, but these errors were encountered: