Skip to content

Add new rule a11y-no-title-usage #316

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
merged 7 commits into from
Feb 13, 2025

Conversation

TylerJDev
Copy link
Member

@TylerJDev TylerJDev commented Feb 13, 2025

Adds new rule a11y-no-title-usage.

This rule recommends that consumers do not utilize the title attribute with the RelativeTime component. This attribute is inherent to the component, so adding the prop noTitle is currently necessary.

The suggested paths for remediating violations found through this rule are:

  • Utilize the Primer Tooltip in with an interactive element
  • Place the title date adjacent or near the RelativeTime component
  • Remove title if it isn't needed

Questions for reviewers:

  • This rule is mainly for relative-time-element, so should the name reference relative-time-element?
  • The goal is that this rule will eventually no longer be needed and we can deprecate it. noTitle will also be deprecated
  • Is there anything else we should look out for?

Context: https://github.com/github/primer/issues/4769

Copy link

changeset-bot bot commented Feb 13, 2025

🦋 Changeset detected

Latest commit: 0c278b7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-primer-react Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@TylerJDev TylerJDev self-assigned this Feb 13, 2025
@TylerJDev TylerJDev marked this pull request as ready for review February 13, 2025 16:01
@TylerJDev TylerJDev requested a review from a team as a code owner February 13, 2025 16:01
const App = () => <RelativeTime date={new Date('2020-01-01T00:00:00Z')} />
```

The `noTitle` attribute can be omitted because its default value is `true` internally.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe "The noTitle attribute is true by default, so it can be omitted." is a bit easier to read? Just nit picking here

Copy link
Member Author

Choose a reason for hiding this comment

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

I like this, your suggestion reads better! Thank you 😄


The `noTitle` attribute can be omitted because its default value is `true` internally.

## With alternative tooltip
Copy link
Contributor

Choose a reason for hiding this comment

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

Great to have this example ❤️

Copy link
Contributor

@khiga8 khiga8 left a comment

Choose a reason for hiding this comment

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

Very nice ✨

@TylerJDev TylerJDev merged commit 40016c8 into main Feb 13, 2025
8 checks passed
@TylerJDev TylerJDev deleted the tylerjdev/add-a11y-no-title-usage-rule branch February 13, 2025 18:23
@primer-css primer-css mentioned this pull request Feb 13, 2025
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

Successfully merging this pull request may close these issues.

3 participants