Ecma 2017 rules are violating a add a semicolon at the end of the line?

sonarqube
(SELVA) #1

Actually I have major confusion on the particular rule like

SonarQube

Statements should end with semicolons

  • Code Smell
  • Minor

Main sources

  • convention
  • Available SinceNov 20, 2018
  • SonarAnalyzer (JavaScript)
  • Constant/issue: 1min

In JavaScript, the semicolon (; is optional as a statement separator, but omitting semicolons can be confusing, and lead to unexpected results because a semicolon is implicitly inserted at the end of each line.

Noncompliant Code Example

function fun() {
return // Noncompliant. ‘;’ implicitly inserted at end of line
5 // Noncompliant. ‘;’ implicitly inserted at end of line
}
print(fun()); // prints “undefined”, not “5”

Compliant Solution

function fun() {
return 5;
}
print(fun());

But ecma script 2017 not need to add a semicolon at end of the line.

So i need an clarity to achieve a verify if semicolon need or not ?