@mui/codemod 6.0.0-alpha.5 → 6.0.0-alpha.7

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.
Files changed (38) hide show
  1. package/README.md +168 -0
  2. package/node/deprecations/all/deprecations-all.js +6 -0
  3. package/node/deprecations/all/postcss.config.js +4 -1
  4. package/node/deprecations/autocomplete-props/autocomplete-props.js +54 -0
  5. package/node/deprecations/autocomplete-props/index.js +13 -0
  6. package/node/deprecations/autocomplete-props/test-cases/actual.js +97 -0
  7. package/node/deprecations/autocomplete-props/test-cases/expected.js +101 -0
  8. package/node/deprecations/autocomplete-props/test-cases/theme.actual.js +65 -0
  9. package/node/deprecations/autocomplete-props/test-cases/theme.expected.js +68 -0
  10. package/node/deprecations/circular-progress-classes/circular-progress-classes.js +77 -0
  11. package/node/deprecations/circular-progress-classes/index.js +13 -0
  12. package/node/deprecations/circular-progress-classes/postcss-plugin.js +33 -0
  13. package/node/deprecations/circular-progress-classes/postcss.config.js +8 -0
  14. package/node/deprecations/circular-progress-classes/test-cases/actual.js +7 -0
  15. package/node/deprecations/circular-progress-classes/test-cases/expected.js +7 -0
  16. package/node/deprecations/divider-props/divider-props.js +36 -30
  17. package/node/deprecations/divider-props/test-cases/actual.js +3 -0
  18. package/node/deprecations/divider-props/test-cases/expected.js +3 -0
  19. package/node/deprecations/divider-props/test-cases/theme.actual.js +7 -0
  20. package/node/deprecations/divider-props/test-cases/theme.expected.js +7 -0
  21. package/node/deprecations/speed-dial-props/index.js +13 -0
  22. package/node/deprecations/speed-dial-props/speed-dial-props.js +31 -0
  23. package/node/deprecations/speed-dial-props/test-cases/actual.js +40 -0
  24. package/node/deprecations/speed-dial-props/test-cases/expected.js +54 -0
  25. package/node/deprecations/speed-dial-props/test-cases/theme.actual.js +33 -0
  26. package/node/deprecations/speed-dial-props/test-cases/theme.expected.js +40 -0
  27. package/node/util/getReturnExpression.js +20 -0
  28. package/node/util/migrateToVariants.js +472 -0
  29. package/node/v6.0.0/styled/styled-v6.js +2 -415
  30. package/node/v6.0.0/styled/test-cases/ConditionalStyled.actual.js +28 -1
  31. package/node/v6.0.0/styled/test-cases/ConditionalStyled.expected.js +38 -1
  32. package/node/v6.0.0/theme-v6/index.js +13 -0
  33. package/node/v6.0.0/theme-v6/test-cases/basicTheme.actual.js +530 -0
  34. package/node/v6.0.0/theme-v6/test-cases/basicTheme.expected.js +626 -0
  35. package/node/v6.0.0/theme-v6/test-cases/themeVariants.actual.js +63 -0
  36. package/node/v6.0.0/theme-v6/test-cases/themeVariants.expected.js +73 -0
  37. package/node/v6.0.0/theme-v6/theme-v6.js +87 -0
  38. package/package.json +5 -5
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = transformer;
7
+ var _postcssPlugin = require("./postcss-plugin");
8
+ /**
9
+ * @param {import('jscodeshift').FileInfo} file
10
+ * @param {import('jscodeshift').API} api
11
+ */
12
+ function transformer(file, api, options) {
13
+ const j = api.jscodeshift;
14
+ const root = j(file.source);
15
+ const printOptions = options.printOptions;
16
+ _postcssPlugin.classes.forEach(({
17
+ deprecatedClass,
18
+ replacementSelector
19
+ }) => {
20
+ const replacementSelectorPrefix = '&';
21
+ root.find(j.ImportDeclaration).filter(path => path.node.source.value.match(/^@mui\/material\/CircularProgress$/)).forEach(path => {
22
+ path.node.specifiers.forEach(specifier => {
23
+ if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'circularProgressClasses') {
24
+ const deprecatedAtomicClass = deprecatedClass.replace(`${deprecatedClass.split('-')[0]}-`, '');
25
+ root.find(j.MemberExpression, {
26
+ object: {
27
+ name: specifier.local.name
28
+ },
29
+ property: {
30
+ name: deprecatedAtomicClass
31
+ }
32
+ }).forEach(memberExpression => {
33
+ const parent = memberExpression.parentPath.parentPath.value;
34
+ if (parent.type === j.TemplateLiteral.name) {
35
+ const memberExpressionIndex = parent.expressions.findIndex(expression => expression === memberExpression.value);
36
+ const precedingTemplateElement = parent.quasis[memberExpressionIndex];
37
+ const atomicClasses = replacementSelector.replaceAll('MuiCircularProgress-', '').replaceAll(replacementSelectorPrefix, '').replaceAll(' > ', '').split('.').filter(Boolean);
38
+ if (precedingTemplateElement.value.raw.endsWith(deprecatedClass.startsWith(' ') ? `${replacementSelectorPrefix} .` : `${replacementSelectorPrefix}.`)) {
39
+ const atomicClassesArgs = [memberExpressionIndex, 1, ...atomicClasses.map(atomicClass => j.memberExpression(memberExpression.value.object, j.identifier(atomicClass)))];
40
+ parent.expressions.splice(...atomicClassesArgs);
41
+ if (replacementSelector.includes(' > ')) {
42
+ const quasisArgs = [memberExpressionIndex, 1, j.templateElement({
43
+ raw: precedingTemplateElement.value.raw.replace(' ', ''),
44
+ cooked: precedingTemplateElement.value.cooked.replace(' ', '')
45
+ }, false), j.templateElement({
46
+ raw: ' > .',
47
+ cooked: ' > .'
48
+ }, false)];
49
+ if (atomicClasses.length === 3) {
50
+ quasisArgs.splice(3, 0, j.templateElement({
51
+ raw: '.',
52
+ cooked: '.'
53
+ }, false));
54
+ }
55
+ parent.quasis.splice(...quasisArgs);
56
+ } else {
57
+ parent.quasis.splice(memberExpressionIndex, 1, j.templateElement({
58
+ raw: precedingTemplateElement.value.raw,
59
+ cooked: precedingTemplateElement.value.cooked
60
+ }, false), j.templateElement({
61
+ raw: '.',
62
+ cooked: '.'
63
+ }, false));
64
+ }
65
+ }
66
+ }
67
+ });
68
+ }
69
+ });
70
+ });
71
+ const selectorRegex = new RegExp(`${replacementSelectorPrefix}${deprecatedClass}$`);
72
+ root.find(j.Literal, literal => typeof literal.value === 'string' && literal.value.match(selectorRegex)).forEach(path => {
73
+ path.replace(j.literal(path.value.value.replace(selectorRegex, `${replacementSelectorPrefix}${replacementSelector}`)));
74
+ });
75
+ });
76
+ return root.toSource(printOptions);
77
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _circularProgressClasses.default;
11
+ }
12
+ });
13
+ var _circularProgressClasses = _interopRequireDefault(require("./circular-progress-classes"));
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ const classes = [{
4
+ deprecatedClass: ' .MuiCircularProgress-circleDeterminate',
5
+ replacementSelector: '.MuiCircularProgress-determinate > .MuiCircularProgress-circle'
6
+ }, {
7
+ deprecatedClass: ' .MuiCircularProgress-circleIndeterminate',
8
+ replacementSelector: '.MuiCircularProgress-indeterminate > .MuiCircularProgress-circle'
9
+ }];
10
+ const plugin = () => {
11
+ return {
12
+ postcssPlugin: `Replace deprecated CircularProgress classes with new classes`,
13
+ Rule(rule) {
14
+ const {
15
+ selector
16
+ } = rule;
17
+ classes.forEach(({
18
+ deprecatedClass,
19
+ replacementSelector
20
+ }) => {
21
+ const selectorRegex = new RegExp(`${deprecatedClass}$`);
22
+ if (selector.match(selectorRegex)) {
23
+ rule.selector = selector.replace(selectorRegex, replacementSelector);
24
+ }
25
+ });
26
+ }
27
+ };
28
+ };
29
+ plugin.postcss = true;
30
+ module.exports = {
31
+ plugin,
32
+ classes
33
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ const {
4
+ plugin
5
+ } = require('./postcss-plugin');
6
+ module.exports = {
7
+ plugins: [plugin]
8
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ var _CircularProgress = require("@mui/material/CircularProgress");
4
+ '& .MuiCircularProgress-circleDeterminate';
5
+ '& .MuiCircularProgress-circleIndeterminate';
6
+ `& .${_CircularProgress.circularProgressClasses.circleDeterminate}`;
7
+ `& .${_CircularProgress.circularProgressClasses.circleIndeterminate}`;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ var _CircularProgress = require("@mui/material/CircularProgress");
4
+ "&.MuiCircularProgress-determinate > .MuiCircularProgress-circle";
5
+ "&.MuiCircularProgress-indeterminate > .MuiCircularProgress-circle";
6
+ `&.${_CircularProgress.circularProgressClasses.determinate} > .${_CircularProgress.circularProgressClasses.circle}`;
7
+ `&.${_CircularProgress.circularProgressClasses.indeterminate} > .${_CircularProgress.circularProgressClasses.circle}`;
@@ -20,27 +20,30 @@ function transformer(file, api, options) {
20
20
  root,
21
21
  componentName: 'Divider'
22
22
  }, elementPath => {
23
- elementPath.node.openingElement.attributes = elementPath.node.openingElement.attributes.filter(attr => {
24
- if (attr.type === 'JSXAttribute' && attr.name.name === 'light') {
25
- return false;
26
- }
27
- return true;
28
- });
29
- const sxIndex = elementPath.node.openingElement.attributes.findIndex(attr => attr.type === 'JSXAttribute' && attr.name.name === 'sx');
30
- if (sxIndex === -1) {
31
- (0, _appendAttribute.default)(j, {
32
- target: elementPath.node,
33
- attributeName: 'sx',
34
- expression: j.objectExpression([j.objectProperty(j.identifier('opacity'), j.literal('0.6'))])
23
+ const hasLightProp = elementPath.node.openingElement.attributes.findIndex(attr => attr.type === 'JSXAttribute' && attr.name.name === 'light') !== -1;
24
+ if (hasLightProp) {
25
+ elementPath.node.openingElement.attributes = elementPath.node.openingElement.attributes.filter(attr => {
26
+ if (attr.type === 'JSXAttribute' && attr.name.name === 'light') {
27
+ return false;
28
+ }
29
+ return true;
35
30
  });
36
- } else {
37
- const opacityIndex = elementPath.node.openingElement.attributes[sxIndex].value.expression.properties.findIndex(key => key.key.name === 'opacity');
38
- if (opacityIndex === -1) {
39
- (0, _assignObject.default)(j, {
40
- target: elementPath.node.openingElement.attributes[sxIndex],
41
- key: 'opacity',
42
- expression: j.literal('0.6')
31
+ const sxIndex = elementPath.node.openingElement.attributes.findIndex(attr => attr.type === 'JSXAttribute' && attr.name.name === 'sx');
32
+ if (sxIndex === -1) {
33
+ (0, _appendAttribute.default)(j, {
34
+ target: elementPath.node,
35
+ attributeName: 'sx',
36
+ expression: j.objectExpression([j.objectProperty(j.identifier('opacity'), j.literal('0.6'))])
43
37
  });
38
+ } else {
39
+ const opacityIndex = elementPath.node.openingElement.attributes[sxIndex].value.expression.properties.findIndex(key => key.key.name === 'opacity');
40
+ if (opacityIndex === -1) {
41
+ (0, _assignObject.default)(j, {
42
+ target: elementPath.node.openingElement.attributes[sxIndex],
43
+ key: 'opacity',
44
+ expression: j.literal('0.6')
45
+ });
46
+ }
44
47
  }
45
48
  }
46
49
  });
@@ -50,17 +53,20 @@ function transformer(file, api, options) {
50
53
  }
51
54
  }).forEach(path => {
52
55
  const defaultPropsObject = path.value.value.properties.find(key => key.key.name === 'defaultProps');
53
- defaultPropsObject.value.properties = defaultPropsObject.value.properties.filter(prop => {
54
- var _prop$key;
55
- return !['light'].includes(prop == null || (_prop$key = prop.key) == null ? void 0 : _prop$key.name);
56
- });
57
- const sxIndex = defaultPropsObject.value.properties.findIndex(prop => prop.key.name === 'sx');
58
- if (sxIndex === -1) {
59
- defaultPropsObject.value.properties.push(j.objectProperty(j.identifier('sx'), j.objectExpression([j.objectProperty(j.identifier('opacity'), j.literal('0.6'))])));
60
- } else {
61
- const opacityIndex = defaultPropsObject.value.properties[sxIndex].value.properties.findIndex(key => key.key.name === 'opacity');
62
- if (opacityIndex === -1) {
63
- defaultPropsObject.value.properties[sxIndex].value.properties.push(j.objectProperty(j.identifier('opacity'), j.literal('0.6')));
56
+ const hasLightProp = defaultPropsObject.value.properties.findIndex(prop => prop.key.name === 'light') !== -1;
57
+ if (hasLightProp) {
58
+ defaultPropsObject.value.properties = defaultPropsObject.value.properties.filter(prop => {
59
+ var _prop$key;
60
+ return !['light'].includes(prop == null || (_prop$key = prop.key) == null ? void 0 : _prop$key.name);
61
+ });
62
+ const sxIndex = defaultPropsObject.value.properties.findIndex(prop => prop.key.name === 'sx');
63
+ if (sxIndex === -1) {
64
+ defaultPropsObject.value.properties.push(j.objectProperty(j.identifier('sx'), j.objectExpression([j.objectProperty(j.identifier('opacity'), j.literal('0.6'))])));
65
+ } else {
66
+ const opacityIndex = defaultPropsObject.value.properties[sxIndex].value.properties.findIndex(key => key.key.name === 'opacity');
67
+ if (opacityIndex === -1) {
68
+ defaultPropsObject.value.properties[sxIndex].value.properties.push(j.objectProperty(j.identifier('opacity'), j.literal('0.6')));
69
+ }
64
70
  }
65
71
  }
66
72
  });
@@ -39,4 +39,7 @@ var _jsxRuntime = require("react/jsx-runtime");
39
39
  sx: {
40
40
  bgcolor: 'black'
41
41
  }
42
+ });
43
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
44
+ className: "test"
42
45
  });
@@ -50,4 +50,7 @@ var _jsxRuntime = require("react/jsx-runtime");
50
50
  bgcolor: 'black',
51
51
  opacity: "0.6"
52
52
  }
53
+ });
54
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
55
+ className: "test"
53
56
  });
