einars/js-beautify — pull request #369 by tgirardi (2013-12-17 05:20:11+00:00)
Title: Support comma-first for vars/object declarations

Support "comma first" style when declaring variables or properties
inside an object, as discussed on issue #245.

The proposed solution is based on changing the order of the newline
(before / after the comma) depending on the value for the new option
"comma_first". The proposed command line argument for this option
is "-F" or "--comma_first").

It is also necessary to modify the indentation string used for some
particular lines, in order to include the comma as part of the
indentation string and achieve the desired result regarding
indentation (in some cases it is easier to think of the comma as part
of the indentation string, in replace of a whitespace).

TODO 1: tests for this feature

TODO 2: implement the feature in the python version (I prefer to get
feedback for this commit first and, once the feature's JS code is
considered correct, then proceed with the py code).

TODO 3: in the future, other variations for the indentation pattern,
for object properties, could be allowed. The currently allowed one
looks like this:

{
prop1: 1
, prop2: 2
, prop3: 3
}

Another version could be:

{
prop1: 1
, prop2: 2
, prop3: 3
}

In "other words", the first property is double indented. However, it
must be noted that jslint errors related with the indentation could
arise (tested with JSHint).