Skip to content
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

label-has-associated-control and label-has-for complaining in my .ts files #869

Closed
MendelBak opened this issue Jul 7, 2022 · 8 comments
Closed

Comments

@MendelBak
Copy link

I have .ts services/data store files in my React projects where I'm receiving complaints about the above linting errors. I literally cannot fix those issues to the satisfaction of ESLint, as I haven't written any JSX in those files, only JS/TS.

@ljharb
Copy link
Member

ljharb commented Jul 7, 2022

Can you share the code that’s being warned?

@clarknc
Copy link

clarknc commented Jul 12, 2022

I am having this problem as well. I am receiving the following linting errors:

  Line 46:9:   A form label must be associated with a control  jsx-a11y/label-has-associated-control
  Line 51:9:   A form label must be associated with a control  jsx-a11y/label-has-associated-control

which correspond to the following lines in my "offending" tsx file:

<label htmlFor="input1">
  Input 1
  <input id="input1" />
</label>

<label htmlFor="input2">
  Input 2
  <input id="input2" /> 
</label>

My dependency version is
"eslint-plugin-jsx-a11y": "6.4.1",

@ljharb
Copy link
Member

ljharb commented Jul 12, 2022

@clarknc i agree, that should be valid. You should be using ^, so that you get the latest in-range - can you try updating to ^6.6.0 and see if the problem is fixed?

@clarknc
Copy link

clarknc commented Jul 18, 2022

I've made the suggested version change to my packjage.json and removed/reinstalled the dependency, but the problem seems to still be occurring.

@kachkaev
Copy link

kachkaev commented Aug 9, 2022

Same here with eslint-plugin-jsx-a11y@6.6.1 in a tsx file. Here are the two code snippets that trigger false positives:

// real app code
<label style={{ marginLeft: 20 }}>
  <input
    type="checkbox"
    onChange={(evt) => setReadonly(evt.target.checked)}
  />
  Read only mode
</label>
// from docs
<label>
  Surname
  <input type="text" />
</label>

@ljharb
Copy link
Member

ljharb commented Aug 9, 2022

@kachkaev those both also need an ID and a "for" to link the label and input.

@kachkaev
Copy link

kachkaev commented Aug 9, 2022

Hmm why should the last example fail? I copied it from rule docs.

@ljharb
Copy link
Member

ljharb commented Aug 9, 2022

It depends on what the assert config is set to. "Both" requires both.

@ljharb ljharb closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2024
anomiex added a commit to Automattic/jetpack that referenced this issue Nov 14, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.
anomiex added a commit to Automattic/jetpack that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.
matticbot pushed a commit to Automattic/social-logos that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-components that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-publicize-components that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/classic-theme-plugin that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-crm that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/automattic-for-agencies-client that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-storybook that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-inspect that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-forms that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-protect-plugin that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-starter-plugin that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-boost-production that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-mu-wpcom that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-backup-plugin that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-social-plugin that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-videopress-plugin that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-mu-wpcom-plugin that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/wpcom-site-helper that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-search-plugin that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
matticbot pushed a commit to Automattic/jetpack-production that referenced this issue Nov 18, 2024
* We no longer need to care about nanoid v3 thinking "browser === esm",
  because the GB package that had that dep no longer does.
* Various `jsx-a11y/label-has-associated-control` ignores referring to
  jsx-eslint/eslint-plugin-jsx-a11y#869 seem to be fixed now that #39736
  requires we use `htmlFor`. The one place still needing an ignore is
  jsx-eslint/eslint-plugin-jsx-a11y#578 instead.
* Remove reference to deleted renovate issue.
* Move reference to a Storybook bug to the code actually implementing
  the workaround.
* Update Storybook FAQ reference.
* Remove TODO references to a fixed Storybook bug (and fix a wrong prop
  in one story).
* Remove workaround for WordPress/WordPress-Coding-Standards#2390.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11896972496

Upstream-Ref: Automattic/jetpack@62e385b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants