2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2021-01-27 13:42:22 +01:00
|
|
|
Extra semicolons (``++;++``) are usually introduced by mistake, for example because:
|
2020-06-30 14:49:38 +02:00
|
|
|
|
2020-06-30 12:47:33 +02:00
|
|
|
* It was meant to be replaced by an actual statement, but this was forgotten.
|
2021-01-27 13:42:22 +01:00
|
|
|
* There was a typo which lead the semicolon to be doubled, i.e. ``++;;++``.
|
2020-06-30 12:47:33 +02:00
|
|
|
* There was a misunderstanding about where semicolons are required or useful.
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2020-06-30 12:47:33 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,javascript]
|
2020-06-30 12:47:33 +02:00
|
|
|
----
|
|
|
|
var x = 1;; // Noncompliant
|
|
|
|
|
|
|
|
function foo() {
|
|
|
|
}; // Noncompliant
|
|
|
|
----
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2020-06-30 12:47:33 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,javascript]
|
2020-06-30 12:47:33 +02:00
|
|
|
----
|
|
|
|
var x = 1;
|
|
|
|
|
|
|
|
function foo() {
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Exceptions
|
2022-07-29 15:11:24 +02:00
|
|
|
|
|
|
|
This rule does not apply when the semicolon is after a line break and before ``++(++`` or ``++[++`` as it is often used in semicolon-less style.
|
|
|
|
|
2022-08-04 14:16:24 +02:00
|
|
|
[source,javascript]
|
2022-07-29 15:11:24 +02:00
|
|
|
----
|
2022-08-04 14:16:24 +02:00
|
|
|
var hello = 'Hello'
|
|
|
|
var world = 'World!'
|
|
|
|
var helloWorld = hello + ' ' + world
|
2022-07-29 15:11:24 +02:00
|
|
|
;[...helloWorld].forEach(c => console.log(c))
|
|
|
|
----
|
|
|
|
|
2022-08-04 14:16:24 +02:00
|
|
|
[source,javascript]
|
2022-07-29 15:11:24 +02:00
|
|
|
----
|
2022-08-04 14:16:24 +02:00
|
|
|
var a = 1
|
|
|
|
var b = 2 * a
|
2022-07-29 15:11:24 +02:00
|
|
|
;(a + b).toString()
|
|
|
|
----
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== Message
|
|
|
|
|
|
|
|
Remove this extra semicolon.
|
|
|
|
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2023-06-22 10:38:01 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|