@atlaskit/eslint-plugin-design-system 8.23.1 → 8.23.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.
Files changed (136) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/ast-nodes/function-call.js +48 -0
  3. package/dist/cjs/ast-nodes/import.js +49 -0
  4. package/dist/cjs/ast-nodes/index.js +40 -0
  5. package/dist/cjs/ast-nodes/jsx-attribute.js +64 -0
  6. package/dist/cjs/ast-nodes/jsx-element.js +55 -0
  7. package/dist/cjs/ast-nodes/root.js +34 -0
  8. package/dist/cjs/rules/consistent-css-prop-usage/index.js +25 -5
  9. package/dist/cjs/rules/use-primitives/index.js +8 -104
  10. package/dist/cjs/rules/use-primitives/transformers/compiled-styled/convert-jsx-call-site.js +39 -0
  11. package/dist/cjs/rules/use-primitives/transformers/compiled-styled/convert-styled-component-call-to-jsx.js +44 -0
  12. package/dist/cjs/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-styled-component-call.js +5 -2
  13. package/dist/cjs/rules/use-primitives/transformers/compiled-styled/index.js +117 -0
  14. package/dist/cjs/rules/use-primitives/transformers/compiled-styled/supported.js +10 -0
  15. package/dist/cjs/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.js +37 -0
  16. package/dist/cjs/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.js +27 -0
  17. package/dist/cjs/rules/use-primitives/transformers/emotion-css/index.js +125 -0
  18. package/dist/cjs/rules/use-primitives/transformers/emotion-css/supported.js +10 -0
  19. package/dist/cjs/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.js +37 -0
  20. package/dist/cjs/rules/use-primitives/transformers/index.js +10 -10
  21. package/dist/cjs/rules/use-primitives/utils/index.js +1 -43
  22. package/dist/cjs/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +3 -0
  23. package/dist/es2019/ast-nodes/function-call.js +42 -0
  24. package/dist/es2019/ast-nodes/import.js +42 -0
  25. package/dist/es2019/ast-nodes/index.js +5 -0
  26. package/dist/es2019/ast-nodes/jsx-attribute.js +59 -0
  27. package/dist/es2019/ast-nodes/jsx-element.js +50 -0
  28. package/dist/es2019/ast-nodes/root.js +28 -0
  29. package/dist/es2019/rules/consistent-css-prop-usage/index.js +23 -5
  30. package/dist/es2019/rules/use-primitives/index.js +9 -105
  31. package/dist/es2019/rules/use-primitives/transformers/compiled-styled/convert-jsx-call-site.js +29 -0
  32. package/dist/es2019/rules/use-primitives/transformers/compiled-styled/convert-styled-component-call-to-jsx.js +37 -0
  33. package/dist/es2019/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-styled-component-call.js +2 -2
  34. package/dist/es2019/rules/use-primitives/transformers/compiled-styled/index.js +107 -0
  35. package/dist/es2019/rules/use-primitives/transformers/compiled-styled/supported.js +4 -0
  36. package/dist/es2019/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.js +30 -0
  37. package/dist/es2019/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.js +19 -0
  38. package/dist/es2019/rules/use-primitives/transformers/emotion-css/index.js +115 -0
  39. package/dist/es2019/rules/use-primitives/transformers/emotion-css/supported.js +4 -0
  40. package/dist/es2019/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.js +30 -0
  41. package/dist/es2019/rules/use-primitives/transformers/index.js +2 -2
  42. package/dist/es2019/rules/use-primitives/utils/index.js +1 -7
  43. package/dist/es2019/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +3 -0
  44. package/dist/esm/ast-nodes/function-call.js +42 -0
  45. package/dist/esm/ast-nodes/import.js +43 -0
  46. package/dist/esm/ast-nodes/index.js +5 -0
  47. package/dist/esm/ast-nodes/jsx-attribute.js +59 -0
  48. package/dist/esm/ast-nodes/jsx-element.js +50 -0
  49. package/dist/esm/ast-nodes/root.js +28 -0
  50. package/dist/esm/rules/consistent-css-prop-usage/index.js +25 -5
  51. package/dist/esm/rules/use-primitives/index.js +9 -105
  52. package/dist/esm/rules/use-primitives/transformers/compiled-styled/convert-jsx-call-site.js +30 -0
  53. package/dist/esm/rules/use-primitives/transformers/compiled-styled/convert-styled-component-call-to-jsx.js +38 -0
  54. package/dist/esm/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-styled-component-call.js +2 -2
  55. package/dist/esm/rules/use-primitives/transformers/compiled-styled/index.js +107 -0
  56. package/dist/esm/rules/use-primitives/transformers/compiled-styled/supported.js +4 -0
  57. package/dist/esm/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.js +29 -0
  58. package/dist/esm/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.js +19 -0
  59. package/dist/esm/rules/use-primitives/transformers/emotion-css/index.js +115 -0
  60. package/dist/esm/rules/use-primitives/transformers/emotion-css/supported.js +4 -0
  61. package/dist/esm/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.js +29 -0
  62. package/dist/esm/rules/use-primitives/transformers/index.js +2 -2
  63. package/dist/esm/rules/use-primitives/utils/index.js +1 -7
  64. package/dist/esm/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +3 -0
  65. package/dist/types/ast-nodes/function-call.d.ts +21 -0
  66. package/dist/types/ast-nodes/import.d.ts +16 -0
  67. package/dist/types/ast-nodes/index.d.ts +5 -0
  68. package/dist/types/ast-nodes/jsx-attribute.d.ts +26 -0
  69. package/dist/types/ast-nodes/jsx-element.d.ts +21 -0
  70. package/dist/types/ast-nodes/root.d.ts +19 -0
  71. package/dist/types/rules/use-primitives/transformers/compiled-styled/convert-jsx-call-site.d.ts +17 -0
  72. package/dist/types/rules/use-primitives/transformers/compiled-styled/convert-styled-component-call-to-jsx.d.ts +17 -0
  73. package/dist/types/rules/use-primitives/transformers/compiled-styled/index.d.ts +25 -0
  74. package/dist/types/rules/use-primitives/transformers/compiled-styled/supported.d.ts +2 -0
  75. package/dist/types/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.d.ts +14 -0
  76. package/dist/types/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.d.ts +7 -0
  77. package/dist/types/rules/use-primitives/transformers/emotion-css/index.d.ts +16 -0
  78. package/dist/types/rules/use-primitives/transformers/emotion-css/supported.d.ts +2 -0
  79. package/dist/types/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.d.ts +14 -0
  80. package/dist/types/rules/use-primitives/transformers/index.d.ts +2 -2
  81. package/dist/types/rules/use-primitives/utils/index.d.ts +0 -6
  82. package/dist/types-ts4.5/ast-nodes/function-call.d.ts +21 -0
  83. package/dist/types-ts4.5/ast-nodes/import.d.ts +16 -0
  84. package/dist/types-ts4.5/ast-nodes/index.d.ts +5 -0
  85. package/dist/types-ts4.5/ast-nodes/jsx-attribute.d.ts +26 -0
  86. package/dist/types-ts4.5/ast-nodes/jsx-element.d.ts +21 -0
  87. package/dist/types-ts4.5/ast-nodes/root.d.ts +19 -0
  88. package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/convert-jsx-call-site.d.ts +17 -0
  89. package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/convert-styled-component-call-to-jsx.d.ts +17 -0
  90. package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/index.d.ts +25 -0
  91. package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/supported.d.ts +2 -0
  92. package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.d.ts +14 -0
  93. package/dist/types-ts4.5/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.d.ts +7 -0
  94. package/dist/types-ts4.5/rules/use-primitives/transformers/emotion-css/index.d.ts +16 -0
  95. package/dist/types-ts4.5/rules/use-primitives/transformers/emotion-css/supported.d.ts +2 -0
  96. package/dist/types-ts4.5/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.d.ts +14 -0
  97. package/dist/types-ts4.5/rules/use-primitives/transformers/index.d.ts +2 -2
  98. package/dist/types-ts4.5/rules/use-primitives/utils/index.d.ts +0 -6
  99. package/package.json +1 -1
  100. package/dist/cjs/rules/use-primitives/transformers/jsx-element-to-box.js +0 -26
  101. package/dist/cjs/rules/use-primitives/transformers/styled-component-to-primitive.js +0 -68
  102. package/dist/cjs/rules/use-primitives/utils/contains-only-supported-attrs.js +0 -19
  103. package/dist/cjs/rules/use-primitives/utils/is-valid-tag-name.js +0 -13
  104. package/dist/cjs/rules/use-primitives/utils/update-jsx-element-name.js +0 -16
  105. package/dist/cjs/rules/use-primitives/utils/upsert-import-declaration.js +0 -80
  106. package/dist/es2019/rules/use-primitives/transformers/jsx-element-to-box.js +0 -16
  107. package/dist/es2019/rules/use-primitives/transformers/styled-component-to-primitive.js +0 -59
  108. package/dist/es2019/rules/use-primitives/utils/contains-only-supported-attrs.js +0 -13
  109. package/dist/es2019/rules/use-primitives/utils/is-valid-tag-name.js +0 -7
  110. package/dist/es2019/rules/use-primitives/utils/update-jsx-element-name.js +0 -12
  111. package/dist/es2019/rules/use-primitives/utils/upsert-import-declaration.js +0 -76
  112. package/dist/esm/rules/use-primitives/transformers/jsx-element-to-box.js +0 -19
  113. package/dist/esm/rules/use-primitives/transformers/styled-component-to-primitive.js +0 -61
  114. package/dist/esm/rules/use-primitives/utils/contains-only-supported-attrs.js +0 -13
  115. package/dist/esm/rules/use-primitives/utils/is-valid-tag-name.js +0 -7
  116. package/dist/esm/rules/use-primitives/utils/update-jsx-element-name.js +0 -10
  117. package/dist/esm/rules/use-primitives/utils/upsert-import-declaration.js +0 -75
  118. package/dist/types/rules/use-primitives/transformers/jsx-element-to-box.d.ts +0 -3
  119. package/dist/types/rules/use-primitives/transformers/styled-component-to-primitive.d.ts +0 -13
  120. package/dist/types/rules/use-primitives/utils/contains-only-supported-attrs.d.ts +0 -2
  121. package/dist/types/rules/use-primitives/utils/is-valid-tag-name.d.ts +0 -3
  122. package/dist/types/rules/use-primitives/utils/update-jsx-element-name.d.ts +0 -3
  123. package/dist/types/rules/use-primitives/utils/upsert-import-declaration.d.ts +0 -11
  124. package/dist/types-ts4.5/rules/use-primitives/transformers/jsx-element-to-box.d.ts +0 -3
  125. package/dist/types-ts4.5/rules/use-primitives/transformers/styled-component-to-primitive.d.ts +0 -13
  126. package/dist/types-ts4.5/rules/use-primitives/utils/contains-only-supported-attrs.d.ts +0 -2
  127. package/dist/types-ts4.5/rules/use-primitives/utils/is-valid-tag-name.d.ts +0 -3
  128. package/dist/types-ts4.5/rules/use-primitives/utils/update-jsx-element-name.d.ts +0 -3
  129. package/dist/types-ts4.5/rules/use-primitives/utils/upsert-import-declaration.d.ts +0 -11
  130. /package/dist/cjs/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-jsx-usage-to-transform.js +0 -0
  131. /package/dist/es2019/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-jsx-usage-to-transform.js +0 -0
  132. /package/dist/esm/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-jsx-usage-to-transform.js +0 -0
  133. /package/dist/types/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-jsx-usage-to-transform.d.ts +0 -0
  134. /package/dist/types/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-styled-component-call.d.ts +0 -0
  135. /package/dist/types-ts4.5/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-jsx-usage-to-transform.d.ts +0 -0
  136. /package/dist/types-ts4.5/rules/use-primitives/{utils → transformers/compiled-styled}/find-valid-styled-component-call.d.ts +0 -0
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.CompiledStyled = void 0;
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
+ var _eslintCodemodUtils = require("eslint-codemod-utils");
11
+ var ast = _interopRequireWildcard(require("../../../../ast-nodes"));
12
+ var _utils = require("../../utils");
13
+ var _convertJsxCallSite = require("./convert-jsx-call-site");
14
+ var _convertStyledComponentCallToJsx = require("./convert-styled-component-call-to-jsx");
15
+ var _findValidJsxUsageToTransform = require("./find-valid-jsx-usage-to-transform");
16
+ var _findValidStyledComponentCall = require("./find-valid-styled-component-call");
17
+ var _upsertImportDeclaration = require("./upsert-import-declaration");
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
+ /* eslint-disable @repo/internal/react/require-jsdoc */
21
+
22
+ var CompiledStyled = exports.CompiledStyled = {
23
+ lint: function lint(node, _ref) {
24
+ var context = _ref.context,
25
+ config = _ref.config;
26
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression')) {
27
+ return;
28
+ }
29
+
30
+ // Check whether all criteria needed to make a transformation are met
31
+ var _CompiledStyled$_chec = CompiledStyled._check(node, {
32
+ context: context,
33
+ config: config
34
+ }),
35
+ success = _CompiledStyled$_chec.success,
36
+ refs = _CompiledStyled$_chec.refs;
37
+ if (!success || !refs) {
38
+ return;
39
+ }
40
+ context.report({
41
+ node: refs.styles,
42
+ messageId: 'preferPrimitivesBox',
43
+ suggest: [{
44
+ desc: "Convert ".concat(ast.JSXElement.getName(refs.jsxElement), " to Box"),
45
+ fix: CompiledStyled._fix(refs, context)
46
+ }]
47
+ });
48
+ },
49
+ _check: function _check(node, _ref2) {
50
+ var context = _ref2.context,
51
+ config = _ref2.config;
52
+ if (!config.patterns.includes('compiled-styled-object')) {
53
+ return {
54
+ success: false
55
+ };
56
+ }
57
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression')) {
58
+ return {
59
+ success: false
60
+ };
61
+ }
62
+ var styledComponentVariableRef = (0, _findValidStyledComponentCall.findValidStyledComponentCall)(node);
63
+ if (!styledComponentVariableRef || !(0, _eslintCodemodUtils.isNodeOfType)(styledComponentVariableRef.id, 'Identifier') || !(0, _utils.isValidCssPropertiesToTransform)(node, config)) {
64
+ return {
65
+ success: false
66
+ };
67
+ }
68
+ var styledComponentJsxRef = (0, _findValidJsxUsageToTransform.findValidJsxUsageToTransform)(styledComponentVariableRef.id.name, context.getScope());
69
+ if (!styledComponentJsxRef) {
70
+ return {
71
+ success: false
72
+ };
73
+ }
74
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(styledComponentJsxRef.parent, 'JSXElement')) {
75
+ return {
76
+ success: false
77
+ };
78
+ }
79
+ var importDeclaration = ast.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/primitives');
80
+
81
+ // If there is more than one `@atlaskit/primitives` import, then it becomes difficult to determine which import to transform
82
+ if (importDeclaration.length > 1) {
83
+ return {
84
+ success: false
85
+ };
86
+ }
87
+ return {
88
+ success: true,
89
+ refs: {
90
+ styles: styledComponentVariableRef,
91
+ jsxElement: styledComponentJsxRef.parent
92
+ }
93
+ };
94
+ },
95
+ /**
96
+ * All required validation steps have been taken care of before this
97
+ * transformer is called, so it just goes ahead providing all necessary fixes
98
+ */
99
+ _fix: function _fix(refs, context) {
100
+ return function (fixer) {
101
+ // generates the new variable name: MyComponent -> myComponentStyles
102
+ var calculatedStylesVariableName = (0, _eslintCodemodUtils.isNodeOfType)(refs.styles.id, 'Identifier') && "".concat(refs.styles.id.name.replace(refs.styles.id.name[0], refs.styles.id.name[0].toLowerCase()), "Styles");
103
+ if (!calculatedStylesVariableName) {
104
+ return [];
105
+ }
106
+ var importFixes = (0, _upsertImportDeclaration.upsertImportDeclaration)({
107
+ module: '@atlaskit/primitives',
108
+ specifiers: ['Box', 'xcss']
109
+ }, context, fixer);
110
+ var stylesFixes = (0, _convertStyledComponentCallToJsx.convertStyledComponentToXcss)(refs.styles, calculatedStylesVariableName, fixer);
111
+ var jsxFixes = (0, _convertJsxCallSite.convertJsxCallSite)(refs.jsxElement, calculatedStylesVariableName, fixer);
112
+ return [importFixes].concat((0, _toConsumableArray2.default)(stylesFixes), (0, _toConsumableArray2.default)(jsxFixes)).filter(function (fix) {
113
+ return Boolean(fix);
114
+ }); // Some of the transformers can return arrays with undefined, so filter them out
115
+ };
116
+ }
117
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.elements = exports.attributes = void 0;
7
+ var elements = exports.elements = ['div'];
8
+ var attributes = exports.attributes = ['css'
9
+ // 'data-testid'
10
+ ];
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.upsertImportDeclaration = void 0;
8
+ var ast = _interopRequireWildcard(require("../../../../ast-nodes"));
9
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ /**
12
+ * Currently this is defined here because it's not very general purpose.
13
+ * If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
14
+ * and the other half would be in `Import`.
15
+ *
16
+ * TODO: Refactor and move to `ast-nodes`
17
+ *
18
+ * Note: It does not handle default imports, namespace imports, or aliased imports.
19
+ */
20
+ var upsertImportDeclaration = exports.upsertImportDeclaration = function upsertImportDeclaration(_ref, context, fixer) {
21
+ var module = _ref.module,
22
+ specifiers = _ref.specifiers;
23
+ // Find any imports that match the packageName
24
+ var root = context.getSourceCode().ast.body;
25
+ var importDeclarations = ast.Root.findImportsByModule(root, module);
26
+
27
+ // The import doesn't exist yet, we can just insert a whole new one
28
+ if (importDeclarations.length === 0) {
29
+ return ast.Root.insertImport(root, {
30
+ module: module,
31
+ specifiers: specifiers
32
+ }, fixer);
33
+ }
34
+
35
+ // The import exists so, modify the existing one
36
+ return ast.Import.insertNamedSpecifiers(importDeclarations[0], specifiers, fixer);
37
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.containsOnlySupportedAttrs = void 0;
8
+ var _eslintCodemodUtils = require("eslint-codemod-utils");
9
+ var ast = _interopRequireWildcard(require("../../../../ast-nodes"));
10
+ var supported = _interopRequireWildcard(require("./supported"));
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ /**
14
+ * Check that every attribute in the JSXElement is something we support.
15
+ * We do this via a whitelist in `this.attributes`. The result is we exclude
16
+ * dangerous attrs like `id` and `style`.
17
+ */
18
+ var containsOnlySupportedAttrs = exports.containsOnlySupportedAttrs = function containsOnlySupportedAttrs(node) {
19
+ var attrs = ast.JSXElement.getAttributes(node);
20
+ return attrs.every(function (attr) {
21
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(attr, 'JSXAttribute')) {
22
+ return false;
23
+ }
24
+ var name = ast.JSXAttribute.getName(attr);
25
+ return supported.attributes.includes(name);
26
+ });
27
+ };
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.EmotionCSS = void 0;
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
+ var _eslintCodemodUtils = require("eslint-codemod-utils");
11
+ var ast = _interopRequireWildcard(require("../../../../ast-nodes"));
12
+ var _utils = require("../../utils");
13
+ var _cssToXcss = require("../css-to-xcss");
14
+ var _containsOnlySupportedAttrs = require("./contains-only-supported-attrs");
15
+ var supported = _interopRequireWildcard(require("./supported"));
16
+ var _upsertImportDeclaration = require("./upsert-import-declaration");
17
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+ /* eslint-disable @repo/internal/react/require-jsdoc */
20
+
21
+ var EmotionCSS = exports.EmotionCSS = {
22
+ lint: function lint(node, _ref) {
23
+ var context = _ref.context,
24
+ config = _ref.config;
25
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) {
26
+ return;
27
+ }
28
+
29
+ // Check whether all criteria needed to make a transformation are met
30
+ if (!EmotionCSS._check(node, {
31
+ context: context,
32
+ config: config
33
+ })) {
34
+ return;
35
+ }
36
+ context.report({
37
+ node: node.openingElement,
38
+ messageId: 'preferPrimitivesBox',
39
+ suggest: [{
40
+ desc: "Convert to Box",
41
+ fix: EmotionCSS._fix(node, {
42
+ context: context
43
+ })
44
+ }]
45
+ });
46
+ },
47
+ _check: function _check(node, _ref2) {
48
+ var _cssVariableValue$nod, _cssVariableValue$nod2;
49
+ var context = _ref2.context,
50
+ config = _ref2.config;
51
+ if (!config.patterns.includes('compiled-css-function')) {
52
+ return false;
53
+ }
54
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) {
55
+ return false;
56
+ }
57
+ var elementName = ast.JSXElement.getName(node);
58
+ if (!elementName) {
59
+ return false;
60
+ }
61
+
62
+ // Currently we only support `div`. This may change in future.
63
+ if (!supported.elements.includes(elementName)) {
64
+ return false;
65
+ }
66
+
67
+ // Ignore elements that contain dangerous attributes like `id`.
68
+ if (!(0, _containsOnlySupportedAttrs.containsOnlySupportedAttrs)(node)) {
69
+ return false;
70
+ }
71
+
72
+ // Currently we don't transform anything to `Box` unless it defines styles
73
+ var cssAttr = ast.JSXElement.getAttributeByName(node, 'css');
74
+ if (!cssAttr) {
75
+ return false;
76
+ }
77
+
78
+ // Get `myStyles` in `css={myStyles}` as a string so we can search for the `const myStyles` VariableDefinition
79
+ var cssAttrValue = ast.JSXAttribute.getValue(cssAttr);
80
+ if ((cssAttrValue === null || cssAttrValue === void 0 ? void 0 : cssAttrValue.type) !== 'ExpressionStatement') {
81
+ return false;
82
+ }
83
+
84
+ // TODO: Everything below this line could be refactored to use `ast-nodes`.
85
+
86
+ // Bail if the styles are used on multiple JSXElements
87
+ if ((0, _utils.getVariableUsagesCount)(cssAttrValue.value, context) !== 1) {
88
+ return false;
89
+ }
90
+
91
+ // Find where `myStyles` is defined. We're looking for `const myStyles = css({...})`
92
+ var cssVariableDefinition = (0, _eslintCodemodUtils.getIdentifierInParentScope)(context.getScope(), cssAttrValue.value);
93
+ var cssVariableValue = (0, _utils.getVariableDefinitionValue)(cssVariableDefinition);
94
+ // Check if `cssVariableValue` is a function called `css()`
95
+ if (ast.FunctionCall.getName(cssVariableValue === null || cssVariableValue === void 0 || (_cssVariableValue$nod = cssVariableValue.node) === null || _cssVariableValue$nod === void 0 ? void 0 : _cssVariableValue$nod.init) !== 'css') {
96
+ return false;
97
+ }
98
+ if (!(0, _utils.isValidCssPropertiesToTransform)(cssVariableValue === null || cssVariableValue === void 0 || (_cssVariableValue$nod2 = cssVariableValue.node) === null || _cssVariableValue$nod2 === void 0 ? void 0 : _cssVariableValue$nod2.init, config)) {
99
+ return false;
100
+ }
101
+ var importDeclaration = ast.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/primitives');
102
+
103
+ // If there is more than one `@atlaskit/primitives` import, then it becomes difficult to determine which import to transform
104
+ if (importDeclaration.length > 1) {
105
+ return false;
106
+ }
107
+ return true;
108
+ },
109
+ _fix: function _fix(node, _ref3) {
110
+ var context = _ref3.context;
111
+ return function (fixer) {
112
+ var importFix = (0, _upsertImportDeclaration.upsertImportDeclaration)({
113
+ module: '@atlaskit/primitives',
114
+ specifiers: ['Box', 'xcss']
115
+ }, context, fixer);
116
+ var cssAttr = ast.JSXElement.getAttributeByName(node, 'css'); // Can strongly assert the type here, because we validated it exists in `check()`.
117
+ var attributeFix = ast.JSXAttribute.updateName(cssAttr, 'xcss', fixer);
118
+ var elementNameFixes = ast.JSXElement.updateName(node, 'Box', fixer);
119
+ var cssToXcssTransform = (0, _cssToXcss.cssToXcssTransformer)(node, context, fixer);
120
+ return [importFix, attributeFix].concat((0, _toConsumableArray2.default)(elementNameFixes), (0, _toConsumableArray2.default)(cssToXcssTransform)).filter(function (fix) {
121
+ return Boolean(fix);
122
+ }); // Some of the transformers can return arrays with undefined, so filter them out
123
+ };
124
+ }
125
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.elements = exports.attributes = void 0;
7
+ var elements = exports.elements = ['div'];
8
+ var attributes = exports.attributes = ['css'
9
+ // 'data-testid'
10
+ ];
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.upsertImportDeclaration = void 0;
8
+ var ast = _interopRequireWildcard(require("../../../../ast-nodes"));
9
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ /**
12
+ * Currently this is defined here because it's not very general purpose.
13
+ * If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
14
+ * and the other half would be in `Import`.
15
+ *
16
+ * TODO: Refactor and move to `ast-nodes`
17
+ *
18
+ * Note: It does not handle default imports, namespace imports, or aliased imports.
19
+ */
20
+ var upsertImportDeclaration = exports.upsertImportDeclaration = function upsertImportDeclaration(_ref, context, fixer) {
21
+ var module = _ref.module,
22
+ specifiers = _ref.specifiers;
23
+ // Find any imports that match the packageName
24
+ var root = context.getSourceCode().ast.body;
25
+ var importDeclarations = ast.Root.findImportsByModule(root, module);
26
+
27
+ // The import doesn't exist yet, we can just insert a whole new one
28
+ if (importDeclarations.length === 0) {
29
+ return ast.Root.insertImport(root, {
30
+ module: module,
31
+ specifiers: specifiers
32
+ }, fixer);
33
+ }
34
+
35
+ // The import exists so, modify the existing one
36
+ return ast.Import.insertNamedSpecifiers(importDeclarations[0], specifiers, fixer);
37
+ };
@@ -3,28 +3,28 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "cssToXcssTransformer", {
6
+ Object.defineProperty(exports, "CompiledStyled", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
- return _cssToXcss.cssToXcssTransformer;
9
+ return _compiledStyled.CompiledStyled;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "jsxElementToBoxTransformer", {
12
+ Object.defineProperty(exports, "EmotionCSS", {
13
13
  enumerable: true,
14
14
  get: function get() {
15
- return _jsxElementToBox.jsxElementToBoxTransformer;
15
+ return _emotionCss.EmotionCSS;
16
16
  }
17
17
  });
18
- Object.defineProperty(exports, "spaceTokenMap", {
18
+ Object.defineProperty(exports, "cssToXcssTransformer", {
19
19
  enumerable: true,
20
20
  get: function get() {
21
- return _cssToXcss.spaceTokenMap;
21
+ return _cssToXcss.cssToXcssTransformer;
22
22
  }
23
23
  });
24
- Object.defineProperty(exports, "styledComponentToPrimitive", {
24
+ Object.defineProperty(exports, "spaceTokenMap", {
25
25
  enumerable: true,
26
26
  get: function get() {
27
- return _styledComponentToPrimitive.styledComponentToPrimitive;
27
+ return _cssToXcss.spaceTokenMap;
28
28
  }
29
29
  });
30
30
  Object.defineProperty(exports, "supportedStylesMap", {
@@ -34,5 +34,5 @@ Object.defineProperty(exports, "supportedStylesMap", {
34
34
  }
35
35
  });
36
36
  var _cssToXcss = require("./css-to-xcss");
37
- var _jsxElementToBox = require("./jsx-element-to-box");
38
- var _styledComponentToPrimitive = require("./styled-component-to-primitive");
37
+ var _compiledStyled = require("./compiled-styled");
38
+ var _emotionCss = require("./emotion-css");
@@ -3,30 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "containsOnlySupportedAttrs", {
7
- enumerable: true,
8
- get: function get() {
9
- return _containsOnlySupportedAttrs.containsOnlySupportedAttrs;
10
- }
11
- });
12
6
  Object.defineProperty(exports, "convertASTObjectExpressionToJSObject", {
13
7
  enumerable: true,
14
8
  get: function get() {
15
9
  return _convertAstObjectExpressionToJsObject.convertASTObjectExpressionToJSObject;
16
10
  }
17
11
  });
18
- Object.defineProperty(exports, "findValidJsxUsageToTransform", {
19
- enumerable: true,
20
- get: function get() {
21
- return _findValidJsxUsageToTransform.findValidJsxUsageToTransform;
22
- }
23
- });
24
- Object.defineProperty(exports, "findValidStyledComponentCall", {
25
- enumerable: true,
26
- get: function get() {
27
- return _findValidStyledComponentCall.findValidStyledComponentCall;
28
- }
29
- });
30
12
  Object.defineProperty(exports, "getAttributeValueIdentifier", {
31
13
  enumerable: true,
32
14
  get: function get() {
@@ -69,34 +51,13 @@ Object.defineProperty(exports, "isValidCssPropertiesToTransform", {
69
51
  return _isValidCssPropertiesToTransform.isValidCssPropertiesToTransform;
70
52
  }
71
53
  });
72
- Object.defineProperty(exports, "isValidTagName", {
73
- enumerable: true,
74
- get: function get() {
75
- return _isValidTagName.isValidTagName;
76
- }
77
- });
78
54
  Object.defineProperty(exports, "updateJSXAttributeByName", {
79
55
  enumerable: true,
80
56
  get: function get() {
81
57
  return _updateJsxAttributeByName.updateJSXAttributeByName;
82
58
  }
83
59
  });
84
- Object.defineProperty(exports, "updateJSXElementName", {
85
- enumerable: true,
86
- get: function get() {
87
- return _updateJsxElementName.updateJSXElementName;
88
- }
89
- });
90
- Object.defineProperty(exports, "upsertImportDeclaration", {
91
- enumerable: true,
92
- get: function get() {
93
- return _upsertImportDeclaration.upsertImportDeclaration;
94
- }
95
- });
96
- var _containsOnlySupportedAttrs = require("./contains-only-supported-attrs");
97
60
  var _convertAstObjectExpressionToJsObject = require("./convert-ast-object-expression-to-js-object");
98
- var _findValidJsxUsageToTransform = require("./find-valid-jsx-usage-to-transform");
99
- var _findValidStyledComponentCall = require("./find-valid-styled-component-call");
100
61
  var _getAttributeValueIdentifier = require("./get-attribute-value-identifier");
101
62
  var _getFunctionArgumentAtPos = require("./get-function-argument-at-pos");
102
63
  var _getJsxAttributeByName = require("./get-jsx-attribute-by-name");
@@ -104,7 +65,4 @@ var _getVariableDefinitionValue = require("./get-variable-definition-value");
104
65
  var _getVariableUsageCount = require("./get-variable-usage-count");
105
66
  var _isFunctionNamed = require("./is-function-named");
106
67
  var _isValidCssPropertiesToTransform = require("./is-valid-css-properties-to-transform");
107
- var _isValidTagName = require("./is-valid-tag-name");
108
- var _updateJsxAttributeByName = require("./update-jsx-attribute-by-name");
109
- var _updateJsxElementName = require("./update-jsx-element-name");
110
- var _upsertImportDeclaration = require("./upsert-import-declaration");
68
+ var _updateJsxAttributeByName = require("./update-jsx-attribute-by-name");
@@ -12,6 +12,9 @@ var _cssToXcss = require("../transformers/css-to-xcss");
12
12
  var _convertAstObjectExpressionToJsObject = require("./convert-ast-object-expression-to-js-object");
13
13
  var _excluded = ["unsupported"];
14
14
  var isValidCssPropertiesToTransform = exports.isValidCssPropertiesToTransform = function isValidCssPropertiesToTransform(node, config) {
15
+ if (!node) {
16
+ return false;
17
+ }
15
18
  var cssObjectExpression = node.arguments[0];
16
19
  // Bail on empty object calls
17
20
  if (!cssObjectExpression || !(0, _eslintCodemodUtils.isNodeOfType)(cssObjectExpression, 'ObjectExpression')) {
@@ -0,0 +1,42 @@
1
+ /* eslint-disable @repo/internal/react/require-jsdoc */
2
+
3
+ import { isNodeOfType } from 'eslint-codemod-utils';
4
+ export const FunctionCall = {
5
+ getName(node) {
6
+ if (!isNodeOfType(node, 'CallExpression')) {
7
+ return undefined;
8
+ }
9
+ if (!isNodeOfType(node.callee, 'Identifier')) {
10
+ return undefined;
11
+ }
12
+ return node.callee.name;
13
+ },
14
+ updateName(node, newName, fixer) {
15
+ return fixer.replaceText(node.callee, newName);
16
+ },
17
+ /**
18
+ * Function arguments can be many things:
19
+ * `css(myStyles, () => {}, undefined, 'literal', ...rest) // etc`
20
+ * They all need slightly different treatment.
21
+ *
22
+ * Currently 'getArgumentAtPos' only implements strategies for Literals and ObjectExpressions.
23
+ * If you need to support another type of arg, add it, and update the type.
24
+ */
25
+ getArgumentAtPos(node, pos) {
26
+ const argument = node.arguments[pos];
27
+ if (isNodeOfType(argument, 'Literal') && argument.value) {
28
+ var _argument$value;
29
+ return {
30
+ type: 'Literal',
31
+ value: (_argument$value = argument.value) === null || _argument$value === void 0 ? void 0 : _argument$value.toString()
32
+ };
33
+ }
34
+ if (isNodeOfType(argument, 'ObjectExpression')) {
35
+ argument;
36
+ return {
37
+ type: 'ObjectExpression',
38
+ value: argument
39
+ };
40
+ }
41
+ }
42
+ };
@@ -0,0 +1,42 @@
1
+ /* eslint-disable @repo/internal/react/require-jsdoc */
2
+
3
+ import { insertImportSpecifier, isNodeOfType } from 'eslint-codemod-utils';
4
+ export const Import = {
5
+ /**
6
+ * Note: fixes can't overlap, which means this will fail:
7
+ * ```
8
+ * const importNode = Root.findImportByModule('@atlaskit/primitives')
9
+ * Import.insertNamedSpecifier(importNode, 'Box')
10
+ * Import.insertNamedSpecifier(importNode, 'xcss')
11
+ * ```
12
+ *
13
+ * For this reason `insertNamedSpecifiers` accepts a `specifiers` array, so you can group all inserts together.
14
+ */
15
+ insertNamedSpecifiers(node, specifiers, fixer) {
16
+ /**
17
+ * `insertImportSpecifier()` has the unfortunate implementation detail of naively adding duplicate specifiers.
18
+ * e.g. calling
19
+ * `insertImportSpecifier(importDecl, 'xcss')`
20
+ * on
21
+ * `import { Inline, xcss } from '@atlaskit/primitives'`
22
+ * will result in:
23
+ * `import { Inline, xcss, xcss } from '@atlaskit/primitives'`.
24
+ * So, we need to filter out specifiers that are already imported.
25
+ */
26
+ const uniqueSpecifiers = specifiers.filter(specifier => {
27
+ return !this.containsNamedSpecifier(node, specifier);
28
+ });
29
+ if (uniqueSpecifiers.length === 0) {
30
+ return;
31
+ }
32
+ return fixer.replaceText(node, `${insertImportSpecifier(node, uniqueSpecifiers.join(', '))};\n`);
33
+ },
34
+ containsNamedSpecifier(node, name) {
35
+ return node.specifiers.some(specifier => {
36
+ if (!isNodeOfType(specifier, 'ImportSpecifier')) {
37
+ return false;
38
+ }
39
+ return specifier.imported.name === name;
40
+ });
41
+ }
42
+ };
@@ -0,0 +1,5 @@
1
+ export { FunctionCall } from './function-call';
2
+ export { Import } from './import';
3
+ export { JSXAttribute } from './jsx-attribute';
4
+ export { JSXElement } from './jsx-element';
5
+ export { Root } from './root';
@@ -0,0 +1,59 @@
1
+ import { isNodeOfType, literal } from 'eslint-codemod-utils';
2
+ const HelperJSXAttribute = {
3
+ getName(node) {
4
+ if (!isNodeOfType(node, 'JSXAttribute')) {
5
+ throw new Error('Not a JSXAttribute');
6
+ }
7
+ if (!isNodeOfType(node.name, 'JSXIdentifier')) {
8
+ throw new Error('name is not a JSXIdentifier');
9
+ }
10
+ return node.name.name;
11
+ },
12
+ updateName(node, name, fixer) {
13
+ if (!isNodeOfType(node, 'JSXAttribute')) {
14
+ throw new Error('Not a JSXAttribute');
15
+ }
16
+ if (!isNodeOfType(node.name, 'JSXIdentifier')) {
17
+ throw new Error('name is not a JSXIdentifier');
18
+ }
19
+ return fixer.replaceText(node.name, literal(name).toString());
20
+ },
21
+ /**
22
+ * A JSXAttribute value can be many things:
23
+ * - css='myStyles'
24
+ * - css={myStyles}
25
+ * - css={[styles1, styles2]}
26
+ * - header={<></>}
27
+ * - css={styleMap.header}
28
+ * - css={...styles}
29
+ *
30
+ * Currently, `getValue` has only implemented strategies for when the value is a string, or an ExpressionStatement
31
+ * If you need additional functionality add it, and set the correct `type` on the returned object
32
+ */
33
+ getValue(node) {
34
+ if (!isNodeOfType(node, 'JSXAttribute')) {
35
+ return;
36
+ }
37
+ if (!node.value) {
38
+ return;
39
+ }
40
+
41
+ // handle `css={myStyles}`
42
+ if (isNodeOfType(node.value, 'JSXExpressionContainer') && isNodeOfType(node.value.expression, 'Identifier')) {
43
+ return {
44
+ type: 'ExpressionStatement',
45
+ value: node.value.expression.name
46
+ };
47
+ }
48
+
49
+ // handle `css='myStyles'`
50
+ if (isNodeOfType(node.value, 'Literal') && node.value.value) {
51
+ var _node$value$value;
52
+ return {
53
+ type: 'Literal',
54
+ value: (_node$value$value = node.value.value) === null || _node$value$value === void 0 ? void 0 : _node$value$value.toString()
55
+ };
56
+ }
57
+ }
58
+ };
59
+ export { HelperJSXAttribute as JSXAttribute };