← Back

no-empty-function warning

Disallow empty functions

Examples

❌  Incorrect

function foo () {}

let foo = function () {};

let foo = () => {};

let obj = {
    foo: function () {},

    foo () {},
};

class A {
    constructor() {}

    foo() {}
}

✅  Correct

function foo () {
    // do nothing.
}

let bar = function () {
    // any clear comments.
};

let baz = () => {
    bar();
};

let quz = {
    foo: function () {
        // do nothing.
    },

    foo () {
        // do nothing.
    },
};

class FooClass {
    constructor () {
        // do nothing.
    }

    foo () {
        // do nothing.
    }
}