@wise/wds-codemods 0.0.1-experimental-2eb5228 → 0.0.1-experimental-0d8d466

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.
@@ -275,41 +275,8 @@ var createReporter = (j, issues) => {
275
275
  return new CodemodReporter({ jscodeshift: j, issues });
276
276
  };
277
277
 
278
- // src/transforms/helpers/packageValidation.ts
279
- function validatePackageRequirements(options, requirements) {
280
- let packageResults = {};
281
- if (options.packageResults) {
282
- if (typeof options.packageResults === "string") {
283
- try {
284
- if (options.packageResults.trim() && options.packageResults.trim().startsWith("{")) {
285
- packageResults = JSON.parse(options.packageResults);
286
- }
287
- } catch (error) {
288
- console.debug("Failed to parse packageResults:", error);
289
- return false;
290
- }
291
- } else if (typeof options.packageResults === "object") {
292
- packageResults = options.packageResults;
293
- }
294
- }
295
- const allRequirementsMet = requirements.every((req) => {
296
- const key = `${req.name}@${req.version}`;
297
- return packageResults[key];
298
- });
299
- if (!allRequirementsMet) {
300
- const missing = requirements.filter((req) => {
301
- const key = `${req.name}@${req.version}`;
302
- return !packageResults[key];
303
- });
304
- const missingPackages = missing.map((pkg) => `${pkg.name}@${pkg.version}`).join(", ");
305
- console.debug(`Skipping transform - missing required packages: ${missingPackages}`);
306
- }
307
- return allRequirementsMet;
308
- }
309
-
310
278
  // src/transforms/button/button.ts
311
279
  var parser = "tsx";
