-
Notifications
You must be signed in to change notification settings - Fork 844
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
[Docs only] Various fixes/cleanups with demo code imports #5641
Conversation
b08b3c8
to
a473452
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_5641/ |
Also, was the order of the React imports vs EUI imports ever discussed in #5533? Maybe it's just what I'm familiar with, but it feels odd to have EUI first, then React especially since EUI depends on React. Didn't know if there might be a quick fix for this. |
@chandlerprall Any thoughts on Caroline's comments above? I have no strong feelings either way personally, I can kind of follow the reasoning that since EUI is the primary library that the demo code is intending to show, it's fine that the EUI imports come first. But like I said, I don't super mind either way and it would be a relatively quick change. |
This wasn't something that was originally discussed and likely happened because I didn't change the order of the original logic in this file, I just cleaned it up. I don't think I have any strong feelings either way and would be fine with the order change. |
I've no strong feelings either, but I do prefer importing react first. Would be a nice change if it's quick & straightforward 👍 |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5641/ |
…roperly grouped with other imports
- remove unnecessary escapes - remove unnecessary catches for multiple spaces - prettier will fix those
- it's unlikely, but otherwise the code outputs `import { } from '@elastic/eui';` which we don't want
…orts that come before
Preview documentation changes for this PR: https://eui.elastic.co/pr_5641/ |
…(??) - c4329bc hadn't fixed every edge case/import permutation, so I wrote some unit tests to make sure I'd fully captured everything
welp, this was a pretty textbook case of going down a rabbit hole 🐰 I went a little extra and wrote unit tests for this file since it was getting pretty complex. @chandlerprall any chance you can help me out with running |
the rabbit hole goes deeper...
Preview documentation changes for this PR: https://eui.elastic.co/pr_5641/ |
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.
This looks good to me! Thank you for adding tests for the utils file. It's become more complex with our recent changes, so the tests are a great addition!
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.
LGTM! Tested in the preview, changes look like they apply as desired in the Demo TS tab, and the codesandbox initial file now opens correctly too.
Holding off on an approval until the local test configuration is updated (talked about the potential fix over zoom), but wanted to get everything else out of the way.
…ocs/ + configure Jest to look at src-docs components
- needed to dedent both texts, not just one
); | ||
baseConfig.plugins.splice( | ||
index + 1, | ||
0, | ||
'./scripts/babel/react-docgen-typescript' | ||
`${__dirname}/../scripts/babel/react-docgen-typescript` |
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.
@chandlerprall I have no idea why this works but I cribbed it from parcel-bundler/parcel#1698 (comment) and it seems to solve the broken Jest tests 🙈 I also don't really know why this one needs ../
and the previous one doesn't, hahaa
FWIW though I ran yarn start
, yarn test-unit
, and yarn build-pack
and all of them ran with no errors with this change (and the new regex unit tests do show up as expected in yarn test-unit
🎉)
Preview documentation changes for this PR: https://eui.elastic.co/pr_5641/ |
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.
Confirmed the src-docs test is detected & executed,
If this causes unexpected babel shenanigans down the line please do feel free to blame/ping (bling, if you will) me! |
Summary
List of fixes/improvements in this PR:
@emotion/react
as a valid importImport comment fix
Certain 3rd-party imports had location-sensitive comments directly above them, e.g.
// @ts-ignore
or// eslint-disable
. Those comments were not getting caught by our new import regex added in #5533 and were falling out of order.Example: https://elastic.github.io/eui/#/tabular-content/data-grid-ref-methods (click on Demo TS tab)
Before
After
Checklist