Skip to content

Control has associated label #515

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

Merged

Conversation

jessebeach
Copy link
Collaborator

@jessebeach jessebeach commented Dec 27, 2018

This rule is the inverse of label-has-associated-control.

Check the Markdown file for details of the rule.

It's intended to catch unlabelled buttons, checkboxes, radios, menuitems, options, etc. I did a bunch of QA work to finagle the configs so that the output is actionable.

The danger here is that we encourage developers to put labels on things like containers, which really shouldn't be labelled. The exceptions to that rule are dialogs and alerts, but I opened a new issue to write a rule for those: #516

There really isn't a difference between the behavior of recommended and strict, so I made the configs the same for both.

@jessebeach jessebeach force-pushed the control-has-associated-label branch from defcc00 to 3544dfd Compare December 27, 2018 00:51
@coveralls
Copy link

Coverage Status

Coverage increased (+0.004%) to 99.445% when pulling 3544dfd on jessebeach:control-has-associated-label into e53906d on evcohen:master.

@coveralls
Copy link

coveralls commented Dec 27, 2018

Coverage Status

Coverage increased (+0.01%) to 99.457% when pulling 5650674 on jessebeach:control-has-associated-label into 9924d03 on evcohen:master.

@jessebeach jessebeach force-pushed the control-has-associated-label branch 4 times, most recently from 98c8398 to 4833376 Compare December 28, 2018 01:22
@jessebeach
Copy link
Collaborator Author

Should we enforce a label on canvas, audio and video tags?

@jessebeach
Copy link
Collaborator Author

I'm testing the rule on the FB codebase right now and fine-tuning it. It's over-capturing a little.

@ljharb
Copy link
Member

ljharb commented Dec 28, 2018

It seems like maybe the default should be to enforce a label on everything, but maybe have an option to ignore input types that aren't that important to label, like canvas/audio/video?

@jessebeach jessebeach force-pushed the control-has-associated-label branch 2 times, most recently from 7d3bf8a to cf98d68 Compare December 28, 2018 22:54
@jessebeach
Copy link
Collaborator Author

The results from my internal tests look good. About 250 errors over ~70K files. Keep in mind that we've done a TON of work to ferret out unlabelled elements. These represent the ones that we had no signal for.

I just need to fill out the control-has-associated-label.md file and this rule should be good to go.

@jessebeach
Copy link
Collaborator Author

I'm finding lots of juicy examples where all the rules in the plugin have been followed except that the element doesn't have a label. This is the last step!

@jessebeach jessebeach force-pushed the control-has-associated-label branch 2 times, most recently from 38f9fbc to a3fa108 Compare December 29, 2018 02:55
@jessebeach
Copy link
Collaborator Author

@ljharb @evcohen thoughts on merging this new rule in? I ran it over the FB codebase and the results are great. Fixable and accurate.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems great. It'd be ideal to rebase this first, so there's no merge commits, but otherwise let's merge, and cut a minor release :-D

@jessebeach jessebeach force-pushed the control-has-associated-label branch from ca14de5 to 5650674 Compare January 24, 2019 01:58
@jessebeach jessebeach merged commit ead1767 into jsx-eslint:master Jan 24, 2019
@jessebeach jessebeach deleted the control-has-associated-label branch January 24, 2019 02:17
@keithmadden-toast
Copy link

@jessebeach Wasn't sure if I should open an issue for this but this PR adds control-has-associated-label to recommended & strict modes but only disables label-has-for for recommended. Is that the intended behaviour? I'm happy to create a follow-up PR if not 🙂

@backwardok
Copy link
Collaborator

Hey @jessebeach ! I was looking through some of the rules that exist and I noticed that this rule isn't enabled for either recommended or strict. Was that intended? I mostly ask because the Airbnb config uses it and I was surprised it wasn't listed on the README as an available rule

@ljharb
Copy link
Member

ljharb commented Mar 25, 2021

@backwardok adding a new rule to a builtin config is a breaking change, so it's planned for whenever we end up doing a semver-major bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants