Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[codemod] Fix system props default import specifier #44170

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(/\(.*\)/),
aarongarciah marked this conversation as resolved.
Show resolved Hide resolved
},
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
Loading