文档管理中心
工具DevEco Studio编写与调试应用代码编辑代码检查Code Linter代码检查规则性能规则@performance@performance/init-list-component

@performance/init-list-component

List组件在使用时,建议同时定义width和height属性。

规则配置

// code-linter.json5
{
  "rules": {
    "@performance/init-list-component": "warn",
  }
}

选项

该规则无需配置选项。

正例

@Component
struct Greeting {
  @Builder myBuilder() {
    List().width(10).height(10)
  }
  build() {
    List() {
    }.width(10).height(10);
  }
}

@Builder function globalBuilder() {
  List().width(10).height(10)
}

反例

@Component
struct Greeting {
  @Builder myBuilder() {
    // missing initialization of attribute 'height'
    List().width(10)
  }
  build() {
    // missing initialization of attribute 'width'
    List().height(10);
  }
}

@Builder function myBuilder() {
  // missing initialization of attribute 'height'
  List().width(10)
}

规则集

plugin:@performance/all

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

在 工具 DevEco Studio 中进行搜索
请输入您想要搜索的关键词