@mui/codemod 6.0.1 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -41,6 +41,7 @@ function transformer(file, api, options) {
|
|
|
41
41
|
});
|
|
42
42
|
const openTaggedNotHavingButtonProp = new Set();
|
|
43
43
|
const openTaggedHavingButtonProp = new Set();
|
|
44
|
+
let addedListItemButton = false;
|
|
44
45
|
// Rename components that have ListItem button to ListItemButton
|
|
45
46
|
(0, _findComponentJSX.default)(j, {
|
|
46
47
|
root,
|
|
@@ -50,6 +51,7 @@ function transformer(file, api, options) {
|
|
|
50
51
|
// The ListItem has a button prop
|
|
51
52
|
if (index !== -1) {
|
|
52
53
|
openTaggedHavingButtonProp.add(elementPath.node.openingElement.name.name);
|
|
54
|
+
addedListItemButton = true;
|
|
53
55
|
elementPath.node.openingElement.name.name = `ListItemButton`;
|
|
54
56
|
elementPath.node.openingElement.attributes.splice(index, 1);
|
|
55
57
|
} else {
|
|
@@ -81,9 +83,10 @@ function transformer(file, api, options) {
|
|
|
81
83
|
}
|
|
82
84
|
return false;
|
|
83
85
|
}).remove();
|
|
84
|
-
|
|
86
|
+
|
|
87
|
+
// If ListItemButton import does not already exist, add it at the end
|
|
85
88
|
const imports = root.find(j.ImportDeclaration).filter(path => path.node.source.value === '@mui/material/ListItemButton');
|
|
86
|
-
if (imports.length === 0) {
|
|
89
|
+
if (addedListItemButton && imports.length === 0) {
|
|
87
90
|
const lastImport = root.find(j.ImportDeclaration).at(-1);
|
|
88
91
|
|
|
89
92
|
// Insert the import for 'ListItemButton' after the last import declaration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/codemod",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"bin": "./codemod.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "MUI Team",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"@babel/traverse": "^7.25.3",
|
|
30
30
|
"jscodeshift": "^0.16.1",
|
|
31
31
|
"jscodeshift-add-imports": "^1.0.11",
|
|
32
|
-
"postcss": "^8.4.
|
|
32
|
+
"postcss": "^8.4.44",
|
|
33
33
|
"postcss-cli": "^11.0.0",
|
|
34
34
|
"yargs": "^17.7.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/chai": "^4.3.
|
|
37
|
+
"@types/chai": "^4.3.19",
|
|
38
38
|
"@types/jscodeshift": "0.11.11",
|
|
39
39
|
"chai": "^4.5.0"
|
|
40
40
|
},
|