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

Add codemod to convert input selectors passed as separate inline arguments to a single array #681

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

aryaemami59
Copy link
Contributor

@aryaemami59 aryaemami59 commented Jan 12, 2024

This PR:

  • Adds convertInputSelectorsToArray codemod to convert input selectors passed as separate inline arguments to a single array.

Before:

const selectTodoById = createSelector(
  (state: RootState) => state.todos,
  (state: RootState, id: number) => id,
  (todos, id) => todos.find((todo) => todo.id === id)
)

After:

const selectTodoById = createSelector(
  [(state: RootState) => state.todos, (state: RootState, id: number) => id],
  (todos, id) => todos.find((todo) => todo.id === id)
)
  • This should also help with transitioning into using the withTypes API since currently it does not support input selectors passed as separate inline arguments.
  • Tested with yalc to make sure the CLI itself works.
  • Added proper documentation for this codemod.

Copy link

netlify bot commented Jan 12, 2024

Deploy Preview for reselect-docs canceled.

Name Link
🔨 Latest commit 11e2815
🔍 Latest deploy log https://app.netlify.com/sites/reselect-docs/deploys/673501603e5bbb0008b92a58

Copy link

codesandbox-ci bot commented Jan 12, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@aryaemami59 aryaemami59 marked this pull request as ready for review February 10, 2024 22:50
@aryaemami59 aryaemami59 force-pushed the codemod branch 10 times, most recently from 1c698d7 to ae36706 Compare May 14, 2024 17:08
@markerikson
Copy link
Contributor

Nits:

  • can we move the codemod tests lower in the file so that the TS and unit test jobs show up first?
  • I don't think we need to test on both Ubuntu and MacOS. Ubuntu seems sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants