6

I have Javascript Lint set up to carry out syntax checking in vim, and when I have a statement such as

if (i > 0){
 i--;
};

It generates the following warning

test.js|160 warning| empty statement or extra semicolon

I thought that it is best to always end statements with semicolons (see here). It's not issuing an error, but why the warning? How can I change this. I don't countless warnings when I am looking for legitimate warnings.

Community
  • 1
  • 1
puk
  • 16,318
  • 29
  • 119
  • 199

1 Answers1

9

Guess it's complaining about the final semicolon after your closing brace.

};

In any programming language I have used, it is not normal to close blocks with semicolons. The block is closed by the closing brace.

There's more discussion on JavaScript: When should I use a semicolon after curly braces?.

Community
  • 1
  • 1
ewan.chalmers
  • 16,145
  • 43
  • 60