diff --git a/tools/codemods/src/codemods/consolidate-props/tests/consolidate-props.output.tsx b/tools/codemods/src/codemods/consolidate-props/tests/consolidate-props.output.tsx index 5b3b10dd72..d2e329bc50 100644 --- a/tools/codemods/src/codemods/consolidate-props/tests/consolidate-props.output.tsx +++ b/tools/codemods/src/codemods/consolidate-props/tests/consolidate-props.output.tsx @@ -15,7 +15,7 @@ export const App = () => { const Test = () => { return ( - /* Please update manually */ + /* Please manually update from prop: propToRemove to prop: propToUpdate */ ); }; @@ -23,7 +23,7 @@ export const App = () => { const TestTwo = () => { return ( <> - {/* Please update manually */} + {/* Please manually update from prop: propToRemove to prop: propToUpdate */} ); @@ -39,7 +39,7 @@ export const App = () => { - {/* Please update manually */} + {/* Please manually update from prop: propToRemove to prop: propToUpdate */} diff --git a/tools/codemods/src/codemods/popover-v12/tests/add-usePortal-consolidate-renderMode.output.tsx b/tools/codemods/src/codemods/popover-v12/tests/add-usePortal-consolidate-renderMode.output.tsx index a8fa3412f9..f94c1a99a7 100644 --- a/tools/codemods/src/codemods/popover-v12/tests/add-usePortal-consolidate-renderMode.output.tsx +++ b/tools/codemods/src/codemods/popover-v12/tests/add-usePortal-consolidate-renderMode.output.tsx @@ -35,14 +35,14 @@ export const App = () => { const WrappedPopover = () => { return ( - /* Please update manually */ + /* Please manually update from prop: usePortal to prop: renderMode */ ); }; const DefaultWrappedPopover = () => { return ( - /* Please add manually */ + /* Please manually add prop: usePortal */ ); }; @@ -62,7 +62,7 @@ export const App = () => { - {/* Please update manually */} + {/* Please manually update from prop: usePortal to prop: renderMode */} diff --git a/tools/codemods/src/codemods/popover-v12/tests/remove-legacy-props.input.tsx b/tools/codemods/src/codemods/popover-v12/tests/remove-legacy-props.input.tsx index 23397f17b5..c2a1cac212 100644 --- a/tools/codemods/src/codemods/popover-v12/tests/remove-legacy-props.input.tsx +++ b/tools/codemods/src/codemods/popover-v12/tests/remove-legacy-props.input.tsx @@ -44,8 +44,8 @@ export const App = () => { return ( <> - - + + diff --git a/tools/codemods/src/codemods/popover-v12/tests/remove-legacy-props.output.tsx b/tools/codemods/src/codemods/popover-v12/tests/remove-legacy-props.output.tsx index e9db42a582..78791b27ad 100644 --- a/tools/codemods/src/codemods/popover-v12/tests/remove-legacy-props.output.tsx +++ b/tools/codemods/src/codemods/popover-v12/tests/remove-legacy-props.output.tsx @@ -39,7 +39,12 @@ export const App = () => { const WrappedInfoSprinkle = (props: any) => { return ( - /* Please remove manually */ + /* Please manually remove prop: popoverZIndex */ + /* Please manually remove prop: portalClassName */ + /* Please manually remove prop: portalContainer */ + /* Please manually remove prop: portalRef */ + /* Please manually remove prop: scrollContainer */ + /* Please manually remove prop: usePortal */ ); }; @@ -59,13 +64,12 @@ export const App = () => { - {/* Please remove manually */} - {/* Please remove manually */} - {/* Please remove manually */} - {/* Please remove manually */} - {/* Please remove manually */} - {/* Please remove manually */} - {/* Please remove manually */} + {/* Please manually remove prop: popoverZIndex */} + {/* Please manually remove prop: portalClassName */} + {/* Please manually remove prop: portalContainer */} + {/* Please manually remove prop: portalRef */} + {/* Please manually remove prop: scrollContainer */} + {/* Please manually remove prop: usePortal */} diff --git a/tools/codemods/src/codemods/popover-v12/tests/remove-shouldTooltipUsePortal.output.tsx b/tools/codemods/src/codemods/popover-v12/tests/remove-shouldTooltipUsePortal.output.tsx index 7b6fd19dd1..25fd5b7d9e 100644 --- a/tools/codemods/src/codemods/popover-v12/tests/remove-shouldTooltipUsePortal.output.tsx +++ b/tools/codemods/src/codemods/popover-v12/tests/remove-shouldTooltipUsePortal.output.tsx @@ -15,7 +15,7 @@ export const App = () => { const WrappedCopyable = (props: any) => { return ( - /* Please remove manually */ + /* Please manually remove prop: shouldTooltipUsePortal */ ); }; @@ -28,13 +28,7 @@ export const App = () => { - {/* Please remove manually */} - {/* Please remove manually */} - {/* Please remove manually */} - {/* Please remove manually */} - {/* Please remove manually */} - {/* Please remove manually */} - {/* Please remove manually */} + {/* Please manually remove prop: shouldTooltipUsePortal */} diff --git a/tools/codemods/src/codemods/popover-v12/transform.ts b/tools/codemods/src/codemods/popover-v12/transform.ts index aa04cc39a5..203d27e665 100644 --- a/tools/codemods/src/codemods/popover-v12/transform.ts +++ b/tools/codemods/src/codemods/popover-v12/transform.ts @@ -13,18 +13,7 @@ const componentNamesForConsolidation = [ 'Select', 'SplitButton', 'Tooltip', -] as const; - -const componentNamesForRemoval = [ - 'Code', - 'Copyable', - 'DatePicker', - 'GuideCue', - 'InfoSprinkle', - 'InlineDefinition', - 'NumberInput', - 'SearchInput', -] as const; +]; const propNamesToRemove = [ 'popoverZIndex', @@ -32,9 +21,21 @@ const propNamesToRemove = [ 'portalContainer', 'portalRef', 'scrollContainer', - 'shouldTooltipUsePortal', 'usePortal', -] as const; +]; + +const componentNamesWithPropsToRemoveMap: Record> = { + Code: propNamesToRemove.filter(propName => propName !== 'portalRef'), + Copyable: ['shouldTooltipUsePortal'], + DatePicker: propNamesToRemove.filter(propName => propName !== 'usePortal'), + GuideCue: propNamesToRemove.filter(propName => propName !== 'usePortal'), + InfoSprinkle: propNamesToRemove, + InlineDefinition: propNamesToRemove, + NumberInput: propNamesToRemove, + SearchInput: propNamesToRemove.filter( + propName => propName !== 'popoverZIndex', + ), +}; /** * Transformer function that: @@ -89,13 +90,13 @@ export default function transformer(file: FileInfo, { jscodeshift: j }: API) { }); }); - componentNamesForRemoval.forEach(componentName => { + Object.keys(componentNamesWithPropsToRemoveMap).forEach(componentName => { const elements = source.findJSXElements(componentName); if (elements.length === 0) return; elements.forEach(element => { - propNamesToRemove.forEach(propName => { + componentNamesWithPropsToRemoveMap[componentName].forEach(propName => { removeJSXAttributes({ j, element, diff --git a/tools/codemods/src/constants.ts b/tools/codemods/src/constants.ts index 0b35faed20..242b8c1da0 100644 --- a/tools/codemods/src/constants.ts +++ b/tools/codemods/src/constants.ts @@ -1,5 +1,5 @@ export const MIGRATOR_ERROR = { - manualAdd: 'Please add manually', - manualRemove: 'Please remove manually', - manualUpdate: 'Please update manually', + manualAdd: 'Please manually add', + manualRemove: 'Please manually remove', + manualUpdate: 'Please manually update', }; diff --git a/tools/codemods/src/utils/transformations/addJSXAttributes/addJSXAttributes.ts b/tools/codemods/src/utils/transformations/addJSXAttributes/addJSXAttributes.ts index b7527c4290..57033c6cab 100644 --- a/tools/codemods/src/utils/transformations/addJSXAttributes/addJSXAttributes.ts +++ b/tools/codemods/src/utils/transformations/addJSXAttributes/addJSXAttributes.ts @@ -73,7 +73,11 @@ export function addJSXAttributes({ } if (hasSpreadOperator) { - insertJSXComment(j, element, MIGRATOR_ERROR.manualAdd); + insertJSXComment( + j, + element, + `${MIGRATOR_ERROR.manualAdd} prop: ${propName}`, + ); return; } diff --git a/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-boolean.output.tsx b/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-boolean.output.tsx index 4d35ae8480..2a5bb4eaf4 100644 --- a/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-boolean.output.tsx +++ b/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-boolean.output.tsx @@ -19,7 +19,7 @@ export const App = () => { Hello - {/* Please add manually */} + {/* Please manually add prop: prop */} diff --git a/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-null.output.tsx b/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-null.output.tsx index d0ea994eb1..579b6aa853 100644 --- a/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-null.output.tsx +++ b/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-null.output.tsx @@ -19,7 +19,7 @@ export const App = () => { Hello - {/* Please add manually */} + {/* Please manually add prop: prop */} Hello diff --git a/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-number.output.tsx b/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-number.output.tsx index 22c680e6bf..d0dd0a704b 100644 --- a/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-number.output.tsx +++ b/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-number.output.tsx @@ -19,7 +19,7 @@ export const App = () => { Hello - {/* Please add manually */} + {/* Please manually add prop: prop */} Hello diff --git a/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-string.output.tsx b/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-string.output.tsx index d5da9bb75c..fc0b70fd04 100644 --- a/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-string.output.tsx +++ b/tools/codemods/src/utils/transformations/addJSXAttributes/tests/add-component-prop-string.output.tsx @@ -19,7 +19,7 @@ export const App = () => { Hello - {/* Please add manually */} + {/* Please manually add prop: prop */} Hello diff --git a/tools/codemods/src/utils/transformations/consolidateJSXAttributes/consolidateJSXAttributes.ts b/tools/codemods/src/utils/transformations/consolidateJSXAttributes/consolidateJSXAttributes.ts index 923773a36a..2721d6be4c 100644 --- a/tools/codemods/src/utils/transformations/consolidateJSXAttributes/consolidateJSXAttributes.ts +++ b/tools/codemods/src/utils/transformations/consolidateJSXAttributes/consolidateJSXAttributes.ts @@ -116,7 +116,11 @@ export function consolidateJSXAttributes({ // if fromProp value is variable of the same name then return early since we don't know the value if (oldValue === propToRemove) { - insertJSXComment(j, element, MIGRATOR_ERROR.manualUpdate); + insertJSXComment( + j, + element, + `${MIGRATOR_ERROR.manualUpdate} from prop: ${propToRemove} to prop: ${propToUpdate}`, + ); return; } @@ -128,7 +132,11 @@ export function consolidateJSXAttributes({ // if the propToUpdate does not exist and there is a spread operator then return early since we don't know if the propToUpdate could be inside the spread if (!_propToUpdate && hasSpreadOperator) { - insertJSXComment(j, element, MIGRATOR_ERROR.manualUpdate); + insertJSXComment( + j, + element, + `${MIGRATOR_ERROR.manualUpdate} from prop: ${propToRemove} to prop: ${propToUpdate}`, + ); return; } diff --git a/tools/codemods/src/utils/transformations/consolidateJSXAttributes/tests/consolidate-jsx-attributes-boolean.output.tsx b/tools/codemods/src/utils/transformations/consolidateJSXAttributes/tests/consolidate-jsx-attributes-boolean.output.tsx index 0e23e8c80a..b78c95364d 100644 --- a/tools/codemods/src/utils/transformations/consolidateJSXAttributes/tests/consolidate-jsx-attributes-boolean.output.tsx +++ b/tools/codemods/src/utils/transformations/consolidateJSXAttributes/tests/consolidate-jsx-attributes-boolean.output.tsx @@ -35,10 +35,10 @@ export const App = (disabled?: boolean) => { - {/* Please update manually */} + {/* Please manually update from prop: disabled to prop: state */} - {/* Please update manually */} + {/* Please manually update from prop: disabled to prop: state */} ); diff --git a/tools/codemods/src/utils/transformations/consolidateJSXAttributes/tests/consolidate-jsx-attributes-string.output.tsx b/tools/codemods/src/utils/transformations/consolidateJSXAttributes/tests/consolidate-jsx-attributes-string.output.tsx index 149d371968..4954b06442 100644 --- a/tools/codemods/src/utils/transformations/consolidateJSXAttributes/tests/consolidate-jsx-attributes-string.output.tsx +++ b/tools/codemods/src/utils/transformations/consolidateJSXAttributes/tests/consolidate-jsx-attributes-string.output.tsx @@ -15,7 +15,7 @@ export const App = (propToRemove?: string) => { const Test = () => { return ( - /* Please update manually */ + /* Please manually update from prop: propToRemove to prop: propToUpdate */ ); }; @@ -23,7 +23,7 @@ export const App = (propToRemove?: string) => { const TestTwo = () => { return ( <> - {/* Please update manually */} + {/* Please manually update from prop: propToRemove to prop: propToUpdate */} ); @@ -39,11 +39,11 @@ export const App = (propToRemove?: string) => { - {/* Please update manually */} + {/* Please manually update from prop: propToRemove to prop: propToUpdate */} - {/* Please update manually */} + {/* Please manually update from prop: propToRemove to prop: propToUpdate */} diff --git a/tools/codemods/src/utils/transformations/removeJSXAttributes/removeJSXAttributes.ts b/tools/codemods/src/utils/transformations/removeJSXAttributes/removeJSXAttributes.ts index b6ff4309e8..472917f279 100644 --- a/tools/codemods/src/utils/transformations/removeJSXAttributes/removeJSXAttributes.ts +++ b/tools/codemods/src/utils/transformations/removeJSXAttributes/removeJSXAttributes.ts @@ -46,7 +46,11 @@ export function removeJSXAttributes({ ); if (hasSpreadOperator) { - insertJSXComment(j, element, MIGRATOR_ERROR.manualRemove); + insertJSXComment( + j, + element, + `${MIGRATOR_ERROR.manualRemove} prop: ${propName}`, + ); return; } diff --git a/tools/codemods/src/utils/transformations/removeJSXAttributes/tests/remove-component-prop.output.tsx b/tools/codemods/src/utils/transformations/removeJSXAttributes/tests/remove-component-prop.output.tsx index 60c18e2262..0e29802cdd 100644 --- a/tools/codemods/src/utils/transformations/removeJSXAttributes/tests/remove-component-prop.output.tsx +++ b/tools/codemods/src/utils/transformations/removeJSXAttributes/tests/remove-component-prop.output.tsx @@ -19,7 +19,7 @@ export const App = () => { Hello - {/* Please remove manually */} + {/* Please manually remove prop: prop */}