
When an include is not surrounded by empty lines, its content is inlined on the same line as the adjacent content. That can lead to broken tags and other display issues. This PR fixes all such includes and introduces a validation step that forbids introducing the same problem again.
62 lines
1.6 KiB
Plaintext
62 lines
1.6 KiB
Plaintext
== Why is this an issue?
|
|
|
|
When a non-existent variable is referenced a ``++ReferenceError++`` is raised.
|
|
|
|
|
|
Due to the dynamic nature of JavaScript this can happen in a number of scenarios:
|
|
|
|
* When typo was made in a symbol's name.
|
|
* When using variable declared with ``++let++`` or ``++const++`` before declaration (unlike ``++var++``-declarations, they are not hoisted to the top of the scope).
|
|
* Due to confusion with scopes of ``++let++``- and ``++const++``-declarations (they have block scope, unlike ``++var++``-declarations, having function scope).
|
|
* When accessing a property in the wrong scope (e.g. forgetting to specify ``++this.++``).
|
|
|
|
This rule does not raise issues on global variables which are defined with ``++sonar.javascript.globals++`` and ``++sonar.javascript.environments++`` properties.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,javascript]
|
|
----
|
|
var john = {
|
|
firstName: "john",
|
|
show: function() { console.log(firstName); } // Noncompliant: firstName is not defined
|
|
}
|
|
john.show();
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,javascript]
|
|
----
|
|
var john = {
|
|
firstName: "john",
|
|
show: function() { console.log(this.firstName); }
|
|
}
|
|
john.show();
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
XX does not exist. Change its name or declare it so that its usage doesn't result in a "ReferenceError".
|
|
|
|
|
|
=== Highlighting
|
|
|
|
Primary location: Statement
|
|
|
|
Secondary location: the variable/class/function's definition later in the same scope (if there is one)
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|