Skip to content

Commit

Permalink
[Grid2] Add removal of item prop to grid-v2-props codemod (#43794)
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 authored Sep 17, 2024
1 parent e941175 commit 52b99cd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/mui-codemod/src/v6.0.0/grid-v2-props/grid-v2-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ export default function gridV2Props(file, api, options) {
el.node.openingElement.attributes = el.node.openingElement.attributes.filter(
(attr) => !attributesToPrune.includes(attr),
);

const itemProp = el.node.openingElement.attributes.find(
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'item',
);

if (itemProp) {
el.node.openingElement.attributes = el.node.openingElement.attributes.filter(
(attr) => attr.type === 'JSXAttribute' && attr.name.name !== 'item',
);
}
});

return root.toSource(printOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import { Grid as GridF } from '@mui/joy';
<GridE xs={2} />;
<GridF xs={2} />;

<GridA item />;
<GridA item={true} />;
<GridA item={false} />;

// Transforms responsive sizes
<GridA xs={2} sm={4} md={6} lg={8} xl={10} />;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import { Grid as GridF } from '@mui/joy';
<GridE size={2} />;
<GridF size={2} />;

<GridA />;
<GridA />;
<GridA />;

// Transforms responsive sizes
<GridA
size={{
Expand Down

0 comments on commit 52b99cd

Please sign in to comment.