puk
puk

Reputation: 16762

Javascript Lint claims extra semicolon is bad (after `if`)

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.

Upvotes: 6

Views: 2708

Answers (1)

ewan.chalmers
ewan.chalmers

Reputation: 16235

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?.

Upvotes: 9

Related Questions