目录

@performance/init-list-component

When using the List component, you are advised to specify both the width and height attributes.

Rule Configuration

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

Options

This rule is not configurable.

Example of Correct Code

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

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

Example of Incorrect Code

@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)
}

Rule Set

plugin:@performance/all

For details about how to configure Code Linter check rules, see Code Linter.