-
Notifications
You must be signed in to change notification settings - Fork 515
requireMultipleVarDecl: add 'skipWithEmptyLine' option #215
Conversation
I wouldn't call it 'all' or 'strict mode'. function main() {
var a=5;
a += a;
var b=5;
} which is unfortunately not implemented (hmm, perhaps I should point to this in #102 ). |
cc @mikesherov |
@twoRoger, thanks for contributing! @markelog, I didn't write this sniff, but here's my opinion: There's no need for an option here. This sniff was just initially written to be to brittle. Rather than check for other variable declarations and positioning, this just needs to check that each variableDeclaration has at most one variableDeclarator. The test is good, but we should remove the option and rewrite the sniff as I described. Thoughts? @twoRoger, can you make that update? |
@mikesherov Seems like the proposed update is related to "disallowMultipleVarDecl" rule only, not to the "require" one. Btw, "disallowMultipleVarDecl" rule is already implemented exactly as you described) |
Yeah, you're right. Sorry! For this rule, we should check all elements of the parent collection for other variableDeclarations, not just the siblings. Still no need for a new option. Right? Mike On Wed, Jan 29, 2014 at 5:40 AM, Igor Agarlev notifications@github.com
|
Not just the immediate siblings, I meant. Mike On Wed, Jan 29, 2014 at 6:49 AM, Mike Sherov mike.sherov@gmail.com
|
The current implementation is exactly what I need. In our team we allow multiple The following example is valid regarding to our codestyle: function main() {
var a = 1;
a += a;
var b = 2;
return a + b;
} Invalid example: function main() {
var a = 1;
var b = 2;
a += a;
return a + b;
} The only thing I wanted to add is a relaxing option ("skipWithEmptyLine"), which would allow the following: function main() {
var a = 1;
var b = 2;
a += a;
return a + b;
} Probably, here should be one more rule which would be an exact replacement for |
The opposite should be true. There should be an additional enforcing rule Thoughts? On Wed, Jan 29, 2014 at 8:26 AM, Igor Agarlev notifications@github.comwrote:
Mike Sherov |
[if I understand you correctly]
|
Actually, onevar does not require the single var declaration to appear on requireMultipleVarDecl: requireVarDeclOnTop: On Wed, Jan 29, 2014 at 2:28 PM, Famlam notifications@github.com wrote:
Mike Sherov |
Ah, right about onevar. |
yes, consecutive should allow empty lines... strict should disallow. I On Wed, Jan 29, 2014 at 3:07 PM, Famlam notifications@github.com wrote:
Mike Sherov |
@Famlam, any update on this? |
@twoRoger you mean? It's not my branch, is it? |
Apologies. I meant @twoRoger |
Sorry, I'm not going to implement suggested behavior. |
Closing this PR for now, I'll pick up on the decided behavior later. @twoRoger, thanks again for contributing! |
No description provided.