@wise/wds-codemods 0.0.1-experimental-0d8d466 → 0.0.1-experimental-e47d8df

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.
@@ -0,0 +1,516 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const require_reportManualReview = require('../../reportManualReview-BfeMigw4.cjs');
3
+
4
+ //#region src/transforms/helpers/hasImport.ts
5
+ /**
6
+ * Checks if a specific import exists in the given root collection and provides
7
+ * a method to remove it if found.
8
+ */
9
+ function hasImport(root, sourceValue, importName, j) {
10
+ const importDeclarations = root.find(j.ImportDeclaration, { source: { value: sourceValue } });
11
+ if (importDeclarations.size() === 0) return {
12
+ exists: false,
13
+ remove: () => {}
14
+ };
15
+ const namedImport = importDeclarations.find(j.ImportSpecifier, { imported: { name: importName } });
16
+ const defaultImport = importDeclarations.find(j.ImportDefaultSpecifier, { local: { name: importName } });
17
+ const exists = namedImport.size() > 0 || defaultImport.size() > 0;
18
+ const remove = () => {
19
+ importDeclarations.forEach((path) => {
20
+ const filteredSpecifiers = path.node.specifiers?.filter((specifier) => {
21
+ if (specifier.type === "ImportSpecifier" && specifier.imported.name === importName) return false;
22
+ if (specifier.type === "ImportDefaultSpecifier" && specifier.local?.name === importName) return false;
23
+ return true;
24
+ }) ?? [];
25
+ if (filteredSpecifiers.length === 0) path.prune();
26
+ else j(path).replaceWith(j.importDeclaration(filteredSpecifiers, path.node.source, path.node.importKind));
27
+ });
28
+ };
29
+ return {
30
+ exists,
31
+ remove
32
+ };
33
+ }
34
+
35
+ //#endregion
36
+ //#region src/transforms/helpers/iconUtils.ts
37
+ /**
38
+ * Process children of a JSX element to detect icon components and add iconStart or iconEnd attributes accordingly.
39
+ * This is specific to icon handling but can be reused in codemods dealing with icon children.
40
+ */
41
+ const processIconChildren = (j, children, iconImports, openingElement) => {
42
+ if (!children || !openingElement.attributes) return;
43
+ const unwrapJsxElement = (node) => {
44
+ if (typeof node === "object" && node !== null && "type" in node && node.type === "JSXExpressionContainer" && j.JSXElement.check(node.expression)) return node.expression;
45
+ return node;
46
+ };
47
+ const totalChildren = children.length;
48
+ const iconChildIndex = children.findIndex((child) => {
49
+ const unwrapped = unwrapJsxElement(child);
50
+ return j.JSXElement.check(unwrapped) && unwrapped.openingElement.name.type === "JSXIdentifier" && iconImports.has(unwrapped.openingElement.name.name);
51
+ });
52
+ if (iconChildIndex === -1) return;
53
+ const iconChild = unwrapJsxElement(children[iconChildIndex]);
54
+ if (!iconChild || iconChild.openingElement.name.type !== "JSXIdentifier") return;
55
+ iconChild.openingElement.name.name;
56
+ const distanceToStart = iconChildIndex;
57
+ const distanceToEnd = totalChildren - 1 - iconChildIndex;
58
+ const iconPropName = distanceToStart <= distanceToEnd ? "addonStart" : "addonEnd";
59
+ const iconObject = j.objectExpression([j.property("init", j.identifier("type"), j.literal("icon")), j.property("init", j.identifier("value"), iconChild)]);
60
+ const iconProp = j.jsxAttribute(j.jsxIdentifier(iconPropName), j.jsxExpressionContainer(iconObject));
61
+ openingElement.attributes.push(iconProp);
62
+ children.splice(iconChildIndex, 1);
63
+ const isWhitespaceJsxText = (node) => {
64
+ return typeof node === "object" && node !== null && node.type === "JSXText" && typeof node.value === "string" && node.value.trim() === "";
65
+ };
66
+ if (iconChildIndex - 1 >= 0 && isWhitespaceJsxText(children[iconChildIndex - 1])) children.splice(iconChildIndex - 1, 1);
67
+ else if (isWhitespaceJsxText(children[iconChildIndex])) children.splice(iconChildIndex, 1);
68
+ };
69
+
70
+ //#endregion
71
+ //#region src/transforms/helpers/jsxElementUtils.ts
72
+ /**
73
+ * Rename a JSX element name if it is a JSXIdentifier.
74
+ */
75
+ const setNameIfJSXIdentifier = (elementName, newName) => {
76
+ if (elementName && elementName.type === "JSXIdentifier") return {
77
+ ...elementName,
78
+ name: newName
79
+ };
80
+ return elementName;
81
+ };
82
+ /**
83
+ * Check if a list of attributes contains a specific attribute by name.
84
+ */
85
+ const hasAttribute = (attributes, attributeName) => {
86
+ return Array.isArray(attributes) && attributes.some((attr) => attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === attributeName);
87
+ };
88
+ /**
89
+ * Check if a JSX element's openingElement has a specific attribute.
90
+ */
91
+ const hasAttributeOnElement = (element, attributeName) => {
92
+ return hasAttribute(element.attributes, attributeName);
93
+ };
94
+ /**
95
+ * Add specified attributes to a JSX element's openingElement if they are not already present.
96
+ */
97
+ const addAttributesIfMissing = (j, openingElement, attributesToAdd) => {
98
+ if (!Array.isArray(openingElement.attributes)) return;
99
+ const attrs = openingElement.attributes;
100
+ attributesToAdd.forEach(({ attribute, name }) => {
101
+ if (!hasAttributeOnElement(openingElement, name)) attrs.push(attribute);
102
+ });
103
+ };
104
+
105
+ //#endregion
106
+ //#region src/transforms/helpers/jsxReportingUtils.ts
107
+ /**
108
+ * CodemodReporter is a utility class for reporting issues found during codemod transformations.
109
+ * It provides methods to report issues related to JSX elements, props, and attributes.
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * const issues: string[] = [];
114
+ * const reporter = createReporter(j, issues);
115
+ *
116
+ * // Report a deprecated prop
117
+ * reporter.reportDeprecatedProp(buttonElement, 'flat', 'variant="text"');
118
+ *
119
+ * // Report complex expression that needs review
120
+ * reporter.reportAmbiguousExpression(element, 'size');
121
+ *
122
+ * // Auto-detect common issues
123
+ * reporter.reportAttributeIssues(element);
124
+ * ```
125
+ */
126
+ var CodemodReporter = class {
127
+ j;
128
+ issues;
129
+ constructor(options) {
130
+ this.j = options.jscodeshift;
131
+ this.issues = options.issues;
132
+ }
133
+ /**
134
+ * Reports an issue with a JSX element
135
+ */
136
+ reportElement(element, reason) {
137
+ const node = this.getNode(element);
138
+ const componentName = this.getComponentName(node);
139
+ const line = this.getLineNumber(node);
140
+ this.addIssue(`Manual review required: <${componentName}> at line ${line} ${reason}.`);
141
+ }
142
+ /**
143
+ * Reports an issue with a specific prop
144
+ */
145
+ reportProp(element, propName, reason) {
146
+ const node = this.getNode(element);
147
+ const componentName = this.getComponentName(node);
148
+ const line = this.getLineNumber(node);
149
+ this.addIssue(`Manual review required: prop "${propName}" on <${componentName}> at line ${line} ${reason}.`);
150
+ }
151
+ /**
152
+ * Reports an issue with a JSX attribute directly
153
+ */
154
+ reportAttribute(attr, element, reason) {
155
+ const node = this.getNode(element);
156
+ const componentName = this.getComponentName(node);
157
+ const propName = this.getAttributeName(attr);
158
+ const line = this.getLineNumber(attr) || this.getLineNumber(node);
159
+ const defaultReason = this.getAttributeReason(attr);
160
+ const finalReason = reason || defaultReason;
161
+ this.addIssue(`Manual review required: prop "${propName}" on <${componentName}> at line ${line} ${finalReason}.`);
162
+ }
163
+ /**
164
+ * Reports spread props on an element
165
+ */
166
+ reportSpreadProps(element) {
167
+ this.reportElement(element, "contains spread props that need manual review");
168
+ }
169
+ /**
170
+ * Reports conflicting prop and children
171
+ */
172
+ reportPropWithChildren(element, propName) {
173
+ this.reportProp(element, propName, `conflicts with children - both "${propName}" prop and children are present`);
174
+ }
175
+ /**
176
+ * Reports unsupported prop value
177
+ */
178
+ reportUnsupportedValue(element, propName, value) {
179
+ this.reportProp(element, propName, `has unsupported value "${value}"`);
180
+ }
181
+ /**
182
+ * Reports ambiguous expression in prop
183
+ */
184
+ reportAmbiguousExpression(element, propName) {
185
+ this.reportProp(element, propName, "contains a complex expression that needs manual review");
186
+ }
187
+ /**
188
+ * Reports ambiguous children (like dynamic icons)
189
+ */
190
+ reportAmbiguousChildren(element, childType = "content") {
191
+ this.reportElement(element, `contains ambiguous ${childType} that needs manual review`);
192
+ }
193
+ /**
194
+ * Reports deprecated prop usage
195
+ */
196
+ reportDeprecatedProp(element, propName, alternative) {
197
+ const suggestion = alternative ? ` Use ${alternative} instead` : "";
198
+ this.reportProp(element, propName, `is deprecated${suggestion}`);
199
+ }
200
+ /**
201
+ * Reports missing required prop
202
+ */
203
+ reportMissingRequiredProp(element, propName) {
204
+ this.reportProp(element, propName, "is required but missing");
205
+ }
206
+ /**
207
+ * Reports conflicting props
208
+ */
209
+ reportConflictingProps(element, propNames) {
210
+ const propList = propNames.map((name) => `"${name}"`).join(", ");
211
+ this.reportElement(element, `has conflicting props: ${propList} cannot be used together`);
212
+ }
213
+ /**
214
+ * Auto-detects and reports common attribute issues
215
+ */
216
+ reportAttributeIssues(element) {
217
+ const node = this.getNode(element);
218
+ const { attributes } = node.openingElement;
219
+ if (!attributes) return;
220
+ if (attributes.some((attr) => attr.type === "JSXSpreadAttribute")) this.reportSpreadProps(element);
221
+ attributes.forEach((attr) => {
222
+ if (attr.type === "JSXAttribute" && attr.value?.type === "JSXExpressionContainer") this.reportAttribute(attr, element);
223
+ });
224
+ }
225
+ getNode(element) {
226
+ return "node" in element ? element.node : element;
227
+ }
228
+ getComponentName(node) {
229
+ const { name } = node.openingElement;
230
+ if (name.type === "JSXIdentifier") return name.name;
231
+ return this.j(name).toSource();
232
+ }
233
+ getLineNumber(node) {
234
+ return node.loc?.start.line?.toString() || "unknown";
235
+ }
236
+ getAttributeName(attr) {
237
+ if (attr.name.type === "JSXIdentifier") return attr.name.name;
238
+ return this.j(attr.name).toSource();
239
+ }
240
+ getAttributeReason(attr) {
241
+ if (!attr.value) return "has no value";
242
+ if (attr.value.type === "JSXExpressionContainer") {
243
+ const expr = attr.value.expression;
244
+ const expressionType = expr.type.replace("Expression", "").toLowerCase();
245
+ if (expr.type === "Identifier" || expr.type === "MemberExpression") {
246
+ const valueText = this.j(expr).toSource();
247
+ return `contains a ${expressionType} (${valueText})`;
248
+ }
249
+ return `contains a complex ${expressionType} expression`;
250
+ }
251
+ return "needs manual review";
252
+ }
253
+ addIssue(message) {
254
+ this.issues.push(message);
255
+ }
256
+ };
257
+ const createReporter = (j, issues) => {
258
+ return new CodemodReporter({
259
+ jscodeshift: j,
260
+ issues
261
+ });
262
+ };
263
+
264
+ //#endregion
265
+ //#region src/transforms/button/transformer.ts
266
+ const parser = "tsx";
267
+ const priorityMapping = {
268
+ accent: {
269
+ primary: "primary",
270
+ secondary: "secondary-neutral",
271
+ tertiary: "tertiary"
272
+ },
273
+ positive: {
274
+ primary: "primary",
275
+ secondary: "secondary-neutral",
276
+ tertiary: "secondary-neutral"
277
+ },
278
+ negative: {
279
+ primary: "primary",
280
+ secondary: "secondary",
281
+ tertiary: "secondary"
282
+ }
283
+ };
284
+ const sizeMap = {
285
+ EXTRA_SMALL: "xs",
286
+ SMALL: "sm",
287
+ MEDIUM: "md",
288
+ LARGE: "lg",
289
+ EXTRA_LARGE: "xl",
290
+ xs: "sm",
291
+ sm: "sm",
292
+ md: "md",
293
+ lg: "lg",
294
+ xl: "xl"
295
+ };
296
+ const resolveSize = (size) => {
297
+ if (!size) return size;
298
+ const match = /^Size\.(EXTRA_SMALL|SMALL|MEDIUM|LARGE|EXTRA_LARGE)$/u.exec(size);
299
+ if (match) return sizeMap[match[1]];
300
+ return sizeMap[size] || size;
301
+ };
302
+ const resolvePriority = (type, priority) => {
303
+ if (type && priority) return priorityMapping[type]?.[priority] || priority;
304
+ return priority;
305
+ };
306
+ const resolveType = (type, htmlType) => {
307
+ if (htmlType) return htmlType;
308
+ const legacyButtonTypes = [
309
+ "accent",
310
+ "negative",
311
+ "positive",
312
+ "primary",
313
+ "pay",
314
+ "secondary",
315
+ "danger",
316
+ "link"
317
+ ];
318
+ return type && legacyButtonTypes.includes(type) ? type : null;
319
+ };
320
+ const convertEnumValue = (value) => {
321
+ if (!value) return value;
322
+ const strippedValue = value.replace(/^['"]|['"]$/gu, "");
323
+ const enumMapping = {
324
+ "Priority.SECONDARY": "secondary",
325
+ "Priority.PRIMARY": "primary",
326
+ "Priority.TERTIARY": "tertiary",
327
+ "ControlType.NEGATIVE": "negative",
328
+ "ControlType.POSITIVE": "positive",
329
+ "ControlType.ACCENT": "accent"
330
+ };
331
+ return enumMapping[strippedValue] || strippedValue;
332
+ };
333
+ /**
334
+ * This transform function modifies the Button and ActionButton components from the @transferwise/components library.
335
+ * It updates the ActionButton component to use the Button component with specific attributes and mappings.
336
+ * It also processes icon children and removes legacy props.
337
+ *
338
+ * @param {FileInfo} file - The file information object.
339
+ * @param {API} api - The API object for jscodeshift.
340
+ * @param {Options} options - The options object for jscodeshift.
341
+ * @returns {string} - The transformed source code.
342
+ */
343
+ const transformer = (file, api, options) => {
344
+ const j = api.jscodeshift;
345
+ const root = j(file.source);
346
+ const manualReviewIssues = [];
347
+ const reporter = createReporter(j, manualReviewIssues);
348
+ const { exists: hasButtonImport } = hasImport(root, "@transferwise/components", "Button", j);
349
+ const { exists: hasActionButtonImport, remove: removeActionButtonImport } = hasImport(root, "@transferwise/components", "ActionButton", j);
350
+ const iconImports = /* @__PURE__ */ new Set();
351
+ root.find(j.ImportDeclaration, { source: { value: "@transferwise/icons" } }).forEach((path) => {
352
+ path.node.specifiers?.forEach((specifier) => {
353
+ if ((specifier.type === "ImportDefaultSpecifier" || specifier.type === "ImportSpecifier") && specifier.local) {
354
+ const localName = specifier.local.name;
355
+ iconImports.add(localName);
356
+ }
357
+ });
358
+ });
359
+ if (hasActionButtonImport) {
360
+ root.findJSXElements("ActionButton").forEach((path) => {
361
+ const { openingElement, closingElement } = path.node;
362
+ openingElement.name = setNameIfJSXIdentifier(openingElement.name, "Button");
363
+ if (closingElement) closingElement.name = setNameIfJSXIdentifier(closingElement.name, "Button");
364
+ addAttributesIfMissing(j, openingElement, [{
365
+ attribute: j.jsxAttribute(j.jsxIdentifier("v2")),
366
+ name: "v2"
367
+ }, {
368
+ attribute: j.jsxAttribute(j.jsxIdentifier("size"), j.literal("sm")),
369
+ name: "size"
370
+ }]);
371
+ processIconChildren(j, path.node.children, iconImports, openingElement);
372
+ if ((openingElement.attributes ?? []).some((attr) => attr.type === "JSXSpreadAttribute")) reporter.reportSpreadProps(path);
373
+ const legacyPropNames = ["priority", "text"];
374
+ const legacyProps = {};
375
+ openingElement.attributes?.forEach((attr) => {
376
+ if (attr.type === "JSXAttribute" && attr.name && attr.name.type === "JSXIdentifier") {
377
+ const { name } = attr.name;
378
+ if (legacyPropNames.includes(name)) {
379
+ if (attr.value) {
380
+ if (attr.value.type === "StringLiteral") legacyProps[name] = attr.value.value;
381
+ else if (attr.value.type === "JSXExpressionContainer") reporter.reportAttribute(attr, path);
382
+ }
383
+ }
384
+ }
385
+ });
386
+ const hasTextProp = openingElement.attributes?.some((attr) => attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "text");
387
+ const hasChildren = path.node.children?.some((child) => child.type === "JSXText" && child.value.trim() !== "" || child.type === "JSXElement" || child.type === "JSXExpressionContainer");
388
+ if (hasTextProp && hasChildren) reporter.reportPropWithChildren(path, "text");
389
+ (path.node.children || []).forEach((child) => {
390
+ if (child.type === "JSXExpressionContainer") {
391
+ const expr = child.expression;
392
+ if (expr.type === "ConditionalExpression" || expr.type === "CallExpression" || expr.type === "Identifier" || expr.type === "MemberExpression") reporter.reportAmbiguousChildren(path, "icon");
393
+ }
394
+ });
395
+ });
396
+ removeActionButtonImport();
397
+ }
398
+ if (hasButtonImport) root.findJSXElements("Button").forEach((path) => {
399
+ const { openingElement } = path.node;
400
+ if (hasAttributeOnElement(openingElement, "v2")) return;
401
+ addAttributesIfMissing(j, openingElement, [{
402
+ attribute: j.jsxAttribute(j.jsxIdentifier("v2")),
403
+ name: "v2"
404
+ }]);
405
+ processIconChildren(j, path.node.children, iconImports, openingElement);
406
+ const legacyProps = {};
407
+ const legacyPropNames = [
408
+ "priority",
409
+ "size",
410
+ "type",
411
+ "htmlType",
412
+ "sentiment"
413
+ ];
414
+ openingElement.attributes?.forEach((attr) => {
415
+ if (attr.type === "JSXAttribute" && attr.name && attr.name.type === "JSXIdentifier") {
416
+ const { name } = attr.name;
417
+ if (legacyPropNames.includes(name)) if (attr.value) {
418
+ if (attr.value.type === "StringLiteral") legacyProps[name] = attr.value.value;
419
+ else if (attr.value.type === "JSXExpressionContainer") legacyProps[name] = convertEnumValue(String(j(attr.value.expression).toSource()));
420
+ } else legacyProps[name] = void 0;
421
+ }
422
+ });
423
+ if (openingElement.attributes) openingElement.attributes = openingElement.attributes.filter((attr) => !(attr.type === "JSXAttribute" && attr.name && legacyPropNames.includes(attr.name.name)));
424
+ if ("size" in legacyProps) {
425
+ const rawValue = legacyProps.size;
426
+ const resolved = resolveSize(rawValue);
427
+ const supportedSizes = [
428
+ "xs",
429
+ "sm",
430
+ "md",
431
+ "lg",
432
+ "xl"
433
+ ];
434
+ if (typeof rawValue === "string" && typeof resolved === "string" && supportedSizes.includes(resolved)) openingElement.attributes?.push(j.jsxAttribute(j.jsxIdentifier("size"), j.literal(resolved)));
435
+ else if (typeof rawValue === "string") reporter.reportUnsupportedValue(path, "size", rawValue);
436
+ else if (rawValue !== void 0) reporter.reportAmbiguousExpression(path, "size");
437
+ }
438
+ if ("priority" in legacyProps) {
439
+ const rawValue = legacyProps.priority;
440
+ const converted = convertEnumValue(rawValue);
441
+ const mapped = resolvePriority(legacyProps.type, converted);
442
+ const supportedPriorities = [
443
+ "primary",
444
+ "secondary",
445
+ "tertiary",
446
+ "secondary-neutral"
447
+ ];
448
+ if (typeof rawValue === "string" && typeof mapped === "string" && supportedPriorities.includes(mapped)) openingElement.attributes?.push(j.jsxAttribute(j.jsxIdentifier("priority"), j.literal(mapped)));
449
+ else if (typeof rawValue === "string") reporter.reportUnsupportedValue(path, "priority", rawValue);
450
+ else if (rawValue !== void 0) reporter.reportAmbiguousExpression(path, "priority");
451
+ }
452
+ if ("type" in legacyProps || "htmlType" in legacyProps) {
453
+ const rawType = legacyProps.type;
454
+ const rawHtmlType = legacyProps.htmlType;
455
+ const resolvedType = typeof rawType === "string" ? rawType : rawType && typeof rawType === "object" ? convertEnumValue(j(rawType).toSource()) : void 0;
456
+ const resolved = resolveType(resolvedType, rawHtmlType);
457
+ const supportedTypes = [
458
+ "accent",
459
+ "negative",
460
+ "positive",
461
+ "primary",
462
+ "pay",
463
+ "secondary",
464
+ "danger",
465
+ "link",
466
+ "submit",
467
+ "button",
468
+ "reset"
469
+ ];
470
+ if (typeof resolved === "string" && supportedTypes.includes(resolved)) {
471
+ openingElement.attributes?.push(j.jsxAttribute(j.jsxIdentifier("type"), j.literal(resolved)));
472
+ if (resolved === "negative") openingElement.attributes?.push(j.jsxAttribute(j.jsxIdentifier("sentiment"), j.literal("negative")));
473
+ } else if (typeof rawType === "string" || typeof rawHtmlType === "string") reporter.reportUnsupportedValue(path, "type", rawType ?? rawHtmlType ?? "");
474
+ else if (rawType !== void 0 || rawHtmlType !== void 0) reporter.reportAmbiguousExpression(path, "type");
475
+ }
476
+ if ("sentiment" in legacyProps) {
477
+ const rawValue = legacyProps.sentiment;
478
+ if (rawValue === "negative") openingElement.attributes?.push(j.jsxAttribute(j.jsxIdentifier("sentiment"), j.literal("negative")));
479
+ else if (typeof rawValue === "string") reporter.reportUnsupportedValue(path, "sentiment", rawValue);
480
+ else if (rawValue !== void 0) reporter.reportAmbiguousExpression(path, "sentiment");
481
+ }
482
+ let asIndex = -1;
483
+ let asValue = null;
484
+ let hrefExists = false;
485
+ openingElement.attributes?.forEach((attr, index) => {
486
+ if (attr.type === "JSXAttribute" && attr.name) {
487
+ if (attr.name.name === "as") {
488
+ if (attr.value) {
489
+ if (attr.value.type === "StringLiteral") asValue = attr.value.value;
490
+ else if (attr.value.type === "JSXExpressionContainer") reporter.reportAttribute(attr, path);
491
+ }
492
+ asIndex = index;
493
+ }
494
+ if (attr.name.name === "href") {
495
+ hrefExists = true;
496
+ if (attr.value && attr.value.type !== "StringLiteral") reporter.reportAttribute(attr, path);
497
+ }
498
+ }
499
+ });
500
+ if (asValue && asValue !== "a") reporter.reportUnsupportedValue(path, "as", asValue);
501
+ if (asValue === "a") {
502
+ if (asIndex !== -1) openingElement.attributes = openingElement.attributes?.filter((_, idx) => idx !== asIndex);
503
+ if (!hrefExists) openingElement.attributes = [...openingElement.attributes ?? [], j.jsxAttribute(j.jsxIdentifier("href"), j.literal("#"))];
504
+ }
505
+ if ((openingElement.attributes ?? []).some((attr) => attr.type === "JSXSpreadAttribute")) reporter.reportSpreadProps(path);
506
+ });
507
+ if (manualReviewIssues.length > 0) manualReviewIssues.forEach(async (issue) => {
508
+ await require_reportManualReview.reportManualReview(file.path, issue);
509
+ });
510
+ return root.toSource();
511
+ };
512
+
513
+ //#endregion
514
+ exports.default = transformer;
515
+ exports.parser = parser;
516
+ //# sourceMappingURL=transformer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformer.cjs","names":["priorityMapping: Record<string, Record<string, string>>","sizeMap: Record<string, string>","enumMapping: Record<string, string>","j: JSCodeshift","manualReviewIssues: string[]","legacyProps: LegacyProps","asValue: string | null","reportManualReview"],"sources":["../../../src/transforms/helpers/hasImport.ts","../../../src/transforms/helpers/iconUtils.ts","../../../src/transforms/helpers/jsxElementUtils.ts","../../../src/transforms/helpers/jsxReportingUtils.ts","../../../src/transforms/button/transformer.ts"],"sourcesContent":["import type { Collection, JSCodeshift } from 'jscodeshift';\n\n/**\n * Checks if a specific import exists in the given root collection and provides\n * a method to remove it if found.\n */\nfunction hasImport(\n root: Collection,\n sourceValue: string,\n importName: string,\n j: JSCodeshift,\n): { exists: boolean; remove: () => void } {\n const importDeclarations = root.find(j.ImportDeclaration, {\n source: { value: sourceValue },\n });\n\n if (importDeclarations.size() === 0) {\n return {\n exists: false,\n remove: () => {},\n };\n }\n\n const namedImport = importDeclarations.find(j.ImportSpecifier, {\n imported: { name: importName },\n });\n\n const defaultImport = importDeclarations.find(j.ImportDefaultSpecifier, {\n local: { name: importName },\n });\n\n const exists = namedImport.size() > 0 || defaultImport.size() > 0;\n\n const remove = () => {\n importDeclarations.forEach((path) => {\n const filteredSpecifiers =\n path.node.specifiers?.filter((specifier) => {\n if (specifier.type === 'ImportSpecifier' && specifier.imported.name === importName) {\n return false;\n }\n if (specifier.type === 'ImportDefaultSpecifier' && specifier.local?.name === importName) {\n return false;\n }\n return true;\n }) ?? [];\n\n if (filteredSpecifiers.length === 0) {\n path.prune();\n } else {\n j(path).replaceWith(\n j.importDeclaration(filteredSpecifiers, path.node.source, path.node.importKind),\n );\n }\n });\n };\n\n return { exists, remove };\n}\n\nexport default hasImport;\n","import type { JSCodeshift, JSXElement, JSXExpressionContainer } from 'jscodeshift';\n\n/**\n * Process children of a JSX element to detect icon components and add iconStart or iconEnd attributes accordingly.\n * This is specific to icon handling but can be reused in codemods dealing with icon children.\n */\nconst processIconChildren = (\n j: JSCodeshift,\n children: (JSXElement | JSXExpressionContainer | unknown)[] | undefined,\n iconImports: Set<string>,\n openingElement: JSXElement['openingElement'],\n) => {\n if (!children || !openingElement.attributes) return;\n\n const unwrapJsxElement = (node: unknown): JSXElement | unknown => {\n if (\n typeof node === 'object' &&\n node !== null &&\n 'type' in node &&\n node.type === 'JSXExpressionContainer' &&\n j.JSXElement.check((node as JSXExpressionContainer).expression)\n ) {\n return (node as JSXExpressionContainer).expression;\n }\n return node;\n };\n\n const totalChildren = children.length;\n\n // Find index of icon child\n const iconChildIndex = children.findIndex((child) => {\n const unwrapped = unwrapJsxElement(child);\n return (\n j.JSXElement.check(unwrapped) &&\n unwrapped.openingElement.name.type === 'JSXIdentifier' &&\n iconImports.has(unwrapped.openingElement.name.name)\n );\n });\n\n if (iconChildIndex === -1) return;\n\n const iconChild = unwrapJsxElement(children[iconChildIndex]) as JSXElement;\n\n if (!iconChild || iconChild.openingElement.name.type !== 'JSXIdentifier') return;\n\n const iconName = iconChild.openingElement.name.name;\n\n // Determine if icon is closer to start or end\n const distanceToStart = iconChildIndex;\n const distanceToEnd = totalChildren - 1 - iconChildIndex;\n const iconPropName = distanceToStart <= distanceToEnd ? 'addonStart' : 'addonEnd';\n\n // Build: { type: 'icon', value: <IconName /> }\n const iconObject = j.objectExpression([\n j.property('init', j.identifier('type'), j.literal('icon')),\n j.property('init', j.identifier('value'), iconChild),\n ]);\n const iconProp = j.jsxAttribute(\n j.jsxIdentifier(iconPropName),\n j.jsxExpressionContainer(iconObject),\n );\n\n openingElement.attributes.push(iconProp);\n\n // Remove the icon child\n children.splice(iconChildIndex, 1);\n\n // Helper to check if a child is whitespace-only JSXText\n const isWhitespaceJsxText = (node: unknown): boolean => {\n return (\n typeof node === 'object' &&\n node !== null &&\n (node as { type?: unknown }).type === 'JSXText' &&\n typeof (node as { value?: string }).value === 'string' &&\n (node as { value?: string }).value!.trim() === ''\n );\n };\n\n // Remove adjacent whitespace-only JSXText node if any\n if (iconChildIndex - 1 >= 0 && isWhitespaceJsxText(children[iconChildIndex - 1])) {\n children.splice(iconChildIndex - 1, 1);\n } else if (isWhitespaceJsxText(children[iconChildIndex])) {\n children.splice(iconChildIndex, 1);\n }\n};\n\nexport default processIconChildren;\n","import type {\n JSCodeshift,\n JSXAttribute,\n JSXElement,\n JSXIdentifier,\n JSXMemberExpression,\n JSXNamespacedName,\n JSXSpreadAttribute,\n} from 'jscodeshift';\n\n/**\n * Rename a JSX element name if it is a JSXIdentifier.\n */\nexport const setNameIfJSXIdentifier = (\n elementName: JSXIdentifier | JSXNamespacedName | JSXMemberExpression | undefined,\n newName: string,\n): JSXIdentifier | JSXNamespacedName | JSXMemberExpression | undefined => {\n if (elementName && elementName.type === 'JSXIdentifier') {\n return { ...elementName, name: newName };\n }\n return elementName;\n};\n\n/**\n * Check if a list of attributes contains a specific attribute by name.\n */\nexport const hasAttribute = (\n attributes: (JSXAttribute | JSXSpreadAttribute)[] | undefined,\n attributeName: string,\n): boolean => {\n return (\n Array.isArray(attributes) &&\n attributes.some(\n (attr): attr is JSXAttribute =>\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n attr.name.name === attributeName,\n )\n );\n};\n\n/**\n * Check if a JSX element's openingElement has a specific attribute.\n */\nexport const hasAttributeOnElement = (\n element: JSXElement['openingElement'],\n attributeName: string,\n): boolean => {\n return hasAttribute(element.attributes, attributeName);\n};\n\n/**\n * Add specified attributes to a JSX element's openingElement if they are not already present.\n */\nexport const addAttributesIfMissing = (\n j: JSCodeshift,\n openingElement: JSXElement['openingElement'],\n attributesToAdd: { attribute: JSXAttribute; name: string }[],\n) => {\n if (!Array.isArray(openingElement.attributes)) return;\n const attrs = openingElement.attributes;\n attributesToAdd.forEach(({ attribute, name }) => {\n if (!hasAttributeOnElement(openingElement, name)) {\n attrs.push(attribute);\n }\n });\n};\n","import type { ASTPath, JSCodeshift, JSXAttribute, JSXElement, Node } from 'jscodeshift';\n\nexport interface ReporterOptions {\n jscodeshift: JSCodeshift;\n issues: string[];\n}\n\n/**\n * CodemodReporter is a utility class for reporting issues found during codemod transformations.\n * It provides methods to report issues related to JSX elements, props, and attributes.\n *\n * @example\n * ```typescript\n * const issues: string[] = [];\n * const reporter = createReporter(j, issues);\n *\n * // Report a deprecated prop\n * reporter.reportDeprecatedProp(buttonElement, 'flat', 'variant=\"text\"');\n *\n * // Report complex expression that needs review\n * reporter.reportAmbiguousExpression(element, 'size');\n *\n * // Auto-detect common issues\n * reporter.reportAttributeIssues(element);\n * ```\n */\nexport class CodemodReporter {\n private readonly j: JSCodeshift;\n private readonly issues: string[];\n\n constructor(options: ReporterOptions) {\n this.j = options.jscodeshift;\n this.issues = options.issues;\n }\n\n /**\n * Reports an issue with a JSX element\n */\n reportElement(element: JSXElement | ASTPath<JSXElement>, reason: string): void {\n const node = this.getNode(element);\n const componentName = this.getComponentName(node);\n const line = this.getLineNumber(node);\n\n this.addIssue(`Manual review required: <${componentName}> at line ${line} ${reason}.`);\n }\n\n /**\n * Reports an issue with a specific prop\n */\n reportProp(element: JSXElement | ASTPath<JSXElement>, propName: string, reason: string): void {\n const node = this.getNode(element);\n const componentName = this.getComponentName(node);\n const line = this.getLineNumber(node);\n\n this.addIssue(\n `Manual review required: prop \"${propName}\" on <${componentName}> at line ${line} ${reason}.`,\n );\n }\n\n /**\n * Reports an issue with a JSX attribute directly\n */\n reportAttribute(\n attr: JSXAttribute,\n element: JSXElement | ASTPath<JSXElement>,\n reason?: string,\n ): void {\n const node = this.getNode(element);\n const componentName = this.getComponentName(node);\n const propName = this.getAttributeName(attr);\n const line = this.getLineNumber(attr) || this.getLineNumber(node);\n\n const defaultReason = this.getAttributeReason(attr);\n const finalReason = reason || defaultReason;\n\n this.addIssue(\n `Manual review required: prop \"${propName}\" on <${componentName}> at line ${line} ${finalReason}.`,\n );\n }\n\n /**\n * Reports spread props on an element\n */\n reportSpreadProps(element: JSXElement | ASTPath<JSXElement>): void {\n this.reportElement(element, 'contains spread props that need manual review');\n }\n\n /**\n * Reports conflicting prop and children\n */\n reportPropWithChildren(element: JSXElement | ASTPath<JSXElement>, propName: string): void {\n this.reportProp(\n element,\n propName,\n `conflicts with children - both \"${propName}\" prop and children are present`,\n );\n }\n\n /**\n * Reports unsupported prop value\n */\n reportUnsupportedValue(\n element: JSXElement | ASTPath<JSXElement>,\n propName: string,\n value: string,\n ): void {\n this.reportProp(element, propName, `has unsupported value \"${value}\"`);\n }\n\n /**\n * Reports ambiguous expression in prop\n */\n reportAmbiguousExpression(element: JSXElement | ASTPath<JSXElement>, propName: string): void {\n this.reportProp(element, propName, 'contains a complex expression that needs manual review');\n }\n\n /**\n * Reports ambiguous children (like dynamic icons)\n */\n reportAmbiguousChildren(element: JSXElement | ASTPath<JSXElement>, childType = 'content'): void {\n this.reportElement(element, `contains ambiguous ${childType} that needs manual review`);\n }\n\n /**\n * Reports deprecated prop usage\n */\n reportDeprecatedProp(\n element: JSXElement | ASTPath<JSXElement>,\n propName: string,\n alternative?: string,\n ): void {\n const suggestion = alternative ? ` Use ${alternative} instead` : '';\n this.reportProp(element, propName, `is deprecated${suggestion}`);\n }\n\n /**\n * Reports missing required prop\n */\n reportMissingRequiredProp(element: JSXElement | ASTPath<JSXElement>, propName: string): void {\n this.reportProp(element, propName, 'is required but missing');\n }\n\n /**\n * Reports conflicting props\n */\n reportConflictingProps(element: JSXElement | ASTPath<JSXElement>, propNames: string[]): void {\n const propList = propNames.map((name) => `\"${name}\"`).join(', ');\n this.reportElement(element, `has conflicting props: ${propList} cannot be used together`);\n }\n\n /**\n * Auto-detects and reports common attribute issues\n */\n reportAttributeIssues(element: JSXElement | ASTPath<JSXElement>): void {\n const node = this.getNode(element);\n const { attributes } = node.openingElement;\n\n if (!attributes) return;\n\n // Check for spread props\n if (attributes.some((attr) => attr.type === 'JSXSpreadAttribute')) {\n this.reportSpreadProps(element);\n }\n\n // Check for complex expressions in attributes\n attributes.forEach((attr) => {\n if (attr.type === 'JSXAttribute' && attr.value?.type === 'JSXExpressionContainer') {\n this.reportAttribute(attr, element);\n }\n });\n }\n\n // Private helper methods\n private getNode(element: JSXElement | ASTPath<JSXElement>): JSXElement {\n return 'node' in element ? element.node : element;\n }\n\n private getComponentName(node: JSXElement): string {\n const { name } = node.openingElement;\n if (name.type === 'JSXIdentifier') {\n return name.name;\n }\n // Handle JSXMemberExpression, JSXNamespacedName, etc.\n return this.j(name).toSource();\n }\n\n private getLineNumber(node: JSXElement | JSXAttribute | Node): string {\n return node.loc?.start.line?.toString() || 'unknown';\n }\n\n private getAttributeName(attr: JSXAttribute): string {\n if (attr.name.type === 'JSXIdentifier') {\n return attr.name.name;\n }\n return this.j(attr.name).toSource();\n }\n\n private getAttributeReason(attr: JSXAttribute): string {\n if (!attr.value) return 'has no value';\n\n if (attr.value.type === 'JSXExpressionContainer') {\n const expr = attr.value.expression;\n const expressionType = expr.type.replace('Expression', '').toLowerCase();\n\n // Show actual value for simple cases\n if (expr.type === 'Identifier' || expr.type === 'MemberExpression') {\n const valueText = this.j(expr).toSource();\n return `contains a ${expressionType} (${valueText})`;\n }\n\n return `contains a complex ${expressionType} expression`;\n }\n\n return 'needs manual review';\n }\n\n private addIssue(message: string): void {\n this.issues.push(message);\n }\n}\n\nexport const createReporter = (j: JSCodeshift, issues: string[]): CodemodReporter => {\n return new CodemodReporter({ jscodeshift: j, issues });\n};\n","import type { API, FileInfo, JSCodeshift, JSXIdentifier, Options } from 'jscodeshift';\n\nimport reportManualReview from '../../utils/reportManualReview';\nimport hasImport from '../helpers/hasImport';\nimport processIconChildren from '../helpers/iconUtils';\nimport {\n addAttributesIfMissing,\n hasAttributeOnElement,\n setNameIfJSXIdentifier,\n} from '../helpers/jsxElementUtils';\nimport { createReporter } from '../helpers/jsxReportingUtils';\n\nexport const parser = 'tsx';\n\ninterface LegacyProps {\n priority?: string;\n size?: string;\n type?: string;\n htmlType?: string;\n sentiment?: string;\n [key: string]: unknown;\n}\n\nconst priorityMapping: Record<string, Record<string, string>> = {\n accent: {\n primary: 'primary',\n secondary: 'secondary-neutral',\n tertiary: 'tertiary',\n },\n positive: {\n primary: 'primary',\n secondary: 'secondary-neutral',\n tertiary: 'secondary-neutral',\n },\n negative: {\n primary: 'primary',\n secondary: 'secondary',\n tertiary: 'secondary',\n },\n};\n\nconst sizeMap: Record<string, string> = {\n EXTRA_SMALL: 'xs',\n SMALL: 'sm',\n MEDIUM: 'md',\n LARGE: 'lg',\n EXTRA_LARGE: 'xl',\n xs: 'sm',\n sm: 'sm',\n md: 'md',\n lg: 'lg',\n xl: 'xl',\n};\n\nconst resolveSize = (size?: string): string | undefined => {\n if (!size) return size;\n const match = /^Size\\.(EXTRA_SMALL|SMALL|MEDIUM|LARGE|EXTRA_LARGE)$/u.exec(size);\n if (match) {\n return sizeMap[match[1]];\n }\n return sizeMap[size] || size;\n};\n\nconst resolvePriority = (type?: string, priority?: string): string | undefined => {\n if (type && priority) {\n return priorityMapping[type]?.[priority] || priority;\n }\n return priority;\n};\n\nconst resolveType = (type?: string, htmlType?: string): string | null => {\n if (htmlType) {\n return htmlType;\n }\n\n const legacyButtonTypes = [\n 'accent',\n 'negative',\n 'positive',\n 'primary',\n 'pay',\n 'secondary',\n 'danger',\n 'link',\n ];\n return type && legacyButtonTypes.includes(type) ? type : null;\n};\n\nconst convertEnumValue = (value?: string): string | undefined => {\n if (!value) return value;\n const strippedValue = value.replace(/^['\"]|['\"]$/gu, '');\n const enumMapping: Record<string, string> = {\n 'Priority.SECONDARY': 'secondary',\n 'Priority.PRIMARY': 'primary',\n 'Priority.TERTIARY': 'tertiary',\n 'ControlType.NEGATIVE': 'negative',\n 'ControlType.POSITIVE': 'positive',\n 'ControlType.ACCENT': 'accent',\n };\n return enumMapping[strippedValue] || strippedValue;\n};\n\n/**\n * This transform function modifies the Button and ActionButton components from the @transferwise/components library.\n * It updates the ActionButton component to use the Button component with specific attributes and mappings.\n * It also processes icon children and removes legacy props.\n *\n * @param {FileInfo} file - The file information object.\n * @param {API} api - The API object for jscodeshift.\n * @param {Options} options - The options object for jscodeshift.\n * @returns {string} - The transformed source code.\n */\nconst transformer = (file: FileInfo, api: API, options: Options) => {\n const j: JSCodeshift = api.jscodeshift;\n const root = j(file.source);\n const manualReviewIssues: string[] = [];\n\n // Create reporter instance\n const reporter = createReporter(j, manualReviewIssues);\n\n const { exists: hasButtonImport } = hasImport(root, '@transferwise/components', 'Button', j);\n const { exists: hasActionButtonImport, remove: removeActionButtonImport } = hasImport(\n root,\n '@transferwise/components',\n 'ActionButton',\n j,\n );\n\n const iconImports = new Set<string>();\n root.find(j.ImportDeclaration, { source: { value: '@transferwise/icons' } }).forEach((path) => {\n path.node.specifiers?.forEach((specifier) => {\n if (\n (specifier.type === 'ImportDefaultSpecifier' || specifier.type === 'ImportSpecifier') &&\n specifier.local\n ) {\n const localName = (specifier.local as { name: string }).name;\n iconImports.add(localName);\n }\n });\n });\n\n if (hasActionButtonImport) {\n root.findJSXElements('ActionButton').forEach((path) => {\n const { openingElement, closingElement } = path.node;\n\n openingElement.name = setNameIfJSXIdentifier(openingElement.name, 'Button')!;\n if (closingElement) {\n closingElement.name = setNameIfJSXIdentifier(closingElement.name, 'Button')!;\n }\n\n addAttributesIfMissing(j, openingElement, [\n { attribute: j.jsxAttribute(j.jsxIdentifier('v2')), name: 'v2' },\n { attribute: j.jsxAttribute(j.jsxIdentifier('size'), j.literal('sm')), name: 'size' },\n ]);\n\n processIconChildren(j, path.node.children, iconImports, openingElement);\n\n if ((openingElement.attributes ?? []).some((attr) => attr.type === 'JSXSpreadAttribute')) {\n reporter.reportSpreadProps(path);\n }\n\n const legacyPropNames = ['priority', 'text'];\n const legacyProps: LegacyProps = {};\n\n openingElement.attributes?.forEach((attr) => {\n if (attr.type === 'JSXAttribute' && attr.name && attr.name.type === 'JSXIdentifier') {\n const { name } = attr.name;\n if (legacyPropNames.includes(name)) {\n if (attr.value) {\n if (attr.value.type === 'StringLiteral') {\n legacyProps[name] = attr.value.value;\n } else if (attr.value.type === 'JSXExpressionContainer') {\n reporter.reportAttribute(attr, path);\n }\n }\n }\n }\n });\n\n const hasTextProp = openingElement.attributes?.some(\n (attr) =>\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n attr.name.name === 'text',\n );\n const hasChildren = path.node.children?.some(\n (child) =>\n (child.type === 'JSXText' && child.value.trim() !== '') ||\n child.type === 'JSXElement' ||\n child.type === 'JSXExpressionContainer',\n );\n\n if (hasTextProp && hasChildren) {\n reporter.reportPropWithChildren(path, 'text');\n }\n\n (path.node.children || []).forEach((child) => {\n if (child.type === 'JSXExpressionContainer') {\n const expr = child.expression;\n if (\n expr.type === 'ConditionalExpression' ||\n expr.type === 'CallExpression' ||\n expr.type === 'Identifier' ||\n expr.type === 'MemberExpression'\n ) {\n reporter.reportAmbiguousChildren(path, 'icon');\n }\n }\n });\n });\n\n removeActionButtonImport();\n }\n\n if (hasButtonImport) {\n root.findJSXElements('Button').forEach((path) => {\n const { openingElement } = path.node;\n\n if (hasAttributeOnElement(openingElement, 'v2')) return;\n\n addAttributesIfMissing(j, openingElement, [\n { attribute: j.jsxAttribute(j.jsxIdentifier('v2')), name: 'v2' },\n ]);\n processIconChildren(j, path.node.children, iconImports, openingElement);\n\n const legacyProps: LegacyProps = {};\n const legacyPropNames = ['priority', 'size', 'type', 'htmlType', 'sentiment'];\n\n openingElement.attributes?.forEach((attr) => {\n if (attr.type === 'JSXAttribute' && attr.name && attr.name.type === 'JSXIdentifier') {\n const { name } = attr.name;\n if (legacyPropNames.includes(name)) {\n if (attr.value) {\n if (attr.value.type === 'StringLiteral') {\n legacyProps[name] = attr.value.value;\n } else if (attr.value.type === 'JSXExpressionContainer') {\n legacyProps[name] = convertEnumValue(String(j(attr.value.expression).toSource()));\n }\n } else {\n legacyProps[name] = undefined;\n }\n }\n }\n });\n\n if (openingElement.attributes) {\n openingElement.attributes = openingElement.attributes.filter(\n (attr) =>\n !(\n attr.type === 'JSXAttribute' &&\n attr.name &&\n legacyPropNames.includes((attr.name as JSXIdentifier).name)\n ),\n );\n }\n\n if ('size' in legacyProps) {\n const rawValue = legacyProps.size;\n const resolved = resolveSize(rawValue);\n const supportedSizes = ['xs', 'sm', 'md', 'lg', 'xl'];\n\n if (\n typeof rawValue === 'string' &&\n typeof resolved === 'string' &&\n supportedSizes.includes(resolved)\n ) {\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('size'), j.literal(resolved)),\n );\n } else if (typeof rawValue === 'string') {\n reporter.reportUnsupportedValue(path, 'size', rawValue);\n } else if (rawValue !== undefined) {\n reporter.reportAmbiguousExpression(path, 'size');\n }\n }\n\n if ('priority' in legacyProps) {\n const rawValue = legacyProps.priority;\n const converted = convertEnumValue(rawValue);\n const mapped = resolvePriority(legacyProps.type, converted);\n const supportedPriorities = ['primary', 'secondary', 'tertiary', 'secondary-neutral'];\n\n if (\n typeof rawValue === 'string' &&\n typeof mapped === 'string' &&\n supportedPriorities.includes(mapped)\n ) {\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('priority'), j.literal(mapped)),\n );\n } else if (typeof rawValue === 'string') {\n reporter.reportUnsupportedValue(path, 'priority', rawValue);\n } else if (rawValue !== undefined) {\n reporter.reportAmbiguousExpression(path, 'priority');\n }\n }\n\n if ('type' in legacyProps || 'htmlType' in legacyProps) {\n const rawType = legacyProps.type;\n const rawHtmlType = legacyProps.htmlType;\n\n const resolvedType =\n typeof rawType === 'string'\n ? rawType\n : rawType && typeof rawType === 'object'\n ? convertEnumValue(j(rawType).toSource())\n : undefined;\n\n const resolved = resolveType(resolvedType, rawHtmlType);\n\n const supportedTypes = [\n 'accent',\n 'negative',\n 'positive',\n 'primary',\n 'pay',\n 'secondary',\n 'danger',\n 'link',\n 'submit',\n 'button',\n 'reset',\n ];\n\n if (typeof resolved === 'string' && supportedTypes.includes(resolved)) {\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('type'), j.literal(resolved)),\n );\n\n if (resolved === 'negative') {\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('sentiment'), j.literal('negative')),\n );\n }\n } else if (typeof rawType === 'string' || typeof rawHtmlType === 'string') {\n reporter.reportUnsupportedValue(path, 'type', rawType ?? rawHtmlType ?? '');\n } else if (rawType !== undefined || rawHtmlType !== undefined) {\n reporter.reportAmbiguousExpression(path, 'type');\n }\n }\n\n if ('sentiment' in legacyProps) {\n const rawValue = legacyProps.sentiment;\n if (rawValue === 'negative') {\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('sentiment'), j.literal('negative')),\n );\n } else if (typeof rawValue === 'string') {\n reporter.reportUnsupportedValue(path, 'sentiment', rawValue);\n } else if (rawValue !== undefined) {\n reporter.reportAmbiguousExpression(path, 'sentiment');\n }\n }\n\n let asIndex = -1;\n let asValue: string | null = null;\n let hrefExists = false;\n let asAmbiguous = false;\n let hrefAmbiguous = false;\n\n openingElement.attributes?.forEach((attr, index) => {\n if (attr.type === 'JSXAttribute' && attr.name) {\n if (attr.name.name === 'as') {\n if (attr.value) {\n if (attr.value.type === 'StringLiteral') {\n asValue = attr.value.value;\n } else if (attr.value.type === 'JSXExpressionContainer') {\n asAmbiguous = true;\n reporter.reportAttribute(attr, path);\n }\n }\n asIndex = index;\n }\n\n if (attr.name.name === 'href') {\n hrefExists = true;\n if (attr.value && attr.value.type !== 'StringLiteral') {\n hrefAmbiguous = true;\n reporter.reportAttribute(attr, path);\n }\n }\n }\n });\n\n if (asValue && asValue !== 'a') {\n reporter.reportUnsupportedValue(path, 'as', asValue);\n }\n\n if (asValue === 'a') {\n if (asIndex !== -1) {\n openingElement.attributes = openingElement.attributes?.filter(\n (_, idx) => idx !== asIndex,\n );\n }\n if (!hrefExists) {\n openingElement.attributes = [\n ...(openingElement.attributes ?? []),\n j.jsxAttribute(j.jsxIdentifier('href'), j.literal('#')),\n ];\n }\n }\n\n if ((openingElement.attributes ?? []).some((attr) => attr.type === 'JSXSpreadAttribute')) {\n reporter.reportSpreadProps(path);\n }\n });\n }\n\n if (manualReviewIssues.length > 0) {\n manualReviewIssues.forEach(async (issue) => {\n await reportManualReview(file.path, issue);\n });\n }\n\n return root.toSource();\n};\n\nexport default transformer;\n"],"mappings":";;;;;;;;AAMA,SAAS,UACP,MACA,aACA,YACA,GACyC;CACzC,MAAM,qBAAqB,KAAK,KAAK,EAAE,mBAAmB,EACxD,QAAQ,EAAE,OAAO,aAAa,EAC/B;AAED,KAAI,mBAAmB,WAAW,EAChC,QAAO;EACL,QAAQ;EACR,cAAc,CAAE;EACjB;CAGH,MAAM,cAAc,mBAAmB,KAAK,EAAE,iBAAiB,EAC7D,UAAU,EAAE,MAAM,YAAY,EAC/B;CAED,MAAM,gBAAgB,mBAAmB,KAAK,EAAE,wBAAwB,EACtE,OAAO,EAAE,MAAM,YAAY,EAC5B;CAED,MAAM,SAAS,YAAY,SAAS,KAAK,cAAc,SAAS;CAEhE,MAAM,eAAe;AACnB,qBAAmB,SAAS,SAAS;GACnC,MAAM,qBACJ,KAAK,KAAK,YAAY,QAAQ,cAAc;AAC1C,QAAI,UAAU,SAAS,qBAAqB,UAAU,SAAS,SAAS,WACtE,QAAO;AAET,QAAI,UAAU,SAAS,4BAA4B,UAAU,OAAO,SAAS,WAC3E,QAAO;AAET,WAAO;GACR,MAAK,EAAE;AAEV,OAAI,mBAAmB,WAAW,EAChC,MAAK;OAEL,GAAE,MAAM,YACN,EAAE,kBAAkB,oBAAoB,KAAK,KAAK,QAAQ,KAAK,KAAK;EAGzE;CACF;AAED,QAAO;EAAE;EAAQ;EAAQ;AAC1B;;;;;;;;ACnDD,MAAM,uBACJ,GACA,UACA,aACA,mBACG;AACH,KAAI,CAAC,YAAY,CAAC,eAAe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