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

Semicolons #79

Closed
goatslacker opened this issue Mar 24, 2015 · 5 comments

Comments

@goatslacker
Copy link

commented Mar 24, 2015

FYI if you're on ES6 then you can't start lines with the template literal syntax either, so that needs to be preceded by a semicolon.

// bad
`hello${world}`

// good
;`hello${world}`

This is because if an identifier precedes the statement then the parser will parse it as a tagged template.

foo

`trololol`

is the same as

foo`trololol`
@maxogden

This comment has been minimized.

Copy link
Contributor

commented Mar 24, 2015

Thanks for the feedback.

We no longer recommend starting lines with semicolons. It's hacky. Start lines with void, var, const or something that makes more sense. Starting lines with e.g. (, [, or ` is always avoidable. See also #78 (comment)

@maxogden maxogden closed this Mar 24, 2015

@goatslacker

This comment has been minimized.

Copy link
Author

commented Mar 24, 2015

This issue still applies to this section in particular:

screen shot 2015-03-24 at 1 03 45 pm

If you're using ES6 then templates are a gotcha too.

@dcousens

This comment has been minimized.

Copy link
Member

commented Mar 24, 2015

@goatslacker could you submit a test to clearly outline this?

@mattdesl

This comment has been minimized.

Copy link

commented Mar 24, 2015

I can't imagine a scenario where a line starts with a template string, or any of these other gotchas:

+ * / - ` , . 

But the readme and standard should discourage these explicitly from the start of the line. [ and ( I'm not so sure about, but I'll open another issue.

@goatslacker

This comment has been minimized.

Copy link
Author

commented Mar 24, 2015

I don't mean to talk about scenarios where you would start a line with any particular character. I think starting lines with any character that fails ASI is poor style anyway.

I'm just pointing this out.

@yoshuawuyts yoshuawuyts referenced this issue Jan 8, 2016

@dcousens dcousens added the i disagree label Jan 11, 2016

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
4 participants
You can’t perform that action at this time.