Skip to content

eslint/no-empty-function Restriction ​

What it does ​

Disallows the usages of empty functions

Why is this bad? ​

Empty functions can reduce readability because readers need to guess whether it’s intentional or not. So writing a clear comment for empty functions is a good practice.

Example ​

Examples of incorrect code for this rule:

javascript
function foo() {}

const bar = () => {};

Examples of correct code for this rule:

javascript
function foo() {
  // do nothing
}

function foo() {
  return;
}
const add = (a, b) => a + b;

References ​

Released under the MIT License.