JavaScript will often insert semicolons for you at the end of lines, but not always.
// Declaration that is not semicolon terminated var myRegex = /foo/ // ← no semicolon // Looks like a common way to define and call a function. (function () { alert('Hi'); }()); alert(myRegex); // myRegex is null. FTW!?!
In the above example, it looks like myRegex
is being
initialized to the regular expression foo
, and then a
closure is defined to do some more initialization. But what actually
happens is that /foo/
is called with the result of the
closure, and the result of that unintended function call is assigned
to myRegex
.
If you see code like this, consider putting a semicolon at the end of the line if you want the statement to end there.
If not, then maybe move the open bracket from the following line to the previous. So you can eliminate the warning by changing
tomyFunction (parameters);
myFunction( parameters);
As always, to turn this off, put the error message name
MAYBE_MISSING_SEMI
in the ignores list.