@mui/x-codemod 6.0.4 → 6.2.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-codemod",
3
- "version": "6.0.4",
3
+ "version": "6.2.1",
4
4
  "bin": "./codemod.js",
5
5
  "private": false,
6
6
  "author": "MUI Team",
@@ -25,15 +25,15 @@
25
25
  "directory": "packages/x-codemod"
26
26
  },
27
27
  "license": "MIT",
28
- "homepage": "https://github.com/mui/mui-x/blob/-/packages/x-codemod",
28
+ "homepage": "https://github.com/mui/mui-x/tree/master/packages/x-codemod",
29
29
  "funding": {
30
30
  "type": "opencollective",
31
31
  "url": "https://opencollective.com/mui"
32
32
  },
33
33
  "dependencies": {
34
- "@babel/core": "^7.21.3",
34
+ "@babel/core": "^7.21.4",
35
35
  "@babel/runtime": "^7.21.0",
36
- "@babel/traverse": "^7.21.3",
36
+ "@babel/traverse": "^7.21.4",
37
37
  "jscodeshift": "0.13.1",
38
38
  "jscodeshift-add-imports": "^1.0.10",
39
39
  "yargs": "^17.7.1"
@@ -78,7 +78,7 @@ function renameIdentifiers({
78
78
  preRequisiteUsages,
79
79
  j
80
80
  }) {
81
- root.find(j.Identifier).filter(path => !!identifiers[path.node.name]).replaceWith(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 => !!VARIABLES[path.node.imported.name]).replaceWith(path => j.importSpecifier(j.identifier(VARIABLES[path.node.imported.name])));
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 => !!VARIABLES[path.node.name]).replaceWith(path => j.identifier(VARIABLES[path.node.name]));
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 => !!renamedLiterals[path.node.value]).replaceWith(path => j.literal(renamedLiterals[path.node.value]));
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 => !!renamedSelectors[path.node.name]).replaceWith(path => j.identifier(renamedSelectors[path.node.name]));
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 => !!renamedEvents[path.node.value]).replaceWith(path => j.literal(renamedEvents[path.node.value]));
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 => !!adapterVariableNames[path.node.name]).replaceWith(path => j.identifier(adapterVariableNames[path.node.name]));
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 => !!VARIABLES[path.node.imported.name]).replaceWith(path => j.importSpecifier(j.identifier(VARIABLES[path.node.imported.name])));
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 => !!SUB_PACKAGES[matchImport(path)?.[3] ?? '']).replaceWith(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 => !!VARIABLES[path.node.name]).replaceWith(path => j.identifier(VARIABLES[path.node.name]));
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
  }