-
Notifications
You must be signed in to change notification settings - Fork 842
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
ESLint rule to detect forwardRef components without display name #3451
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
Did a quick search and re-discovered an existing eslint rule that's already part of the react/ rules: The rule can be disabled for |
@chandlerprall Thanks for the suggestion. I tried adding But it couldn't find Am I doing something wrong? |
Ugh, good catch! Had to dig into the eslint rule's code to figure out why, ultimately this declaration was being triggered for saturation.tsx but not color_picker_swatch.tsx https://github.com/yannickcr/eslint-plugin-react/blob/master/lib/rules/display-name.js#L84-L89 Turns out, any component containing the pattern
This appears to try and understand an old way of defining React components,
which does/did automatically get a displayName. But, wow. At this point, I'd much prefer this PR's existing solution with a custom eslint rule. @thompsongl any thoughts? (FWIW - the react/display-name rule does have a configuration flag to disable it trying to understand auto-generated display names, but toggling that flags a lot of our code base, and most of those do actually get a displayName value during transpilation) |
I'm with you on this. It may require some maintenance, but we get exactly what we need. |
@chandlerprall Thanks for the review. Changes committed 👍 |
jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3451/ |
CI flagged a number of other components missing display names
|
@chandlerprall The issue was with the rule. I think I missed it due to the cache. Fixed 👍 |
jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3451/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM! 🎉
Summary
Fixes #3441
forwardRef
components withoutdisplayName
forwardRef
components withoutdisplayName
Checklist
- [ ] Check against all themes for compatibility in both light and dark modes- [ ] Checked in mobile- [ ] Checked in IE11 and Firefox- [ ] Props have proper autodocs- [ ] Added documentation examples- [ ] Added or updated jest tests- [ ] Checked for accessibility including keyboard-only and screenreader modes