目录

@typescript-eslint/no-empty-function

不允许使用空函数。

规则配置

// code-linter.json5
{
  "rules": {
    "@typescript-eslint/no-empty-function": "error"
  }
}

选项

详情请参考@typescript-eslint/no-empty-function选项。

正例

该规则旨在消除空函数。如果函数包含注释,则不会将其视为问题。

/*eslint no-empty-function: "error"*/
function foo() {
  // do nothing.
}

const baz = () => {
  foo();
};

export class Bar {
  public meth1() {
    // do something
  }

  public meth2() {
    baz();
  }
}

反例

/*eslint no-empty-function: "error"*/
function foo() {

}

const baz = () => {

};

export class Bar {
  public meth1() {

  }

  public meth2() {

  }
}

规则集

plugin:@typescript-eslint/all

Code Linter代码检查规则的配置指导请参考Code Linter代码检查。