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

Create a lint rule that restricts aria-label or aria-labelledby usage based on tag #54

Closed
khiga8 opened this issue Jun 6, 2023 · 2 comments
Labels

Comments

@khiga8
Copy link
Contributor

khiga8 commented Jun 6, 2023

We should never allow aria-label or aria-labelledby on roles that do not support it. I've noticed instances of <Text aria-label> and <Box aria-label> in the codebase, which should be flagged.

I think we could flag inappropriate aria-label misuse based on what the as is set as, the role, and the default tag for the component.

Examples of what should be flagged:

<Heading aria-label="Some text">
<Box as="p" aria-label="Some text">
<Text aria-labelledby="some-id">

eslint-plugin-jsx-a11y has limited support for linting (polymorphic) components so unfortunately we aren't getting the a11y linting we need. We could get around this with a custom rule in this plugin.

@khiga8
Copy link
Contributor Author

khiga8 commented Jul 7, 2023

I left a comment in #epic-maturing-accessibility-linting-tooling so please hold off. We might be able to take care of this with an existing rule and changes to eslint-plugin-github.

@khiga8
Copy link
Contributor Author

khiga8 commented Jul 13, 2023

This should be taken care of with the latest [eslint-plugin-github v4.9.0] which includes the rule a11y-role-supports-aria-props and added support for determining the element based off the asprop.

I am closing this, but we can re-open it if we notice otherwise. cc: @TylerJDev

@khiga8 khiga8 closed this as completed Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@lesliecdubs @khiga8 and others