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
Option to preserve existing var and object alignment (like preserve_array_indentation) #396
Comments
Theoretically — yes, it wouldn't be against the beautifier's spirit, |
See #200. |
Thanks. |
Interesting. Yes, that seems possible - we have an option to preserve array indentation the serves a similar purpose. The code path for this feature would be similar to that. (I've edited the title for this.) However, it is lower priority for us than several other highly requested features and fixes. You are welcome to code it up and submit a PR, but I will warn you we're asking people to submit tests as well and we're trying to minimize api changes, especially on the command-line. So there might need to be some additional discussion. Worst case if we don't accept your PR is still that you have a patch that you can use locally. 😄 |
+1 |
+1 PHP_Beautifier has this feature |
I have no idea what bearing the features of PHP_Beautify has have on this project. 😄 |
@bitwiseman It demonstrates a precedent for the feature |
Sorry, I was mostly teasing you. 😄 |
I'll try to find some free time to make a PR then :) |
A little unsolicited advice: I'd try implementing this for just the object literal case first. It's relatively cleanly recognized start and end, during which you can easily track the lines where fields are declared and the field lengths. Do a PR for that, we can discuss and work out any rough edges, and the go back and do that var case next. If you get stuck, drop me a line or an intermediate branch to look at. |
eslint can do this for you with
and the configuration:
|
@clawconduce - Agreed, thanks. |
+1. A solution that either handles the spacing or at least ignores the spacing inside objects. I don't even mind doing the spacing myself (my editor can do that) so long as JSB doesn't then revert my changes when I save. |
See #1209 , it's not pretty, but it's at least a start, and could be mergeable with some love. |
I gave this a quick go in #1209, but I don't think I'll have the time to properly wrap it up. Among the harder things to figure out are when to ignore this logic - I maintain some files where the keys are function names and the values are the functions themselves - so the objects are hundreds of lines and I don't want those indented. Maybe if a function appears in the object, this formatting doesn't happen? Maybe it doesn't happen if the object covers a certain number of lines? Anyways, hope someone can pick this up! |
Would it be possible/acceptable to add an option that converts
to
The text was updated successfully, but these errors were encountered: