目录

@performance/hp-performance-no-closures

Prioritize parameters in transferring internal variables of functions.

You are advised to modify the code to comply with the ArkTS Performant Programming Practices.

Rule Configuration

// code-linter.json5
{
  "rules": {
    "@performance/hp-performance-no-closures": "suggestion",
  }
}

Options

This rule is not configurable.

Example of Correct Code

let arr = [0, 1, 2];
function foo(array: Array<number>): number {
  // Whenever possible, use parameters to transfer arr.
  return array[0] + array[1];
}
foo(arr);

Example of Incorrect Code

let arr = [0, 1, 2];
function foo() {
  // Whenever possible, use parameters to transfer arr.
  return arr[0] + arr[1];
}
foo();

Rule Set

plugin:@performance/all

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