Skip to content

Commit

Permalink
[codemod] Leave numeric arguments to breakpoints functions unchanged
Browse files Browse the repository at this point in the history
- The codemod was previously changing numeric values to `undefined`
  • Loading branch information
ryancogswell committed Apr 23, 2022
1 parent af81aae commit 32b72af
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/mui-codemod/src/v5.0.0/theme-breakpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export default function transformer(file, api, options) {
})
.forEach((path) => {
path.node.arguments.forEach((node) => {
node.value = map[node.value];
const replacementValue = map[node.value];
if (replacementValue !== undefined) {
node.value = replacementValue;
}
});
});

Expand All @@ -36,7 +39,10 @@ export default function transformer(file, api, options) {
})
.forEach((path) => {
const node = path.node.arguments[1];
node.value = map[node.value];
const replacementValue = map[node.value];
if (replacementValue !== undefined) {
node.value = replacementValue;
}
});

return root.toSource(printOptions);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
theme.breakpoints.down('sm')
theme.breakpoints.down('xl')
theme.breakpoints.down(360)
theme.breakpoints.between('sm', 'md')
theme.breakpoints.between('sm', 'xl')
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
theme.breakpoints.down('md')
theme.breakpoints.down('xl')
theme.breakpoints.down(360)
theme.breakpoints.between('sm', 'lg')
theme.breakpoints.between('sm', 'xl')

0 comments on commit 32b72af

Please sign in to comment.