@mui/x-codemod 6.0.5 → 6.9.0
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.
- package/package.json +5 -5
- package/util/renameIdentifiers.js +1 -1
- package/v6.0.0/data-grid/column-menu-components-rename/index.js +2 -2
- package/v6.0.0/data-grid/rename-linkOperators-logicOperators/index.js +1 -1
- package/v6.0.0/data-grid/rename-selectors-and-events/index.js +2 -2
- package/v6.0.0/pickers/adapter-change-import/index.js +1 -1
- package/v6.0.0/pickers/view-components-rename/index.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-codemod",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.9.0",
|
|
4
4
|
"bin": "./codemod.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "MUI Team",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"url": "https://opencollective.com/mui"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@babel/core": "^7.
|
|
35
|
-
"@babel/runtime": "^7.
|
|
36
|
-
"@babel/traverse": "^7.
|
|
34
|
+
"@babel/core": "^7.22.5",
|
|
35
|
+
"@babel/runtime": "^7.22.5",
|
|
36
|
+
"@babel/traverse": "^7.22.5",
|
|
37
37
|
"jscodeshift": "0.13.1",
|
|
38
38
|
"jscodeshift-add-imports": "^1.0.10",
|
|
39
|
-
"yargs": "^17.7.
|
|
39
|
+
"yargs": "^17.7.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/jscodeshift": "^0.11.5"
|
|
@@ -78,7 +78,7 @@ function renameIdentifiers({
|
|
|
78
78
|
preRequisiteUsages,
|
|
79
79
|
j
|
|
80
80
|
}) {
|
|
81
|
-
root.find(j.Identifier).filter(path =>
|
|
81
|
+
root.find(j.Identifier).filter(path => identifiers.hasOwnProperty(path.node.name)).replaceWith(path => {
|
|
82
82
|
if (!preRequisiteUsages || !preRequisiteUsages[path.node.name]) {
|
|
83
83
|
return j.importSpecifier(j.identifier(identifiers[path.node.name]));
|
|
84
84
|
}
|
|
@@ -29,12 +29,12 @@ function transformer(file, api, options) {
|
|
|
29
29
|
// Rename the import specifiers
|
|
30
30
|
// - import { GridFilterMenuItem } from '@mui/x-data-grid'
|
|
31
31
|
// + import { GridColumnMenuFilterItem } from '@mui/x-data-grid'
|
|
32
|
-
matchingImports.find(j.ImportSpecifier).filter(path =>
|
|
32
|
+
matchingImports.find(j.ImportSpecifier).filter(path => VARIABLES.hasOwnProperty(path.node.imported.name)).replaceWith(path => j.importSpecifier(j.identifier(VARIABLES[path.node.imported.name])));
|
|
33
33
|
|
|
34
34
|
// Rename the import usage
|
|
35
35
|
// - <GridFilterMenuItem />
|
|
36
36
|
// + <GridColumnMenuFilterItem />
|
|
37
|
-
root.find(j.Identifier).filter(path =>
|
|
37
|
+
root.find(j.Identifier).filter(path => VARIABLES.hasOwnProperty(path.node.name)).replaceWith(path => j.identifier(VARIABLES[path.node.name]));
|
|
38
38
|
|
|
39
39
|
// Rename `column` prop to `colDef`
|
|
40
40
|
// - <GridFilterMenuItem column={col} onClick={onClick} />
|
|
@@ -91,7 +91,7 @@ function transform(file, api, options) {
|
|
|
91
91
|
// Rename the literals
|
|
92
92
|
// - apiRef.current.getLocaleText('filterPanelLinkOperator')
|
|
93
93
|
// + apiRef.current.getLocaleText('filterPanelLogicOperator')
|
|
94
|
-
root.find(j.Literal).filter(path =>
|
|
94
|
+
root.find(j.Literal).filter(path => renamedLiterals.hasOwnProperty(path.node.value)).replaceWith(path => j.literal(renamedLiterals[path.node.value]));
|
|
95
95
|
|
|
96
96
|
// Rename the classes
|
|
97
97
|
// - 'MuiDataGrid-filterFormLinkOperatorInput'
|
|
@@ -38,14 +38,14 @@ function transformer(file, api, options) {
|
|
|
38
38
|
// Rename the import and usage of renamed selectors
|
|
39
39
|
// - import { gridSelectionStateSelector } from '@mui/x-data-grid'
|
|
40
40
|
// + import { gridRowSelectionStateSelector } from '@mui/x-data-grid'
|
|
41
|
-
root.find(j.Identifier).filter(path =>
|
|
41
|
+
root.find(j.Identifier).filter(path => renamedSelectors.hasOwnProperty(path.node.name)).replaceWith(path => j.identifier(renamedSelectors[path.node.name]));
|
|
42
42
|
|
|
43
43
|
// Rename the usage of renamed event literals
|
|
44
44
|
// - useGridApiEventHandler(apiRef, 'selectionChange', handleEvent);
|
|
45
45
|
// - apiRef.current.subscribeEvent('selectionChange', handleEvent);
|
|
46
46
|
// + useGridApiEventHandler(apiRef, 'rowSelectionChange', handleEvent);
|
|
47
47
|
// + apiRef.current.subscribeEvent('rowSelectionChange', handleEvent);
|
|
48
|
-
root.find(j.CallExpression).find(j.Literal).filter(path =>
|
|
48
|
+
root.find(j.CallExpression).find(j.Literal).filter(path => renamedEvents.hasOwnProperty(path.node.value)).replaceWith(path => j.literal(renamedEvents[path.node.value]));
|
|
49
49
|
}
|
|
50
50
|
return root.toSource(printOptions);
|
|
51
51
|
}
|
|
@@ -51,6 +51,6 @@ function transformer(file, api, options) {
|
|
|
51
51
|
// Rename the import usage
|
|
52
52
|
// - <LocalizationProvider dateAdapter={WhateverDateFns} />
|
|
53
53
|
// + <LocalizationProvider dateAdapter={AdapterDateFns} />
|
|
54
|
-
root.find(j.Identifier).filter(path =>
|
|
54
|
+
root.find(j.Identifier).filter(path => adapterVariableNames.hasOwnProperty(path.node.name)).replaceWith(path => j.identifier(adapterVariableNames[path.node.name]));
|
|
55
55
|
return root.toSource(printOptions);
|
|
56
56
|
}
|
|
@@ -61,12 +61,12 @@ function transformer(file, api, options) {
|
|
|
61
61
|
// Rename the import specifiers
|
|
62
62
|
// - import { MonthPicker } from '@mui/x-date-pickers/MonthPicker'
|
|
63
63
|
// + import { MonthCalendar } from '@mui/x-date-pickers/MonthPicker'
|
|
64
|
-
matchingImports.find(j.ImportSpecifier).filter(path =>
|
|
64
|
+
matchingImports.find(j.ImportSpecifier).filter(path => VARIABLES.hasOwnProperty(path.node.imported.name)).replaceWith(path => j.importSpecifier(j.identifier(VARIABLES[path.node.imported.name])));
|
|
65
65
|
|
|
66
66
|
// Rename the nested import declarations
|
|
67
67
|
// - import {} from '@mui/x-date-pickers/MonthPicker'
|
|
68
68
|
// + import {} from '@mui/x-date-pickers/MonthCalendar'
|
|
69
|
-
matchingImports.filter(path =>
|
|
69
|
+
matchingImports.filter(path => SUB_PACKAGES.hasOwnProperty(matchImport(path)?.[3] ?? '')).replaceWith(path => {
|
|
70
70
|
const subPackage = matchImport(path)[3];
|
|
71
71
|
const importPath = path.node.source.value?.toString() ?? '';
|
|
72
72
|
return j.importDeclaration(path.node.specifiers,
|
|
@@ -78,6 +78,6 @@ function transformer(file, api, options) {
|
|
|
78
78
|
// Rename the import usage
|
|
79
79
|
// - <CalendarPicker />
|
|
80
80
|
// + <DateCalendar />
|
|
81
|
-
root.find(j.Identifier).filter(path =>
|
|
81
|
+
root.find(j.Identifier).filter(path => VARIABLES.hasOwnProperty(path.node.name)).replaceWith(path => j.identifier(VARIABLES[path.node.name]));
|
|
82
82
|
return root.toSource(printOptions);
|
|
83
83
|
}
|