-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[codemod] Fix Divider props codemod #42919
[codemod] Fix Divider props codemod #42919
Conversation
Netlify deploy previewhttps://deploy-preview-42919--material-ui.netlify.app/ Bundle size report |
key: 'opacity', | ||
expression: j.literal('0.6'), | ||
}); | ||
if (!lightProp) { |
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.
Most of the changes above are because of the indentation change due to this early return.
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.
const isLightPropTruthy = | ||
!!lightProp.value?.expression.value || lightProp.value?.expression.value === undefined; | ||
|
||
if (!isLightPropTruthy) { |
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.
If light={false}
we already removed the prop so we don't continue with adding opacity
to the sx
prop.
packages/mui-codemod/src/deprecations/divider-props/test-cases/expected.js
Show resolved
Hide resolved
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.
Test cases looks good, didn't dig deeper into codemod implementation
@sai6855 the implementation is almost the same, just switched to early returns and added a check to do nothing in case |
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.
Yes, checked again, implementation is mostly same 👍. Reviewing codemods is always bit overwhelming 😅
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.
👍
The
divider-props
codemod (introduced in #40947) removes thelight
prop and addssx={{ opacity: 0.6 }}
if noopacity
is already passed to thesx
prop.I noticed that the codemod adds the
opacity
even whenlight={false}
, which seems wrong:The correct output should be:
This PR fixes the codemod and adds some tests cases to also cover the presence of
light: false
in theMuiDivider.defaultProps
of thetheme
object.@sai6855 let me know if my reasoning is correct.