目录

@performance/hp-arkui-avoid-empty-callback

Avoid empty system callbacks.

You are advised to modify the code to comply with the ArkUI programming specifications.

Rule Configuration

// code-linter.json5
{
  "rules": {
    "@performance/hp-arkui-avoid-empty-callback": "suggestion",
  }
}

Options

This rule is not configurable.

Example of Correct Code

@Component
struct MyComponent {
  doSomething() {
    // Service logic
  }

  build() {
    Button('Click', { type: ButtonType.Normal, stateEffect: true })
      .onClick(() => {
        this.doSomething()
      })
  }
}

Example of Incorrect Code

@Component
struct MyComponent {
  build() {
    Button('Click', { type: ButtonType.Normal, stateEffect: true })
      .onClick(() => {
         // No service logic
      })
  }
}

Rule Set

plugin:@performance/all

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