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

Add a11y-use-next-tooltip rule #103

Merged
merged 19 commits into from
Jul 18, 2024
Merged

Add a11y-use-next-tooltip rule #103

merged 19 commits into from
Jul 18, 2024

Conversation

broccolinisoup
Copy link
Member

@broccolinisoup broccolinisoup commented Oct 20, 2023

Closes #114
As a part of Tooltip adoption discussion, we decided to introduce an eslint rule that recommends switch over to the Tooltip v2 which will be released under the primer/react/next bundle based on the naming discussion.

The rule also suggests fixes to update the import from @primer/react to @primer/react/next as well as updating the prop name from aria-label to text

@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2023

🦋 Changeset detected

Latest commit: 1bfbc8a

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 Minor

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

category: 'Best Practices',
recommended: true,
},
fixable: null,
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 didn't add a fix option that updates the path from @primer/react to @primer/react/next because most of the time, Tooltip component itself will require updates as well. Let me know if you have a thought though!

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe its still ok to fix. Any lessening of manual work is welcome right?

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 think so! My only concern is that if we provide a fix to update the path, would it give an impression that "you are done and good to go"? Because after fixing the path, in many cases Tooltip will need an update too (i.e. aria-labeltext or adding type="description" etc)

Copy link
Contributor

Choose a reason for hiding this comment

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

ok cool 👍 we can add it if someone requests it

Copy link
Member

Choose a reason for hiding this comment

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

in many cases Tooltip will need an update too (i.e. aria-label → text or adding type="description" etc)

Will the typescript compiler warn about those issues?

Bonus: Can aria-label → text also be fixed by the linter? 😇

Copy link
Member Author

Choose a reason for hiding this comment

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

(We chatted about these questions in our call with Sid, writing here for visibility)

Will the typescript compiler warn about those issues?

It does now :) With making the text prop required. primer/react#3925

Bonus: Can aria-label → text also be fixed by the linter? 😇

😇 I'm working on it to see if it is feasible to update the path as well as aria-label > text in one rule.

If anyone has any idea, thoughts, I'd love to hear 🙏🏻

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like it worked

@broccolinisoup broccolinisoup marked this pull request as ready for review October 20, 2023 01:35
Copy link
Contributor

@pksjce pksjce left a comment

Choose a reason for hiding this comment

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

I leave it upto you to decide if you want to make this lint rule generic or not.
One edge case I can think of is, if we have multiple components to lint for, will the variable system work correctly in that case?

docs/rules/use-next-tooltip.md Outdated Show resolved Hide resolved
ruleTester.run('use-next-tooltip', rule, {
valid: [
`import {Tooltip} from '@primer/react/next'`,
`import {UnderlineNav, Button} from '@primer/react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we need this line of code too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably not 😆 I was just adding examples to replicate real life cases but if it is confusing or you think it doesn't seem very related, I can totally remove it.

category: 'Best Practices',
recommended: true,
},
fixable: null,
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe its still ok to fix. Any lessening of manual work is welcome right?

Copy link
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

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

Looks good!

I leave it upto you to decide if you want to make this lint rule generic or not.

Same same :)

@broccolinisoup broccolinisoup changed the title Add use-next-tooltip rule Add a11y-use-next-tooltip rule Jul 5, 2024
@broccolinisoup broccolinisoup merged commit 8617a66 into main Jul 18, 2024
8 checks passed
@broccolinisoup broccolinisoup deleted the bs/rule-for-tooltip-v2 branch July 18, 2024 04:44
@primer-css primer-css mentioned this pull request Jul 18, 2024
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.

Create an eslint rule that suggest using the new accessible Tooltip
4 participants