
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
75 lines
1.4 KiB
Plaintext
75 lines
1.4 KiB
Plaintext
== Why is this an issue?
|
|
|
|
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)
|
|
|
|
=== 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[]
|