-
Notifications
You must be signed in to change notification settings - Fork 515
requireSpaceBetweenArguments: new rule #774
requireSpaceBetweenArguments: new rule #774
Conversation
Validates that call expression arguments have the correct spacing before and after. Closes jscs-dev#771
How is this different than "validateParameterSeparator" |
Yeah, sorry didn't mean to be short there, just got to Paris. Super jet lagged. This looks to be exactly the same rules though: https://github.com/jscs-dev/node-jscs/blob/master/README.md#validateparameterseparator |
@indexzero This rule validates the separation of arguments in call expressions. The function a(b, c, d) {} // validateParameterSeparators
a(1, 2, 3); // requireSpaceBetweenArguments See #771. The code is largely similar between the two (only difference is the error message itself) but I couldn't see a way to DRY it easily (doesn't seem to be anywhere to put code relevant to multiple rules). Open to suggestions if I've overlooked something. |
Ah ok. Thanks for explaining it to me! Is the plan to move "validateParameterSeparators" to "requireSpaceBetweenParameters" in 2.0.0 then? |
No problem. Yeah I believe so. At least that's what I took this to mean:
Rule naming seems a lot more consistent that the last time I contributed which was a good few months ago. Most rules are now |
|
||
it('accepts valid separator', function() { | ||
var validSeparators = [ | ||
',', |
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.
Should this be a valid separator? It's not in the list of acceptable values for this rule.
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.
@mrjoelkemp I think it probably should be. I'm sure there are are people who write that way. I can remove it if you think it's not very useful or I can add it to the readme.
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.
If this is a "valid" separator, your rule's regex might need to be strengthened to disallow that.
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.
I think it's useful, but the rule is meant to force a space between arguments. Forcing ','
(no spaces) is best for disallowSpaceBetweenArguments
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.
@mrjoelkemp Sorry, to clarify that, it is a valid separator. It just isn't mentioned in the list of acceptable values. I will add it to the list.
Great job on this @jamesallardice! It's looking good except for a the |
@mrjoelkemp Sorry, GitHub failed to notify me about half of your comments! Yes, I agree, I will remove the |
How about doStuff(a, b, c); // valid
doStuff(a,b,c); // invalid Whereas value would be more consistent with other rules, yes, it would be not flexible as it could have been, but really, who would write code like: doStuff(a , b ,); ? That would mean implementing opposite rule too. |
@markelog I think that's a good idea. I based this rule off the doStuff(a , b , c); // I doubt it
doStuff(a ,b ,c); // Maybe So I also guess it depends on how flexible we want to be. Allow people to define their own separators, or just cater for |
I think those cases could be used in the presets, when others are not, so they are probably more common then others. I would say, let's be a little less flexible and a little bit more consistent. |
Validates that call expression arguments have no space after the separator token
I think the solution now follows what we discussed. There are 2 rules, Should the commits be squashed so it appears as it was done this way first time around or do you prefer to keep the history? |
Took care of it, thank you! |
Validates that call expression arguments have the correct spacing before and after.
Closes #771