[mui-codemod] Fix findComponentJSX util#40855
Merged
DiegoAndai merged 2 commits intomui:masterfrom Jan 31, 2024
Merged
Conversation
Netlify deploy previewhttps://deploy-preview-40855--material-ui.netlify.app/ Bundle size report |
DiegoAndai
reviewed
Jan 31, 2024
Member
DiegoAndai
left a comment
There was a problem hiding this comment.
Thanks for catching this @sai6855
Comment on lines
+20
to
+23
| .filter( | ||
| (path) => | ||
| path.node.source.value.match(new RegExp(`^@mui/material/(${componentName})`)) || | ||
| path.node.source.value === '@mui/material', |
Member
There was a problem hiding this comment.
We can make it simpler:
Suggested change
| .filter( | |
| (path) => | |
| path.node.source.value.match(new RegExp(`^@mui/material/(${componentName})`)) || | |
| path.node.source.value === '@mui/material', | |
| .filter((path) => | |
| path.node.source.value.match(new RegExp(`^@mui/material(/${componentName})?$`)), |
It's the same as your fix, as $ indicates to match the end of the line, so it's either
- string start (
^) ->@mui/material-> string end ($) - string start (
^) ->@mui/material/componentName-> string end ($)
Member
Author
There was a problem hiding this comment.
Thanks for clear explaination. fixed in this commit 8b714f8
Member
There was a problem hiding this comment.
Nice! Did you test if it's fixed on your side after the refactor?
Member
Author
There was a problem hiding this comment.
Yes, ran codemod script. Now util is filtering out data correctly
DiegoAndai
approved these changes
Jan 31, 2024
mostafa-rio
pushed a commit
to mostafa-rio/material-ui
that referenced
this pull request
Feb 3, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
How to test the fix
console.log(elementPath.node.openingElement.name.name);below this linematerial-ui/packages/mui-codemod/src/deprecations/accordion-props/accordion-props.js
Line 14 in 97f225c
node packages/mui-codemod/codemod deprecations/accordion-props packages/mui-codemod/src/deprecations/accordion-props/test-cases/actual.jsAccordion2 times, everything is good until nowcomponentName: "Accordion"tocomponentName: "sank" (or any random value)on this line and runnode packages/mui-codemod/codemod deprecations/accordion-props packages/mui-codemod/src/deprecations/accordion-props/test-cases/actual.jsAccordionagain 2 times, as per my understandingfindComponentJSXfunction should filter out components which matches withcomponentNamebut i don't think that's the case now. This PR fixes itNote: I'm really new to
codemodsandRegex, apologies in advance if my understanding or logic is wrong