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

unnecessary semicolon #70

Closed
jprichardson opened this issue Mar 18, 2015 · 2 comments

Comments

@jprichardson
Copy link
Member

commented Mar 18, 2015

Consider this program:

var a = 1
if (a) {
  console.log('do something')
}

var b = 3
console.log(b)

;(function () {
  console.log('do another thing')
})()

Runs fine, no standard errors either.

Now consider this program:

var a = 1
if (a) {
  console.log('do something')
}

;(function () {
  console.log('do another thing')
})()

Runs fine, but standard prints the unnecessary semicolon error. While standard is indeed correct that the program and IIFE is fine without the semicolon prefix, the rule seems to be a bit too tight in this context. By default, I always prefix my IIFE with a ; so that I don't have to think of the contextual situations when it's necessary and when it is not. Do others do this? Is this a rule that should be relaxed? I'm guessing it's an eslint change.

Either way, this feels pretty low-priority to the other standard issues, but I thought that I'd bring it up for discussion.

Loving standard btw :)

@feross

This comment has been minimized.

Copy link
Member

commented Mar 18, 2015

Thanks for the nice words :)

You're right – this is a weird edge case and it's inconsistent. In the second example eslint is complaining because ; is not required after an if statement block. We could fix this by disabling the no-extra-semi rule.

@feross feross closed this in de02f0b Mar 18, 2015

@feross

This comment has been minimized.

Copy link
Member

commented Mar 18, 2015

Released as 3.1.2.

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