
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.
79 lines
1.4 KiB
Plaintext
79 lines
1.4 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Because semicolons at the ends of statements are optional, starting function call arguments on a separate line makes the code confusing. It could lead to errors and most likely _will_ lead to questions for maintainers.
|
|
|
|
|
|
What was the initial intent of the developer?
|
|
|
|
. Define a function and then execute some unrelated code inside a closure ?
|
|
. Pass the second function as a parameter to the first one ?
|
|
|
|
The first option will be the one chosen by the JavaScript interpreter.
|
|
|
|
|
|
By extension, and to improve readability, any kind of function call argument should not start on new line.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,flex]
|
|
----
|
|
var fn = function () {
|
|
//...
|
|
}
|
|
|
|
(function () { // Noncompliant
|
|
//...
|
|
})();
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
Either
|
|
|
|
|
|
[source,flex]
|
|
----
|
|
// define a function
|
|
var fn = function () {
|
|
//...
|
|
}; // <-- semicolon added
|
|
|
|
// then execute some code inside a closure
|
|
(function () {
|
|
//...
|
|
})();
|
|
----
|
|
|
|
Or
|
|
|
|
|
|
[source,flex]
|
|
----
|
|
var fn = function () {
|
|
//...
|
|
}(function () { // <-- start function call arguments on same line
|
|
//...
|
|
})();
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|