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

Support comma first style of variable declaration #59

Closed
mrchief opened this issue Apr 23, 2013 · 6 comments
Closed

Support comma first style of variable declaration #59

mrchief opened this issue Apr 23, 2013 · 6 comments

Comments

@mrchief
Copy link

mrchief commented Apr 23, 2013

Allow code to be formatted like this:

var a = 1
  , b = "somethign else"
  , isAwesome = true;

JSBeautifier supports it (or can be tweaked easily): http://stackoverflow.com/questions/10872184/comma-first-js-formatter
https://gist.github.com/nemtsov/2864266

@bitwiseman
Copy link
Collaborator

"Tweaked easily": That is a relative term. You'll want to file this with the upstream project https://github.com/einars/js-beautify .

@mrchief
Copy link
Author

mrchief commented Apr 23, 2013

Agreed. But the author has already provided the fix. If my Python-fu was strong enough, I would have sent you a pull request already.

@bitwiseman
Copy link
Collaborator

You don't need python-fu to work in javascript - js-beautify has both javascript and python implementations. And we maintain close parity between js and python, so you can work in which ever language you prefer and then port by following existing patterns.

We actually don't have a issue filed for this, the closest match would be beautifier/js-beautify#80 . And this issue is unlikely to get fixed here unless/until it gets fixed upstream. So, at very least, you'll want to file an issue over there.

@jdavisclark
Copy link
Owner

And this issue is unlikely to get fixed here unless/until it gets fixed upstream.

@bitwiseman That would be an understatement. I learned my lesson once already. I check pull requests much more carefully for jsbeautifier modifications now.

@mrchief, I think a formatting option for this would be valuable. However Liam is very correct, we can not make changes to js-beautifier here at the dependency level, as it makes it impossible to easily merge upgrades in the future. I would urge you to submit a pull request (javascript or python port) over at einars/js-beautify, or at least submit an issue. In the meantime I have tagged this as a jsbeautifier feature so we don't loose track of it. If you do so, respond in this thread with a link to the pull request or issue and anyone from here can throw in support/suggestions.

@mrchief
Copy link
Author

mrchief commented Apr 23, 2013

@jdc0589 Thanks for the explanation. I understand now what Liam meant by his first comment. This makes perfect sense. I'll either submit an issue or send a pull request to upstream!

Update: Issue created! beautifier/js-beautify#245

@bitwiseman
Copy link
Collaborator

It took a while, but the initial implementation of this is available in v1.5.5 of js-beautify.

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

No branches or pull requests

3 participants