71 lines
1.1 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2020-06-30 12:47:33 +02:00
include::../description.adoc[]
=== 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
----
function doSomething(a, b) { // "a" is unused
return compute(b);
}
----
=== 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
----
function doSomething(b) {
return compute(b);
}
----
or
2021-02-02 15:02:10 +01:00
[source,javascript]
2020-06-30 12:47:33 +02:00
----
function doSomething(_a, b) {
return compute(b);
}
2020-06-30 12:47:33 +02:00
----
2021-02-02 15:02:10 +01:00
=== Exceptions
When ``++arguments++`` is used in the function body, no parameter is reported as unused.
2020-06-30 12:47:33 +02:00
[source,javascript]
----
function doSomething(a, b, c) {
compute(arguments);
}
2020-06-30 12:47:33 +02:00
----
Also, the rule ignores all parameters whose name starts with an underscore (``++_++``).
This is a common practice to acknowledge the fact that some parameter is unused (e.g. in TypeScript compiler).
2021-02-02 15:02:10 +01:00
[source,javascript]
2020-06-30 12:47:33 +02:00
----
function doSomething(_a, b) {
return compute(b);
2020-06-30 12:47:33 +02:00
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]