no-empty-function
eslint
Suggestion
eslint.config.js
export default [
{
rules: {
"no-empty-function": "error",
},
},
];function foo() {}
const bar = function() {};
const bar1 = () => {};
function* baz() {}
const bar2 = function*() {};
const obj = {
foo: function() {},
foo: function*() {},
foo() {},
*foo() {},
get foo() {},
set foo(value) {}
};
class A {
constructor() {}
foo() {}
*foo() {}
get foo() {}
// …function foo() {
// do nothing.
}
const baz = function() {
// any clear comments.
};
const baz1 = () => {
bar();
};
function* foobar() {
// do nothing.
}
const baz2 = function*() {
// do nothing.
};
const obj = {
foo: function() {
// do nothing.
},
foo: function*() {
// do nothing.
},
foo() {
// do nothing.
},
// …Examples from the ESLint documentation.
no-empty-function
eslint
export default [
{
rules: {
"no-empty-function": "error",
},
},
];no-empty-function
eslint plugin · restriction
{
"rules": {
"no-empty-function": "error"
}
}suspicious/noEmptyBlockStatements
suspicious · since 1.3.0
{
"linter": {
"rules": {
"suspicious": {
"noEmptyBlockStatements": "error"
}
}
}
}Disallow nested ternary expressions
Disallow variable declarations from shadowing variables declared in the outer scope
Enforce a maximum number of classes per file
Enforce default parameters to be last
Require default cases in switch statements