ESLint rule to detect forwardRef components without display name#3451
ESLint rule to detect forwardRef components without display name#3451chandlerprall merged 12 commits intoelastic:masterfrom
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/ |
Summary
Fixes #3441
forwardRefcomponents withoutdisplayNameforwardRefcomponents withoutdisplayNameChecklist
- [ ] 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