79 lines
1.6 KiB
Plaintext

== Why is this an issue?
include::../description.adoc[]
=== Exceptions
When `arguments` is used in the function body, no parameter is reported as unused.
[source,javascript]
----
function doSomething(a, b, c) {
compute(arguments);
}
----
The rule also ignores all parameters with names starting with an underscore (`_`).
This practice is often used to indicate that some parameter is intentionally unused.
This practice is frequently seen in the TypeScript compiler, for example.
[source,javascript]
----
function doSomething(_a, b) {
return compute(b);
}
----
== How to fix it
include::../how-to-fix-it.adoc[]
=== Code examples
==== Noncompliant code example
[source,javascript,diff-id=1,diff-type=noncompliant]
----
function doSomething(a, b) { // "a" is unused
return compute(b);
}
----
==== Compliant solution
[source,javascript,diff-id=1,diff-type=compliant]
----
function doSomething(b) {
return compute(b);
}
----
or
[source,javascript,diff-id=1,diff-type=compliant]
----
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)
=== on 9 Apr 2015, 11:15:56 Elena Vilchik wrote:
I removed part "for function-expression" from Exceptions block, as there is no difference between usage of function-declarations and function-expressions. In some cases (passing functions as arguments to other functions) function-expressions are more common, but function-declarations are still in use.
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]