Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(PPDSC-2163): codemods for enums #331

Merged
merged 12 commits into from
Aug 16, 2022

Conversation

Xin00163
Copy link
Contributor

@Xin00163 Xin00163 commented Aug 10, 2022

PPDSC-2163

Write a codemod transform script to find out the components that are using Enums and replace it with union types. Make sure all the tests are passing. No visual changes.

Context: PPDSC-1872: Remove TextFieldSize and replace with a union type

I have done:

  • Written unit tests against changes
  • Written functional tests against the component and/or NewsKit site
  • Updated relevant documentation

I have tested manually:

  • The feature's functionality is working as expected on Chrome, Firefox, Safari and Edge
  • The screen reader reads and flows through the elements as expected.
  • There are no new errors in the browser console coming from this PR.
  • When visual test is not added, it renders correctly on different browsers and mobile viewports (Safari, Firefox, small mobile viewport, tablet)
  • The Playground feature is working as expected

Before:

After:

Who should review this PR:

How to test:

@github-actions github-actions bot added the feature This change contains a new feature label Aug 10, 2022
Copy link
Contributor

@mutebg mutebg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you will need to update readme and cli file as well

lib/codemod/.eslintcache Outdated Show resolved Hide resolved
@Xin00163
Copy link
Contributor Author

There are three enums that I didn't include in the codemod script:

AudioEvents: there is a mapping used not sure how to achieve in union types
OverrideProp: same as above
EventTrigger: it's not easy to write a codemod script for this as EventTrigger is used differently. 

Maybe it's OK to leave them as enums for now?

@Xin00163 Xin00163 added the ready for review Please assist in getting this reviewed label Aug 11, 2022
mutebg
mutebg previously approved these changes Aug 15, 2022
Copy link
Contributor

@mutebg mutebg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good, did you check how it works on our docs site and other projects like virgin radio?

@Xin00163
Copy link
Contributor Author

Looks very good, did you check how it works on our docs site and other projects like virgin radio?

Good idea. Let me test it.

@Xin00163
Copy link
Contributor Author

Xin00163 commented Aug 15, 2022

Looks very good, did you check how it works on our docs site and other projects like virgin radio?

Good idea. Let me test it.

The enum to union script works well with Newskit components but not renamed components like CustomStack:

const CustomStack = styled(Stack)`
  width: 100%;
`;

Have fixed this by removing the componentName. Don't think it's needed in this case

@Xin00163 Xin00163 merged commit 1430e4e into main Aug 16, 2022
@Xin00163 Xin00163 deleted the feat/PPDSC-2163-codemod-enums-to-union branch August 16, 2022 15:22
Xin00163 added a commit that referenced this pull request Oct 17, 2022
* feat(PPDSC-2163): codemods for enums

* fix(PPDSC-2163): address reviews

* fix(PPDSC-2163): ignore eslintcache

* fix(PPDSC-2163): remove then ignore

* fix(PPDSC-2163): remove eslint change

* fix(PPDSC-2163): add more comps

* fix(PPDSC-2163): add iconButton and allow renaming

* fix(PPDSC-2163): lint

* fix(PPDSC-2163): address reviews
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This change contains a new feature ready for review Please assist in getting this reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants