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

JS Beautifier "short objects" #55

Closed
wants to merge 15 commits into from
Closed

JS Beautifier "short objects" #55

wants to merge 15 commits into from

Conversation

chrisjshull
Copy link

This commit adds an option on the JS Beautifier CLI allowing the user to specify the maximum length of "short objects".
Typically the JS Beautifier expands all JS object declarations into multiple lines, each line having a key value pair. However, this is overly verbose for many situations (e.g. short objects which could easily fit on a single line).

Right now this is only for the python CLI.

--short-object=0
objects less than this many characters long
will stay on a single line (newlines within
the object's code will override this)
recommended: 80

Currently, "short objects" defaults to 0, which disables it.
Recommended value might be 80, via --short-object=80

e.g.:
a = {a:1,b:2}
becomes:
a = { a: 1, b: 2 }

also:
a = {c:{a:b,b:[1,2,34,5,6,7,8]}}
becomes:
a = { c: { a: b, b: [1, 2, 34, 5, 6, 7, 8] } }

changes posted back under the MIT license

@chrisjshull
Copy link
Author

closing this pull request. may send again int he future

@chrisjshull chrisjshull closed this Dec 5, 2011
@mrchief
Copy link

mrchief commented Aug 13, 2013

👍 This is a much needed feature. Why was it not merged?

@einars
Copy link
Contributor

einars commented Aug 13, 2013

I have no idea. Probably because it is python-only and nobody had a willpower to port it to javascript, and it would be bad if python and js would diverge too far.

@mrchief
Copy link

mrchief commented Aug 13, 2013

What a bummer! :(

@bitwiseman
Copy link
Member

@mrchief - feel free to file an issue to for this feature (reference this pull request). At least then we can track it as an open request for future milestone.

@mrchief
Copy link

mrchief commented Aug 14, 2013

@einars Does it also mean that someone coming up with a JS fix has to come up with a python port? I can see someone landing into a situation where the JS fix (for a new feature) is not merged as no one has come with a python port yet and over time, the project changes so merging the JS fix becomes impossible or very hard, in effect impeding feature growth on the library as a whole.

@einars
Copy link
Contributor

einars commented Aug 14, 2013

While it would be very welcome, if you can't update the python version of the library and your js fix/feature is excellent, most probably somebody — me or @bitwiseman or somebody else here — will gladly do that.

And, if nobody responds, then probably it just went under the radar, try again and write a comment: the notification might have been received in a very bad moment, intense day, etc and was forgotten soon after, etc. Yes, that sucks, and yes, these things happen all the time.

I, for example, feel somewhat bad about this very pull request: I don't remember its history, but I see that it was sitting without an attention for 5 months, and now I'm sorry for @chrisjshull . At the same time, a comment "hey, what's about this, is it bad, or are you going to do something about it?" might have fixed situation with this forgotten changeset.

@bitwiseman
Copy link
Member

👍
Also, python isn't exactly rocket science. I've been asking people to take the time to do the port themselves, so far it's hasn't stopped anyone.

@nisaacson
Copy link

This is a great feature. Is there a configuration setting to never split objects into multiple lines either in this patch or in the current version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants