== Why is this an issue?

This rule checks that functions declared in same scope don't have identical names. Indeed, it is possible to declare 2 functions with the same name, but only the last definition will be kept by the JavaScript engine before starting execution of the code.


This use of duplicate function name is often unwanted and can lead to bugs and more generally to confusing code.


=== Noncompliant code example

[source,text]
----
fun(); // prints "bar"

// first declaration of the function
function fun() {
  print("foo");
}

fun(); // prints "bar"

// redeclaration of the "fun" function: this definition overrides the previous one
function fun() {
  print("bar");
}

fun(); // prints "bar"
----


=== Compliant solution

[source,text]
----
fun(); // prints "foo"

function fun() {
  print("foo");
}

fun(); // prints "foo"
----
or

[source,text]
----
fun(); // prints "foo"

function fun() {
  print("foo");
}

fun(); // prints "foo"

function printBar() {
  print("bar");
}

fun(); // prints "foo"
----


