-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix/babel plugin emotion function object crash #2585
Fix/babel plugin emotion function object crash #2585
Conversation
returned by a function
🦋 Changeset detectedLatest commit: cd6bb15 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit cd6bb15:
|
Codecov Report
|
@@ -137,7 +148,7 @@ function getDeclaratorName(path, t) { | |||
} | |||
|
|||
let variableDeclarator = parent.findParent(p => p.isVariableDeclarator()) | |||
if (!variableDeclarator) { | |||
if (!variableDeclarator || !variableDeclarator.get('id').isIdentifier()) { |
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.
@kddc this was the more appropriate fix. The isArrowFunctionExpression
block that you have introduced has covered the introduced test case but I believe that it was more about improving label extraction for this specific case than about fixing a crash (the latter was a byproduct of the former though, in that scenario).
By patching the underlying issue here I've managed to also fixed the weird test case introduced as no-label-obj-pattern-computed-property
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.
@Andarist Awesome - that's even better then :)
b0787c1
to
cd6bb15
Compare
@kddc thank you very much for the PR! this means a lot ❤️ |
What:
Fix the babel plugin crashing when facing objects with multiple emotion classes where some of them are arrow functions and adding the correct labels to the classes.
Why:
We have something like this in our code
When the babel plugin processes the arrow function inside of it, it crashes with
TypeError: Cannot read properties of undefined (reading 'charAt')
, as it can not find a declaratorName for the function in thelabel.js
file.How:
The
getDeclaratorName
method checked for parents that could be of typeArrowFunctionExpression
, but this was not handled inside the body of this function. I check the parents parent in this case using the existinggetDeclaratorName
method.Checklist: