Skip to content

Commit

Permalink
Add removal to item prop to grid codemod
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed Sep 17, 2024
1 parent 7723197 commit 9df5de9
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 lightProp = el.node.openingElement.attributes.find(
(attr) => attr.type === 'JSXAttribute' && attr.name.name === 'item',
);

if (lightProp) {
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 9df5de9

Please sign in to comment.