69 lines
1.1 KiB
Plaintext
69 lines
1.1 KiB
Plaintext
include::../description.adoc[]
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,javascript]
|
|
----
|
|
function doSomething(a, b) { // "a" is unused
|
|
return compute(b);
|
|
}
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
[source,javascript]
|
|
----
|
|
function doSomething(b) {
|
|
return compute(b);
|
|
}
|
|
----
|
|
|
|
or
|
|
|
|
[source,javascript]
|
|
----
|
|
function doSomething(_a, b) {
|
|
return compute(b);
|
|
}
|
|
----
|
|
|
|
|
|
|
|
== Exceptions
|
|
|
|
When ``++arguments++`` is used in the function body, no parameter is reported as unused.
|
|
|
|
|
|
[source,javascript]
|
|
----
|
|
function doSomething(a, b, c) {
|
|
compute(arguments);
|
|
}
|
|
----
|
|
|
|
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).
|
|
|
|
[source,javascript]
|
|
----
|
|
function doSomething(_a, b) {
|
|
return compute(b);
|
|
}
|
|
----
|
|
|
|
|
|
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[]
|