80 lines
1.4 KiB
Plaintext

== Why is this an issue?
:operationName: method
include::../description.adoc[]
=== Exceptions
This does not raise an issue in the following cases:
* Function expressions and arrow functions as they can denote default values
* Empty functions with a name starting with the prefix `on` like `onClick`.
[source,javascript]
----
static defaultProps = {
listStyle: () => {}
};
function onClick() {
}
----
== How to fix it
=== Code examples
==== Noncompliant code example
[source,javascript,diff-id=1,diff-type=noncompliant]
----
function shouldNotBeEmpty() { // Noncompliant - method is empty
}
function notImplemented() { // Noncompliant - method is empty
}
function emptyOnPurpose() { // Noncompliant - method is empty
}
----
==== Compliant solution
[source,javascript,diff-id=1,diff-type=compliant]
----
function shouldNotBeEmpty() {
doSomething();
}
function notImplemented() {
throw new Error("notImplemented() cannot be performed because ...");
}
function emptyOnPurpose() {
// comment explaining why the method is empty
}
----
== Resources
=== Documentation
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions[Functions]
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[]