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

I have a Javascript Lint configured to check syntax in vim, and when I have a statement like

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

It generates the following warning

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

I thought it was best to always end statements with a semicolon (see here ). This is not a mistake, but why a warning? How can I change that. I do not have countless warnings when I look for legal warnings.

+6
source share
1 answer

Guess it complains about the final semicolon after your closing brace.

 }; 

In any programming language that I used, it is okay to close blocks with semicolons. The block is closed with a closing bracket.

More JavaScript discussions : when should I use a semicolon after curly braces? .

+9
source

Source: https://habr.com/ru/post/900273/


All Articles