reselect icon indicating copy to clipboard operation
reselect copied to clipboard

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

Open aryaemami59 opened this issue 5 months ago • 2 comments

This PR:

  • [X] 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)
)
  • [X] This should also help with transitioning into using the withTypes API since currently it does not support input selectors passed as separate inline arguments.
  • [X] Tested with yalc to make sure the CLI itself works.
  • [x] Added proper documentation for this codemod.

aryaemami59 avatar Jan 12 '24 19:01 aryaemami59