@compiled/react 0.6.12 → 0.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.
Files changed (219) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/browser/class-names/index.d.ts +2 -2
  3. package/dist/browser/class-names/index.js.flow +45 -0
  4. package/dist/browser/css/index.d.ts +17 -3
  5. package/dist/browser/css/index.js +4 -12
  6. package/dist/browser/css/index.js.flow +35 -0
  7. package/dist/browser/css/index.js.map +1 -1
  8. package/dist/browser/index.d.ts +4 -1
  9. package/dist/browser/index.js +1 -0
  10. package/dist/browser/index.js.flow +40 -0
  11. package/dist/browser/index.js.map +1 -1
  12. package/dist/browser/keyframes/__fixtures__/index.d.ts +3 -0
  13. package/dist/browser/keyframes/__fixtures__/index.js +12 -0
  14. package/dist/browser/keyframes/__fixtures__/index.js.map +1 -0
  15. package/dist/browser/keyframes/index.d.ts +47 -0
  16. package/dist/browser/keyframes/index.js +9 -0
  17. package/dist/browser/keyframes/index.js.flow +54 -0
  18. package/dist/browser/keyframes/index.js.map +1 -0
  19. package/dist/browser/runtime/ax.js.flow +27 -0
  20. package/dist/browser/runtime/css-custom-property.js.flow +19 -0
  21. package/dist/browser/runtime/dev-warnings.d.ts +0 -1
  22. package/dist/browser/runtime/dev-warnings.js +1 -1
  23. package/dist/browser/runtime/dev-warnings.js.flow +7 -0
  24. package/dist/browser/runtime/dev-warnings.js.map +1 -1
  25. package/dist/browser/runtime/index.js.flow +10 -0
  26. package/dist/browser/runtime/is-node.js.flow +19 -0
  27. package/dist/browser/runtime/sheet.d.ts +1 -1
  28. package/dist/browser/runtime/sheet.js.flow +36 -0
  29. package/dist/browser/runtime/style-cache.d.ts +1 -1
  30. package/dist/browser/runtime/style-cache.js.flow +19 -0
  31. package/dist/browser/runtime/style.d.ts +1 -1
  32. package/dist/browser/runtime/style.js.flow +17 -0
  33. package/dist/browser/runtime/types.js.flow +23 -0
  34. package/dist/browser/runtime.js.flow +7 -0
  35. package/dist/browser/styled/index.d.ts +6 -9
  36. package/dist/browser/styled/index.js.flow +69 -0
  37. package/dist/browser/styled/index.js.map +1 -1
  38. package/dist/browser/types.d.ts +6 -3
  39. package/dist/browser/types.js.flow +29 -0
  40. package/dist/browser/utils/error.js.flow +7 -0
  41. package/dist/cjs/class-names/index.d.ts +2 -2
  42. package/dist/cjs/class-names/index.js.flow +45 -0
  43. package/dist/cjs/css/index.d.ts +17 -3
  44. package/dist/cjs/css/index.js +4 -12
  45. package/dist/cjs/css/index.js.flow +35 -0
  46. package/dist/cjs/css/index.js.map +1 -1
  47. package/dist/cjs/index.d.ts +4 -1
  48. package/dist/cjs/index.js +3 -1
  49. package/dist/cjs/index.js.flow +40 -0
  50. package/dist/cjs/index.js.map +1 -1
  51. package/dist/cjs/keyframes/__fixtures__/index.d.ts +3 -0
  52. package/dist/cjs/keyframes/__fixtures__/index.js +15 -0
  53. package/dist/cjs/keyframes/__fixtures__/index.js.map +1 -0
  54. package/dist/cjs/keyframes/index.d.ts +47 -0
  55. package/dist/cjs/keyframes/index.js +13 -0
  56. package/dist/cjs/keyframes/index.js.flow +54 -0
  57. package/dist/cjs/keyframes/index.js.map +1 -0
  58. package/dist/cjs/runtime/ax.js.flow +27 -0
  59. package/dist/cjs/runtime/css-custom-property.js.flow +19 -0
  60. package/dist/cjs/runtime/dev-warnings.d.ts +0 -1
  61. package/dist/cjs/runtime/dev-warnings.js +2 -3
  62. package/dist/cjs/runtime/dev-warnings.js.flow +7 -0
  63. package/dist/cjs/runtime/dev-warnings.js.map +1 -1
  64. package/dist/cjs/runtime/index.js.flow +10 -0
  65. package/dist/cjs/runtime/is-node.js.flow +19 -0
  66. package/dist/cjs/runtime/sheet.d.ts +1 -1
  67. package/dist/cjs/runtime/sheet.js.flow +36 -0
  68. package/dist/cjs/runtime/style-cache.d.ts +1 -1
  69. package/dist/cjs/runtime/style-cache.js.flow +19 -0
  70. package/dist/cjs/runtime/style.d.ts +1 -1
  71. package/dist/cjs/runtime/style.js.flow +17 -0
  72. package/dist/cjs/runtime/types.js.flow +23 -0
  73. package/dist/cjs/runtime.js.flow +7 -0
  74. package/dist/cjs/styled/index.d.ts +6 -9
  75. package/dist/cjs/styled/index.js.flow +69 -0
  76. package/dist/cjs/styled/index.js.map +1 -1
  77. package/dist/cjs/types.d.ts +6 -3
  78. package/dist/cjs/types.js.flow +29 -0
  79. package/dist/cjs/utils/error.js.flow +7 -0
  80. package/dist/esm/class-names/index.d.ts +2 -2
  81. package/dist/esm/class-names/index.js.flow +45 -0
  82. package/dist/esm/css/index.d.ts +17 -3
  83. package/dist/esm/css/index.js +4 -12
  84. package/dist/esm/css/index.js.flow +35 -0
  85. package/dist/esm/css/index.js.map +1 -1
  86. package/dist/esm/index.d.ts +4 -1
  87. package/dist/esm/index.js +1 -0
  88. package/dist/esm/index.js.flow +40 -0
  89. package/dist/esm/index.js.map +1 -1
  90. package/dist/esm/keyframes/__fixtures__/index.d.ts +3 -0
  91. package/dist/esm/keyframes/__fixtures__/index.js +12 -0
  92. package/dist/esm/keyframes/__fixtures__/index.js.map +1 -0
  93. package/dist/esm/keyframes/index.d.ts +47 -0
  94. package/dist/esm/keyframes/index.js +9 -0
  95. package/dist/esm/keyframes/index.js.flow +54 -0
  96. package/dist/esm/keyframes/index.js.map +1 -0
  97. package/dist/esm/runtime/ax.js.flow +27 -0
  98. package/dist/esm/runtime/css-custom-property.js.flow +19 -0
  99. package/dist/esm/runtime/dev-warnings.d.ts +0 -1
  100. package/dist/esm/runtime/dev-warnings.js +1 -1
  101. package/dist/esm/runtime/dev-warnings.js.flow +7 -0
  102. package/dist/esm/runtime/dev-warnings.js.map +1 -1
  103. package/dist/esm/runtime/index.js.flow +10 -0
  104. package/dist/esm/runtime/is-node.js.flow +19 -0
  105. package/dist/esm/runtime/sheet.d.ts +1 -1
  106. package/dist/esm/runtime/sheet.js.flow +36 -0
  107. package/dist/esm/runtime/style-cache.d.ts +1 -1
  108. package/dist/esm/runtime/style-cache.js.flow +19 -0
  109. package/dist/esm/runtime/style.d.ts +1 -1
  110. package/dist/esm/runtime/style.js.flow +17 -0
  111. package/dist/esm/runtime/types.js.flow +23 -0
  112. package/dist/esm/runtime.js.flow +7 -0
  113. package/dist/esm/styled/index.d.ts +6 -9
  114. package/dist/esm/styled/index.js.flow +69 -0
  115. package/dist/esm/styled/index.js.map +1 -1
  116. package/dist/esm/types.d.ts +6 -3
  117. package/dist/esm/types.js.flow +29 -0
  118. package/dist/esm/utils/error.js.flow +7 -0
  119. package/package.json +18 -20
  120. package/src/class-names/__tests__/types.test.js.flow +28 -0
  121. package/src/class-names/index.js.flow +45 -0
  122. package/src/class-names/index.tsx +2 -2
  123. package/src/css/__tests__/index.test.tsx +41 -0
  124. package/src/css/__tests__/types.test.js.flow +17 -0
  125. package/src/css/index.js.flow +35 -0
  126. package/src/css/index.tsx +26 -3
  127. package/src/index.js.flow +40 -0
  128. package/src/index.tsx +5 -2
  129. package/src/keyframes/__fixtures__/index.tsx +14 -0
  130. package/src/keyframes/__tests__/index.test.tsx +324 -0
  131. package/src/keyframes/__tests__/types.test.js.flow +31 -0
  132. package/src/keyframes/index.js.flow +54 -0
  133. package/src/keyframes/index.tsx +61 -0
  134. package/src/runtime/__tests__/style.test.tsx +91 -57
  135. package/src/runtime/ax.js.flow +27 -0
  136. package/src/runtime/css-custom-property.js.flow +19 -0
  137. package/src/runtime/dev-warnings.js.flow +7 -0
  138. package/src/runtime/dev-warnings.tsx +1 -1
  139. package/src/runtime/index.js.flow +10 -0
  140. package/src/runtime/is-node.js.flow +19 -0
  141. package/src/runtime/sheet.js.flow +36 -0
  142. package/src/runtime/sheet.tsx +1 -1
  143. package/src/runtime/style-cache.js.flow +19 -0
  144. package/src/runtime/style-cache.tsx +1 -1
  145. package/src/runtime/style.js.flow +17 -0
  146. package/src/runtime/style.tsx +1 -1
  147. package/src/runtime/types.js.flow +23 -0
  148. package/src/runtime.js.flow +7 -0
  149. package/src/styled/__tests__/types.test.js.flow +30 -0
  150. package/src/styled/index.js.flow +69 -0
  151. package/src/styled/index.tsx +6 -10
  152. package/src/types.js.flow +29 -0
  153. package/src/types.tsx +7 -3
  154. package/src/utils/error.js.flow +7 -0
  155. package/dist/browser/codemods/codemods-helpers.d.ts +0 -60
  156. package/dist/browser/codemods/codemods-helpers.js +0 -201
  157. package/dist/browser/codemods/codemods-helpers.js.map +0 -1
  158. package/dist/browser/codemods/constants.d.ts +0 -3
  159. package/dist/browser/codemods/constants.js +0 -4
  160. package/dist/browser/codemods/constants.js.map +0 -1
  161. package/dist/browser/codemods/emotion-to-compiled/emotion-to-compiled.d.ts +0 -3
  162. package/dist/browser/codemods/emotion-to-compiled/emotion-to-compiled.js +0 -178
  163. package/dist/browser/codemods/emotion-to-compiled/emotion-to-compiled.js.map +0 -1
  164. package/dist/browser/codemods/emotion-to-compiled/index.d.ts +0 -1
  165. package/dist/browser/codemods/emotion-to-compiled/index.js +0 -2
  166. package/dist/browser/codemods/emotion-to-compiled/index.js.map +0 -1
  167. package/dist/browser/codemods/styled-components-to-compiled/index.d.ts +0 -1
  168. package/dist/browser/codemods/styled-components-to-compiled/index.js +0 -2
  169. package/dist/browser/codemods/styled-components-to-compiled/index.js.map +0 -1
  170. package/dist/browser/codemods/styled-components-to-compiled/styled-components-to-compiled.d.ts +0 -3
  171. package/dist/browser/codemods/styled-components-to-compiled/styled-components-to-compiled.js +0 -33
  172. package/dist/browser/codemods/styled-components-to-compiled/styled-components-to-compiled.js.map +0 -1
  173. package/dist/cjs/codemods/codemods-helpers.d.ts +0 -60
  174. package/dist/cjs/codemods/codemods-helpers.js +0 -217
  175. package/dist/cjs/codemods/codemods-helpers.js.map +0 -1
  176. package/dist/cjs/codemods/constants.d.ts +0 -3
  177. package/dist/cjs/codemods/constants.js +0 -7
  178. package/dist/cjs/codemods/constants.js.map +0 -1
  179. package/dist/cjs/codemods/emotion-to-compiled/emotion-to-compiled.d.ts +0 -3
  180. package/dist/cjs/codemods/emotion-to-compiled/emotion-to-compiled.js +0 -180
  181. package/dist/cjs/codemods/emotion-to-compiled/emotion-to-compiled.js.map +0 -1
  182. package/dist/cjs/codemods/emotion-to-compiled/index.d.ts +0 -1
  183. package/dist/cjs/codemods/emotion-to-compiled/index.js +0 -9
  184. package/dist/cjs/codemods/emotion-to-compiled/index.js.map +0 -1
  185. package/dist/cjs/codemods/styled-components-to-compiled/index.d.ts +0 -1
  186. package/dist/cjs/codemods/styled-components-to-compiled/index.js +0 -9
  187. package/dist/cjs/codemods/styled-components-to-compiled/index.js.map +0 -1
  188. package/dist/cjs/codemods/styled-components-to-compiled/styled-components-to-compiled.d.ts +0 -3
  189. package/dist/cjs/codemods/styled-components-to-compiled/styled-components-to-compiled.js +0 -35
  190. package/dist/cjs/codemods/styled-components-to-compiled/styled-components-to-compiled.js.map +0 -1
  191. package/dist/esm/codemods/codemods-helpers.d.ts +0 -60
  192. package/dist/esm/codemods/codemods-helpers.js +0 -201
  193. package/dist/esm/codemods/codemods-helpers.js.map +0 -1
  194. package/dist/esm/codemods/constants.d.ts +0 -3
  195. package/dist/esm/codemods/constants.js +0 -4
  196. package/dist/esm/codemods/constants.js.map +0 -1
  197. package/dist/esm/codemods/emotion-to-compiled/emotion-to-compiled.d.ts +0 -3
  198. package/dist/esm/codemods/emotion-to-compiled/emotion-to-compiled.js +0 -178
  199. package/dist/esm/codemods/emotion-to-compiled/emotion-to-compiled.js.map +0 -1
  200. package/dist/esm/codemods/emotion-to-compiled/index.d.ts +0 -1
  201. package/dist/esm/codemods/emotion-to-compiled/index.js +0 -2
  202. package/dist/esm/codemods/emotion-to-compiled/index.js.map +0 -1
  203. package/dist/esm/codemods/styled-components-to-compiled/index.d.ts +0 -1
  204. package/dist/esm/codemods/styled-components-to-compiled/index.js +0 -2
  205. package/dist/esm/codemods/styled-components-to-compiled/index.js.map +0 -1
  206. package/dist/esm/codemods/styled-components-to-compiled/styled-components-to-compiled.d.ts +0 -3
  207. package/dist/esm/codemods/styled-components-to-compiled/styled-components-to-compiled.js +0 -33
  208. package/dist/esm/codemods/styled-components-to-compiled/styled-components-to-compiled.js.map +0 -1
  209. package/src/codemods/README.md +0 -8
  210. package/src/codemods/codemods-helpers.tsx +0 -369
  211. package/src/codemods/constants.tsx +0 -3
  212. package/src/codemods/emotion-to-compiled/README.md +0 -71
  213. package/src/codemods/emotion-to-compiled/__tests__/emotion-to-compiled.test.tsx +0 -526
  214. package/src/codemods/emotion-to-compiled/emotion-to-compiled.tsx +0 -249
  215. package/src/codemods/emotion-to-compiled/index.tsx +0 -1
  216. package/src/codemods/styled-components-to-compiled/README.md +0 -37
  217. package/src/codemods/styled-components-to-compiled/__tests__/styled-components-to-compiled.test.tsx +0 -109
  218. package/src/codemods/styled-components-to-compiled/index.tsx +0 -1
  219. package/src/codemods/styled-components-to-compiled/styled-components-to-compiled.tsx +0 -45
