emptyFunctions
Reports empty functions that should contain code or a comment.
✅ This rule is included in the tsstylisticandstylisticStrictpresets.
Empty functions can reduce readability because readers need to guess whether it’s intentional or not. If a function is intentionally empty, adding a comment makes the intention clear.
Examples
Section titled “Examples”function foo() {}const foo = function () {};const foo = () => {};class Foo { bar() {}}class Foo { constructor() {}}function foo() { doSomething();}const foo = function () { doSomething();};const foo = () => doSomething();function foo() { // intentionally empty}class Foo { bar() { /* empty */ }}Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you prefer to allow empty functions without comments, you may disable this rule. Some codebases use empty functions as no-ops or placeholders intentionally.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.