@@ -44,4 +44,11 @@ fn({
44
44
  }
45
45
  }
46
46
  }
47
+ });
48
+ fn({
49
+ MuiDivider: {
50
+ defaultProps: {
51
+ className: 'my-class'
52
+ }
53
+ }
47
54
  });
@@ -49,4 +49,11 @@ fn({
49
49
  }
50
50
  }
51
51
  }
52
+ });
53
+ fn({
54
+ MuiDivider: {
55
+ defaultProps: {
56
+ className: 'my-class'
57
+ }
58
+ }
52
59
  });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _speedDialProps.default;
11
+ }
12
+ });
13
+ var _speedDialProps = _interopRequireDefault(require("./speed-dial-props"));
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = transformer;
8
+ var _movePropIntoSlots = _interopRequireDefault(require("../utils/movePropIntoSlots"));
9
+ var _movePropIntoSlotProps = _interopRequireDefault(require("../utils/movePropIntoSlotProps"));
10
+ /**
11
+ * @param {import('jscodeshift').FileInfo} file
12
+ * @param {import('jscodeshift').API} api
13
+ */
14
+ function transformer(file, api, options) {
15
+ const j = api.jscodeshift;
16
+ const root = j(file.source);
17
+ const printOptions = options.printOptions;
18
+ (0, _movePropIntoSlots.default)(j, {
19
+ root,
20
+ componentName: 'SpeedDial',
21
+ propName: 'TransitionComponent',
22
+ slotName: 'transition'
23
+ });
24
+ (0, _movePropIntoSlotProps.default)(j, {
25
+ root,
26
+ componentName: 'SpeedDial',
27
+ propName: 'TransitionProps',
28
+ slotName: 'transition'
29
+ });
30
+ return root.toSource(printOptions);
31
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
5
+ var _SpeedDial = _interopRequireDefault(require("@mui/material/SpeedDial"));
6
+ var _material = require("@mui/material");
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_SpeedDial.default, {
9
+ TransitionComponent: CustomTransition,
10
+ TransitionProps: CustomTransitionProps
11
+ });
12
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.SpeedDial, {
13
+ TransitionComponent: CustomTransition,
14
+ TransitionProps: CustomTransitionProps
15
+ });
16
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_SpeedDial.default, {
17
+ TransitionComponent: CustomTransition,
18
+ TransitionProps: CustomTransitionProps,
19
+ slots: {
20
+ root: 'div'
21
+ }
22
+ });
23
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.SpeedDial, {
24
+ TransitionComponent: CustomTransition,
25
+ TransitionProps: CustomTransitionProps,
26
+ slots: (0, _extends2.default)({}, outerSlots)
27
+ });
28
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_SpeedDial.default, {
29
+ TransitionComponent: ComponentTransition,
30
+ TransitionProps: CustomTransitionProps,
31
+ slots: {
32
+ root: 'div',
33
+ transition: SlotTransition
34
+ }
35
+ });
36
+ // should skip non MUI components
37
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(NonMuiSpeedDial, {
38
+ TransitionComponent: CustomTransition,
39
+ TransitionProps: CustomTransitionProps
40
+ });
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
5
+ var _SpeedDial = _interopRequireDefault(require("@mui/material/SpeedDial"));
6
+ var _material = require("@mui/material");
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_SpeedDial.default, {
9
+ slots: {
10
+ transition: CustomTransition
11
+ },
12
+ slotProps: {
13
+ transition: CustomTransitionProps
14
+ }
15
+ });
16
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.SpeedDial, {
17
+ slots: {
18
+ transition: CustomTransition
19
+ },
20
+ slotProps: {
21
+ transition: CustomTransitionProps
22
+ }
23
+ });
24
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_SpeedDial.default, {
25
+ slots: {
26
+ root: 'div',
27
+ transition: CustomTransition
28
+ },
29
+ slotProps: {
30
+ transition: CustomTransitionProps
31
+ }
32
+ });
33
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.SpeedDial, {
34
+ slots: (0, _extends2.default)({}, outerSlots, {
35
+ transition: CustomTransition
36
+ }),
37
+ slotProps: {
38
+ transition: CustomTransitionProps
39
+ }
40
+ });
41
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_SpeedDial.default, {
42
+ slots: {
43
+ root: 'div',
44
+ transition: SlotTransition
45
+ },
46
+ slotProps: {
47
+ transition: CustomTransitionProps
48
+ }
49
+ });
50
+ // should skip non MUI components
51
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(NonMuiSpeedDial, {
52
+ TransitionComponent: CustomTransition,
53
+ TransitionProps: CustomTransitionProps
54
+ });
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ fn({
4
+ MuiSpeedDial: {
5
+ defaultProps: {
6
+ TransitionComponent: CustomTransition,
7
+ TransitionProps: CustomTransitionProps
8
+ }
9
+ }
10
+ });
11
+ fn({
12
+ MuiSpeedDial: {
13
+ defaultProps: {
14
+ TransitionComponent: CustomTransition,
15
+ TransitionProps: CustomTransitionProps,
16
+ slots: {
17
+ root: 'div'
18
+ }
19
+ }
20
+ }
21
+ });
22
+ fn({
23
+ MuiSpeedDial: {
24
+ defaultProps: {
25
+ TransitionComponent: ComponentTransition,
26
+ TransitionProps: CustomTransitionProps,
27
+ slots: {
28
+ root: 'div',
29
+ transition: SlotTransition
30
+ }
31
+ }
32
+ }
33
+ });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ fn({
4
+ MuiSpeedDial: {
5
+ defaultProps: {
6
+ slots: {
7
+ transition: CustomTransition
8
+ },
9
+ slotProps: {
10
+ transition: CustomTransitionProps
11
+ }
12
+ }
13
+ }
14
+ });
15
+ fn({
16
+ MuiSpeedDial: {
17
+ defaultProps: {
18
+ slots: {
19
+ root: 'div',
20
+ transition: CustomTransition
21
+ },
22
+ slotProps: {
23
+ transition: CustomTransitionProps
24
+ }
25
+ }
26
+ }
27
+ });
28
+ fn({
29
+ MuiSpeedDial: {
30
+ defaultProps: {
31
+ slots: {
32
+ root: 'div',
33
+ transition: SlotTransition
34
+ },
35
+ slotProps: {
36
+ transition: CustomTransitionProps
37
+ }
38
+ }
39
+ }
40
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = getReturnExpression;
7
+ /**
8
+ * @param {import('ast-types').namedTypes.ArrowFunctionExpression | import('ast-types').namedTypes.FunctionExpression} node
9
+ */
10
+ function getReturnExpression(node) {
11
+ let body = node.body;
12
+ if (body === 'BlockStatement') {
13
+ body = body.body;
14
+ }
15
+ if (Array.isArray(body)) {
16
+ var _body$find;
17
+ return (_body$find = body.find(statement => statement.type === 'ReturnStatement')) == null ? void 0 : _body$find.argument;
18
+ }
19
+ return body;
20
+ }