@@ -1,60 +0,0 @@
1
- import { JSCodeshift, ImportDeclaration, ImportDefaultSpecifier, ImportSpecifier, Program, Identifier, JSXIdentifier, TSTypeParameter, Node, Collection } from 'jscodeshift';
2
- declare type Identifiers = Array<Identifier | JSXIdentifier | TSTypeParameter>;
3
- export declare const getImportDeclarationCollection: ({ j, collection, importPath, }: {
4
- j: JSCodeshift;
5
- collection: Collection<any>;
6
- importPath: string;
7
- }) => Collection<ImportDeclaration>;
8
- export declare const hasImportDeclaration: ({ j, collection, importPath, }: {
9
- j: JSCodeshift;
10
- collection: Collection<any>;
11
- importPath: string;
12
- }) => boolean;
13
- export declare const getImportDefaultSpecifierName: (importDefaultSpecifierCollection: Collection<ImportDefaultSpecifier>) => string;
14
- export declare const getImportSpecifierName: (importSpecifierCollection: Collection<ImportSpecifier>) => string | undefined;
15
- export declare const getAllImportSpecifiers: ({ j, importDeclarationCollection, }: {
16
- j: JSCodeshift;
17
- importDeclarationCollection: Collection<ImportDeclaration>;
18
- }) => Identifiers;
19
- export declare const findImportSpecifierName: ({ j, importDeclarationCollection, importName, }: {
20
- j: JSCodeshift;
21
- importDeclarationCollection: Collection<ImportDeclaration>;
22
- importName: string;
23
- }) => string | null | undefined;
24
- export declare const convertDefaultImportToNamedImport: ({ j, collection, importPath, namedImport, }: {
25
- j: JSCodeshift;
26
- collection: Collection<any>;
27
- importPath: string;
28
- namedImport: string;
29
- }) => void;
30
- export declare const addCommentBefore: ({ j, collection, message, }: {
31
- j: JSCodeshift;
32
- collection: Collection<Program>;
33
- message: string;
34
- }) => void;
35
- export declare const addCommentToStartOfFile: ({ j, collection, message, }: {
36
- j: JSCodeshift;
37
- collection: Collection<Node>;
38
- message: string;
39
- }) => void;
40
- export declare const addCommentForUnresolvedImportSpecifiers: ({ j, collection, importPath, allowedImportSpecifierNames, }: {
41
- j: JSCodeshift;
42
- collection: Collection<Node>;
43
- importPath: string;
44
- allowedImportSpecifierNames: string[];
45
- }) => void;
46
- export declare const addReactIdentifier: ({ j, collection, }: {
47
- j: JSCodeshift;
48
- collection: Collection<Node>;
49
- }) => void;
50
- export declare const replaceImportDeclaration: ({ j, collection, importPath, }: {
51
- j: JSCodeshift;
52
- collection: Collection<Node>;
53
- importPath: string;
54
- }) => void;
55
- export declare const mergeImportSpecifiersAlongWithTheirComments: ({ j, collection, filter, }: {
56
- j: JSCodeshift;
57
- collection: Collection<Node>;
58
- filter?: ((name: string | undefined) => boolean) | undefined;
59
- }) => void;
60
- export {};
@@ -1,201 +0,0 @@
1
- import { COMPILED_IMPORT_PATH, REACT_IMPORT_PATH, REACT_IMPORT_NAME } from './constants';
2
- export var getImportDeclarationCollection = function (_a) {
3
- var j = _a.j, collection = _a.collection, importPath = _a.importPath;
4
- var found = collection
5
- .find(j.ImportDeclaration)
6
- .filter(function (importDeclarationPath) { return importDeclarationPath.node.source.value === importPath; });
7
- return found;
8
- };
9
- export var hasImportDeclaration = function (_a) {
10
- var j = _a.j, collection = _a.collection, importPath = _a.importPath;
11
- var result = getImportDeclarationCollection({
12
- j: j,
13
- collection: collection,
14
- importPath: importPath,
15
- });
16
- return result.length > 0;
17
- };
18
- export var getImportDefaultSpecifierName = function (importDefaultSpecifierCollection) {
19
- var name = importDefaultSpecifierCollection.nodes()[0].local.name;
20
- if (!name) {
21
- throw new Error('Name should exist.');
22
- }
23
- return name;
24
- };
25
- export var getImportSpecifierName = function (importSpecifierCollection) { return importSpecifierCollection.nodes()[0].local.name; };
26
- export var getAllImportSpecifiers = function (_a) {
27
- var j = _a.j, importDeclarationCollection = _a.importDeclarationCollection;
28
- var importSpecifiersImportedNodes = [];
29
- importDeclarationCollection.find(j.ImportSpecifier).forEach(function (importSpecifierPath) {
30
- var node = importSpecifierPath.node.imported;
31
- if (node) {
32
- importSpecifiersImportedNodes.push(node);
33
- }
34
- });
35
- return importSpecifiersImportedNodes;
36
- };
37
- export var findImportSpecifierName = function (_a) {
38
- var j = _a.j, importDeclarationCollection = _a.importDeclarationCollection, importName = _a.importName;
39
- var importSpecifierCollection = importDeclarationCollection
40
- .find(j.ImportSpecifier)
41
- .filter(function (importSpecifierPath) { return importSpecifierPath.node.imported.name === importName; });
42
- if (importSpecifierCollection.length === 0) {
43
- return null;
44
- }
45
- return getImportSpecifierName(importSpecifierCollection);
46
- };
47
- export var convertDefaultImportToNamedImport = function (_a) {
48
- var j = _a.j, collection = _a.collection, importPath = _a.importPath, namedImport = _a.namedImport;
49
- var importDeclarationCollection = getImportDeclarationCollection({
50
- j: j,
51
- collection: collection,
52
- importPath: importPath,
53
- });
54
- importDeclarationCollection.forEach(function (importDeclarationPath) {
55
- var importDefaultSpecifierCollection = j(importDeclarationPath).find(j.ImportDefaultSpecifier);
56
- if (importDefaultSpecifierCollection.length > 0) {
57
- var oldNode = importDeclarationPath.node;
58
- var comments = oldNode.comments;
59
- j(importDeclarationPath).replaceWith([
60
- j.importDeclaration([
61
- j.importSpecifier(j.identifier(namedImport), j.identifier(getImportDefaultSpecifierName(importDefaultSpecifierCollection))),
62
- ], j.literal(COMPILED_IMPORT_PATH)),
63
- ]);
64
- var newNode = importDeclarationPath.node;
65
- if (newNode !== oldNode) {
66
- newNode.comments = comments;
67
- }
68
- }
69
- });
70
- };
71
- // not replacing newlines (which \s does)
72
- var spacesAndTabs = /[ \t]{2,}/g;
73
- var lineStartWithSpaces = /^[ \t]*/gm;
74
- var clean = function (value) {
75
- return value
76
- .replace(spacesAndTabs, ' ')
77
- .replace(lineStartWithSpaces, '')
78
- // using .trim() to clear the any newlines before the first text and after last text
79
- .trim();
80
- };
81
- export var addCommentBefore = function (_a) {
82
- var j = _a.j, collection = _a.collection, message = _a.message;
83
- var content = " TODO(" + COMPILED_IMPORT_PATH + " codemod): " + clean(message) + " ";
84
- collection.forEach(function (path) {
85
- path.value.comments = path.value.comments || [];
86
- var exists = path.value.comments.find(function (comment) { return comment.value === content; });
87
- // avoiding duplicates of the same comment
88
- if (exists) {
89
- return;
90
- }
91
- path.value.comments.push(j.commentBlock(content));
92
- });
93
- };
94
- export var addCommentToStartOfFile = function (_a) {
95
- var j = _a.j, collection = _a.collection, message = _a.message;
96
- addCommentBefore({
97
- j: j,
98
- collection: collection.find(j.Program),
99
- message: message,
100
- });
101
- };
102
- export var addCommentForUnresolvedImportSpecifiers = function (_a) {
103
- var j = _a.j, collection = _a.collection, importPath = _a.importPath, allowedImportSpecifierNames = _a.allowedImportSpecifierNames;
104
- var importDeclarationCollection = getImportDeclarationCollection({
105
- j: j,
106
- collection: collection,
107
- importPath: importPath,
108
- });
109
- var importSpecifiers = getAllImportSpecifiers({
110
- j: j,
111
- importDeclarationCollection: importDeclarationCollection,
112
- });
113
- importSpecifiers
114
- .filter(function (identifierPath) { return !allowedImportSpecifierNames.includes(identifierPath.name); })
115
- .forEach(function (importSpecifierPath) {
116
- addCommentToStartOfFile({
117
- j: j,
118
- collection: collection,
119
- message: "\"" + importSpecifierPath.name + "\" is not exported from \"" + COMPILED_IMPORT_PATH + "\" at the moment. Please find an alternative for it.",
120
- });
121
- });
122
- };
123
- export var addReactIdentifier = function (_a) {
124
- var j = _a.j, collection = _a.collection;
125
- var hasReactImportDeclaration = hasImportDeclaration({
126
- j: j,
127
- collection: collection,
128
- importPath: REACT_IMPORT_PATH,
129
- });
130
- if (!hasReactImportDeclaration) {
131
- collection.find(j.Program).forEach(function (programPath) {
132
- programPath.node.body.unshift(j.importDeclaration([j.importNamespaceSpecifier(j.identifier(REACT_IMPORT_NAME))], j.literal(REACT_IMPORT_PATH)));
133
- });
134
- }
135
- else {
136
- var importDeclarationCollection = getImportDeclarationCollection({
137
- j: j,
138
- collection: collection,
139
- importPath: REACT_IMPORT_PATH,
140
- });
141
- importDeclarationCollection.forEach(function (importDeclarationPath) {
142
- var importDefaultSpecifierCollection = j(importDeclarationPath).find(j.ImportDefaultSpecifier);
143
- var importNamespaceSpecifierCollection = j(importDeclarationPath).find(j.ImportNamespaceSpecifier);
144
- var hasNoDefaultReactImportDeclaration = importDefaultSpecifierCollection.length === 0;
145
- var hasNoNamespaceReactImportDeclaration = importNamespaceSpecifierCollection.length === 0;
146
- if (hasNoDefaultReactImportDeclaration &&
147
- hasNoNamespaceReactImportDeclaration &&
148
- importDeclarationPath.node.specifiers) {
149
- importDeclarationPath.node.specifiers.unshift(j.importDefaultSpecifier(j.identifier(REACT_IMPORT_NAME)));
150
- }
151
- });
152
- }
153
- };
154
- export var replaceImportDeclaration = function (_a) {
155
- var j = _a.j, collection = _a.collection, importPath = _a.importPath;
156
- var importDeclarationCollection = getImportDeclarationCollection({
157
- j: j,
158
- collection: collection,
159
- importPath: importPath,
160
- });
161
- importDeclarationCollection.forEach(function (importDeclarationPath) {
162
- importDeclarationPath.node.source.value = COMPILED_IMPORT_PATH;
163
- });
164
- };
165
- export var mergeImportSpecifiersAlongWithTheirComments = function (_a) {
166
- var j = _a.j, collection = _a.collection, _b = _a.filter, filter = _b === void 0 ? function (_) { return true; } : _b;
167
- var importDeclarationCollection = getImportDeclarationCollection({
168
- j: j,
169
- collection: collection,
170
- importPath: COMPILED_IMPORT_PATH,
171
- });
172
- var importSpecifiers = [];
173
- importDeclarationCollection
174
- .find(j.ImportSpecifier)
175
- .filter(function (importSpecifierPath) { return filter(importSpecifierPath.node.imported.name); })
176
- .forEach(function (importSpecifierPath) {
177
- importSpecifiers.push(importSpecifierPath.node);
178
- });
179
- var importDeclarationCollectionLength = importDeclarationCollection.length;
180
- var importDeclarationComments = [];
181
- importDeclarationCollection.forEach(function (importDeclarationPath, index) {
182
- var oldNode = importDeclarationPath.node;
183
- var comments = oldNode.comments;
184
- if (comments) {
185
- importDeclarationComments.push.apply(importDeclarationComments, comments);
186
- }
187
- if (index === importDeclarationCollectionLength - 1) {
188
- j(importDeclarationPath).replaceWith([
189
- j.importDeclaration(importSpecifiers, j.literal(COMPILED_IMPORT_PATH)),
190
- ]);
191
- var newNode = importDeclarationPath.node;
192
- if (newNode !== oldNode) {
193
- newNode.comments = importDeclarationComments;
194
- }
195
- }
196
- else {
197
- j(importDeclarationPath).remove();
198
- }
199
- });
200
- };
201
- //# sourceMappingURL=codemods-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codemods-helpers.js","sourceRoot":"","sources":["../../../src/codemods/codemods-helpers.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIzF,MAAM,CAAC,IAAM,8BAA8B,GAAG,UAAC,EAQ9C;QAPC,CAAC,OAAA,EACD,UAAU,gBAAA,EACV,UAAU,gBAAA;IAMV,IAAM,KAAK,GAAkC,UAAU;SACpD,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC;SACzB,MAAM,CAAC,UAAC,qBAAqB,IAAK,OAAA,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,UAAU,EAAtD,CAAsD,CAAC,CAAC;IAE7F,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,oBAAoB,GAAG,UAAC,EAQpC;QAPC,CAAC,OAAA,EACD,UAAU,gBAAA,EACV,UAAU,gBAAA;IAMV,IAAM,MAAM,GAAkC,8BAA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3C,IAAI,OAAO,KAAK,OAAO,EAAE;gBACvB,OAAO,CAAC,QAAQ,GAAG,yBAAyB,CAAC;aAC9C;SACF;aAAM;YACL,CAAC,CAAC,qBAAqB,CAAC,CAAC,MAAM,EAAE,CAAC;SACnC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare const COMPILED_IMPORT_PATH = "@compiled/react";
2
- export declare const REACT_IMPORT_PATH = "react";
3
- export declare const REACT_IMPORT_NAME = "React";
@@ -1,4 +0,0 @@
1
- export var COMPILED_IMPORT_PATH = '@compiled/react';
2
- export var REACT_IMPORT_PATH = 'react';
3
- export var REACT_IMPORT_NAME = 'React';
4
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/codemods/constants.tsx"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,oBAAoB,GAAG,iBAAiB,CAAC;AACtD,MAAM,CAAC,IAAM,iBAAiB,GAAG,OAAO,CAAC;AACzC,MAAM,CAAC,IAAM,iBAAiB,GAAG,OAAO,CAAC"}
@@ -1,3 +0,0 @@
1
- import { FileInfo, API, Options } from 'jscodeshift';
2
- declare const transformer: (fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) => string;
3
- export default transformer;
@@ -1,178 +0,0 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
2
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
3
- to[j] = from[i];
4
- return to;
5
- };
6
- import { COMPILED_IMPORT_PATH } from '../constants';
7
- import { hasImportDeclaration, getImportDeclarationCollection, findImportSpecifierName, addCommentForUnresolvedImportSpecifiers, addReactIdentifier, convertDefaultImportToNamedImport, replaceImportDeclaration, mergeImportSpecifiersAlongWithTheirComments, addCommentBefore, } from '../codemods-helpers';
8
- var imports = {
9
- compiledStyledImportName: 'styled',
10
- emotionStyledPackageName: '@emotion/styled',
11
- emotionCoreJSXPragma: '@jsx jsx',
12
- emotionCoreImportNames: { jsx: 'jsx', css: 'css', ClassNames: 'ClassNames' },
13
- emotionCorePackageName: '@emotion/core',
14
- };
15
- var removeEmotionCoreJSXPragma = function (j, collection) {
16
- var commentCollection = collection.find(j.Comment);
17
- commentCollection.forEach(function (commentPath) {
18
- var commentBlockCollection = j(commentPath).filter(function (commentBlockPath) {
19
- return commentBlockPath.value.value.includes(imports.emotionCoreJSXPragma);
20
- });
21
- commentBlockCollection.forEach(function (commentBlockPath) {
22
- j(commentBlockPath).remove();
23
- addReactIdentifier({ j: j, collection: collection });
24
- });
25
- });
26
- };
27
- var replaceEmotionCoreCSSTaggedTemplateExpression = function (j, collection) {
28
- var importDeclarationCollection = getImportDeclarationCollection({
29
- j: j,
30
- collection: collection,
31
- importPath: imports.emotionCorePackageName,
32
- });
33
- var name = findImportSpecifierName({
34
- j: j,
35
- importDeclarationCollection: importDeclarationCollection,
36
- importName: imports.emotionCoreImportNames.css,
37
- });
38
- if (name == null) {
39
- return;
40
- }
41
- collection
42
- .find(j.TaggedTemplateExpression)
43
- .filter(function (taggedTemplateExpressionPath) {
44
- return j(taggedTemplateExpressionPath)
45
- .find(j.Identifier)
46
- .some(function (identifierPath) { return identifierPath.node.name === name; });
47
- })
48
- .forEach(function (taggedTemplateExpressionPath) {
49
- var quasi = taggedTemplateExpressionPath.node.quasi;
50
- if (quasi) {
51
- j(taggedTemplateExpressionPath).replaceWith([quasi]);
52
- }
53
- });
54
- };
55
- var handleClassNamesCXBehavior = function (j, objectPattern) {
56
- var cxIdentifierName = 'cx';
57
- var axIdentifierName = 'ax';
58
- var compiledRuntimePackageName = COMPILED_IMPORT_PATH + "/runtime";
59
- var cxObjectPropertyCollection = j(objectPattern)
60
- .find(j.ObjectProperty)
61
- .filter(function (objectPropertyPath) {
62
- return objectPropertyPath.node.key.type === 'Identifier' &&
63
- objectPropertyPath.node.key.name === cxIdentifierName;
64
- });
65
- cxObjectPropertyCollection.forEach(function (cxObjectPropertyPath) {
66
- addCommentBefore({
67
- j: j,
68
- collection: j(cxObjectPropertyPath.node),
69
- message: "Please replace \"" + cxIdentifierName + "\" with \"" + axIdentifierName + "\" from \"" + compiledRuntimePackageName + "\".\n Usage: import { " + axIdentifierName + " } from '" + compiledRuntimePackageName + "';\n\n NOTE: Both \"" + cxIdentifierName + "\" and \"" + axIdentifierName + "\" have some differences, so we have not replaced its usage.\n Please check the docs for \"" + axIdentifierName + "\" usage.\n\n In future, we will expose \"" + axIdentifierName + "\" directly from \"" + imports.emotionCoreImportNames.ClassNames + "\" props.\n\n Issue tracked on Github: https://github.com/atlassian-labs/compiled/issues/373",
70
- });
71
- });
72
- };
73
- var handleClassNamesStyleBehavior = function (j, objectPattern) {
74
- var styleIdentifierName = 'style';
75
- var hasStyleObjectProperty = j(objectPattern)
76
- .find(j.ObjectProperty)
77
- .some(function (objectPropertyPath) {
78
- return objectPropertyPath.node.key.type === 'Identifier' &&
79
- objectPropertyPath.node.key.name === styleIdentifierName;
80
- });
81
- if (!hasStyleObjectProperty) {
82
- var styleObjectProperty = j.objectProperty(j.identifier(styleIdentifierName), j.identifier(styleIdentifierName));
83
- objectPattern.properties.push(styleObjectProperty);
84
- addCommentBefore({
85
- j: j,
86
- collection: j(styleObjectProperty),
87
- message: "We have exported \"" + styleIdentifierName + "\" from \"" + imports.emotionCoreImportNames.ClassNames + "\" props.\n If you are using dynamic declarations, make sure to set the \"" + styleIdentifierName + "\"\n prop otherwise remove it.",
88
- });
89
- }
90
- };
91
- var handleClassNamesBehavior = function (j, collection) {
92
- var importDeclarationCollection = getImportDeclarationCollection({
93
- j: j,
94
- collection: collection,
95
- importPath: imports.emotionCorePackageName,
96
- });
97
- var name = findImportSpecifierName({
98
- j: j,
99
- importDeclarationCollection: importDeclarationCollection,
100
- importName: imports.emotionCoreImportNames.ClassNames,
101
- });
102
- if (name == null) {
103
- return;
104
- }
105
- collection
106
- .find(j.JSXElement)
107
- .filter(function (jsxElementPath) {
108
- return j(jsxElementPath)
109
- .find(j.JSXIdentifier)
110
- .some(function (jsxIdentifierPath) { return jsxIdentifierPath.node.name === name; });
111
- })
112
- .find(j.JSXExpressionContainer)
113
- .forEach(function (jsxExpressionContainer) {
114
- var expression = jsxExpressionContainer.node.expression;
115
- if (expression.type === 'FunctionExpression' ||
116
- expression.type === 'ArrowFunctionExpression') {
117
- if (expression.params.length && expression.params[0].type === 'ObjectPattern') {
118
- var objectPattern = expression.params[0];
119
- handleClassNamesStyleBehavior(j, objectPattern);
120
- handleClassNamesCXBehavior(j, objectPattern);
121
- }
122
- }
123
- });
124
- };
125
- var mergeCompiledImportSpecifiers = function (j, collection) {
126
- var allowedCompiledNames = __spreadArray([
127
- imports.compiledStyledImportName
128
- ], Object.values(imports.emotionCoreImportNames)).filter(function (name) {
129
- return ![imports.emotionCoreImportNames.jsx, imports.emotionCoreImportNames.css].includes(name);
130
- });
131
- mergeImportSpecifiersAlongWithTheirComments({
132
- j: j,
133
- collection: collection,
134
- filter: function (name) { return !!(name && allowedCompiledNames.includes(name)); },
135
- });
136
- };
137
- var transformer = function (fileInfo, _a, options) {
138
- var j = _a.jscodeshift;
139
- var source = fileInfo.source;
140
- var collection = j(source);
141
- var hasEmotionCoreImportDeclaration = hasImportDeclaration({
142
- j: j,
143
- collection: collection,
144
- importPath: imports.emotionCorePackageName,
145
- });
146
- var hasEmotionStyledImportDeclaration = hasImportDeclaration({
147
- j: j,
148
- collection: collection,
149
- importPath: imports.emotionStyledPackageName,
150
- });
151
- if (!hasEmotionCoreImportDeclaration && !hasEmotionStyledImportDeclaration) {
152
- return source;
153
- }
154
- if (hasEmotionStyledImportDeclaration) {
155
- convertDefaultImportToNamedImport({
156
- j: j,
157
- collection: collection,
158
- importPath: imports.emotionStyledPackageName,
159
- namedImport: imports.compiledStyledImportName,
160
- });
161
- }
162
- if (hasEmotionCoreImportDeclaration) {
163
- removeEmotionCoreJSXPragma(j, collection);
164
- addCommentForUnresolvedImportSpecifiers({
165
- j: j,
166
- collection: collection,
167
- importPath: imports.emotionCorePackageName,
168
- allowedImportSpecifierNames: Object.values(imports.emotionCoreImportNames),
169
- });
170
- replaceEmotionCoreCSSTaggedTemplateExpression(j, collection);
171
- handleClassNamesBehavior(j, collection);
172
- replaceImportDeclaration({ j: j, collection: collection, importPath: imports.emotionCorePackageName });
173
- }
174
- mergeCompiledImportSpecifiers(j, collection);
175
- return collection.toSource(options.printOptions || { quote: 'single' });
176
- };
177
- export default transformer;
178
- //# sourceMappingURL=emotion-to-compiled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emotion-to-compiled.js","sourceRoot":"","sources":["../../../../src/codemods/emotion-to-compiled/emotion-to-compiled.tsx"],"names":[],"mappings":";;;;;AAUA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EACL,oBAAoB,EACpB,8BAA8B,EAC9B,uBAAuB,EACvB,uCAAuC,EACvC,kBAAkB,EAClB,iCAAiC,EACjC,wBAAwB,EACxB,2CAA2C,EAC3C,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAE7B,IAAM,OAAO,GAAG;IACd,wBAAwB,EAAE,QAAQ;IAClC,wBAAwB,EAAE,iBAAiB;IAC3C,oBAAoB,EAAE,UAAU;IAChC,sBAAsB,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE;IAC5E,sBAAsB,EAAE,eAAe;CACxC,CAAC;AAEF,IAAM,0BAA0B,GAAG,UAAC,CAAmB,EAAE,UAAsB;IAC7E,IAAM,iBAAiB,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAErD,iBAAiB,CAAC,OAAO,CAAC,UAAC,WAAW;QACpC,IAAM,sBAAsB,GAAG,CAAC,CAC7B,WAAgD,CAClD,CAAC,MAAM,CAAC,UAAC,gBAAgB;YACxB,OAAA,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,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
- export { default } from './emotion-to-compiled';
@@ -1,2 +0,0 @@
1
- export { default } from './emotion-to-compiled';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/codemods/emotion-to-compiled/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1 +0,0 @@
1
- export { default } from './styled-components-to-compiled';
@@ -1,2 +0,0 @@
1
- export { default } from './styled-components-to-compiled';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/codemods/styled-components-to-compiled/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { FileInfo, API, Options } from 'jscodeshift';
2
- declare const transformer: (fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) => string;
3
- export default transformer;
@@ -1,33 +0,0 @@
1
- import { hasImportDeclaration, convertDefaultImportToNamedImport, addCommentForUnresolvedImportSpecifiers, } from '../codemods-helpers';
2
- var imports = {
3
- compiledStyledImportName: 'styled',
4
- styledComponentsPackageName: 'styled-components',
5
- };
6
- var transformer = function (fileInfo, _a, options) {
7
- var j = _a.jscodeshift;
8
- var source = fileInfo.source;
9
- var collection = j(source);
10
- var hasStyledComponentsImportDeclaration = hasImportDeclaration({
11
- j: j,
12
- collection: collection,
13
- importPath: imports.styledComponentsPackageName,
14
- });
15
- if (!hasStyledComponentsImportDeclaration) {
16
- return source;
17
- }
18
- addCommentForUnresolvedImportSpecifiers({
19
- j: j,
20
- collection: collection,
21
- importPath: imports.styledComponentsPackageName,
22
- allowedImportSpecifierNames: [],
23
- });
24
- convertDefaultImportToNamedImport({
25
- j: j,
26
- collection: collection,
27
- importPath: imports.styledComponentsPackageName,
28
- namedImport: imports.compiledStyledImportName,
29
- });
30
- return collection.toSource(options.printOptions || { quote: 'single' });
31
- };
32
- export default transformer;
33
- //# sourceMappingURL=styled-components-to-compiled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styled-components-to-compiled.js","sourceRoot":"","sources":["../../../../src/codemods/styled-components-to-compiled/styled-components-to-compiled.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,iCAAiC,EACjC,uCAAuC,GACxC,MAAM,qBAAqB,CAAC;AAE7B,IAAM,OAAO,GAAG;IACd,wBAAwB,EAAE,QAAQ;IAClC,2BAA2B,EAAE,mBAAmB;CACjD,CAAC;AAEF,IAAM,WAAW,GAAG,UAAC,QAAkB,EAAE,EAAuB,EAAE,OAAgB;QAA1B,CAAC,iBAAA;IAC/C,IAAA,MAAM,GAAK,QAAQ,OAAb,CAAc;IAC5B,IAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IAE7B,IAAM,oCAAoC,GAAG,oBAAoB,CAAC;QAChE,CAAC,GAAA;QACD,UAAU,YAAA;QACV,UAAU,EAAE,OAAO,CAAC,2BAA2B;KAChD,CAAC,CAAC;IAEH,IAAI,CAAC,oCAAoC,EAAE;QACzC,OAAO,MAAM,CAAC;KACf;IAED,uCAAuC,CAAC;QACtC,CAAC,GAAA;QACD,UAAU,YAAA;QACV,UAAU,EAAE,OAAO,CAAC,2BAA2B;QAC/C,2BAA2B,EAAE,EAAE;KAChC,CAAC,CAAC;IAEH,iCAAiC,CAAC;QAChC,CAAC,GAAA;QACD,UAAU,YAAA;QACV,UAAU,EAAE,OAAO,CAAC,2BAA2B;QAC/C,WAAW,EAAE,OAAO,CAAC,wBAAwB;KAC9C,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,60 +0,0 @@
1
- import { JSCodeshift, ImportDeclaration, ImportDefaultSpecifier, ImportSpecifier, Program, Identifier, JSXIdentifier, TSTypeParameter, Node, Collection } from 'jscodeshift';
2
- declare type Identifiers = Array<Identifier | JSXIdentifier | TSTypeParameter>;
3
- export declare const getImportDeclarationCollection: ({ j, collection, importPath, }: {
4
- j: JSCodeshift;
5
- collection: Collection<any>;
6
- importPath: string;
7
- }) => Collection<ImportDeclaration>;
8
- export declare const hasImportDeclaration: ({ j, collection, importPath, }: {
9
- j: JSCodeshift;
10
- collection: Collection<any>;
11
- importPath: string;
12
- }) => boolean;
13
- export declare const getImportDefaultSpecifierName: (importDefaultSpecifierCollection: Collection<ImportDefaultSpecifier>) => string;
14
- export declare const getImportSpecifierName: (importSpecifierCollection: Collection<ImportSpecifier>) => string | undefined;
15
- export declare const getAllImportSpecifiers: ({ j, importDeclarationCollection, }: {
16
- j: JSCodeshift;
17
- importDeclarationCollection: Collection<ImportDeclaration>;
18
- }) => Identifiers;
19
- export declare const findImportSpecifierName: ({ j, importDeclarationCollection, importName, }: {
20
- j: JSCodeshift;
21
- importDeclarationCollection: Collection<ImportDeclaration>;
22
- importName: string;
23
- }) => string | null | undefined;
24
- export declare const convertDefaultImportToNamedImport: ({ j, collection, importPath, namedImport, }: {
25
- j: JSCodeshift;
26
- collection: Collection<any>;
27
- importPath: string;
28
- namedImport: string;
29
- }) => void;
30
- export declare const addCommentBefore: ({ j, collection, message, }: {
31
- j: JSCodeshift;
32
- collection: Collection<Program>;
33
- message: string;
34
- }) => void;
35
- export declare const addCommentToStartOfFile: ({ j, collection, message, }: {
36
- j: JSCodeshift;
37
- collection: Collection<Node>;
38
- message: string;
39
- }) => void;
40
- export declare const addCommentForUnresolvedImportSpecifiers: ({ j, collection, importPath, allowedImportSpecifierNames, }: {
41
- j: JSCodeshift;
42
- collection: Collection<Node>;
43
- importPath: string;
44
- allowedImportSpecifierNames: string[];
45
- }) => void;
46
- export declare const addReactIdentifier: ({ j, collection, }: {
47
- j: JSCodeshift;
48
- collection: Collection<Node>;
49
- }) => void;
50
- export declare const replaceImportDeclaration: ({ j, collection, importPath, }: {
51
- j: JSCodeshift;
52
- collection: Collection<Node>;
53
- importPath: string;
54
- }) => void;
55
- export declare const mergeImportSpecifiersAlongWithTheirComments: ({ j, collection, filter, }: {
56
- j: JSCodeshift;
57
- collection: Collection<Node>;
58
- filter?: ((name: string | undefined) => boolean) | undefined;
59
- }) => void;
60
- export {};