Skip to content

Commit

Permalink
[codemod] Fix system props default import specifier (#44170)
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp authored Oct 28, 2024
1 parent c4b48a6 commit 16c974c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ export default function removeSystemProps(file, api, options) {
matcher: (key, val) =>
key !== 'color' ||
(val.value?.includes('.') && val.value !== 'inherit') ||
val.value === 'divider',
val.value === 'divider' ||
val.value.startsWith('#') ||
val.value.match(/\(.*\)/),
},
Link: {
matcher: (key) => key !== 'color',
Expand All @@ -162,8 +164,12 @@ export default function removeSystemProps(file, api, options) {
.forEach((decl) => {
decl.node.specifiers.forEach((spec) => {
if (spec.type === 'ImportSpecifier') {
if (components.includes(spec.imported.name)) {
const name = spec.imported.name;
if (components.includes(name)) {
deprecatedElements.push(spec.local.name);
if (customReplacement[name]) {
elementReplacement[spec.local.name] = customReplacement[name];
}
}
}
if (spec.type === 'ImportDefaultSpecifier') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box as Boxxx, Grid as Griddd, Grid2 as Griddd2 } from '@mui/material';
import Typography from '@mui/material/Typography';
import Typographyyy from '@mui/material/Typography';
import Stackkk from '@mui/material/Stack';

Expand All @@ -10,6 +11,8 @@ import Stackkk from '@mui/material/Stack';

const sx = { display: 'flex' };
const ml = 2;
<Typography color="#fff" mb={5} />;
<Typography color="hsl(200 30% 30%)" mb={5} />;
<Typographyyy variant="body1" color="primary.main" ml={ml} sx={sx} />;
<Typographyyy variant="body1" color="divider" ml={ml} sx={sx} />;
<Typographyyy variant="body1" color="inherit" ml={ml} sx={sx} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box as Boxxx, Grid as Griddd, Grid2 as Griddd2 } from '@mui/material';
import Typography from '@mui/material/Typography';
import Typographyyy from '@mui/material/Typography';
import Stackkk from '@mui/material/Stack';

Expand All @@ -20,6 +21,16 @@ import Stackkk from '@mui/material/Stack';

const sx = { display: 'flex' };
const ml = 2;
<Typography
sx={{
color: "#fff",
mb: 5
}} />;
<Typography
sx={{
color: "hsl(200 30% 30%)",
mb: 5
}} />;
<Typographyyy
variant="body1"
sx={[{
Expand Down

0 comments on commit 16c974c

Please sign in to comment.