@mui/x-codemod 8.0.0-beta.0 → 8.0.0-beta.3
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/README.md +103 -1
- package/package.json +5 -5
- package/v8.0.0/data-grid/add-showToolbar-prop/index.js +60 -0
- package/v8.0.0/data-grid/preset-safe/index.js +8 -0
- package/v8.0.0/data-grid/reform-row-selection-model/index.js +47 -0
- package/v8.0.0/data-grid/remove-props/index.js +1 -1
- package/v8.0.0/data-grid/rename-imports/index.js +28 -0
- package/v8.0.0/data-grid/rename-package/index.js +34 -0
- package/v8.0.0/data-grid/rename-package/rename-package.js +33 -0
- package/v8.0.0/data-grid/rename-props/index.js +8 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Options:
|
|
|
29
29
|
--jscodeshift Pass options directly to jscodeshift [array]
|
|
30
30
|
|
|
31
31
|
Examples:
|
|
32
|
-
npx @mui/x-codemod@next
|
|
32
|
+
npx @mui/x-codemod@next v8.0.0/preset-safe src
|
|
33
33
|
npx @mui/x-codemod@next v6.0.0/component-rename-prop src --
|
|
34
34
|
--component=DataGrid --from=prop --to=newProp
|
|
35
35
|
```
|
|
@@ -326,6 +326,10 @@ The list includes these transformers
|
|
|
326
326
|
- [`remove-stabilized-v8-experimentalFeatures`](#remove-stabilized-v8-experimentalFeatures)
|
|
327
327
|
- [`remove-props`](#remove-props)
|
|
328
328
|
- [`rename-props`](#rename-props)
|
|
329
|
+
- [`rename-imports`](#rename-imports)
|
|
330
|
+
- [`reform-row-selection-model`](#reform-row-selection-model)
|
|
331
|
+
- [`rename-package`](#rename-package)
|
|
332
|
+
- [`add-showToolbar-prop`](#add-showToolbar-prop)
|
|
329
333
|
|
|
330
334
|
#### `remove-stabilized-v8-experimentalFeatures`
|
|
331
335
|
|
|
@@ -353,11 +357,13 @@ The list includes these props:
|
|
|
353
357
|
|
|
354
358
|
- `indeterminateCheckboxAction`
|
|
355
359
|
- `rowPositionsDebounceMs`
|
|
360
|
+
- `resetPageOnSortFilter`
|
|
356
361
|
|
|
357
362
|
```diff
|
|
358
363
|
<DataGrid
|
|
359
364
|
- indeterminateCheckboxAction="deselect"
|
|
360
365
|
- rowPositionsDebounceMs={100}
|
|
366
|
+
- resetPageOnSortFilter
|
|
361
367
|
/>
|
|
362
368
|
```
|
|
363
369
|
|
|
@@ -374,11 +380,32 @@ Rename props to the new ones.
|
|
|
374
380
|
The list includes these props:
|
|
375
381
|
|
|
376
382
|
- `unstable_rowSpanning` to `rowSpanning`
|
|
383
|
+
- `unstable_dataSource` to `dataSource`
|
|
384
|
+
- `unstable_dataSourceCache` to `dataSourceCache`
|
|
385
|
+
- `unstable_lazyLoading` to `lazyLoading`
|
|
386
|
+
- `unstable_lazyLoadingRequestThrottleMs` to `lazyLoadingRequestThrottleMs`
|
|
387
|
+
- `unstable_onDataSourceError` to `onDataSourceError`
|
|
388
|
+
- `unstable_listView` to `listView`
|
|
389
|
+
- `unstable_listColumn` to `listViewColumn`
|
|
377
390
|
|
|
378
391
|
```diff
|
|
379
392
|
<DataGrid
|
|
380
393
|
- unstable_rowSpanning
|
|
394
|
+
- unstable_dataSource={dataSource}
|
|
395
|
+
- unstable_dataSourceCache={dataSourceCache}
|
|
396
|
+
- unstable_lazyLoading
|
|
397
|
+
- unstable_lazyLoadingRequestThrottleMs={100}
|
|
398
|
+
- unstable_onDataSourceError={() => {}}
|
|
399
|
+
- unstable_listView
|
|
400
|
+
- unstable_listColumn={{}}
|
|
381
401
|
+ rowSpanning
|
|
402
|
+
+ dataSource={dataSource}
|
|
403
|
+
+ dataSourceCache={dataSourceCache}
|
|
404
|
+
+ lazyLoading
|
|
405
|
+
+ lazyLoadingRequestThrottleMs={100}
|
|
406
|
+
+ onDataSourceError={() => {}}
|
|
407
|
+
+ listView
|
|
408
|
+
+ listViewColumn={{}}
|
|
382
409
|
/>
|
|
383
410
|
```
|
|
384
411
|
|
|
@@ -388,6 +415,81 @@ The list includes these props:
|
|
|
388
415
|
npx @mui/x-codemod@next v8.0.0/data-grid/rename-props <path>
|
|
389
416
|
```
|
|
390
417
|
|
|
418
|
+
#### `rename-imports`
|
|
419
|
+
|
|
420
|
+
This codemod renames the imports of the Data Grid components. The list includes these imports:
|
|
421
|
+
|
|
422
|
+
- `selectedGridRowsSelector` to `gridRowSelectionIdsSelector`
|
|
423
|
+
- `selectedGridRowsCountSelector` to `gridRowSelectionCountSelector`
|
|
424
|
+
|
|
425
|
+
```diff
|
|
426
|
+
-import { selectedGridRowsSelector, selectedGridRowsCountSelector } from '@mui/x-data-grid';
|
|
427
|
+
+import { gridRowSelectionIdsSelector, gridRowSelectionCountSelector } from '@mui/x-data-grid';
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
<!-- #default-branch-switch -->
|
|
431
|
+
|
|
432
|
+
```bash
|
|
433
|
+
npx @mui/x-codemod@next v8.0.0/data-grid/rename-imports <path>
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
#### `reform-row-selection-model`
|
|
437
|
+
|
|
438
|
+
Reforms the controlled `rowSelectionModel` prop value to the new one.
|
|
439
|
+
|
|
440
|
+
```diff
|
|
441
|
+
-const [rowSelectionModel, setRowSelectionModel] = React.useState([1, 2]);
|
|
442
|
+
+const [rowSelectionModel, setRowSelectionModel] = React.useState({
|
|
443
|
+
+ type: 'include',
|
|
444
|
+
+ ids: new Set([1, 2]),
|
|
445
|
+
+});
|
|
446
|
+
|
|
447
|
+
<DataGrid
|
|
448
|
+
rowSelectionModel={rowSelectionModel}
|
|
449
|
+
onRowSelectionModelChange={setRowSelectionModel}
|
|
450
|
+
/>
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
<!-- #default-branch-switch -->
|
|
454
|
+
|
|
455
|
+
```bash
|
|
456
|
+
npx @mui/x-codemod@next v8.0.0/data-grid/reform-row-selection-model <path>
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
#### `rename-package`
|
|
460
|
+
|
|
461
|
+
Reorganizes the imports moved from `@mui/x-data-grid-pro` and `@mui/x-data-grid-premium`.
|
|
462
|
+
|
|
463
|
+
```diff
|
|
464
|
+
-import { LicenseInfo } from '@mui/x-data-grid-pro';
|
|
465
|
+
+import { LicenseInfo } from '@mui/x-license';
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
<!-- #default-branch-switch -->
|
|
469
|
+
|
|
470
|
+
```bash
|
|
471
|
+
npx @mui/x-codemod@next v8.0.0/data-grid/rename-package <path>
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
#### `add-showToolbar-prop`
|
|
475
|
+
|
|
476
|
+
Adds the `showToolbar` prop to the Data Grid components that are using `slots.toolbar` prop.
|
|
477
|
+
|
|
478
|
+
```diff
|
|
479
|
+
<DataGridPremium
|
|
480
|
+
slots={{
|
|
481
|
+
toolbar: GridToolbar,
|
|
482
|
+
}}
|
|
483
|
+
+ showToolbar
|
|
484
|
+
/>
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
<!-- #default-branch-switch -->
|
|
488
|
+
|
|
489
|
+
```bash
|
|
490
|
+
npx @mui/x-codemod@next v8.0.0/data-grid/add-showToolbar-prop <path>
|
|
491
|
+
```
|
|
492
|
+
|
|
391
493
|
### Pickers codemods
|
|
392
494
|
|
|
393
495
|
#### `preset-safe` for Pickers v8.0.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-codemod",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.3",
|
|
4
4
|
"bin": "./codemod.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "MUI Team",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/core": "^7.26.10",
|
|
29
|
-
"@babel/runtime": "^7.
|
|
30
|
-
"@babel/traverse": "^7.
|
|
29
|
+
"@babel/runtime": "^7.27.0",
|
|
30
|
+
"@babel/traverse": "^7.27.0",
|
|
31
31
|
"jscodeshift": "17.1.2",
|
|
32
32
|
"yargs": "^17.7.2",
|
|
33
|
-
"@mui/x-internals": "8.0.0-beta.
|
|
33
|
+
"@mui/x-internals": "8.0.0-beta.3"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/jscodeshift": "^0.12.0",
|
|
37
37
|
"dayjs": "^1.11.13",
|
|
38
|
-
"moment-timezone": "^0.5.
|
|
38
|
+
"moment-timezone": "^0.5.48",
|
|
39
39
|
"rimraf": "^6.0.1"
|
|
40
40
|
},
|
|
41
41
|
"sideEffects": false,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
function transformer(file, api, options) {
|
|
8
|
+
const j = api.jscodeshift;
|
|
9
|
+
const root = j(file.source);
|
|
10
|
+
|
|
11
|
+
// List of DataGrid components
|
|
12
|
+
const dataGridComponents = new Set(['DataGrid', 'DataGridPro', 'DataGridPremium']);
|
|
13
|
+
// List of allowed import sources
|
|
14
|
+
const dataGridSources = new Set(['@mui/x-data-grid', '@mui/x-data-grid-pro', '@mui/x-data-grid-premium']);
|
|
15
|
+
|
|
16
|
+
// Find relevant DataGrid imports
|
|
17
|
+
const importedDataGrids = new Set();
|
|
18
|
+
root.find(j.ImportDeclaration).forEach(path => {
|
|
19
|
+
if (dataGridSources.has(path.node.source.value)) {
|
|
20
|
+
path.node.specifiers?.forEach(specifier => {
|
|
21
|
+
if (specifier.imported && dataGridComponents.has(specifier.imported.name)) {
|
|
22
|
+
const localName = specifier.local?.name;
|
|
23
|
+
if (localName) {
|
|
24
|
+
importedDataGrids.add(localName);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
if (importedDataGrids.size === 0) {
|
|
31
|
+
return file.source;
|
|
32
|
+
}
|
|
33
|
+
root.find(j.JSXOpeningElement).forEach(path => {
|
|
34
|
+
if (!importedDataGrids.has(path.node.name.name)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
let hasSlotsToolbar = false;
|
|
38
|
+
let hasShowToolbar = false;
|
|
39
|
+
path.node.attributes?.forEach(attr => {
|
|
40
|
+
if (attr.type === 'JSXAttribute') {
|
|
41
|
+
if (attr.name.name === 'slots') {
|
|
42
|
+
if (attr.value && attr.value.type === 'JSXExpressionContainer' && attr.value.expression.type === 'ObjectExpression') {
|
|
43
|
+
hasSlotsToolbar = attr.value.expression.properties.some(prop => prop.key.name === 'toolbar');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (attr.name.name === 'showToolbar') {
|
|
47
|
+
hasShowToolbar = true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
if (hasSlotsToolbar && !hasShowToolbar) {
|
|
52
|
+
path.node.attributes?.push(j.jsxAttribute(j.jsxIdentifier('showToolbar')));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const printOptions = options.printOptions || {
|
|
56
|
+
quote: 'single',
|
|
57
|
+
trailingComma: true
|
|
58
|
+
};
|
|
59
|
+
return root.toSource(printOptions);
|
|
60
|
+
}
|
|
@@ -8,9 +8,17 @@ exports.default = transformer;
|
|
|
8
8
|
var _removeStabilizedExperimentalFeatures = _interopRequireDefault(require("../remove-stabilized-experimentalFeatures"));
|
|
9
9
|
var _removeProps = _interopRequireDefault(require("../remove-props"));
|
|
10
10
|
var _renameProps = _interopRequireDefault(require("../rename-props"));
|
|
11
|
+
var _reformRowSelectionModel = _interopRequireDefault(require("../reform-row-selection-model"));
|
|
12
|
+
var _renameImports = _interopRequireDefault(require("../rename-imports"));
|
|
13
|
+
var _renamePackage = _interopRequireDefault(require("../rename-package"));
|
|
14
|
+
var _addShowToolbarProp = _interopRequireDefault(require("../add-showToolbar-prop"));
|
|
11
15
|
function transformer(file, api, options) {
|
|
12
16
|
file.source = (0, _removeStabilizedExperimentalFeatures.default)(file, api, options);
|
|
13
17
|
file.source = (0, _renameProps.default)(file, api, options);
|
|
14
18
|
file.source = (0, _removeProps.default)(file, api, options);
|
|
19
|
+
file.source = (0, _reformRowSelectionModel.default)(file, api, options);
|
|
20
|
+
file.source = (0, _renameImports.default)(file, api, options);
|
|
21
|
+
file.source = (0, _renamePackage.default)(file, api, options);
|
|
22
|
+
file.source = (0, _addShowToolbarProp.default)(file, api, options);
|
|
15
23
|
return file.source;
|
|
16
24
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
// @ts-nocheck - TODO: fix this
|
|
8
|
+
|
|
9
|
+
const componentNames = ['DataGrid', 'DataGridPro', 'DataGridPremium'];
|
|
10
|
+
const attrName = 'rowSelectionModel';
|
|
11
|
+
function transformer(file, api, options) {
|
|
12
|
+
const j = api.jscodeshift;
|
|
13
|
+
const root = j(file.source);
|
|
14
|
+
|
|
15
|
+
// Step 1: Collect variable names used in <DataGrid rowSelectionModel={...} />
|
|
16
|
+
const usedInDataGrid = new Set();
|
|
17
|
+
root.find(j.JSXOpeningElement).filter(path => j.JSXIdentifier.check(path.node.name) && componentNames.some(name => name === path.node.name.name)).forEach(path => {
|
|
18
|
+
path.node.attributes?.forEach(attr => {
|
|
19
|
+
if (j.JSXAttribute.check(attr) && j.JSXIdentifier.check(attr.name) && attr.name.name === attrName && attr.value && j.JSXExpressionContainer.check(attr.value) && j.Identifier.check(attr.value.expression)) {
|
|
20
|
+
usedInDataGrid.add(attr.value.expression.name);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
if (usedInDataGrid.size === 0) {
|
|
25
|
+
return file.source; // No relevant transformations needed
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Step 2: Convert only relevant `useState` or `useMemo` variables
|
|
29
|
+
root.find(j.VariableDeclarator).filter(path => j.ArrayPattern.check(path.node.id) && path.node.id.elements.length === 2 && j.Identifier.check(path.node.id.elements[0]) && usedInDataGrid.has(path.node.id.elements[0].name) &&
|
|
30
|
+
// Only modify if used in `componentNames`
|
|
31
|
+
path.node.init && j.CallExpression.check(path.node.init) && (j.MemberExpression.check(path.node.init.callee) && j.Identifier.check(path.node.init.callee.object) && ['React', 'useState', 'useMemo'].includes(path.node.init.callee.object.name) || ['useState', 'useMemo'].includes(path.node.init.callee.name)) &&
|
|
32
|
+
// Handle direct calls
|
|
33
|
+
path.node.init.arguments.length > 0 && (j.ArrayExpression.check(path.node.init.arguments[0]) || j.ArrowFunctionExpression.check(path.node.init.arguments[0]) && j.BlockStatement.check(path.node.init.arguments[0].body) === false && j.ArrayExpression.check(path.node.init.arguments[0].body))).forEach(path => {
|
|
34
|
+
const arrayExpression = j.ArrayExpression.check(path.node.init?.arguments[0]) ? path.node.init?.arguments[0] : path.node.init?.arguments[0]?.body;
|
|
35
|
+
const newObject = j.objectExpression([j.property('init', j.identifier('type'), j.literal('include')), j.property('init', j.identifier('ids'), j.newExpression(j.identifier('Set'), [arrayExpression]))]);
|
|
36
|
+
if (j.ArrayExpression.check(path.node.init.arguments[0])) {
|
|
37
|
+
path.node.init.arguments[0] = newObject;
|
|
38
|
+
} else {
|
|
39
|
+
path.node.init.arguments[0].body = newObject;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
const printOptions = options?.printOptions || {
|
|
43
|
+
quote: 'single',
|
|
44
|
+
trailingComma: true
|
|
45
|
+
};
|
|
46
|
+
return root.toSource(printOptions);
|
|
47
|
+
}
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = transformer;
|
|
8
8
|
var _removeProps = _interopRequireDefault(require("../../../util/removeProps"));
|
|
9
9
|
const componentNames = ['DataGrid', 'DataGridPro', 'DataGridPremium'];
|
|
10
|
-
const props = ['indeterminateCheckboxAction', 'rowPositionsDebounceMs'];
|
|
10
|
+
const props = ['indeterminateCheckboxAction', 'rowPositionsDebounceMs', 'resetPageOnSortFilter'];
|
|
11
11
|
function transformer(file, api, options) {
|
|
12
12
|
const j = api.jscodeshift;
|
|
13
13
|
const root = j(file.source);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
var _renameImports = require("../../../util/renameImports");
|
|
8
|
+
function transformer(file, api, options) {
|
|
9
|
+
const j = api.jscodeshift;
|
|
10
|
+
const root = j(file.source);
|
|
11
|
+
const printOptions = options.printOptions || {
|
|
12
|
+
quote: 'single',
|
|
13
|
+
trailingComma: true
|
|
14
|
+
};
|
|
15
|
+
(0, _renameImports.renameImports)({
|
|
16
|
+
j,
|
|
17
|
+
root,
|
|
18
|
+
packageNames: ['@mui/x-data-grid', '@mui/x-data-grid-pro', '@mui/x-data-grid-premium'],
|
|
19
|
+
imports: [{
|
|
20
|
+
oldEndpoint: 'DataGrid',
|
|
21
|
+
importsMapping: {
|
|
22
|
+
selectedGridRowsSelector: 'gridRowSelectionIdsSelector',
|
|
23
|
+
selectedGridRowsCountSelector: 'gridRowSelectionCountSelector'
|
|
24
|
+
}
|
|
25
|
+
}]
|
|
26
|
+
});
|
|
27
|
+
return root.toSource(printOptions);
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
// TODO: Make it generic and move to utils
|
|
8
|
+
function transformer(file, api, options) {
|
|
9
|
+
const j = api.jscodeshift;
|
|
10
|
+
const root = j(file.source);
|
|
11
|
+
root.find(j.ImportDeclaration).filter(path => ['@mui/x-data-grid-pro', '@mui/x-data-grid-premium'].includes(path.node.source.value)).forEach(path => {
|
|
12
|
+
const specifiers = path.node.specifiers;
|
|
13
|
+
const filteredSpecifiers = specifiers.filter(spec => !(j.ImportSpecifier.check(spec) && spec.imported.name === 'LicenseInfo'));
|
|
14
|
+
|
|
15
|
+
// If `LicenseInfo` was found and removed
|
|
16
|
+
if (filteredSpecifiers.length !== specifiers.length) {
|
|
17
|
+
const licenseImport = j.importDeclaration([j.importSpecifier(j.identifier('LicenseInfo'))], j.stringLiteral('@mui/x-license'));
|
|
18
|
+
if (filteredSpecifiers.length > 0) {
|
|
19
|
+
// Keep other imports but remove `LicenseInfo`
|
|
20
|
+
path.node.specifiers = filteredSpecifiers;
|
|
21
|
+
// Insert new import right after the modified import
|
|
22
|
+
j(path).insertAfter(licenseImport);
|
|
23
|
+
} else {
|
|
24
|
+
// Remove import entirely and insert new one at the same position
|
|
25
|
+
j(path).replaceWith(licenseImport);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const printOptions = options?.printOptions || {
|
|
30
|
+
quote: 'single',
|
|
31
|
+
trailingComma: true
|
|
32
|
+
};
|
|
33
|
+
return root.toSource(printOptions);
|
|
34
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _path = _interopRequireDefault(require("path"));
|
|
5
|
+
var _chai = require("chai");
|
|
6
|
+
var _jscodeshift = _interopRequireDefault(require("jscodeshift"));
|
|
7
|
+
var _ = _interopRequireDefault(require("."));
|
|
8
|
+
var _readFile = _interopRequireDefault(require("../../../util/readFile"));
|
|
9
|
+
function read(fileName) {
|
|
10
|
+
return (0, _readFile.default)(_path.default.join(__dirname, fileName));
|
|
11
|
+
}
|
|
12
|
+
describe('v8.0.0/data-grid', () => {
|
|
13
|
+
describe('rename package', () => {
|
|
14
|
+
it('transforms props as needed', () => {
|
|
15
|
+
const actual = (0, _.default)({
|
|
16
|
+
source: read('./actual.spec.js')
|
|
17
|
+
}, {
|
|
18
|
+
jscodeshift: _jscodeshift.default
|
|
19
|
+
});
|
|
20
|
+
const expected = read('./expected.spec.js');
|
|
21
|
+
(0, _chai.expect)(actual).to.equal(expected, 'The transformed version should be correct');
|
|
22
|
+
});
|
|
23
|
+
it('should be idempotent', () => {
|
|
24
|
+
const actual = (0, _.default)({
|
|
25
|
+
source: read('./expected.spec.js')
|
|
26
|
+
}, {
|
|
27
|
+
jscodeshift: _jscodeshift.default
|
|
28
|
+
});
|
|
29
|
+
const expected = read('./expected.spec.js');
|
|
30
|
+
(0, _chai.expect)(actual).to.equal(expected, 'The transformed version should be correct');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -8,7 +8,14 @@ exports.default = transformer;
|
|
|
8
8
|
var _renameProps = _interopRequireDefault(require("../../../util/renameProps"));
|
|
9
9
|
const componentNames = ['DataGrid', 'DataGridPro', 'DataGridPremium'];
|
|
10
10
|
const props = {
|
|
11
|
-
unstable_rowSpanning: 'rowSpanning'
|
|
11
|
+
unstable_rowSpanning: 'rowSpanning',
|
|
12
|
+
unstable_dataSource: 'dataSource',
|
|
13
|
+
unstable_dataSourceCache: 'dataSourceCache',
|
|
14
|
+
unstable_lazyLoading: 'lazyLoading',
|
|
15
|
+
unstable_lazyLoadingRequestThrottleMs: 'lazyLoadingRequestThrottleMs',
|
|
16
|
+
unstable_onDataSourceError: 'onDataSourceError',
|
|
17
|
+
unstable_listView: 'listView',
|
|
18
|
+
unstable_listColumn: 'listViewColumn'
|
|
12
19
|
};
|
|
13
20
|
function transformer(file, api, options) {
|
|
14
21
|
const j = api.jscodeshift;
|