guides
guides copied to clipboard
[JS Styleguide] - Disallows multiple `var` declaration
https://github.com/jscs-dev/node-jscs/blob/f55bbae8bfbd8d57a4f756193d824e6f398ff7a7/lib/rules/disallow-multiple-var-decl.js
Basically I'd go for the exceptUndefined mode.
I happen to do this a lot:
var a, b;
// use later on
What's wrong with this?
var a = 1,
b = 2;
The only issue I can think of is if you want to remove or move either the first or last declaration. Is this enough to disallow it, or is there something else?
Can't think of any reasons besides those. Actually I think i did assume we were going with a strict approach and this was an attempt to use a more loose one. Nevertheless, I don't think allowing multiple declarations, like your example, brings any benefits.
My only issue, if you can call it that, with this, is that it seems a bit incoherent to force this, and not go with comma first on object definition. It seems to me the same exact problems are present in both situations, wouldn't you say?
Similar only in the moving around part. My problem with comma first is that it doesn't look good ;) So I would not put these in the same bag
Hum... I don't think this way of declaring variables looks good as well, but I understand the possible benefits. I also don't like comma first, but both situations seem very similar to me, and it seems strange to suggest one and oppose the other.