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.
2
u/[deleted] Mar 28 '15
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.