目录

@correctness/accessibility-label-check

Use accessibilityText to add accessibility text to components when implementing accessibility features.

Rule Configuration

// code-linter.json5
{
  "rules": {
    "@correctness/accessibility-label-check": "suggestion"
  }
}

Options

This rule is not configurable.

Example of Correct Code

@Entry
@Component
struct AccessibilityLabelPositive {
    build() {
        Column() {
            Text('Text')
                .width(60)
                .height(60)
                .accessibilityText('Back')
                .onClick(() => {})
        }
    }
}

Example of Incorrect Code

@Entry
@Component
struct AccessibilityLabelNegative {
    build() {
        Column() {
            Text()
                .width(60)
                .height(60)
                .backgroundColor(0xeaeaea)
                .onClick(() => {})
        }
    }
}

Rule Set

plugin:@correctness/all

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