Skip to content

[label-has-associated-control] Allow overriding of default label inputs #2359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cprestegard opened this issue Apr 9, 2025 · 0 comments
Open
Labels
package: eslint-plugin-template Angular Template rules triage This issue needs to be looked at and categorized by a maintainer

Comments

@cprestegard
Copy link

Description and reproduction of the issue

The [label-has-associated-control] rule hard codes the default inputs to check for on label elements. It would be great to allow users to override the defaults. This would allow projects to lint labels that rely on custom directives to hook into custom controls.

Suggestion to have the ability to declare the rule like this:

{
  "rules": {
    "@angular-eslint/template/label-has-associated-control": [
      "error",
      {
        "controlComponents": [
          "my-custom-control"
        ],
        "labelComponents": [
          {
            "inputs": [
              "for",
              "htmlFor",
              "myCustomFor"
            ],
            "selector": "label"
          }
        ]
      }
    ]
  }
}

so that the following would be valid:

<label [myCustomFor]="customId">Label</label>
<my-custom-control [id]="customId"></my-custom-control>

Versions

package version
@angular-eslint/eslint-plugin-template 19.3.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: eslint-plugin-template Angular Template rules triage This issue needs to be looked at and categorized by a maintainer
Projects
None yet
Development

No branches or pull requests

1 participant