softlayer/ember-style-guide

Evaluate semicolons after function exports

Closed this issue · 4 comments

Currently, sl-eslint does not allow for semicolons after functions. As a result, exporting like so triggers an error:

export function foo() {
};

However, all other exports are followed by semicolons, and semicolons after functions is accepted syntax.

Should we allow for semicolons after function exports?

Making @joshforisha aware of this

I'd say no.

Semicolons serve to separate statements from one another. A function declaration is not a statement, and is defined to not need a semicolon. The export keyword simply makes the following statement or declaration available to consumers of the module. So, the semicolon does absolutely nothing in these cases.

I am okay with this.

However, just to make sure, if we are exporting functions, do we always want to export function declarations, i.e.

export function foo() {
}

and not function expressions?

export const foo = function() {
};

For function expressions, there should definitely be a semicolon, as explained here:
http://stackoverflow.com/questions/1834642/why-should-i-use-a-semicolon-after-every-function-in-javascript

If we are going to enforce only exporting function declarations, then I'm okay with no semicolons.

I agree with function expressions needing semicolons, but I don't see any advantage to using them over declarations.