From 988bf8c5bcbfacf0aa7dce40e7813d5235a7cbf9 Mon Sep 17 00:00:00 2001 From: csandman Date: Fri, 20 Oct 2023 18:29:17 -0400 Subject: [PATCH] Update codemod readme and remove unused color scheme mod --- codemod/README.md | 13 +++++++++++++ codemod/transforms/v5.ts | 14 -------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/codemod/README.md b/codemod/README.md index 95032e9..23171b5 100644 --- a/codemod/README.md +++ b/codemod/README.md @@ -36,6 +36,15 @@ npx crs-codemod v5 . npx crs-codemod v5 ./src ``` +> **NOTE:** This codemod currently has a side effect where it removes any +> [TypeScript generics](https://www.typescriptlang.org/docs/handbook/2/generics.html) +> you pass into your `Select` components. This appears to be a shortcoming of +> `jscodeshift`, as it appears not to recognize generics used in JSX. While in +> most cases you shouldn't need generics in order for your component to be typed +> properly, there are some edge cases where they are necessary. If you have a +> need for them, you should either add them back in after the codemod is run, or +> manually make the following transformations. + This codemod runs on all versions of the `Select` component (`Select`, `AsyncSelect`, `AsyncCreatableSelect`, `CreatableSelect`), and performs the following modifications to your every instance of them: @@ -53,3 +62,7 @@ following modifications to your every instance of them: as well due to it not working properly with keyboard navigation, and being outside the scope of the intentions for this project. It has also been fully removed in `v5.0.0`. + +This codemod will only work for props that are added directly to a `Select` +instance. If you have a shared props object, you will have to make these changes +manually. diff --git a/codemod/transforms/v5.ts b/codemod/transforms/v5.ts index 44b0a9f..df09892 100644 --- a/codemod/transforms/v5.ts +++ b/codemod/transforms/v5.ts @@ -81,20 +81,6 @@ export default function transformer(file: FileInfo, api: API) { ) ) ); - - // TODO: Decide if I want to rename this one - // Replace `colorScheme` prop with `tagColorScheme` - // $select - // .find(j.JSXAttribute) - // .filter((nodePath) => nodePath.node.name.name === "colorScheme") - // .forEach((attribute) => - // j(attribute).replaceWith( - // j.jsxAttribute( - // j.jsxIdentifier("tagColorScheme"), - // attribute.node.value - // ) - // ) - // ); }); }); })