Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces around function declarations vs. function invocation parens #16

Closed
jedrichards opened this issue Mar 18, 2014 · 5 comments
Closed

Comments

@jedrichards
Copy link

Unless I'm missing it, it seems like a handy rule would relate to spaces around the function keyword parens in different scenarios. Namely, function declaration vs. function invocation. For example:

Enforce spaces around parens for function declarations

// Good
function () {
}
function foo () {
}

// Bad
function() {
}
function(){
}
function foo() {
}
function foo (){
}
function foo(){
}

Enforce no spaces around parens for function invocation

// Good
var a = function();

// Bad
var a = function ();

The rationale behind this rule relates to the fact that some devs like to enforce a visual distinction between a function declaration and a function invocation.

What do you think?

@dsheiko
Copy link
Owner

dsheiko commented Mar 20, 2014

Working on formalization of the rules. Does it look fine to you?

{
        "FunctionDeclarationParameterListSpacing": {
            "allowTrailingWhitespaces": 1,
            "allowPrecedingWhitespaces": 1
        },
        "FunctionExpressionParameterListSpacing": {
            "allowTrailingWhitespaces": 1,
            "allowPrecedingWhitespaces": 1
        },
        "CallExpressionArgumentListSpacing": {
            "allowTrailingWhitespaces": 1,
            "allowPrecedingWhitespaces": 1
        },
}

@jedrichards
Copy link
Author

Yeah, that looks like it covers things well.

dsheiko added a commit that referenced this issue Mar 25, 2014
@dsheiko
Copy link
Owner

dsheiko commented Mar 25, 2014

Implemented in v.2.1.7

@dsheiko dsheiko closed this as completed Mar 25, 2014
@jedrichards
Copy link
Author

Ty :)

@dsheiko
Copy link
Owner

dsheiko commented Mar 26, 2014

BTW, you can find these sniffs explained in README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants