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 upIIFE not checkt for semicolon at the start? #669
Comments
This comment has been minimized.
This comment has been minimized.
|
If there is no code above the IIFE, it will work OK. It becomes more clear when adding a line at the top: |
This comment has been minimized.
This comment has been minimized.
|
Here is an example with code above. It’s still ok: if (typeof foo !== 'undefined') {
throw new Error('foo is already defined!')
}
(function () {
window.alert('ok')
}())http://standardjs.com/demo.html?gist=7382351fed23caf08381c01669b0900d |
This comment has been minimized.
This comment has been minimized.
|
Indeed, this one is a funny edge case :) Somewhat related: #70 |
This comment has been minimized.
This comment has been minimized.
|
There is not a specific rule that enforces semicolons before IIFEs, but other rules will catch problems if they arise (like
The guideline above will ensure code always works, even if there is a special edge case where its not required (like a preceding If this is uncomfortable, there is always semistandard :) |
This comment has been minimized.
This comment has been minimized.
|
As long as standard catches all problems related to missing semicolons I feel comfortable.
Maybe that should be noted in the RULES.md? |
This comment has been minimized.
This comment has been minimized.
|
|
borisdiakur commentedOct 29, 2016
•
edited
https://github.com/feross/standard/blob/master/RULES.md#semicolons suggests the following:
However, when I navigate to http://standardjs.com/demo.html and paste the following code, the linter tells me it’s fine:
I’m new to the no semicolons style, so now I’m confused. Either the documentation or the linter is wrong.