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

why airbnb is using yet semicolons? #1567

Closed
webmobiles opened this issue Sep 23, 2017 · 7 comments
Closed

why airbnb is using yet semicolons? #1567

webmobiles opened this issue Sep 23, 2017 · 7 comments

Comments

@webmobiles
Copy link

I've read moderns apps don't use anymore semicolons, maybe in the future airbnb style too ? maybe with https://standardjs.com/ ?

@ljharb
Copy link
Collaborator

ljharb commented Sep 23, 2017

I'm not sure where you've read that, and it's quite false. Using semicolons is something the vast majority of JS devs do, despite the recent rise in usage of "standardJS" - something that is not actually a standard, nor something that aligns with what the majority of JS devs do in a number of ways.

The professional and modern thing to do is not to omit optional tokens, but to always use them, since explicit > implicit.

@ljharb ljharb closed this as completed Sep 23, 2017
@Bamieh
Copy link

Bamieh commented Sep 24, 2017

Additionally, not using semicolons can rise a series of unexpected bugs, take this line of code for example:

var obj = {n: 1};
var a = obj
[a].forEach(item => console.log(item)) //error

This results in an error, although the expected is to log the obj.

@mraak

This comment has been minimized.

@omidkrad
Copy link

I started a new project without using semicolons and after a few days I switched back to using semicolons for a simple reason: With semicolons, you get better parser, and in case of TypeScript, compiler messages.

Let's say you have forgotten a closing parenthesis on one line and went to the next line. The compiler may tell you that it expects a comma at the end of the line for an optional parameter, but if you closed the line with a semicolon, it will tell you that it expects a closing parenthesis. Also, I find it easier to skim through the code when lines are ended with semicolons.

@mraak

This comment has been minimized.

@ljharb

This comment has been minimized.

@Luxcium

This comment has been minimized.

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

6 participants