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 upStandard allows certain unnecessary semicolons #786
Comments
This comment has been minimized.
This comment has been minimized.
|
Is this on purpose? Otherwise, are we missing an |
dcousens
added
bug
and removed
bug
labels
Feb 14, 2017
This comment has been minimized.
This comment has been minimized.
|
We're missing an eslint rule: We used to enable this, but it was relaxed in 3.1.2. Context here: #70 Options are:
|
feross
added
the
bug
label
Feb 14, 2017
This comment has been minimized.
This comment has been minimized.
|
i vote #1
i think it means they have to follow that rule, right? |
This comment has been minimized.
This comment has been minimized.
|
@dcposch If you have an immediately executing function like this: ;(function () {
console.log('hey')
})()It's common to put a semi in front, in case there's something before it that fails with ASI. Here's an example where the semi is required to get the correct behavior: console.log('hi')
;(function () { // without the semi, this is interpreted as a function invocation
console.log('hey')
})()However, there are certain things that could come before that don't actually require a semi: if (x) {
console.log('hi')
}
;(function () { // this semi is technically NOT required
console.log('hey')
})()If-blocks don't actually require a semi after them, since there's no way the paren that follows could be a function invocation. That said, it's a good idea to just always put in a semi before if (x) {
console.log('hi')
}
(function () { // this is perfectly safe, though it doesn't look like it
console.log('hey')
})() |
This comment has been minimized.
This comment has been minimized.
tunnckoCore
commented
Feb 21, 2017
|
So we should go back to use semicolons everywhere! I'm for 1 too.
There's autofix and everyone should use it. The autofix will remove it in that last case, but won't remove it in the example with console.log console.log('hi')
;(function () { // without the semi, this is interpreted as a function invocation
console.log('hey')
})()Above is confirmed. So I don't see any problems. |
feross
added
question
and removed
bug
labels
Apr 4, 2017
This comment has been minimized.
This comment has been minimized.
indiesquidge
commented
May 5, 2017
•
|
I don't know if this should count as part of this thread or opened as a new issue (or if this case is even supported at all since it requires the export class Bork {
// Property initializer syntax
instanceProperty = 'bork';
boundFunction = () => {
return this.instanceProperty
};
// Static class properties
static staticProperty = 'babelIsCool';
static staticFunction = function () {
return Bork.staticProperty
};
};
// standard does not complain about these semicolons. |
This comment has been minimized.
This comment has been minimized.
stale
bot
commented
May 10, 2018
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
dcposch commentedFeb 14, 2017
•
edited
Version: 8.6.0
Example 1: reports the unnecessary semicolon
Example 2: no error
Example 3: no error