Rule: template-accessibility-label-for

Checks if the label has associated for attribute or a form element

Rationale

The label tag should either have a for attribute or should have associated control. This rule supports two ways, either the label component should explicitly have a for attribute or a control nested inside the label component It also supports adding custom control component and custom label component support.

Notes:
TS Only

Config

Add custom label, label attribute and controls

Examples
"template-accessibility-label-for": [
  true,
  {
    "labelComponents": ["app-label"],
    "labelAttributes": ["id"],
    "controlComponents": ["app-input", "app-select"]
  }
]
Schema
{
  "items": {
    "type": "object",
    "properties": {
      "labelComponents": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "labelAttributes": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "controlComponents": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    }
  },
  "type": "array"
}