文档管理中心
我的
您当前浏览的HarmonyOS 5.0.1(API 13)文档归档不再维护,推荐您使用最新版本。详细请参考文档维护策略变更。
指南DevEco Studio附录Code Linter代码检查规则通用规则@typescript-eslint@typescript-eslint/no-empty-interface

@typescript-eslint/no-empty-interface

不允许声明空接口。

规则配置

收起
自动换行
深色代码主题
复制
  1. // code-linter.json5
  2. {
  3. "rules": {
  4. "@typescript-eslint/no-empty-interface": "error"
  5. }
  6. }

正例

收起
自动换行
深色代码主题
复制
  1. // an interface with any number of members
  2. interface Foo {
  3. name: string;
  4. }
  5. interface Bar {
  6. age: number;
  7. }
  8. // an interface with more than one supertype
  9. // in this case the interface can be used as a replacement of an intersection type.
  10. export interface Baz extends Foo, Bar {}

反例

收起
自动换行
深色代码主题
复制
  1. // an empty interface
  2. interface Foo {}
  3. // an interface with only one supertype (Bar === Foo)
  4. export interface Bar extends Foo {}
  5. // an interface with an empty list of supertypes
  6. export interface Baz {}

规则集

收起
自动换行
深色代码主题
复制
  1. plugin:@typescript-eslint/all

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