bulyshko / esformatter-semicolons

esformatter plugin for adding missing and removing unnecessary semicolons
MIT License
12 stars 2 forks source link

Unnecessary semicolons added to ForStatement #3

Closed PhilippSoehnlein closed 10 years ago

PhilippSoehnlein commented 10 years ago

The following code breaks when using esformatter-semicolons:

for (var i = 0; i < 10; i++) {
}

esformatter-semicolons adds an additional semicolon and ends up with:

for (var i = 0;; i < 10; i++) {
}

If the var keyword is moved out of the for loop everything seems fine:

var i;
for (i = 0; i < 10; i++) {
}

I know the original example is considered bad style because of JavaScript's function scope, but sometimes people declare loop variables this way…

The bug appears independently of the config file, I tried with a full blown config file and with the minimum config file:

{
  "plugins": [
    "esformatter-semicolons"
  ]
}
bulyshko commented 10 years ago

@PhilippSoehnlein Thanks for reporting this. I'll fix it in the next few hours.

bulyshko commented 10 years ago

Fixed. See https://github.com/bulyshko/esformatter-semicolons/commit/69e3f8d44e4ca504585bed9b6769a36bf3760e09