目录

@performance/hp-arkui-limit-refresh-scope (Deprecated)

Reduce the component update scope. This rule is deprecated since 5.0.3.500.

Rule Configuration

// code-linter.json5
{
  "rules": {
    "@performance/hp-arkui-limit-refresh-scope": "suggestion",
  }
}

Options

This rule is not configurable.

Example of Correct Code

@Entry
@Component
struct StackExample6 {
  @State isVisible : boolean = false;
  build() {
    Column() {
      Stack({alignContent: Alignment.Top}) {
        Text().width('100%').height('70%').backgroundColor(0xd2cab3)
          .align(Alignment.Center).textAlign(TextAlign.Center);
        // 100 identical Text components are omitted here.
        Stack() {
          if (this.isVisible) {
            Text('New Page').height("70%").backgroundColor(0xd2cab3)
              .align(Alignment.Center).textAlign(TextAlign.Center);
          }
        }.width('100%').height('70%')
      }
      Button("press").onClick(() => {
        this.isVisible = !(this.isVisible);
      })
    }
  }
}

Example of Incorrect Code

@Entry
@Component
struct StackExample5 {
  @State isVisible : boolean = false;
  build() {
    Column() {
      Stack({alignContent: Alignment.Top}) {
        Text().width('100%').height('70%').backgroundColor(0xd2cab3)
          .align(Alignment.Center).textAlign(TextAlign.Center);
        // 100 identical Text components are omitted here.
        if (this.isVisible) {
          Text('New Page').height("70%").backgroundColor(0xd2cab3)
            .align(Alignment.Center).textAlign(TextAlign.Center);
        }
      }
      Button("press").onClick(() => {
        this.isVisible = !(this.isVisible);
      })
    }
  }
}

Rule Set

plugin:@performance/all

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