== Why is this an issue?

:operationName: method

include::../description.adoc[]

=== Exceptions

This does not raise an issue in the following cases:

* Arrow functions as they can denote default values.
* Functions with a name starting with the prefix `on` like `onClick`.
* Functions whose name includes `noop`.
* Constructors as it is already covered by S6647.

[source,javascript]
----
static defaultProps = {
  listStyle: () => {}
};

function onClick() {
}

function myNoopFunction() {
}

class C {
  constructor() {}
}
----

== 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]

=== Related rules

* S6647 - Unnecessary constructors should be removed

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[]
