Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign uptypo: "No semicolons" should read "Semicolons" #5
Comments
This comment has been minimized.
This comment has been minimized.
aharris
commented
Jan 27, 2015
|
+1 |
This comment has been minimized.
This comment has been minimized.
feross
closed this
Jan 27, 2015
This comment has been minimized.
This comment has been minimized.
KrisSiegel
commented
Jan 27, 2015
|
Issues like this means you can't simply have one style standard to rule them all without options like jshint otherwise you won't get the highest adoption rate. For me and the code bases I manage I won't allow eliding of semicolons in JavaScript. Yes it works without them but you can really screw yourself over by simply omitting a part of the language's syntax in some, admittedly rare, situations. You can't elide them in all situations (again, rare, but I'd rather have a rule that covers the most cases and not just some due to someone wanting their code to look slightly nicer). |
This comment has been minimized.
This comment has been minimized.
@KrisSiegel Can you provide a situation where you can "really screw yourself" by omitting semicolons? The absence of them in any of the three required cases before |
This comment has been minimized.
This comment has been minimized.
|
There are actual (albeit VERY rare) gotchas with omitting semicolons. However, this module detects those cases and prints an error. You can't footgun yourself if you add Here's one specific case to watch for: alert('hi')
(function () { var x = 1 })()Gets treated as: alert('hi')(function () { var x = 1 })()The rule is: "If not inserting a semicolon where there is a newline would cause a parse error, then automatically insert one." |
This comment has been minimized.
This comment has been minimized.
|
@KrisSiegel The goal of this module is not to get the highest adoption rate. The goal is to save time in two ways:
|
This comment has been minimized.
This comment has been minimized.
KrisSiegel
commented
Jan 27, 2015
|
I understand the goal isn't the highest adoption rate (sorry, I worded that poorly earlier and didn't really mean exactly that). I'm just not sure who the target audience is for a strict style-enforcing module with no options (granted I was given this link by a friend, perhaps this isn't really meant for wide use I don't know). I like the other rules but wouldn't use the module due to the no semicolon enforcement (I really feel uncomfortable ignoring a part of the syntax especially when there are issues, even rare, when omitted). Either way it works out, good luck! |
This comment has been minimized.
This comment has been minimized.
I just wanted to clarify one thing in case others read this thread: automatic semicolon insertion is well-understood and exactly specified in the ECMAScript spec. It's not like C's "undefined" or "implimentation defined" behavior. The behavior is completely predictable if you just take the time to understand it. |
This comment has been minimized.
This comment has been minimized.
|
I'm almost tempted to add a |
This comment has been minimized.
This comment has been minimized.
mattdesl
commented
Jan 27, 2015
|
Yeah, I would avoid options. Otherwise you may as well just make another jshint. If somebody really wants semicolons, or 6 spaces, or tighter whitespace, etc they can make their own fork. |
This comment has been minimized.
This comment has been minimized.
|
I'll just leave this here https://github.com/flet/semistandard |
This comment has been minimized.
This comment has been minimized.
|
@Flet nice one! |
This comment has been minimized.
This comment has been minimized.
|
@Flet++ If you really want semicolons just use https://github.com/flet/semistandard, please no bike-shedding! @KrisSiegel for me the whole point of adopting something like (Thanks @feross) |
This comment has been minimized.
This comment has been minimized.
callumacrae
commented
Mar 29, 2015
|
@ngoldman Are you telling flet to use flet/semistandard? |
This comment has been minimized.
This comment has been minimized.
|
@callumacrae What is the point of calling someone out like that? Also if you re-read the comment you'll see it was a general statement directed at bike shedders. |
This comment has been minimized.
This comment has been minimized.
|
Sorry I probably should have said nothing. Everyone's doing great work |
This comment has been minimized.
This comment has been minimized.
mearns
commented
Jan 12, 2018
|
Given that TC39 has been coming out pretty hard against relying on ASI, is this project going to consider revising this rule at all? I use standardjs for the reason cited by @ungoldman above, to avoid bikeshedding. However, recent discussions about ASI seem to be more about the structural integrity of the shed, rather than the color, and might warrant some further consideration. |
This comment has been minimized.
This comment has been minimized.
|
If anything, we might take brendaneich’s recomendation to use semicolons in class bodies as statement separators (think for loops). In terms of outside class bodies, it’s yet to be seen what class of asi errors and hazards tc-39 is willing to add. Doesn’t sound good, but I also haven’t seen anything bad yet. It’s an unfortunate situation because their semicolon statement is probably one of the worst options on the table. As always the goal is to make writing js fun and leightwheight and less error prone, so standard will evolve as ECMA script does. |
This comment has been minimized.
This comment has been minimized.
Exactly. Right now, there's nothing concretely bad, i.e. no new ASI hazards. We'll keep an eye on the discussions and advocate for no-semi users. If we have to evolve, we'll happily do it. But we're not there yet. |
ajschumacher commentedJan 27, 2015
No description provided.