feat: implement includeRoles option for control-has-associated-label rule#1083
Open
rdcrampton wants to merge 1 commit intojsx-eslint:mainfrom
Open
feat: implement includeRoles option for control-has-associated-label rule#1083rdcrampton wants to merge 1 commit intojsx-eslint:mainfrom
rdcrampton wants to merge 1 commit intojsx-eslint:mainfrom
Conversation
…rule The includeRoles option was configured in both recommended and strict configs but never implemented in the rule logic, causing elements with alert and dialog roles to silently skip the label check. Fixes jsx-eslint#1072
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
includeRolesoption for thecontrol-has-associated-labelrule, which was configured in both recommended and strict configs (includeRoles: ['alert', 'dialog']) but never actually implemented in the rule logicincludeRolesnow correctly require an accessible text labelFixes #1072
Changes
includeRolesto the rule's JSON schemaincludeRolesfrom rule options with[]defaultnodeIsIncludedRolecheck usingincludes(includeRoles, role)to the condition that triggers label validationalert/dialogentries fromalwaysValidtoneverValid, added labeled valid cases, addedno-configcoverage, and added a dedicatedincludeRolestest sectionincludeRolesoption description and exampleDesign decisions
ignoreRolestakes precedence overincludeRoles(checked first via early return) — explicit ignore winsisDOMElement— custom components like<MyAlert role="alert" />also require labels, consistent withcontrolComponentsbehavioraria-hidden="true") still excluded — checked beforeincludeRolesTest plan
npm run test)npm run lint)npm run flow)alert/dialogwithout labels now correctly flaggedalert/dialogwithout labels remain valid (noincludeRolesset)includeRolestests cover valid (labeled), invalid (unlabeled), and non-matching roles