jsx-eslint / eslint-plugin-jsx-a11y

Static AST checker for a11y rules on JSX elements.
MIT License
3.38k stars 637 forks source link

[control-has-associated-label]: Does not allow for custom components that would result in accessible labels #981

Open eddhurst opened 4 months ago

eddhurst commented 4 months ago

This rule doesn't support dynamic components that can't be statically analysed as providing a label, but would result in an accessible label at run time.

Specifically in my instance, the react-intl component <FormattedMessage /> takes the prop id and then results in the HTML structure

<span>Locale-aware content</span>

However, the control-has-associated-label has no way to be extended and accept an array of components that can be safely considered as providing a label.

Screenshot 2024-04-22 at 13 42 10

The config only allows for adding components that should be parsed by this rule, and allows for removing components that should be excluded, but doesn't allow for extending to match a given component that would then result in a pass.

ljharb commented 4 months ago

This is a duplicate of #863, i believe.