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

ASI exceptions #535

Closed
maciejhirsz opened this issue May 31, 2016 · 5 comments

Comments

@maciejhirsz
Copy link

commented May 31, 2016

You list [ and ( as exceptions for starting new lines without semicolon, someone also added the template string backtick ```. There is actually more of those:

  1. unary + and - operators:
foo = bar
+new Date

becomes
foo = bar + new Date

  1. the regex /
foo = bar
/baz/g.test('baz')

becomes
foo = bar / baz / g.test('baz')

That makes it a total of 6 exceptions you have to look out for: [, (, ```, +, `-`, `/`

@dcousens

This comment has been minimized.

Copy link
Member

commented May 31, 2016

look out for

Is a strong word, seeing as all of these emit glaring warnings

@maciejhirsz

This comment has been minimized.

Copy link
Author

commented May 31, 2016

All of those examples parse fine and produce valid code, it can fail on execution with an exception, but if you are unlucky enough with variable naming, it can also execute fine and produce unexpected behavior.

@dcousens

This comment has been minimized.

Copy link
Member

commented May 31, 2016

I meant if you are using standard, you don't have to worry about "looking out" for those cases. It's done for you.

@dcousens dcousens added the question label May 31, 2016

@maciejhirsz

This comment has been minimized.

Copy link
Author

commented May 31, 2016

Aye, I get that, and it's certainly great to have a tool that statically checks against it. My comment is solely about the readme, apologies if that wasn't clear. I think people should make informed decisions, but that only works if the information you get is accurate.

@feross

This comment has been minimized.

Copy link
Member

commented May 31, 2016

@maciejhirsz Thanks for your comments. The reason we omitted the other cases in the readme is that they usually don't appear in real code.

foo = bar
+new Date
/baz/g.test('baz')

is most likely to be:

foo = bar
myFn(+new Date)
var isBaz = /baz/g.test('baz')

The full details are explained in RULES.md which is linked at the bottom of the bulleted list in the README.md. See here: https://github.com/feross/standard/blob/master/RULES.md#helpful-reading

@feross feross closed this May 31, 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.
3 participants
You can’t perform that action at this time.