eslint-plugin-vuejs-accessibility icon indicating copy to clipboard operation
eslint-plugin-vuejs-accessibility copied to clipboard

Allow bind syntax for "label-has-for"

Open aKzenT opened this issue 1 year ago • 4 comments

We sometimes have components that combine form elements and labels:

       <label :for="id" ...>
       <input :id="id" ...>

id in this case is a property set on the custom component.

Unfortunately the plugin ignores :for completely and complains about missing for attribute.

aKzenT avatar Jul 12 '22 13:07 aKzenT

can you provide a short reproduction of this behavior so we can try fixing it properly?

vhoyer avatar Jul 20 '22 15:07 vhoyer

This is yet another barrier to Vue3 adoption. If Vue allows binding with :for then this should be part of the linting rules.

RieMars avatar Aug 17 '22 05:08 RieMars

As far as I could tell, it is a problem both in vue@2 and vue@3, but anyway, could you, then, provide a reproduction link?

vhoyer avatar Aug 17 '22 09:08 vhoyer

There's an example - Vue SFC Link

And regarding the Vue3 comment, I just started encountering this issue as I was forced to upgrade to Vue3 and used the ESLint AirBnB preset. That preset required me to get familiar with disabling a lot of rules that just didn't work with legit code like this one.

RieMars avatar Aug 19 '22 01:08 RieMars

Any updates on this topic?

cniklas avatar Nov 12 '22 09:11 cniklas

A PR would be merged if someone wants to put one together.

kddnewton avatar Nov 12 '22 20:11 kddnewton

So, I just gave this a look, and I'm pretty sure that this is an issue with your configuration, also it should be related to this other issue: https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility/issues/54 (in this other issue there are some recommendations of workarounds, but PRs are still welcomed to fix that issue).

and as far as I can tell, it does not have anything to do with Vue@3.

The reproduction I made is here: https://github.com/vhoyer-bug-reproductions/eslint-plugin-vuejs-accessibility

if you think there was a mistake in my judgement feel free to re-open this issue


EDIT: as the reproduction link provided didn't have any information about the configuration used, I assumed the recommended

vhoyer avatar Nov 14 '22 14:11 vhoyer

So, I just gave this a look, and I'm pretty sure that this is an issue with your configuration, also it should be related to this other issue: #54 (in this other issue there are some recommendations of workarounds, but PRs are still welcomed to fix that issue).

and as far as I can tell, it does not have anything to do with Vue@3.

The reproduction I made is here: https://github.com/vhoyer-bug-reproductions/eslint-plugin-vuejs-accessibility

if you think there was a mistake in my judgement feel free to re-open this issue

EDIT: as the reproduction link provided didn't have any information about the configuration used, I assumed the recommended

Thanks for sharing the reproduction code example. Going along your configuration over there fixed the issue for me!

cniklas avatar Nov 14 '22 17:11 cniklas