Skip to content

Commit 5bb5a98

Browse files
authored
[Grid2] Add removal zeroMinWidth prop to codemod (#44178)
1 parent 1c7f61f commit 5bb5a98

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

packages/mui-codemod/src/v6.0.0/grid-v2-props/grid-v2-props.js

+10
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ export default function gridV2Props(file, api, options) {
202202
(attr) => attr.type === 'JSXAttribute' && attr.name.name !== 'item',
203203
);
204204
}
205+
206+
const zeroMinWidthProp = el.node.openingElement.attributes.find(
207+
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'zeroMinWidth',
208+
);
209+
210+
if (zeroMinWidthProp) {
211+
el.node.openingElement.attributes = el.node.openingElement.attributes.filter(
212+
(attr) => attr.type === 'JSXAttribute' && attr.name.name !== 'zeroMinWidth',
213+
);
214+
}
205215
});
206216

207217
return root.toSource(printOptions);

packages/mui-codemod/src/v6.0.0/grid-v2-props/test-cases/actual.js

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import { Grid as GridF } from '@mui/joy';
1818
<GridA item={true} />;
1919
<GridA item={false} />;
2020

21+
<GridA zeroMinWidth />;
22+
<GridA zeroMinWidth={true} />;
23+
<GridA zeroMinWidth={false} />;
24+
2125
// Transforms responsive sizes
2226
<GridA xs={2} sm={4} md={6} lg={8} xl={10} />;
2327

packages/mui-codemod/src/v6.0.0/grid-v2-props/test-cases/expected.js

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import { Grid as GridF } from '@mui/joy';
1818
<GridA />;
1919
<GridA />;
2020

21+
<GridA />;
22+
<GridA />;
23+
<GridA />;
24+
2125
// Transforms responsive sizes
2226
<GridA
2327
size={{

0 commit comments

Comments
 (0)