This rule checks that a declaration doesn't use a name that is already in use. Indeed, it is possible to declare multiple variables and/or functions with the same name, but it's hard to predict which declaration will be kept by the JavaScript interpreter.

Typically, this kind of re-declaration is an error, and can lead to bugs and more generally to confusing code.

This rule also applies to function parameters.

## Noncompliant Code Example

    var a = 'foo';
    function a() {}   // Noncompliant
    console.log(a);   // prints "foo"

    function myFunc(arg) {
      var arg = "event"; // Noncompliant, argument value is lost
    }

    fun(); // prints "bar"

    function fun() {
      console.log("foo");
    }

    fun(); // prints "bar"

    function fun() {  // Noncompliant
      console.log("bar");
    }

    fun(); // prints "bar"

## Compliant Solution

    var a = 'foo';
    function otherName() {}
    console.log(a);

    function myFunc(arg) {
      var newName = "event";
    }

    fun(); // prints "foo"

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

    fun(); // prints "foo"

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

    printBar(); // prints "bar"