(I would have expected one var per line to be an obvious no brainer which didn't need to be stated.)
I don't get why people form such strong opinions about these things when software can automagically convert a list of variables into separate vars or convert one type of string quote into the other. Do what ever the hell you want and then convert your code to the team standard before commit.
That only works for valid code. One of the main arguing points is which is more error-prone - and faulty code will need to be fixed by hand before you run it through a tool.
Sure. Let's say you have a variable declaration like this:
var foo = 'foo',
bar = 'bar';
And modify it to this:
var foo = 'foo,
bar = 'bar';
baz = 'baz';
You can spot the error, but a tool to convert var styles won't. It will (likely, I haven't run it) correctly convert the first var statement and leave the implicit global intact because it doesn't want to modify behavior.
The above mistake is much less likely if you're using this style:
var foo = 'foo';
var bar = 'bar';
And because that is correct code, your tool can correctly convert it to the single-var style.
Your editor (or jshint or jscs) should be warning you that you have a global assignment. I prefer multiple vars myself, most minifiers handle them, but seriously this is a non-issue
Actually, the Pretty Diff tool I linked to told me what the error was, an unterminated string. This is something most automation tools would catch. They may not fix your broken unparsable code for you, but they will likely tell you its broken and where to look.
3
u/[deleted] Mar 27 '15 edited Mar 27 '15
I don't get why people form such strong opinions about these things when software can automagically convert a list of variables into separate vars or convert one type of string quote into the other. Do what ever the hell you want and then convert your code to the team standard before commit.
edit
Convert quotes with this option -> http://prettydiff.com/documentation.php#quoteconvert
Convert variable styles with this option -> http://prettydiff.com/documentation.php#varword
Or just use the
airbnbvalue with this option -> http://prettydiff.com/documentation.php#styleguide