312
- var packageRequirements = [{ name: "@transferwise/components", version: ">=46.5.0" }];
313
280
  var priorityMapping = {
314
281
  accent: {
315
282
  primary: "primary",
@@ -365,15 +332,12 @@ var resolveType = (type, htmlType) => {
365
332
  "pay",
366
333
  "secondary",
367
334
  "danger",
368
- "link",
369
- "button",
370
- "reset",
371
- "submit"
335
+ "link"
372
336
  ];
373
337
  return type && legacyButtonTypes.includes(type) ? type : null;
374
338
  };
375
339
  var convertEnumValue = (value) => {
376
- if (!value) return { converted: value, wasEnum: false };
340
+ if (!value) return value;
377
341
  const strippedValue = value.replace(/^['"]|['"]$/gu, "");
378
342
  const enumMapping = {
379
343
  "Priority.SECONDARY": "secondary",
@@ -381,22 +345,11 @@ var convertEnumValue = (value) => {
381
345
  "Priority.TERTIARY": "tertiary",
382
346
  "ControlType.NEGATIVE": "negative",
383
347
  "ControlType.POSITIVE": "positive",
384
- "ControlType.ACCENT": "accent",
385
- "ControlType.BUTTON": "button",
386
- "ControlType.RESET": "reset",
387
- "HtmlType.SUBMIT": "submit",
388
- "HtmlType.BUTTON": "button",
389
- "HtmlType.RESET": "reset",
390
- "Sentiment.NEGATIVE": "negative"
348
+ "ControlType.ACCENT": "accent"
391
349
  };
392
- const wasEnum = strippedValue in enumMapping;
393
- const converted = enumMapping[strippedValue] || strippedValue;
394
- return { converted, wasEnum };
350
+ return enumMapping[strippedValue] || strippedValue;
395
351
  };
396
352
  var transformer = (file, api, options) => {
397
- if (!validatePackageRequirements(options, packageRequirements)) {
398
- return file.source;
399
- }
400
353
  const j = api.jscodeshift;
401
354
  const root = j(file.source);
402
355
  const manualReviewIssues = [];
@@ -478,114 +431,107 @@ var transformer = (file, api, options) => {
478
431
  iconUtils_default(j, path2.node.children, iconImports, openingElement);
479
432
  const legacyProps = {};
480
433
  const legacyPropNames = ["priority", "size", "type", "htmlType", "sentiment"];
481
- const keepAttributes = [];
482
- (openingElement.attributes ?? []).forEach((attr) => {
483
- if (attr.type === "JSXAttribute" && attr.name && attr.name.type === "JSXIdentifier" && legacyPropNames.includes(attr.name.name)) {
434
+ openingElement.attributes?.forEach((attr) => {
435
+ if (attr.type === "JSXAttribute" && attr.name && attr.name.type === "JSXIdentifier") {
484
436
  const { name } = attr.name;
485
- let migrated = false;
486
- let rawStringValue;
487
- if (attr.value) {
488
- if (attr.value.type === "StringLiteral") {
489
- rawStringValue = attr.value.value;
490
- legacyProps[name] = attr.value.value;
491
- } else if (attr.value.type === "JSXExpressionContainer") {
492
- rawStringValue = String(j(attr.value.expression).toSource());
493
- const { converted } = convertEnumValue(rawStringValue);
494
- legacyProps[name] = converted;
495
- }
496
- } else {
497
- legacyProps[name] = void 0;
498
- }
499
- const { wasEnum } = convertEnumValue(rawStringValue);
500
- if (rawStringValue && wasEnum) {
501
- migrated = true;
502
- } else if (name === "size") {
503
- const rawValue = legacyProps.size;
504
- const resolved2 = resolveSize(rawValue);
505
- const supportedSizes = ["xs", "sm", "md", "lg", "xl"];
506
- if (typeof rawValue === "string" && typeof resolved2 === "string" && supportedSizes.includes(resolved2)) {
507
- migrated = true;
508
- } else if (typeof rawValue === "string") {
509
- reporter.reportUnsupportedValue(path2, "size", rawValue);
510
- } else if (rawValue !== void 0) {
511
- reporter.reportAmbiguousExpression(path2, "size");
512
- }
513
- } else if (name === "priority") {
514
- const rawValue = legacyProps.priority;
515
- const { converted } = convertEnumValue(rawValue);
516
- const mapped = resolvePriority(legacyProps.type, converted);
517
- const supportedPriorities = ["primary", "secondary", "tertiary", "secondary-neutral"];
518
- if (typeof rawValue === "string" && typeof mapped === "string" && supportedPriorities.includes(mapped)) {
519
- migrated = true;
520
- } else if (typeof rawValue === "string") {
521
- reporter.reportUnsupportedValue(path2, "priority", rawValue);
522
- } else if (rawValue !== void 0) {
523
- reporter.reportAmbiguousExpression(path2, "priority");
524
- }
525
- } else if (name === "type" || name === "htmlType") {
526
- const rawType2 = legacyProps.type;
527
- const rawHtmlType2 = legacyProps.htmlType;
528
- const resolvedType2 = typeof rawType2 === "string" ? rawType2 : rawType2 && typeof rawType2 === "object" ? convertEnumValue(j(rawType2).toSource()).converted : void 0;
529
- const resolved2 = resolveType(resolvedType2, rawHtmlType2);
530
- const supportedTypes2 = ["button", "reset", "submit"];
531
- if (typeof resolved2 === "string" && supportedTypes2.includes(resolved2)) {
532
- migrated = true;
533
- } else if (typeof rawType2 === "string" || typeof rawHtmlType2 === "string") {
534
- reporter.reportUnsupportedValue(path2, "type", rawType2 ?? rawHtmlType2 ?? "");
535
- } else if (rawType2 !== void 0 || rawHtmlType2 !== void 0) {
536
- reporter.reportAmbiguousExpression(path2, "type");
537
- }
538
- } else if (name === "sentiment") {
539
- const rawValue = legacyProps.sentiment;
540
- if (rawValue === "negative") {
541
- migrated = true;
542
- } else if (typeof rawValue === "string") {
543
- reporter.reportUnsupportedValue(path2, "sentiment", rawValue);
544
- } else if (rawValue !== void 0) {
545
- reporter.reportAmbiguousExpression(path2, "sentiment");
437
+ if (legacyPropNames.includes(name)) {
438
+ if (attr.value) {
439
+ if (attr.value.type === "StringLiteral") {
440
+ legacyProps[name] = attr.value.value;
441
+ } else if (attr.value.type === "JSXExpressionContainer") {
442
+ legacyProps[name] = convertEnumValue(String(j(attr.value.expression).toSource()));
443
+ }
444
+ } else {
445
+ legacyProps[name] = void 0;
546
446
  }
547
447
  }
548
- if (!migrated) keepAttributes.push(attr);
549
- } else {
550
- keepAttributes.push(attr);
551
448
  }
552
449
  });
553
- const newAttributes = [];
554
- const rawSize = legacyProps.size;
555
- const resolvedSize = resolveSize(rawSize);
556
- if (typeof rawSize === "string" && typeof resolvedSize === "string" && ["xs", "sm", "md", "lg", "xl"].includes(resolvedSize)) {
557
- newAttributes.push(j.jsxAttribute(j.jsxIdentifier("size"), j.literal(resolvedSize)));
450
+ if (openingElement.attributes) {
451
+ openingElement.attributes = openingElement.attributes.filter(
452
+ (attr) => !(attr.type === "JSXAttribute" && attr.name && legacyPropNames.includes(attr.name.name))
453
+ );
558
454
  }
559
- const rawPriority = legacyProps.priority;
560
- const { converted: convertedPriority } = convertEnumValue(rawPriority);
561
- const mappedPriority = resolvePriority(legacyProps.type, convertedPriority);
562
- if (typeof rawPriority === "string" && typeof mappedPriority === "string" && ["primary", "secondary", "tertiary", "secondary-neutral"].includes(mappedPriority)) {
563
- newAttributes.push(j.jsxAttribute(j.jsxIdentifier("priority"), j.literal(mappedPriority)));
455
+ if ("size" in legacyProps) {
456
+ const rawValue = legacyProps.size;
457
+ const resolved = resolveSize(rawValue);
458
+ const supportedSizes = ["xs", "sm", "md", "lg", "xl"];
459
+ if (typeof rawValue === "string" && typeof resolved === "string" && supportedSizes.includes(resolved)) {
460
+ openingElement.attributes?.push(
461
+ j.jsxAttribute(j.jsxIdentifier("size"), j.literal(resolved))
462
+ );
463
+ } else if (typeof rawValue === "string") {
464
+ reporter.reportUnsupportedValue(path2, "size", rawValue);
465
+ } else if (rawValue !== void 0) {
466
+ reporter.reportAmbiguousExpression(path2, "size");
467
+ }
564
468
  }
565
- const rawType = legacyProps.type;
566
- const rawHtmlType = legacyProps.htmlType;
567
- const resolvedType = typeof rawType === "string" ? rawType : rawType && typeof rawType === "object" ? convertEnumValue(j(rawType).toSource()).converted : void 0;
568
- const resolved = resolveType(resolvedType, rawHtmlType);
569
- const supportedTypes = ["button", "reset", "submit", "negative"];
570
- if (typeof resolved === "string" && supportedTypes.includes(resolved)) {
571
- if (resolved !== "negative") {
572
- newAttributes.push(j.jsxAttribute(j.jsxIdentifier("type"), j.literal(resolved)));
469
+ if ("priority" in legacyProps) {
470
+ const rawValue = legacyProps.priority;
471
+ const converted = convertEnumValue(rawValue);
472
+ const mapped = resolvePriority(legacyProps.type, converted);
473
+ const supportedPriorities = ["primary", "secondary", "tertiary", "secondary-neutral"];
474
+ if (typeof rawValue === "string" && typeof mapped === "string" && supportedPriorities.includes(mapped)) {
475
+ openingElement.attributes?.push(
476
+ j.jsxAttribute(j.jsxIdentifier("priority"), j.literal(mapped))
477
+ );
478
+ } else if (typeof rawValue === "string") {
479
+ reporter.reportUnsupportedValue(path2, "priority", rawValue);
480
+ } else if (rawValue !== void 0) {
481
+ reporter.reportAmbiguousExpression(path2, "priority");
573
482
  }
574
- if (resolved === "negative") {
575
- newAttributes.push(j.jsxAttribute(j.jsxIdentifier("sentiment"), j.literal("negative")));
483
+ }
484
+ if ("type" in legacyProps || "htmlType" in legacyProps) {
485
+ const rawType = legacyProps.type;
486
+ const rawHtmlType = legacyProps.htmlType;
487
+ const resolvedType = typeof rawType === "string" ? rawType : rawType && typeof rawType === "object" ? convertEnumValue(j(rawType).toSource()) : void 0;
488
+ const resolved = resolveType(resolvedType, rawHtmlType);
489
+ const supportedTypes = [
490
+ "accent",
491
+ "negative",
492
+ "positive",
493
+ "primary",
494
+ "pay",
495
+ "secondary",
496
+ "danger",
497
+ "link",
498
+ "submit",
499
+ "button",
500
+ "reset"
501
+ ];
502
+ if (typeof resolved === "string" && supportedTypes.includes(resolved)) {
503
+ openingElement.attributes?.push(
504
+ j.jsxAttribute(j.jsxIdentifier("type"), j.literal(resolved))
505
+ );
506
+ if (resolved === "negative") {
507
+ openingElement.attributes?.push(
508
+ j.jsxAttribute(j.jsxIdentifier("sentiment"), j.literal("negative"))
509
+ );
510
+ }
511
+ } else if (typeof rawType === "string" || typeof rawHtmlType === "string") {
512
+ reporter.reportUnsupportedValue(path2, "type", rawType ?? rawHtmlType ?? "");
513
+ } else if (rawType !== void 0 || rawHtmlType !== void 0) {
514
+ reporter.reportAmbiguousExpression(path2, "type");
576
515
  }
577
516
  }
578
- const rawSentiment = legacyProps.sentiment;
579
- if (rawSentiment === "negative") {
580
- newAttributes.push(j.jsxAttribute(j.jsxIdentifier("sentiment"), j.literal("negative")));
517
+ if ("sentiment" in legacyProps) {
518
+ const rawValue = legacyProps.sentiment;
519
+ if (rawValue === "negative") {
520
+ openingElement.attributes?.push(
521
+ j.jsxAttribute(j.jsxIdentifier("sentiment"), j.literal("negative"))
522
+ );
523
+ } else if (typeof rawValue === "string") {
524
+ reporter.reportUnsupportedValue(path2, "sentiment", rawValue);
525
+ } else if (rawValue !== void 0) {
526
+ reporter.reportAmbiguousExpression(path2, "sentiment");
527
+ }
581
528
  }
582
- Array.prototype.push.apply(newAttributes, keepAttributes);
583
529
  let asIndex = -1;
584
530
  let asValue = null;
585
531
  let hrefExists = false;
586
532
  let asAmbiguous = false;
587
533
  let hrefAmbiguous = false;
588
- newAttributes.forEach((attr, index) => {
534
+ openingElement.attributes?.forEach((attr, index) => {
589
535
  if (attr.type === "JSXAttribute" && attr.name) {
590
536
  if (attr.name.name === "as") {
591
537
  if (attr.value) {
@@ -612,13 +558,17 @@ var transformer = (file, api, options) => {
612
558
  }
613
559
  if (asValue === "a") {
614
560
  if (asIndex !== -1) {
615
- newAttributes.splice(asIndex, 1);
561
+ openingElement.attributes = openingElement.attributes?.filter(
562
+ (_, idx) => idx !== asIndex
563
+ );
616
564
  }
617
565
  if (!hrefExists) {
618
- newAttributes.push(j.jsxAttribute(j.jsxIdentifier("href"), j.literal("#")));
566
+ openingElement.attributes = [
567
+ ...openingElement.attributes ?? [],
568
+ j.jsxAttribute(j.jsxIdentifier("href"), j.literal("#"))
569
+ ];
619
570
  }
620
571
  }
621
- openingElement.attributes = newAttributes;
622
572
  if ((openingElement.attributes ?? []).some((attr) => attr.type === "JSXSpreadAttribute")) {
623
573
  reporter.reportSpreadProps(path2);
624
574
  }
@@ -634,7 +584,6 @@ var transformer = (file, api, options) => {
634
584
  var button_default = transformer;
635
585
  export {
636
586
  button_default as default,
637
- packageRequirements,
638
587
  parser
639
588
  };
640
589
  //# sourceMappingURL=button.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/reportManualReview.ts","../../src/transforms/helpers/hasImport.ts","../../src/transforms/helpers/iconUtils.ts","../../src/transforms/helpers/jsxElementUtils.ts","../../src/transforms/helpers/jsxReportingUtils.ts","../../src/transforms/helpers/packageValidation.ts","../../src/transforms/button/button.ts"],"sourcesContent":["import fs from 'node:fs/promises';\n\nimport path from 'path';\n\nconst REPORT_PATH = path.resolve(process.cwd(), 'codemod-report.txt');\n\nconst reportManualReview = async (filePath: string, message: string): Promise<void> => {\n const lineMatch = /at line (\\d+)/u.exec(message);\n const lineNumber = lineMatch?.[1];\n\n const cleanMessage = message.replace(/ at line \\d+/u, '');\n const lineInfo = lineNumber ? `:${lineNumber}` : '';\n\n await fs.appendFile(REPORT_PATH, `[${filePath}${lineInfo}] ${cleanMessage}\\n`, 'utf8');\n};\n\nexport default reportManualReview;\n","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 { Options } from 'jscodeshift';\n\ninterface PackageRequirement {\n name: string;\n version: string;\n}\n\n/**\n * Check if package requirements are met\n * Returns true if all packages are found, false otherwise\n */\nexport function validatePackageRequirements(\n options: Options,\n requirements: PackageRequirement[],\n): boolean {\n let packageResults: Record<string, boolean> = {};\n\n // Handle both string and object cases\n if (options.packageResults) {\n if (typeof options.packageResults === 'string') {\n // Parse JSON string\n try {\n if (options.packageResults.trim() && options.packageResults.trim().startsWith('{')) {\n packageResults = JSON.parse(options.packageResults) as Record<string, boolean>;\n }\n } catch (error) {\n console.debug('Failed to parse packageResults:', error);\n return false;\n }\n } else if (typeof options.packageResults === 'object') {\n // Already an object, use directly\n packageResults = options.packageResults as Record<string, boolean>;\n }\n }\n\n // Check if all requirements are met\n const allRequirementsMet = requirements.every((req) => {\n const key = `${req.name}@${req.version}`;\n return packageResults[key];\n });\n\n if (!allRequirementsMet) {\n const missing = requirements.filter((req) => {\n const key = `${req.name}@${req.version}`;\n return !packageResults[key];\n });\n\n const missingPackages = missing.map((pkg) => `${pkg.name}@${pkg.version}`).join(', ');\n console.debug(`Skipping transform - missing required packages: ${missingPackages}`);\n }\n\n return allRequirementsMet;\n}\n","import type { API, FileInfo, JSCodeshift, JSXIdentifier, Options } from 'jscodeshift';\n\nimport reportManualReview from '../../utils/reportManualReview';\nimport {\n addAttributesIfMissing,\n createReporter,\n hasAttributeOnElement,\n hasImport,\n processIconChildren,\n setNameIfJSXIdentifier,\n validatePackageRequirements,\n} from '../helpers';\n\nexport const parser = 'tsx';\nexport const packageRequirements = [{ name: '@transferwise/components', version: '>=46.5.0' }];\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 'button',\n 'reset',\n 'submit',\n ];\n return type && legacyButtonTypes.includes(type) ? type : null;\n};\n\nconst convertEnumValue = (value?: string): { converted: string | undefined; wasEnum: boolean } => {\n if (!value) return { converted: value, wasEnum: false };\n\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 'ControlType.BUTTON': 'button',\n 'ControlType.RESET': 'reset',\n 'HtmlType.SUBMIT': 'submit',\n 'HtmlType.BUTTON': 'button',\n 'HtmlType.RESET': 'reset',\n 'Sentiment.NEGATIVE': 'negative',\n };\n\n const wasEnum = strippedValue in enumMapping;\n const converted = enumMapping[strippedValue] || strippedValue;\n\n return { converted, wasEnum };\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 if (!validatePackageRequirements(options, packageRequirements)) {\n return file.source;\n }\n\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\n processIconChildren(j, path.node.children, iconImports, openingElement);\n\n const legacyProps: LegacyProps = {};\n const legacyPropNames = ['priority', 'size', 'type', 'htmlType', 'sentiment'];\n const keepAttributes: typeof openingElement.attributes = [];\n\n (openingElement.attributes ?? []).forEach((attr) => {\n if (\n attr.type === 'JSXAttribute' &&\n attr.name &&\n attr.name.type === 'JSXIdentifier' &&\n legacyPropNames.includes(attr.name.name)\n ) {\n const { name } = attr.name;\n let migrated = false;\n let rawStringValue: string | undefined;\n\n if (attr.value) {\n if (attr.value.type === 'StringLiteral') {\n rawStringValue = attr.value.value;\n legacyProps[name] = attr.value.value;\n } else if (attr.value.type === 'JSXExpressionContainer') {\n rawStringValue = String(j(attr.value.expression).toSource());\n const { converted } = convertEnumValue(rawStringValue);\n legacyProps[name] = converted;\n }\n } else {\n legacyProps[name] = undefined;\n }\n\n // Check if this is an enum value that should be removed\n const { wasEnum } = convertEnumValue(rawStringValue);\n if (rawStringValue && wasEnum) {\n migrated = true; // Remove enum values\n } else if (name === 'size') {\n const rawValue = legacyProps.size;\n const resolved = resolveSize(rawValue);\n const supportedSizes = ['xs', 'sm', 'md', 'lg', 'xl'];\n if (\n typeof rawValue === 'string' &&\n typeof resolved === 'string' &&\n supportedSizes.includes(resolved)\n ) {\n migrated = true;\n } else if (typeof rawValue === 'string') {\n reporter.reportUnsupportedValue(path, 'size', rawValue);\n } else if (rawValue !== undefined) {\n reporter.reportAmbiguousExpression(path, 'size');\n }\n } else if (name === 'priority') {\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 if (\n typeof rawValue === 'string' &&\n typeof mapped === 'string' &&\n supportedPriorities.includes(mapped)\n ) {\n migrated = true;\n } else if (typeof rawValue === 'string') {\n reporter.reportUnsupportedValue(path, 'priority', rawValue);\n } else if (rawValue !== undefined) {\n reporter.reportAmbiguousExpression(path, 'priority');\n }\n } else if (name === 'type' || name === 'htmlType') {\n const rawType = legacyProps.type;\n const rawHtmlType = legacyProps.htmlType;\n const resolvedType =\n typeof rawType === 'string'\n ? rawType\n : rawType && typeof rawType === 'object'\n ? convertEnumValue(j(rawType).toSource()).converted\n : undefined;\n const resolved = resolveType(resolvedType, rawHtmlType);\n const supportedTypes = ['button', 'reset', 'submit'];\n if (typeof resolved === 'string' && supportedTypes.includes(resolved)) {\n migrated = true;\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 } else if (name === 'sentiment') {\n const rawValue = legacyProps.sentiment;\n if (rawValue === 'negative') {\n migrated = true;\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 if (!migrated) keepAttributes.push(attr);\n } else {\n keepAttributes.push(attr);\n }\n });\n\n const newAttributes = [];\n const rawSize = legacyProps.size;\n const resolvedSize = resolveSize(rawSize);\n if (\n typeof rawSize === 'string' &&\n typeof resolvedSize === 'string' &&\n ['xs', 'sm', 'md', 'lg', 'xl'].includes(resolvedSize)\n ) {\n newAttributes.push(j.jsxAttribute(j.jsxIdentifier('size'), j.literal(resolvedSize)));\n }\n\n const rawPriority = legacyProps.priority;\n const { converted: convertedPriority } = convertEnumValue(rawPriority);\n const mappedPriority = resolvePriority(legacyProps.type, convertedPriority);\n if (\n typeof rawPriority === 'string' &&\n typeof mappedPriority === 'string' &&\n ['primary', 'secondary', 'tertiary', 'secondary-neutral'].includes(mappedPriority)\n ) {\n newAttributes.push(j.jsxAttribute(j.jsxIdentifier('priority'), j.literal(mappedPriority)));\n }\n\n const rawType = legacyProps.type;\n const rawHtmlType = legacyProps.htmlType;\n const resolvedType =\n typeof rawType === 'string'\n ? rawType\n : rawType && typeof rawType === 'object'\n ? convertEnumValue(j(rawType).toSource()).converted\n : undefined;\n const resolved = resolveType(resolvedType, rawHtmlType);\n const supportedTypes = ['button', 'reset', 'submit', 'negative'];\n if (typeof resolved === 'string' && supportedTypes.includes(resolved)) {\n if (resolved !== 'negative') {\n newAttributes.push(j.jsxAttribute(j.jsxIdentifier('type'), j.literal(resolved)));\n }\n if (resolved === 'negative') {\n newAttributes.push(j.jsxAttribute(j.jsxIdentifier('sentiment'), j.literal('negative')));\n }\n }\n\n const rawSentiment = legacyProps.sentiment;\n if (rawSentiment === 'negative') {\n newAttributes.push(j.jsxAttribute(j.jsxIdentifier('sentiment'), j.literal('negative')));\n }\n\n Array.prototype.push.apply(newAttributes, keepAttributes);\n\n // as/href logic as before\n let asIndex = -1;\n let asValue: string | null = null;\n let hrefExists = false;\n let asAmbiguous = false;\n let hrefAmbiguous = false;\n\n newAttributes.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 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 newAttributes.splice(asIndex, 1);\n }\n if (!hrefExists) {\n newAttributes.push(j.jsxAttribute(j.jsxIdentifier('href'), j.literal('#')));\n }\n }\n\n openingElement.attributes = newAttributes;\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":";AAAA,OAAO,QAAQ;AAEf,OAAO,UAAU;AAEjB,IAAM,cAAc,KAAK,QAAQ,QAAQ,IAAI,GAAG,oBAAoB;AAEpE,IAAM,qBAAqB,OAAO,UAAkB,YAAmC;AACrF,QAAM,YAAY,iBAAiB,KAAK,OAAO;AAC/C,QAAM,aAAa,YAAY,CAAC;AAEhC,QAAM,eAAe,QAAQ,QAAQ,iBAAiB,EAAE;AACxD,QAAM,WAAW,aAAa,IAAI,UAAU,KAAK;AAEjD,QAAM,GAAG,WAAW,aAAa,IAAI,QAAQ,GAAG,QAAQ,KAAK,YAAY;AAAA,GAAM,MAAM;AACvF;AAEA,IAAO,6BAAQ;;;ACVf,SAAS,UACP,MACA,aACA,YACA,GACyC;AACzC,QAAM,qBAAqB,KAAK,KAAK,EAAE,mBAAmB;AAAA,IACxD,QAAQ,EAAE,OAAO,YAAY;AAAA,EAC/B,CAAC;AAED,MAAI,mBAAmB,KAAK,MAAM,GAAG;AACnC,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ,MAAM;AAAA,MAAC;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,cAAc,mBAAmB,KAAK,EAAE,iBAAiB;AAAA,IAC7D,UAAU,EAAE,MAAM,WAAW;AAAA,EAC/B,CAAC;AAED,QAAM,gBAAgB,mBAAmB,KAAK,EAAE,wBAAwB;AAAA,IACtE,OAAO,EAAE,MAAM,WAAW;AAAA,EAC5B,CAAC;AAED,QAAM,SAAS,YAAY,KAAK,IAAI,KAAK,cAAc,KAAK,IAAI;AAEhE,QAAM,SAAS,MAAM;AACnB,uBAAmB,QAAQ,CAACA,UAAS;AACnC,YA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portedTypes"]}
1
+ {"version":3,"sources":["../../src/utils/reportManualReview.ts","../../src/transforms/helpers/hasImport.ts","../../src/transforms/helpers/iconUtils.ts","../../src/transforms/helpers/jsxElementUtils.ts","../../src/transforms/helpers/jsxReportingUtils.ts","../../src/transforms/button/button.ts"],"sourcesContent":["import fs from 'node:fs/promises';\n\nimport path from 'path';\n\nconst REPORT_PATH = path.resolve(process.cwd(), 'codemod-report.txt');\n\nconst reportManualReview = async (filePath: string, message: string): Promise<void> => {\n const lineMatch = /at line (\\d+)/u.exec(message);\n const lineNumber = lineMatch?.[1];\n\n const cleanMessage = message.replace(/ at line \\d+/u, '');\n const lineInfo = lineNumber ? `:${lineNumber}` : '';\n\n await fs.appendFile(REPORT_PATH, `[${filePath}${lineInfo}] ${cleanMessage}\\n`, 'utf8');\n};\n\nexport default reportManualReview;\n","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":";AAAA,OAAO,QAAQ;AAEf,OAAO,UAAU;AAEjB,IAAM,cAAc,KAAK,QAAQ,QAAQ,IAAI,GAAG,oBAAoB;AAEpE,IAAM,qBAAqB,OAAO,UAAkB,YAAmC;AACrF,QAAM,YAAY,iBAAiB,KAAK,OAAO;AAC/C,QAAM,aAAa,YAAY,CAAC;AAEhC,QAAM,eAAe,QAAQ,QAAQ,iBAAiB,EAAE;AACxD,QAAM,WAAW,aAAa,IAAI,UAAU,KAAK;AAEjD,QAAM,GAAG,WAAW,aAAa,IAAI,QAAQ,GAAG,QAAQ,KAAK,YAAY;AAAA,GAAM,MAAM;AACvF;AAEA,IAAO,6BAAQ;;;ACVf,SAAS,UACP,MACA,aACA,YACA,GACyC;AACzC,QAAM,qBAAqB,KAAK,KAAK,EAAE,mBAAmB;AAAA,IACxD,QAAQ,EAAE,OAAO,YAAY;AAAA,EAC/B,CAAC;AAED,MAAI,mBAAmB,KAAK,MAAM,GAAG;AACnC,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ,MAAM;AAAA,MAAC;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,cAAc,mBAAmB,KAAK,EAAE,iBAAiB;AAAA,IAC7D,UAAU,EAAE,MAAM,WAAW;AAAA,EAC/B,CAAC;AAED,QAAM,gBAAgB,mBAAmB,KAAK,EAAE,wBAAwB;AAAA,IACtE,OAAO,EAAE,MAAM,WAAW;AAAA,EAC5B,CAAC;AAED,QAAM,SAAS,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QACF;AAAA,MACF;AAEA,WAAK,eAAe,cAAc,CAAC,GAAG,KAAK,CAAC,SAAS,KAAK,SAAS,oBAAoB,GAAG;AACxF,iBAAS,kBAAkBA,KAAI;AAAA,MACjC;AAAA,IACF,CAAC;AAAA,EACH;AAEA,MAAI,mBAAmB,SAAS,GAAG;AACjC,uBAAmB,QAAQ,OAAO,UAAU;AAC1C,YAAM,2BAAmB,KAAK,MAAM,KAAK;AAAA,IAC3C,CAAC;AAAA,EACH;AAEA,SAAO,KAAK,SAAS;AACvB;AAEA,IAAO,iBAAQ;","names":["path","path"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/wds-codemods",
3
- "version": "0.0.1-experimental-2eb5228",
3
+ "version": "0.0.1-experimental-0d8d466",
4
4
  "license": "UNLICENSED",
5
5
  "author": "Wise Payments Ltd.",
6
6
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  "lint": "pnpm run lint:js+ts && pnpm run lint:format",
21
21
  "lint:js+ts": "eslint '**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}'",
22
22
  "lint:format": "prettier \"**/*\" --check --ignore-unknown",
23
- "lint:types": "tsc --noEmit -p tsconfig.src.json && tsc --noEmit -p tsconfig.transforms.json",
23
+ "lint:types": "tsc --noEmit",
24
24
  "lint:fix": "pnpm run lint:fix:js+ts && pnpm run lint:fix:format",
25
25
  "lint:fix:js+ts": "pnpm run lint:js+ts --fix",
26
26
  "lint:fix:format": "prettier \"**/*\" --write --ignore-unknown",
@@ -31,9 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@inquirer/prompts": "^7.5.0",
34
- "jscodeshift": "^17.3",
35
- "semver": "^7.7.2",
36
- "yaml": "^2.6.1"
34
+ "jscodeshift": "^17.3"
37
35
  },
38
36
  "devDependencies": {
39
37
  "@babel/core": "^7.27.1",
@@ -56,11 +54,11 @@
56
54
  "husky": "^9.1.7",
57
55
  "jest": "^29.7.0",
58
56
  "prettier": "^3.5.3",
57
+ "semver": "^7.7.2",
59
58
  "ts-jest": "^29.3.2",
60
59
  "ts-node": "^10.9.2",
61
60
  "tsup": "^8.4.0",
62
- "typescript": "^5.8.3",
63
- "@transferwise/components": "^46.5.0"
61
+ "typescript": "^5.8.3"
64
62
  },
65
63
  "publishConfig": {
66
64
  "access": "public"