-
Notifications
You must be signed in to change notification settings - Fork 515
disallowMultipleVarDecl: add exception for undefined variable declaratio... #749
Conversation
var hasDefinedVariables = false; | ||
var isForStatement = node.parentNode.type === 'ForStatement'; | ||
|
||
for (var i = 0, l = node.declarations.length; i < l; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might also be able to do:
hasDefinedVariables = node.declarations.some(function(declaration) {
return !!declaration.init;
});
Thanks for this @hzoo! Great work getting this together. I agree that the condition is hard to follow. See my suggestion for making it a bit more readable. I'm pretty excited to land this, as it's one step closer to the |
555e869
to
08eb39f
Compare
K added your suggestions: removed 2 extraneous tests, cleaned up |
@@ -1045,7 +1045,7 @@ Disallows multiple `var` declaration (except for-loop). | |||
|
|||
Type: `Boolean` or `String` | |||
|
|||
Values: `true` or 'strict' (to disallow multiple variable declarations within a for loop) | |||
Values: `true` or 'strict' (to disallow multiple variable declarations within a for loop) or 'exceptUndefined' (to allow declarations where all variables are not defined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please turn the options into a list now that there are 3 options each with a sentence explaining them
Should I be making changes in multiple commits or just force push the same one again? |
Doesn't matter much; we'll clean up the commit messages before merging to master. Amend + force push is totally fine. |
I guess it's just because of the outdated comments since looking at what changed again might be weird but ok cool. |
08eb39f
to
e272664
Compare
added list format to readme, reorder comments in https://github.com/jscs-dev/node-jscs/pull/749/files#diff-b6e5523d8d2184da7a33a74a9162fc95R34 |
@hzoo Great work! Thanks for contributing. |
...ns
Rather messy as boolean logic could be simpler?
Not sure about the option name
exceptUndefined
either.#451