@openrewrite/recipes-react 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/i18n/translate-hard-coded-strings.d.ts.map +1 -1
- package/dist/i18n/translate-hard-coded-strings.js +3 -2
- package/dist/i18n/translate-hard-coded-strings.js.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -18
- package/dist/index.js.map +1 -1
- package/dist/migration/change-component-prop-value.d.ts.map +1 -1
- package/dist/migration/change-component-prop-value.js.map +1 -1
- package/dist/migration/cra-to-vite/add-vite-config.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/add-vite-config.js.map +1 -1
- package/dist/migration/cra-to-vite/cra-to-vite.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/cra-to-vite.js.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-config-blockers.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-config-blockers.js.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-env-file-blockers.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-env-file-blockers.js.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-source-blockers.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-source-blockers.js.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-to-vite-blockers.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-to-vite-blockers.js.map +1 -1
- package/dist/migration/cra-to-vite/migrate-cra-package.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/migrate-cra-package.js.map +1 -1
- package/dist/migration/cra-to-vite/migrate-cra-svg-imports.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/migrate-cra-svg-imports.js +3 -3
- package/dist/migration/cra-to-vite/migrate-cra-svg-imports.js.map +1 -1
- package/dist/migration/cra-to-vite/migrate-cra-tests-to-vitest.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/migrate-cra-tests-to-vitest.js.map +1 -1
- package/dist/migration/cra-to-vite/move-public-index-html.d.ts +1 -1
- package/dist/migration/cra-to-vite/move-public-index-html.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/move-public-index-html.js +1 -1
- package/dist/migration/cra-to-vite/move-public-index-html.js.map +1 -1
- package/dist/migration/cra-to-vite/remove-cra-configuration.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/remove-cra-configuration.js.map +1 -1
- package/dist/migration/cra-to-vite/rename-jsx-files.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/rename-jsx-files.js.map +1 -1
- package/dist/migration/cra-to-vite/rename-process-env-react-app.d.ts +1 -1
- package/dist/migration/cra-to-vite/rename-process-env-react-app.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/rename-process-env-react-app.js +1 -1
- package/dist/migration/cra-to-vite/rename-process-env-react-app.js.map +1 -1
- package/dist/migration/cra-to-vite/rename-react-app-env-vars-in-env-files.d.ts +1 -1
- package/dist/migration/cra-to-vite/rename-react-app-env-vars-in-env-files.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/rename-react-app-env-vars-in-env-files.js +1 -1
- package/dist/migration/cra-to-vite/rename-react-app-env-vars-in-env-files.js.map +1 -1
- package/dist/migration/cra-to-vite/replace-react-scripts-dependency.d.ts +1 -1
- package/dist/migration/cra-to-vite/replace-react-scripts-dependency.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/replace-react-scripts-dependency.js +1 -1
- package/dist/migration/cra-to-vite/replace-react-scripts-dependency.js.map +1 -1
- package/dist/migration/cra-to-vite/update-react-app-env-types.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/update-react-app-env-types.js.map +1 -1
- package/dist/migration/cra-to-vite/update-react-scripts-scripts.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/update-react-scripts-scripts.js.map +1 -1
- package/dist/migration/cra-to-vite/update-tsconfig-for-vite.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/update-tsconfig-for-vite.js.map +1 -1
- package/dist/mui/adapt-v4-theme.d.ts.map +1 -1
- package/dist/mui/adapt-v4-theme.js +1 -1
- package/dist/mui/adapt-v4-theme.js.map +1 -1
- package/dist/mui/add-component-prop.d.ts.map +1 -1
- package/dist/mui/add-component-prop.js.map +1 -1
- package/dist/mui/add-emotion-prepend.d.ts.map +1 -1
- package/dist/mui/add-emotion-prepend.js +3 -16
- package/dist/mui/add-emotion-prepend.js.map +1 -1
- package/dist/mui/convert-mui-imports.d.ts.map +1 -1
- package/dist/mui/convert-mui-imports.js +1 -1
- package/dist/mui/convert-mui-imports.js.map +1 -1
- package/dist/mui/convert-prop-to-sx.d.ts.map +1 -1
- package/dist/mui/convert-prop-to-sx.js +1 -1
- package/dist/mui/convert-prop-to-sx.js.map +1 -1
- package/dist/mui/mark-manual-migration.d.ts.map +1 -1
- package/dist/mui/mark-manual-migration.js.map +1 -1
- package/dist/mui/mark-palette-mode-usage.d.ts.map +1 -1
- package/dist/mui/mark-palette-mode-usage.js.map +1 -1
- package/dist/mui/move-component-prop-to-slot.d.ts.map +1 -1
- package/dist/mui/move-component-prop-to-slot.js.map +1 -1
- package/dist/mui/move-primary-text-to-children.d.ts.map +1 -1
- package/dist/mui/move-primary-text-to-children.js.map +1 -1
- package/dist/mui/move-system-props-to-sx.d.ts.map +1 -1
- package/dist/mui/move-system-props-to-sx.js +1 -1
- package/dist/mui/move-system-props-to-sx.js.map +1 -1
- package/dist/mui/remove-component-prop.d.ts.map +1 -1
- package/dist/mui/remove-component-prop.js.map +1 -1
- package/dist/mui/remove-root-ref.d.ts.map +1 -1
- package/dist/mui/remove-root-ref.js +1 -1
- package/dist/mui/remove-root-ref.js.map +1 -1
- package/dist/mui/remove-spacing-px-suffix.d.ts.map +1 -1
- package/dist/mui/remove-spacing-px-suffix.js +7 -10
- package/dist/mui/remove-spacing-px-suffix.js.map +1 -1
- package/dist/mui/rename-component-prop.d.ts.map +1 -1
- package/dist/mui/rename-component-prop.js.map +1 -1
- package/dist/mui/rename-joy-css-variables.d.ts.map +1 -1
- package/dist/mui/rename-joy-css-variables.js.map +1 -1
- package/dist/mui/rename-theme-palette-type.d.ts.map +1 -1
- package/dist/mui/rename-theme-palette-type.js.map +1 -1
- package/dist/mui/replace-box-border-radius.d.ts.map +1 -1
- package/dist/mui/replace-box-border-radius.js.map +1 -1
- package/dist/mui/replace-breakpoints-width.d.ts.map +1 -1
- package/dist/mui/replace-breakpoints-width.js.map +1 -1
- package/dist/mui/replace-component-class.d.ts.map +1 -1
- package/dist/mui/replace-component-class.js.map +1 -1
- package/dist/mui/replace-components-with-slots.d.ts.map +1 -1
- package/dist/mui/replace-components-with-slots.js.map +1 -1
- package/dist/mui/replace-import-paths.d.ts.map +1 -1
- package/dist/mui/replace-import-paths.js.map +1 -1
- package/dist/mui/replace-in-string-literals.d.ts.map +1 -1
- package/dist/mui/replace-in-string-literals.js.map +1 -1
- package/dist/mui/replace-list-item-button-prop.d.ts.map +1 -1
- package/dist/mui/replace-list-item-button-prop.js +2 -2
- package/dist/mui/replace-list-item-button-prop.js.map +1 -1
- package/dist/mui/replace-tabs-scroll-buttons.d.ts.map +1 -1
- package/dist/mui/replace-tabs-scroll-buttons.js.map +1 -1
- package/dist/mui/replace-theme-color-functions.d.ts.map +1 -1
- package/dist/mui/replace-theme-color-functions.js +7 -21
- package/dist/mui/replace-theme-color-functions.js.map +1 -1
- package/dist/mui/replace-theme-spacing-unit.d.ts.map +1 -1
- package/dist/mui/replace-theme-spacing-unit.js.map +1 -1
- package/dist/mui/replace-typography-round.d.ts.map +1 -1
- package/dist/mui/replace-typography-round.js.map +1 -1
- package/dist/mui/shift-hidden-down-props.d.ts.map +1 -1
- package/dist/mui/shift-hidden-down-props.js +4 -5
- package/dist/mui/shift-hidden-down-props.js.map +1 -1
- package/dist/mui/update-theme-breakpoints.d.ts.map +1 -1
- package/dist/mui/update-theme-breakpoints.js.map +1 -1
- package/dist/mui/upgrade-grid-props.d.ts.map +1 -1
- package/dist/mui/upgrade-grid-props.js +1 -1
- package/dist/mui/upgrade-grid-props.js.map +1 -1
- package/dist/react-native/view-prop-types.d.ts.map +1 -1
- package/dist/react-native/view-prop-types.js +3 -9
- package/dist/react-native/view-prop-types.js.map +1 -1
- package/dist/react16/error-boundaries.d.ts.map +1 -1
- package/dist/react16/error-boundaries.js +1 -1
- package/dist/react16/error-boundaries.js.map +1 -1
- package/dist/react16/find-dom-node.d.ts.map +1 -1
- package/dist/react16/find-dom-node.js.map +1 -1
- package/dist/react16/react-dom-factories.d.ts.map +1 -1
- package/dist/react16/react-dom-factories.js.map +1 -1
- package/dist/react16/react-prop-types.d.ts.map +1 -1
- package/dist/react16/react-prop-types.js +3 -9
- package/dist/react16/react-prop-types.js.map +1 -1
- package/dist/react16/react-to-react-dom.d.ts.map +1 -1
- package/dist/react16/react-to-react-dom.js +2 -2
- package/dist/react16/react-to-react-dom.js.map +1 -1
- package/dist/react17/migrate-deprecated-lifecycles.d.ts +1 -1
- package/dist/react17/migrate-deprecated-lifecycles.d.ts.map +1 -1
- package/dist/react17/migrate-deprecated-lifecycles.js +5 -6
- package/dist/react17/migrate-deprecated-lifecycles.js.map +1 -1
- package/dist/react17/remove-event-persist.d.ts.map +1 -1
- package/dist/react17/remove-event-persist.js +128 -63
- package/dist/react17/remove-event-persist.js.map +1 -1
- package/dist/react17/rename-unsafe-lifecycles.d.ts.map +1 -1
- package/dist/react17/rename-unsafe-lifecycles.js +1 -1
- package/dist/react17/rename-unsafe-lifecycles.js.map +1 -1
- package/dist/react17/update-react-imports.d.ts.map +1 -1
- package/dist/react17/update-react-imports.js +1 -1
- package/dist/react17/update-react-imports.js.map +1 -1
- package/dist/react17/use-new-jsx-transform.d.ts +1 -1
- package/dist/react17/use-new-jsx-transform.d.ts.map +1 -1
- package/dist/react17/use-new-jsx-transform.js +2 -1
- package/dist/react17/use-new-jsx-transform.js.map +1 -1
- package/dist/react18/add-children-to-props.js +1 -1
- package/dist/react18/add-children-to-props.js.map +1 -1
- package/dist/react18/replace-reactdom-render.d.ts.map +1 -1
- package/dist/react18/replace-reactdom-render.js +1 -1
- package/dist/react18/replace-reactdom-render.js.map +1 -1
- package/dist/react18/replace-render-callback.d.ts.map +1 -1
- package/dist/react18/replace-render-callback.js +3 -12
- package/dist/react18/replace-render-callback.js.map +1 -1
- package/dist/react18/replace-unmount-component-at-node.d.ts.map +1 -1
- package/dist/react18/replace-unmount-component-at-node.js +1 -1
- package/dist/react18/replace-unmount-component-at-node.js.map +1 -1
- package/dist/react19/find-context-consumer.d.ts.map +1 -1
- package/dist/react19/find-context-consumer.js.map +1 -1
- package/dist/react19/find-deprecated-reactdom-apis.d.ts.map +1 -1
- package/dist/react19/find-deprecated-reactdom-apis.js +16 -61
- package/dist/react19/find-deprecated-reactdom-apis.js.map +1 -1
- package/dist/react19/find-element-ref.d.ts.map +1 -1
- package/dist/react19/find-element-ref.js.map +1 -1
- package/dist/react19/find-legacy-context-api.d.ts.map +1 -1
- package/dist/react19/find-legacy-context-api.js.map +1 -1
- package/dist/react19/no-implicit-ref-callback-return.d.ts.map +1 -1
- package/dist/react19/no-implicit-ref-callback-return.js +1 -1
- package/dist/react19/no-implicit-ref-callback-return.js.map +1 -1
- package/dist/react19/remove-context-provider.d.ts.map +1 -1
- package/dist/react19/remove-context-provider.js +1 -7
- package/dist/react19/remove-context-provider.js.map +1 -1
- package/dist/react19/remove-forward-ref.d.ts.map +1 -1
- package/dist/react19/remove-forward-ref.js +2 -2
- package/dist/react19/remove-forward-ref.js.map +1 -1
- package/dist/react19/remove-prop-types.d.ts.map +1 -1
- package/dist/react19/remove-prop-types.js.map +1 -1
- package/dist/react19/remove-react-fc.js +2 -2
- package/dist/react19/remove-react-fc.js.map +1 -1
- package/dist/react19/remove-unstable-batched-updates.d.ts +1 -1
- package/dist/react19/remove-unstable-batched-updates.d.ts.map +1 -1
- package/dist/react19/remove-unstable-batched-updates.js +9 -88
- package/dist/react19/remove-unstable-batched-updates.js.map +1 -1
- package/dist/{react16 → react19}/replace-create-factory.d.ts +1 -1
- package/dist/react19/replace-create-factory.d.ts.map +1 -0
- package/dist/{react16 → react19}/replace-create-factory.js +5 -5
- package/dist/react19/replace-create-factory.js.map +1 -0
- package/dist/react19/replace-reactdom-hydrate.d.ts.map +1 -1
- package/dist/react19/replace-reactdom-hydrate.js +1 -1
- package/dist/react19/replace-reactdom-hydrate.js.map +1 -1
- package/dist/react19/replace-string-ref.d.ts.map +1 -1
- package/dist/react19/replace-string-ref.js.map +1 -1
- package/dist/react19/scoped-jsx-namespace.d.ts.map +1 -1
- package/dist/react19/scoped-jsx-namespace.js +2 -6
- package/dist/react19/scoped-jsx-namespace.js.map +1 -1
- package/dist/react19/use-context-hook.d.ts.map +1 -1
- package/dist/react19/use-context-hook.js +1 -1
- package/dist/react19/use-context-hook.js.map +1 -1
- package/dist/react19/use-ref-required-initial.d.ts.map +1 -1
- package/dist/react19/use-ref-required-initial.js +3 -1
- package/dist/react19/use-ref-required-initial.js.map +1 -1
- package/dist/refactoring/class-to-functional.d.ts.map +1 -1
- package/dist/refactoring/class-to-functional.js +7 -3
- package/dist/refactoring/class-to-functional.js.map +1 -1
- package/dist/refactoring/create-class-to-es6.d.ts.map +1 -1
- package/dist/refactoring/create-class-to-es6.js +1 -1
- package/dist/refactoring/create-class-to-es6.js.map +1 -1
- package/dist/refactoring/create-element-to-jsx.d.ts.map +1 -1
- package/dist/refactoring/create-element-to-jsx.js +5 -7
- package/dist/refactoring/create-element-to-jsx.js.map +1 -1
- package/dist/refactoring/fix-async-effect.d.ts.map +1 -1
- package/dist/refactoring/fix-async-effect.js.map +1 -1
- package/dist/refactoring/manual-bind-to-arrow.d.ts.map +1 -1
- package/dist/refactoring/manual-bind-to-arrow.js.map +1 -1
- package/dist/refactoring/prop-types-to-typescript.d.ts +1 -1
- package/dist/refactoring/prop-types-to-typescript.d.ts.map +1 -1
- package/dist/refactoring/prop-types-to-typescript.js +2 -2
- package/dist/refactoring/prop-types-to-typescript.js.map +1 -1
- package/dist/refactoring/pure-render-mixin.d.ts.map +1 -1
- package/dist/refactoring/pure-render-mixin.js +2 -8
- package/dist/refactoring/pure-render-mixin.js.map +1 -1
- package/dist/refactoring/sort-comp.d.ts.map +1 -1
- package/dist/refactoring/sort-comp.js +1 -1
- package/dist/refactoring/sort-comp.js.map +1 -1
- package/dist/search/find-deprecated-lifecycles.d.ts +1 -1
- package/dist/search/find-deprecated-lifecycles.d.ts.map +1 -1
- package/dist/search/find-deprecated-lifecycles.js +2 -2
- package/dist/search/find-deprecated-lifecycles.js.map +1 -1
- package/dist/search/find-effects-without-cleanup.d.ts +1 -1
- package/dist/search/find-effects-without-cleanup.d.ts.map +1 -1
- package/dist/search/find-effects-without-cleanup.js +7 -9
- package/dist/search/find-effects-without-cleanup.js.map +1 -1
- package/dist/search/find-enzyme-usage.d.ts.map +1 -1
- package/dist/search/find-enzyme-usage.js.map +1 -1
- package/dist/search/find-function-component-default-props.d.ts +1 -1
- package/dist/search/find-function-component-default-props.d.ts.map +1 -1
- package/dist/search/find-function-component-default-props.js +2 -2
- package/dist/search/find-function-component-default-props.js.map +1 -1
- package/dist/search/find-hard-coded-strings.d.ts.map +1 -1
- package/dist/search/find-hard-coded-strings.js.map +1 -1
- package/dist/search/find-hook-usage.d.ts.map +1 -1
- package/dist/search/find-hook-usage.js.map +1 -1
- package/dist/search/find-legacy-react-apis.d.ts +1 -1
- package/dist/search/find-legacy-react-apis.d.ts.map +1 -1
- package/dist/search/find-legacy-react-apis.js +1 -1
- package/dist/search/find-legacy-react-apis.js.map +1 -1
- package/dist/search/find-missing-use-client-directive.d.ts.map +1 -1
- package/dist/search/find-missing-use-client-directive.js +11 -10
- package/dist/search/find-missing-use-client-directive.js.map +1 -1
- package/dist/search/find-prop-usage.d.ts.map +1 -1
- package/dist/search/find-prop-usage.js.map +1 -1
- package/dist/search/find-react-component.d.ts.map +1 -1
- package/dist/search/find-react-component.js.map +1 -1
- package/dist/search/find-reactdom-root-apis.d.ts.map +1 -1
- package/dist/search/find-reactdom-root-apis.js +2 -42
- package/dist/search/find-reactdom-root-apis.js.map +1 -1
- package/dist/search/find-redux-stores.d.ts +1 -1
- package/dist/search/find-redux-stores.d.ts.map +1 -1
- package/dist/search/find-redux-stores.js +1 -1
- package/dist/search/find-redux-stores.js.map +1 -1
- package/dist/search/find-server-rendering-usage.d.ts.map +1 -1
- package/dist/search/find-server-rendering-usage.js +13 -54
- package/dist/search/find-server-rendering-usage.js.map +1 -1
- package/dist/simplify-object-pattern-property.d.ts.map +1 -1
- package/dist/simplify-object-pattern-property.js.map +1 -1
- package/dist/simplify-react-imports.d.ts.map +1 -1
- package/dist/simplify-react-imports.js +1 -1
- package/dist/simplify-react-imports.js.map +1 -1
- package/dist/testing/enzyme-host-components.d.ts.map +1 -1
- package/dist/testing/enzyme-host-components.js +2 -2
- package/dist/testing/enzyme-host-components.js.map +1 -1
- package/dist/testing/enzyme-to-react-testing-library.d.ts.map +1 -1
- package/dist/testing/enzyme-to-react-testing-library.js +11 -19
- package/dist/testing/enzyme-to-react-testing-library.js.map +1 -1
- package/dist/testing/enzyme-usage.js +2 -2
- package/dist/testing/enzyme-usage.js.map +1 -1
- package/dist/testing/enzyme-wrapper-scope.d.ts.map +1 -1
- package/dist/testing/enzyme-wrapper-scope.js +5 -12
- package/dist/testing/enzyme-wrapper-scope.js.map +1 -1
- package/dist/util/react-class.d.ts +2 -0
- package/dist/util/react-class.d.ts.map +1 -1
- package/dist/util/react-class.js +14 -0
- package/dist/util/react-class.js.map +1 -1
- package/dist/util/react-matchers.d.ts +8 -0
- package/dist/util/react-matchers.d.ts.map +1 -0
- package/dist/util/react-matchers.js +25 -0
- package/dist/util/react-matchers.js.map +1 -0
- package/dist/zustand/redux-to-zustand.d.ts.map +1 -1
- package/dist/zustand/redux-to-zustand.js +20 -20
- package/dist/zustand/redux-to-zustand.js.map +1 -1
- package/package.json +2 -2
- package/src/i18n/translate-hard-coded-strings.ts +5 -12
- package/src/index.ts +3 -12
- package/src/migration/change-component-prop-value.ts +0 -40
- package/src/migration/cra-to-vite/add-vite-config.ts +0 -10
- package/src/migration/cra-to-vite/cra-to-vite.ts +0 -3
- package/src/migration/cra-to-vite/find-cra-config-blockers.ts +2 -7
- package/src/migration/cra-to-vite/find-cra-env-file-blockers.ts +0 -7
- package/src/migration/cra-to-vite/find-cra-source-blockers.ts +0 -9
- package/src/migration/cra-to-vite/find-cra-to-vite-blockers.ts +0 -4
- package/src/migration/cra-to-vite/migrate-cra-package.ts +0 -1
- package/src/migration/cra-to-vite/migrate-cra-svg-imports.ts +3 -4
- package/src/migration/cra-to-vite/migrate-cra-tests-to-vitest.ts +1 -3
- package/src/migration/cra-to-vite/move-public-index-html.ts +1 -13
- package/src/migration/cra-to-vite/remove-cra-configuration.ts +0 -1
- package/src/migration/cra-to-vite/rename-jsx-files.ts +0 -4
- package/src/migration/cra-to-vite/rename-process-env-react-app.ts +1 -17
- package/src/migration/cra-to-vite/rename-react-app-env-vars-in-env-files.ts +1 -11
- package/src/migration/cra-to-vite/replace-react-scripts-dependency.ts +1 -12
- package/src/migration/cra-to-vite/update-react-app-env-types.ts +0 -9
- package/src/migration/cra-to-vite/update-react-scripts-scripts.ts +0 -15
- package/src/migration/cra-to-vite/update-tsconfig-for-vite.ts +0 -11
- package/src/mui/adapt-v4-theme.ts +2 -7
- package/src/mui/add-component-prop.ts +0 -7
- package/src/mui/add-emotion-prepend.ts +5 -17
- package/src/mui/convert-mui-imports.ts +1 -12
- package/src/mui/convert-prop-to-sx.ts +1 -9
- package/src/mui/mark-manual-migration.ts +0 -6
- package/src/mui/mark-palette-mode-usage.ts +0 -6
- package/src/mui/move-component-prop-to-slot.ts +0 -9
- package/src/mui/move-primary-text-to-children.ts +0 -5
- package/src/mui/move-system-props-to-sx.ts +1 -11
- package/src/mui/remove-component-prop.ts +0 -5
- package/src/mui/remove-root-ref.ts +2 -8
- package/src/mui/remove-spacing-px-suffix.ts +3 -11
- package/src/mui/rename-component-prop.ts +0 -7
- package/src/mui/rename-joy-css-variables.ts +0 -6
- package/src/mui/rename-theme-palette-type.ts +0 -5
- package/src/mui/replace-box-border-radius.ts +0 -5
- package/src/mui/replace-breakpoints-width.ts +0 -2
- package/src/mui/replace-component-class.ts +0 -10
- package/src/mui/replace-components-with-slots.ts +0 -8
- package/src/mui/replace-import-paths.ts +0 -11
- package/src/mui/replace-in-string-literals.ts +0 -7
- package/src/mui/replace-list-item-button-prop.ts +3 -10
- package/src/mui/replace-tabs-scroll-buttons.ts +0 -5
- package/src/mui/replace-theme-color-functions.ts +9 -26
- package/src/mui/replace-theme-spacing-unit.ts +0 -6
- package/src/mui/replace-typography-round.ts +0 -5
- package/src/mui/shift-hidden-down-props.ts +3 -12
- package/src/mui/update-theme-breakpoints.ts +0 -8
- package/src/mui/upgrade-grid-props.ts +1 -9
- package/src/react-native/view-prop-types.ts +4 -26
- package/src/react16/error-boundaries.ts +1 -20
- package/src/react16/find-dom-node.ts +0 -17
- package/src/react16/react-dom-factories.ts +0 -14
- package/src/react16/react-prop-types.ts +4 -29
- package/src/react16/react-to-react-dom.ts +3 -20
- package/src/react17/migrate-deprecated-lifecycles.ts +6 -21
- package/src/react17/remove-event-persist.ts +157 -92
- package/src/react17/rename-unsafe-lifecycles.ts +1 -24
- package/src/react17/update-react-imports.ts +2 -27
- package/src/react17/use-new-jsx-transform.ts +2 -15
- package/src/react18/add-children-to-props.ts +2 -2
- package/src/react18/replace-reactdom-render.ts +2 -24
- package/src/react18/replace-render-callback.ts +5 -31
- package/src/react18/replace-unmount-component-at-node.ts +2 -22
- package/src/react19/find-context-consumer.ts +0 -23
- package/src/react19/find-deprecated-reactdom-apis.ts +20 -80
- package/src/react19/find-element-ref.ts +0 -15
- package/src/react19/find-legacy-context-api.ts +0 -12
- package/src/react19/no-implicit-ref-callback-return.ts +1 -19
- package/src/react19/remove-context-provider.ts +1 -25
- package/src/react19/remove-forward-ref.ts +3 -18
- package/src/react19/remove-prop-types.ts +0 -24
- package/src/react19/remove-react-fc.ts +3 -3
- package/src/react19/remove-unstable-batched-updates.ts +15 -129
- package/src/{react16 → react19}/replace-create-factory.ts +8 -21
- package/src/react19/replace-reactdom-hydrate.ts +2 -19
- package/src/react19/replace-string-ref.ts +0 -14
- package/src/react19/scoped-jsx-namespace.ts +3 -7
- package/src/react19/use-context-hook.ts +2 -20
- package/src/react19/use-ref-required-initial.ts +4 -17
- package/src/refactoring/class-to-functional.ts +9 -33
- package/src/refactoring/create-class-to-es6.ts +1 -15
- package/src/refactoring/create-element-to-jsx.ts +7 -31
- package/src/refactoring/fix-async-effect.ts +0 -28
- package/src/refactoring/manual-bind-to-arrow.ts +0 -23
- package/src/refactoring/prop-types-to-typescript.ts +3 -34
- package/src/refactoring/pure-render-mixin.ts +3 -30
- package/src/refactoring/sort-comp.ts +1 -11
- package/src/search/find-deprecated-lifecycles.ts +3 -6
- package/src/search/find-effects-without-cleanup.ts +5 -15
- package/src/search/find-enzyme-usage.ts +0 -3
- package/src/search/find-function-component-default-props.ts +3 -7
- package/src/search/find-hard-coded-strings.ts +0 -9
- package/src/search/find-hook-usage.ts +0 -10
- package/src/search/find-legacy-react-apis.ts +1 -18
- package/src/search/find-missing-use-client-directive.ts +13 -19
- package/src/search/find-prop-usage.ts +0 -11
- package/src/search/find-react-component.ts +0 -11
- package/src/search/find-reactdom-root-apis.ts +5 -44
- package/src/search/find-redux-stores.ts +1 -9
- package/src/search/find-server-rendering-usage.ts +15 -72
- package/src/simplify-object-pattern-property.ts +0 -8
- package/src/simplify-react-imports.ts +3 -23
- package/src/testing/enzyme-host-components.ts +3 -2
- package/src/testing/enzyme-to-react-testing-library.ts +10 -50
- package/src/testing/enzyme-usage.ts +2 -2
- package/src/testing/enzyme-wrapper-scope.ts +7 -15
- package/src/util/react-class.ts +17 -1
- package/src/util/react-matchers.ts +34 -0
- package/src/zustand/redux-to-zustand.ts +21 -75
- package/dist/react16/replace-create-factory.d.ts.map +0 -1
- package/dist/react16/replace-create-factory.js.map +0 -1
- package/dist/react19/replace-act-import.d.ts +0 -9
- package/dist/react19/replace-act-import.d.ts.map +0 -1
- package/dist/react19/replace-act-import.js +0 -34
- package/dist/react19/replace-act-import.js.map +0 -1
- package/dist/react19/replace-react-shallow-renderer.d.ts +0 -8
- package/dist/react19/replace-react-shallow-renderer.d.ts.map +0 -1
- package/dist/react19/replace-react-shallow-renderer.js +0 -49
- package/dist/react19/replace-react-shallow-renderer.js.map +0 -1
- package/dist/react19/replace-use-form-state.d.ts +0 -8
- package/dist/react19/replace-use-form-state.d.ts.map +0 -1
- package/dist/react19/replace-use-form-state.js +0 -57
- package/dist/react19/replace-use-form-state.js.map +0 -1
- package/src/react19/replace-act-import.ts +0 -36
- package/src/react19/replace-react-shallow-renderer.ts +0 -47
- package/src/react19/replace-use-form-state.ts +0 -69
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {Cursor, ExecutionContext} from "@openrewrite/rewrite";
|
|
2
|
-
import {
|
|
2
|
+
import {isObjectLiteral, JavaScriptVisitor, JS, JSX, MethodMatcher, referencesOf, walk} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {emptySpace, Expression, isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {create} from "mutative";
|
|
5
5
|
import {enzymeMethod, enzymeWrapper} from "./enzyme-usage";
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
const ENZYME_TO_JSON = new MethodMatcher("enzyme-to-json *(..)");
|
|
7
8
|
|
|
8
9
|
const HTML_TAGS = new Set(["a", "abbr", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo",
|
|
9
10
|
"blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data",
|
|
@@ -414,7 +415,6 @@ export function analyzeWrapperScope(block: Cursor, {declaration, name}: WrapperD
|
|
|
414
415
|
optInSnapshots?: boolean, optionalChaining?: boolean, constant?: (node: J) => string | undefined,
|
|
415
416
|
/** Told every reference that rejects the scope, whether it comes after an unmount, and the snapshot assertion it is the subject of. */
|
|
416
417
|
blocked?: (references: BlockingReference[]) => void}): WrapperScope | undefined {
|
|
417
|
-
let serializers: ReadonlySet<string> | undefined;
|
|
418
418
|
const uses = new Map<string, WrapperRead>();
|
|
419
419
|
const removedStatements = new Set<string>();
|
|
420
420
|
const unmounts = new Set<string>();
|
|
@@ -457,8 +457,7 @@ export function analyzeWrapperScope(block: Cursor, {declaration, name}: WrapperD
|
|
|
457
457
|
const ancestors = ancestorsOf(reference);
|
|
458
458
|
const first = ancestors[0]?.value as J | undefined;
|
|
459
459
|
if (snapshots) {
|
|
460
|
-
|
|
461
|
-
const assertion = snapshotAssertion(identifier, ancestors, serializers);
|
|
460
|
+
const assertion = snapshotAssertion(identifier, ancestors);
|
|
462
461
|
if (assertion) return record(assertion, {wrapper: identifier, use: "snapshot"});
|
|
463
462
|
}
|
|
464
463
|
if (!selectOf(first, identifier)) return false;
|
|
@@ -567,9 +566,8 @@ export function analyzeWrapperScope(block: Cursor, {declaration, name}: WrapperD
|
|
|
567
566
|
if (!blocked) return undefined;
|
|
568
567
|
let snapshot: J.MethodInvocation | undefined;
|
|
569
568
|
if (optInSnapshots && !after && !reference.declares) {
|
|
570
|
-
serializers ??= snapshotSerializers(block);
|
|
571
569
|
const ancestors = ancestorsOf(reference.cursor);
|
|
572
|
-
const expectCall = snapshotAssertion(reference.identifier, ancestors
|
|
570
|
+
const expectCall = snapshotAssertion(reference.identifier, ancestors);
|
|
573
571
|
snapshot = expectCall && ancestors.find(c => c.value.kind === J.Kind.MethodInvocation && (c.value as J.MethodInvocation).select?.element === expectCall)?.value;
|
|
574
572
|
}
|
|
575
573
|
rejected.push({cursor: reference.cursor, unmounted: after, snapshot});
|
|
@@ -582,23 +580,17 @@ export function analyzeWrapperScope(block: Cursor, {declaration, name}: WrapperD
|
|
|
582
580
|
return {declaration, name, uses, removedStatements, unmounts};
|
|
583
581
|
}
|
|
584
582
|
|
|
585
|
-
/** The local names a source binds to `enzyme-to-json`'s serializers, such as its default export `toJson`. */
|
|
586
|
-
function snapshotSerializers(cursor: Cursor): ReadonlySet<string> {
|
|
587
|
-
const cu = compilationUnitOf(cursor);
|
|
588
|
-
return new Set(cu ? importBindings(cu).filter(({module}) => module === "enzyme-to-json").map(({local}) => local) : []);
|
|
589
|
-
}
|
|
590
|
-
|
|
591
583
|
/**
|
|
592
584
|
* The `expect(wrapper)` or `expect(toJson(wrapper))` call of a `toMatchSnapshot()` assertion of the
|
|
593
585
|
* wrapper, with no property matcher and at most a snapshot name.
|
|
594
586
|
*/
|
|
595
|
-
function snapshotAssertion(identifier: J.Identifier, ancestors: Cursor[]
|
|
587
|
+
function snapshotAssertion(identifier: J.Identifier, ancestors: Cursor[]): J.MethodInvocation | undefined {
|
|
596
588
|
let k = 0;
|
|
597
589
|
const onlyArgument = (call: J | undefined, argument: J) => call?.kind === J.Kind.MethodInvocation && !(call as J.MethodInvocation).select &&
|
|
598
590
|
(call as J.MethodInvocation).arguments.elements.length === 1 && (call as J.MethodInvocation).arguments.elements[0].element === argument;
|
|
599
591
|
let subject: J = identifier;
|
|
600
592
|
const serialized = ancestors[k]?.value as J | undefined;
|
|
601
|
-
if (onlyArgument(serialized, subject) &&
|
|
593
|
+
if (onlyArgument(serialized, subject) && ENZYME_TO_JSON.matches((serialized as J.MethodInvocation).methodType)) {
|
|
602
594
|
subject = serialized!;
|
|
603
595
|
k++;
|
|
604
596
|
}
|
package/src/util/react-class.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {J} from "@openrewrite/rewrite/java";
|
|
1
|
+
import {J, Type} from "@openrewrite/rewrite/java";
|
|
2
2
|
import {JS} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
|
|
4
4
|
/** The React base classes of a class component. */
|
|
5
5
|
export const COMPONENT_BASES: ReadonlySet<string> = new Set(['Component', 'PureComponent']);
|
|
6
|
+
const COMPONENT_TYPES: ReadonlySet<string> = new Set(['React.Component', 'React.PureComponent']);
|
|
6
7
|
|
|
7
8
|
/** `Component<P, S>` is a parameterized type (possibly wrapped in a type-tree expression) around the plain name; this returns that name. */
|
|
8
9
|
export function unwrapBaseType(type: J | undefined): J | undefined {
|
|
@@ -33,3 +34,18 @@ export function extendsReactComponentByName(cd: J.ClassDeclaration): boolean {
|
|
|
33
34
|
const name = extendedClassName(cd);
|
|
34
35
|
return !!name && COMPONENT_BASES.has(name);
|
|
35
36
|
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Whether the class directly extends React's `Component` or `PureComponent`, as its supertype says, or `undefined` where
|
|
40
|
+
* the supertype is not attributed, such as in plain JavaScript without `@types/react`.
|
|
41
|
+
*/
|
|
42
|
+
export function reactComponentSupertype(cd: J.ClassDeclaration): boolean | undefined {
|
|
43
|
+
const supertype = (cd.type as Type.Class | undefined)?.supertype;
|
|
44
|
+
if (!supertype || supertype.kind === Type.Kind.Unknown) return undefined;
|
|
45
|
+
return Type.isOfTypeWithName(supertype, false, name => COMPONENT_TYPES.has(name));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Whether the class extends `Component` or `PureComponent`: by its supertype, or by name where that is not attributed. */
|
|
49
|
+
export function extendsReactComponent(cd: J.ClassDeclaration): boolean {
|
|
50
|
+
return reactComponentSupertype(cd) ?? extendsReactComponentByName(cd);
|
|
51
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {MethodMatcher} from "@openrewrite/rewrite/javascript";
|
|
2
|
+
import {isIdentifier, J, Type} from "@openrewrite/rewrite/java";
|
|
3
|
+
|
|
4
|
+
export interface CallMatcher {
|
|
5
|
+
matches(method: Type.Method | undefined): boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function anyOf(...patterns: string[]): CallMatcher {
|
|
9
|
+
const matchers = patterns.map(pattern => new MethodMatcher(pattern));
|
|
10
|
+
return {matches: method => matchers.some(matcher => matcher.matches(method))};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Matches calls of a function `react` exports, such as `reactFunction("useRef")`. `@types/react` declares them on
|
|
15
|
+
* the `React` namespace; in an LST built without it, a call is declared on the module it was imported or required
|
|
16
|
+
* from, `react`.
|
|
17
|
+
*/
|
|
18
|
+
export function reactFunction(name: string): CallMatcher {
|
|
19
|
+
return anyOf(`React ${name}(..)`, `react ${name}(..)`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Matches `<receiver>.<name>(..)` calls of an API that legacy JavaScript often reaches through a global, such as the
|
|
24
|
+
* UMD build's `ReactDOM`: by type where the call is attributed, and by the receiver's and method's names only where its
|
|
25
|
+
* declaring type is unknown.
|
|
26
|
+
*/
|
|
27
|
+
export function typedOrNamedCall(matcher: CallMatcher, receiver: string, name: string): (method: J.MethodInvocation) => boolean {
|
|
28
|
+
return method => {
|
|
29
|
+
const declaringType = method.methodType?.declaringType;
|
|
30
|
+
if (declaringType && declaringType.kind !== Type.Kind.Unknown) return matcher.matches(method.methodType);
|
|
31
|
+
const select = method.select?.element;
|
|
32
|
+
return method.name.simpleName === name && !!select && isIdentifier(select) && select.simpleName === receiver;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Cursor, DataTable, emptyMarkers, ExecutionContext, Markup, MarkersKind, Option, or, randomId, ScanningRecipe, SourceFile, Tree, TreePrinters, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
2
|
import {
|
|
3
|
-
AddDependencyOptions, autoFormat, ChangeImport, findNodeResolutionResult, isVendoredOrBundled, JavaScriptVisitor, JS, JSX,
|
|
3
|
+
AddDependencyOptions, autoFormat, ChangeImport, findNodeResolutionResult, isVendoredOrBundled, JavaScriptVisitor, JS, JSX, maybeBind, maybeUnbind, namesReferencedWithin, raw, template
|
|
4
4
|
} from "@openrewrite/rewrite/javascript";
|
|
5
5
|
import {emptySpace, isIdentifier, J, Statement} from "@openrewrite/rewrite/java";
|
|
6
6
|
import {Json, JsonVisitor} from "@openrewrite/rewrite/json";
|
|
@@ -210,7 +210,6 @@ function newWarning(before: SourceFile, after: SourceFile): Markup | undefined {
|
|
|
210
210
|
(marker.kind === MarkersKind.MarkupWarn || marker.kind === MarkersKind.MarkupError)) as Markup | undefined;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
/** Adds zustand 5 where a store of a package on React 18 or later converts. */
|
|
214
213
|
export class AddZustand extends ZustandDependency {
|
|
215
214
|
readonly name = "org.openrewrite.react.migrate.add-zustand";
|
|
216
215
|
readonly displayName = "Add `zustand` where a Redux store is migrated";
|
|
@@ -221,7 +220,6 @@ export class AddZustand extends ZustandDependency {
|
|
|
221
220
|
}
|
|
222
221
|
}
|
|
223
222
|
|
|
224
|
-
/** Adds zustand 4 where a store of a package on React 16.8 to 17 converts. */
|
|
225
223
|
export class AddZustand4 extends ZustandDependency {
|
|
226
224
|
readonly name = "org.openrewrite.react.migrate.add-zustand-4";
|
|
227
225
|
readonly displayName = "Add `zustand` 4 where a Redux store is migrated on React 16.8 to 17";
|
|
@@ -232,7 +230,6 @@ export class AddZustand4 extends ZustandDependency {
|
|
|
232
230
|
}
|
|
233
231
|
}
|
|
234
232
|
|
|
235
|
-
/** Adds immer, whose `produce` runs the slices' reducers as Redux Toolkit did. */
|
|
236
233
|
export class AddImmer extends ZustandDependency {
|
|
237
234
|
readonly name = "org.openrewrite.react.migrate.add-immer";
|
|
238
235
|
readonly displayName = "Add `immer` where a Redux store is migrated";
|
|
@@ -257,57 +254,6 @@ const ADDS_DEPENDENCIES = (() => {
|
|
|
257
254
|
})();
|
|
258
255
|
|
|
259
256
|
/**
|
|
260
|
-
* Moves a repository's Redux Toolkit store to zustand, all or nothing. The repository's one store converts when it is
|
|
261
|
-
* a `configureStore` of `createSlice` reducers and nothing else (see `FindReduxStores`), its sources are JavaScript,
|
|
262
|
-
* and every use of it converts:
|
|
263
|
-
*
|
|
264
|
-
* - each slice becomes a zustand store, `useCounterStore` for the `counter` key, whose state is the slice's state,
|
|
265
|
-
* frozen as Redux Toolkit freezes it; each exported action creator becomes a function of the same name that runs
|
|
266
|
-
* the slice's reducer through immer's `produce`, as Redux Toolkit does;
|
|
267
|
-
* - `useSelector(state => state.counter.value)` becomes `useCounterStore(state => state.value)`;
|
|
268
|
-
* - `dispatch(increment())` and `store.dispatch(increment())`, whose result is unused, become `increment()`, and
|
|
269
|
-
* `const dispatch = useDispatch()` goes;
|
|
270
|
-
* - `store.getState().counter` becomes `useCounterStore.getState()`;
|
|
271
|
-
* - `<Provider store={store}>` is replaced with its one child, or a fragment `<>` of its children, and the store's
|
|
272
|
-
* source is removed;
|
|
273
|
-
* - a `createAsyncThunk` of the slice's source whose stages `extraReducers` handles stays RTK's, and runs its actions
|
|
274
|
-
* through those cases on the slice's zustand store; a dispatch of it becomes a call.
|
|
275
|
-
*
|
|
276
|
-
* A `configureStore` of its `reducer` alone whose slices can't move one by one, such as one with a reducer that is no
|
|
277
|
-
* slice's, a thunk that reaches the rest of the store or a dispatch whose result is used, moves whole instead:
|
|
278
|
-
*
|
|
279
|
-
* - the store's reducer, combined as `configureStore` combines it, runs on one zustand store, `useAppStore`, whose
|
|
280
|
-
* `dispatch` runs a thunk as Redux Toolkit's default middleware does, and any other action through the reducer
|
|
281
|
-
* once it is a plain object with a `type`, a string on Redux 5, and throws otherwise, as Redux does;
|
|
282
|
-
* - the store's variable keeps the store's `getState` and `dispatch`, so their uses stay as they are, in the store's
|
|
283
|
-
* source too, as do the slices, their action creators and thunks;
|
|
284
|
-
* - where the store's source or another calls `store.subscribe(listener)`, the store keeps a `subscribe` too, whose
|
|
285
|
-
* listeners its `dispatch` calls after every action, changed state or not, as they were when the dispatch began, as
|
|
286
|
-
* Redux does. They are called before the components render, as Redux calls the listeners that subscribe before
|
|
287
|
-
* react-redux's `Provider` does; one that subscribes once they are mounted, which Redux calls after they render, is too;
|
|
288
|
-
* - `useSelector(state => state.counter.value)` becomes `useAppStore(state => state.counter.value)`, as does
|
|
289
|
-
* `useSelector(selectValue)` of a top-level `const selectValue = state => state.counter.value`, declared in the source
|
|
290
|
-
* or imported from another, `const dispatch = useDispatch()` becomes `const dispatch = useAppStore.dispatch`, and
|
|
291
|
-
* the `Provider` goes, as above;
|
|
292
|
-
* - any other `useSelector(selector)`, such as one that builds a value, becomes `useAppStore(selector)` on zustand 4,
|
|
293
|
-
* whose hook keeps the selection per state as react-redux's does, and on zustand 5, whose hook runs the selector on
|
|
294
|
-
* each read, `useAppStoreSelector(selector)`, a hook the store's source declares that keeps it.
|
|
295
|
-
*
|
|
296
|
-
* A legacy `createStore(reducer)` or `createStore(reducer, preloadedState)`, of a preloaded state written as a value,
|
|
297
|
-
* moves whole the same way. It has no middleware, so its `dispatch` runs no thunk, and its state starts from the
|
|
298
|
-
* preloaded state. One
|
|
299
|
-
* whose enhancer is `applyMiddleware(thunk)`, perhaps inside `compose` or Redux DevTools, also runs a function it is
|
|
300
|
-
* dispatched with `dispatch` and `getState`, as redux-thunk does; DevTools is dropped.
|
|
301
|
-
*
|
|
302
|
-
* A store that moves whole also takes its components connected with `connect`, with no `mergeProps` and no option
|
|
303
|
-
* but `forwardRef`: the store's source declares a `connect` that passes the props, copies the statics and skips the
|
|
304
|
-
* re-renders react-redux's does, reading the zustand store, and each source imports it from there. The store then
|
|
305
|
-
* batches its updates with `unstable_batchedUpdates`, as react-redux does, so that before React 18 a parent renders
|
|
306
|
-
* before a child it removes.
|
|
307
|
-
*
|
|
308
|
-
* Any other use, such as `connect` with `mergeProps`, `persistStore(store)`, or a selector with its own equality function, keeps the
|
|
309
|
-
* store in Redux, recorded in the `ReduxStores` table with the reason.
|
|
310
|
-
*
|
|
311
257
|
* @see https://zustand.docs.pmnd.rs/guides/migrating-to-zustand
|
|
312
258
|
*/
|
|
313
259
|
export class ReduxToZustand extends ScanningRecipe<Scanned> {
|
|
@@ -728,10 +674,10 @@ async function convertSlice(visitor: JavaScriptVisitor<ExecutionContext>, cu: JS
|
|
|
728
674
|
result = await new class extends JavaScriptVisitor<ExecutionContext> {
|
|
729
675
|
override async visitJsCompilationUnit(unit: JS.CompilationUnit, p: ExecutionContext): Promise<J | undefined> {
|
|
730
676
|
const quoteStyle = quoteOf(cu);
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
677
|
+
maybeUnbind(this, {module: RTK, member: "createSlice"});
|
|
678
|
+
maybeBind(this, {module: ZUSTAND, member: "create", onlyIfReferenced: false, quoteStyle});
|
|
679
|
+
maybeBind(this, {module: IMMER, member: "freeze", onlyIfReferenced: false, quoteStyle});
|
|
680
|
+
maybeBind(this, {module: IMMER, member: "produce", onlyIfReferenced: false, quoteStyle});
|
|
735
681
|
return super.visitJsCompilationUnit(unit, p);
|
|
736
682
|
}
|
|
737
683
|
}().visit(result, ctx) as JS.CompilationUnit;
|
|
@@ -864,14 +810,14 @@ async function convertConsumer(cu: JS.CompilationUnit, p: Plan, scanned: Scanned
|
|
|
864
810
|
return await new class extends JavaScriptVisitor<ExecutionContext> {
|
|
865
811
|
override async visitJsCompilationUnit(unit: JS.CompilationUnit, q: ExecutionContext): Promise<J | undefined> {
|
|
866
812
|
for (const member of ["useSelector", "useDispatch", "Provider"]) {
|
|
867
|
-
if (removed.has(member))
|
|
813
|
+
if (removed.has(member)) maybeUnbind(this, {module: REACT_REDUX, member: member});
|
|
868
814
|
}
|
|
869
815
|
// The store's source is removed, so no import of it may stay, even one nothing here used
|
|
870
816
|
for (const binding of bindings) {
|
|
871
|
-
if (binding.module !== REACT_REDUX && isStore(binding.local))
|
|
817
|
+
if (binding.module !== REACT_REDUX && isStore(binding.local)) maybeUnbind(this, {module: binding.module, member: binding.name});
|
|
872
818
|
}
|
|
873
819
|
for (const slice of hooks) {
|
|
874
|
-
|
|
820
|
+
maybeBind(this, {module: relativeSpecifier(cu.sourcePath, slice.path), member: slice.hook, onlyIfReferenced: false, quoteStyle: quoteOf(cu)});
|
|
875
821
|
}
|
|
876
822
|
return super.visitJsCompilationUnit(unit, q);
|
|
877
823
|
}
|
|
@@ -1190,21 +1136,21 @@ async function convertReducerStore(cu: JS.CompilationUnit, p: Plan, facts: Packa
|
|
|
1190
1136
|
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
1191
1137
|
override async visitJsCompilationUnit(unit: JS.CompilationUnit, q: ExecutionContext): Promise<J | undefined> {
|
|
1192
1138
|
const quoteStyle = quoteOf(cu);
|
|
1193
|
-
|
|
1194
|
-
for (const module of [REDUX, RTK]) for (const member of ["createStore", "legacy_createStore"])
|
|
1139
|
+
maybeUnbind(this, {module: RTK, member: "configureStore"});
|
|
1140
|
+
for (const module of [REDUX, RTK]) for (const member of ["createStore", "legacy_createStore"]) maybeUnbind(this, {module: module, member: member});
|
|
1195
1141
|
if (legacy) {
|
|
1196
|
-
for (const member of ["applyMiddleware", "compose"])
|
|
1197
|
-
for (const member of ["default", "thunk"])
|
|
1142
|
+
for (const member of ["applyMiddleware", "compose"]) maybeUnbind(this, {module: REDUX, member: member});
|
|
1143
|
+
for (const member of ["default", "thunk"]) maybeUnbind(this, {module: "redux-thunk", member: member});
|
|
1198
1144
|
for (const module of ["redux-devtools-extension", "@redux-devtools/extension"]) {
|
|
1199
|
-
for (const member of ["composeWithDevTools", "devToolsEnhancer", "devToolsEnhancerLogOnlyInProduction"])
|
|
1145
|
+
for (const member of ["composeWithDevTools", "devToolsEnhancer", "devToolsEnhancerLogOnlyInProduction"]) maybeUnbind(this, {module: module, member: member});
|
|
1200
1146
|
}
|
|
1201
1147
|
}
|
|
1202
|
-
if (combined)
|
|
1203
|
-
|
|
1204
|
-
if (selectorHook) for (const member of ["useRef", "useSyncExternalStore"])
|
|
1148
|
+
if (combined) maybeBind(this, {module: RTK, member: "combineReducers", onlyIfReferenced: false, quoteStyle});
|
|
1149
|
+
maybeBind(this, {module: ZUSTAND, member: "create", onlyIfReferenced: false, quoteStyle});
|
|
1150
|
+
if (selectorHook) for (const member of ["useRef", "useSyncExternalStore"]) maybeBind(this, {module: "react", member, onlyIfReferenced: false, quoteStyle});
|
|
1205
1151
|
if (renderer) {
|
|
1206
|
-
for (const member of ["createElement", "forwardRef", "memo", "useRef"])
|
|
1207
|
-
|
|
1152
|
+
for (const member of ["createElement", "forwardRef", "memo", "useRef"]) maybeBind(this, {module: "react", member, onlyIfReferenced: false, quoteStyle});
|
|
1153
|
+
maybeBind(this, {module: renderer, member: "unstable_batchedUpdates", onlyIfReferenced: false, quoteStyle});
|
|
1208
1154
|
}
|
|
1209
1155
|
return super.visitJsCompilationUnit(unit, q);
|
|
1210
1156
|
}
|
|
@@ -1291,16 +1237,16 @@ async function convertReducerConsumer(cu: JS.CompilationUnit, p: Plan, scanned:
|
|
|
1291
1237
|
return await new class extends JavaScriptVisitor<ExecutionContext> {
|
|
1292
1238
|
override async visitJsCompilationUnit(unit: JS.CompilationUnit, q: ExecutionContext): Promise<J | undefined> {
|
|
1293
1239
|
for (const member of ["useSelector", "useDispatch", "Provider"]) {
|
|
1294
|
-
if (removed.has(member))
|
|
1240
|
+
if (removed.has(member)) maybeUnbind(this, {module: REACT_REDUX, member: member});
|
|
1295
1241
|
}
|
|
1296
1242
|
// The store's variable stays, so its import goes only where nothing uses it any more
|
|
1297
1243
|
if (removed.has("Provider")) {
|
|
1298
1244
|
for (const binding of bindings) {
|
|
1299
|
-
if (binding.module !== REACT_REDUX && resolverOf(scanned)(cu.sourcePath, binding.module) === p.store!.path)
|
|
1245
|
+
if (binding.module !== REACT_REDUX && resolverOf(scanned)(cu.sourcePath, binding.module) === p.store!.path) maybeUnbind(this, {module: binding.module, member: binding.name});
|
|
1300
1246
|
}
|
|
1301
1247
|
}
|
|
1302
1248
|
for (const member of [hook, selectorHook]) {
|
|
1303
|
-
if (member && uses.has(member))
|
|
1249
|
+
if (member && uses.has(member)) maybeBind(this, {module: relativeSpecifier(cu.sourcePath, p.store!.path), member, onlyIfReferenced: false, quoteStyle: quoteOf(cu)});
|
|
1304
1250
|
}
|
|
1305
1251
|
return super.visitJsCompilationUnit(unit, q);
|
|
1306
1252
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replace-create-factory.d.ts","sourceRoot":"","sources":["../../src/react16/replace-create-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAa,MAAM,sBAAsB,CAAC;AAsBvF,qBAAa,oBAAqB,SAAQ,MAAM;IAC5C,QAAQ,CAAC,IAAI,qDAAqD;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA8D;IAC1F,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAwL;IAE9M,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CA4D9D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replace-create-factory.js","sourceRoot":"","sources":["../../src/react16/replace-create-factory.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAuF;AACvF,gEAA2F;AAC3F,oDAAyD;AAoBzD,MAAa,oBAAqB,SAAQ,gBAAM;IAAhD;;QACa,SAAI,GAAG,iDAAiD,CAAC;QACzD,gBAAW,GAAW,0DAA0D,CAAC;QACjF,gBAAW,GAAW,oLAAoL,CAAC;IA8DxN,CAAC;IA5DS,MAAM;;YACR,OAAO,IAAA,eAAK,EAAC,IAAA,aAAG,EAAC,IAAA,gCAAmB,GAAE,CAAC,EAAE,IAAI,KAAM,SAAQ,8BAAmC;gBAC3E,iBAAiB,CAAC,YAA6B,EAAE,CAAmB;;;;;;wBAC/E,IAAI,EAAE,GAAG,MAAM,OAAM,iBAAiB,YAAC,YAAY,EAAE,CAAC,CAAoB,CAAC;wBAG3E,IAAI,CAAC,EAAE,CAAC,QAAQ;4BAAE,OAAO,EAAE,CAAC;wBAC5B,MAAM,MAAM,GAAG,MAAC,EAAE,CAAC,QAAgB,CAAC,OAAO,mCAAI,EAAE,CAAC,QAAQ,CAAC;wBAE3D,IAAI,MAAM,CAAC,IAAI,KAAK,QAAC,CAAC,IAAI,CAAC,gBAAgB;4BAAE,OAAO,EAAE,CAAC;wBACvD,MAAM,SAAS,GAAG,MAA4B,CAAC;wBAE/C,IAAI,SAAS,CAAC,IAAI,CAAC,UAAU,KAAK,eAAe;4BAAE,OAAO,EAAE,CAAC;wBAE7D,IAAI,CAAC,SAAS,CAAC,MAAM;4BAAE,OAAO,EAAE,CAAC;wBAEjC,MAAM,SAAS,GAAG,MAAA,SAAS,CAAC,SAAS,0CAAE,QAAQ,CAAC;wBAChD,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;4BAAE,OAAO,EAAE,CAAC;wBAEpD,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;wBAE7B,MAAM,SAAS,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAO,EAAE,EAAE;;4BACvD,MAAM,OAAO,GAAG,MAAA,EAAE,CAAC,OAAO,mCAAI,EAAE,CAAC;4BACjC,OAAO,OAAO,CAAC,IAAI,KAAK,QAAC,CAAC,IAAI,CAAC,KAAK,CAAC;wBACzC,CAAC,CAAC,CAAC;wBAGH,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,EAAO,EAAE,CAAS,EAAE,EAAE;4BACtD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;gCACxB,uCACO,EAAE,KACL,OAAO,kCACA,EAAE,CAAC,OAAO,KACb,MAAM,EAAE,kBAAW,OAEzB;4BACN,CAAC;4BACD,OAAO,EAAE,CAAC;wBACd,CAAC,CAAC,CAAC;wBAEH,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC;4BAChC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC;4BAC5B,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;wBAEhB,OAAO,gCACA,SAAS,KACZ,MAAM,EAAG,EAAU,CAAC,MAAM,EAC1B,MAAM,EAAE,SAAS,CAAC,MAAM,EACxB,IAAI,kCACG,SAAS,CAAC,IAAI,KACjB,UAAU,EAAE,eAAe,KAE/B,SAAS,kCACF,EAAE,CAAC,SAAS,KACf,QAAQ,EAAE,OAAO,MAEK,CAAC;oBACnC,CAAC;iBAAA;aACJ,EAAE,CAAC,CAAC;QACT,CAAC;KAAA;CACJ;AAjED,oDAiEC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
-
export declare class ReplaceActImport extends Recipe {
|
|
3
|
-
readonly name = "org.openrewrite.react.19.replace-act-import";
|
|
4
|
-
readonly displayName: string;
|
|
5
|
-
readonly description: string;
|
|
6
|
-
private changeImport;
|
|
7
|
-
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=replace-act-import.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replace-act-import.d.ts","sourceRoot":"","sources":["../../src/react19/replace-act-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,gBAAgB,EAAO,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAqBvF,qBAAa,gBAAiB,SAAQ,MAAM;IACxC,QAAQ,CAAC,IAAI,iDAAiD;IAC9D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAoD;IAChF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAyH;IAErJ,OAAO,CAAC,YAAY,CAIjB;IAEG,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAG9D"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ReplaceActImport = void 0;
|
|
13
|
-
const rewrite_1 = require("@openrewrite/rewrite");
|
|
14
|
-
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
15
|
-
class ReplaceActImport extends rewrite_1.Recipe {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(...arguments);
|
|
18
|
-
this.name = "org.openrewrite.react.19.replace-act-import";
|
|
19
|
-
this.displayName = "Replace `act` import from react-dom/test-utils";
|
|
20
|
-
this.description = "In React 19, `act` has been moved from `react-dom/test-utils` to `react`. This recipe updates the import statement.";
|
|
21
|
-
this.changeImport = new javascript_1.ChangeImport({
|
|
22
|
-
oldModule: "react-dom/test-utils",
|
|
23
|
-
oldMember: "act",
|
|
24
|
-
newModule: "react"
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
editor() {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
return (0, rewrite_1.check)((0, rewrite_1.not)((0, javascript_1.isVendoredOrBundled)()), this.changeImport.editor());
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.ReplaceActImport = ReplaceActImport;
|
|
34
|
-
//# sourceMappingURL=replace-act-import.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replace-act-import.js","sourceRoot":"","sources":["../../src/react19/replace-act-import.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAuF;AACvF,gEAAkF;AAoBlF,MAAa,gBAAiB,SAAQ,gBAAM;IAA5C;;QACa,SAAI,GAAG,6CAA6C,CAAC;QACrD,gBAAW,GAAW,gDAAgD,CAAC;QACvE,gBAAW,GAAW,qHAAqH,CAAC;QAE7I,iBAAY,GAAG,IAAI,yBAAY,CAAC;YACpC,SAAS,EAAE,sBAAsB;YACjC,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,OAAO;SACrB,CAAC,CAAC;IAKP,CAAC;IAHS,MAAM;;YACR,OAAO,IAAA,eAAK,EAAC,IAAA,aAAG,EAAC,IAAA,gCAAmB,GAAE,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzE,CAAC;KAAA;CACJ;AAdD,4CAcC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
-
export declare class ReplaceReactShallowRenderer extends Recipe {
|
|
3
|
-
readonly name = "org.openrewrite.react.19.replace-react-shallow-renderer";
|
|
4
|
-
readonly displayName: string;
|
|
5
|
-
readonly description: string;
|
|
6
|
-
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=replace-react-shallow-renderer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replace-react-shallow-renderer.d.ts","sourceRoot":"","sources":["../../src/react19/replace-react-shallow-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAwC,MAAM,sBAAsB,CAAC;AAsBlH,qBAAa,2BAA4B,SAAQ,MAAM;IACnD,QAAQ,CAAC,IAAI,6DAA6D;IAC1E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAkD;IAC9E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAgK;IAEtL,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAmB9D"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ReplaceReactShallowRenderer = void 0;
|
|
13
|
-
const rewrite_1 = require("@openrewrite/rewrite");
|
|
14
|
-
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
15
|
-
const java_1 = require("@openrewrite/rewrite/java");
|
|
16
|
-
class ReplaceReactShallowRenderer extends rewrite_1.Recipe {
|
|
17
|
-
constructor() {
|
|
18
|
-
super(...arguments);
|
|
19
|
-
this.name = "org.openrewrite.react.19.replace-react-shallow-renderer";
|
|
20
|
-
this.displayName = "Replace `react-test-renderer/shallow` import";
|
|
21
|
-
this.description = "Changes import of shallow renderer from `react-test-renderer/shallow` to the standalone `react-shallow-renderer` package, as it was removed from React 19.";
|
|
22
|
-
}
|
|
23
|
-
editor() {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
return (0, rewrite_1.check)((0, rewrite_1.not)((0, javascript_1.isVendoredOrBundled)()), new class extends javascript_1.JavaScriptVisitor {
|
|
26
|
-
visitJsCompilationUnit(cu, ctx) {
|
|
27
|
-
const _super = Object.create(null, {
|
|
28
|
-
visitJsCompilationUnit: { get: () => super.visitJsCompilationUnit }
|
|
29
|
-
});
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const result = yield _super.visitJsCompilationUnit.call(this, cu, ctx);
|
|
32
|
-
return (0, rewrite_1.updateIfChanged)(result, {
|
|
33
|
-
statements: yield (0, rewrite_1.mapAsync)(result.statements, (paddedStmt) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const imp = paddedStmt.element;
|
|
35
|
-
const moduleSpecifier = imp.kind === javascript_1.JS.Kind.Import ? imp.moduleSpecifier : undefined;
|
|
36
|
-
const literal = moduleSpecifier === null || moduleSpecifier === void 0 ? void 0 : moduleSpecifier.element;
|
|
37
|
-
if ((literal === null || literal === void 0 ? void 0 : literal.kind) !== java_1.J.Kind.Literal || literal.value !== 'react-test-renderer/shallow')
|
|
38
|
-
return paddedStmt;
|
|
39
|
-
return Object.assign(Object.assign({}, paddedStmt), { element: Object.assign(Object.assign({}, imp), { moduleSpecifier: Object.assign(Object.assign({}, moduleSpecifier), { element: (0, javascript_1.withStringValue)(literal, 'react-shallow-renderer') }) }) });
|
|
40
|
-
}))
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}());
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.ReplaceReactShallowRenderer = ReplaceReactShallowRenderer;
|
|
49
|
-
//# sourceMappingURL=replace-react-shallow-renderer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replace-react-shallow-renderer.js","sourceRoot":"","sources":["../../src/react19/replace-react-shallow-renderer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAkH;AAClH,gEAA4G;AAC5G,oDAA4C;AAoB5C,MAAa,2BAA4B,SAAQ,gBAAM;IAAvD;;QACa,SAAI,GAAG,yDAAyD,CAAC;QACjE,gBAAW,GAAW,8CAA8C,CAAC;QACrE,gBAAW,GAAW,4JAA4J,CAAC;IAqBhM,CAAC;IAnBS,MAAM;;YACR,OAAO,IAAA,eAAK,EAAC,IAAA,aAAG,EAAC,IAAA,gCAAmB,GAAE,CAAC,EAAE,IAAI,KAAM,SAAQ,8BAAmC;gBAC3E,sBAAsB,CAAC,EAAsB,EAAE,GAAqB;;;;;wBAC/E,MAAM,MAAM,GAAG,MAAM,OAAM,sBAAsB,YAAC,EAAE,EAAE,GAAG,CAAuB,CAAC;wBACjF,OAAO,IAAA,yBAAe,EAAC,MAAM,EAAE;4BAC3B,UAAU,EAAE,MAAM,IAAA,kBAAQ,EAAC,MAAM,CAAC,UAAU,EAAE,CAAM,UAAU,EAAC,EAAE;gCAC7D,MAAM,GAAG,GAAG,UAAU,CAAC,OAAoB,CAAC;gCAC5C,MAAM,eAAe,GAAG,GAAG,CAAC,IAAI,KAAK,eAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC;gCACtF,MAAM,OAAO,GAAG,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,OAAgC,CAAC;gCAClE,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,QAAC,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK,KAAK,6BAA6B;oCAAE,OAAO,UAAU,CAAC;gCAC3G,uCACO,UAAU,KACb,OAAO,kCAAM,GAAG,KAAE,eAAe,kCAAM,eAAgB,KAAE,OAAO,EAAE,IAAA,4BAAe,EAAC,OAAO,EAAE,wBAAwB,CAAC,UACtH;4BACN,CAAC,CAAA,CAAC;yBACL,CAAC,CAAC;oBACP,CAAC;iBAAA;aACJ,EAAE,CAAC,CAAC;QACT,CAAC;KAAA;CACJ;AAxBD,kEAwBC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
-
export declare class ReplaceUseFormState extends Recipe {
|
|
3
|
-
readonly name = "org.openrewrite.react.19.replace-use-form-state";
|
|
4
|
-
readonly displayName: string;
|
|
5
|
-
readonly description: string;
|
|
6
|
-
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=replace-use-form-state.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replace-use-form-state.d.ts","sourceRoot":"","sources":["../../src/react19/replace-use-form-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAa,MAAM,sBAAsB,CAAC;AAgCvF,qBAAa,mBAAoB,SAAQ,MAAM;IAC3C,QAAQ,CAAC,IAAI,qDAAqD;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAkD;IAC9E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA6G;IAEnI,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CA+B9D"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ReplaceUseFormState = void 0;
|
|
13
|
-
const rewrite_1 = require("@openrewrite/rewrite");
|
|
14
|
-
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
15
|
-
class ReplaceUseFormState extends rewrite_1.Recipe {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(...arguments);
|
|
18
|
-
this.name = "org.openrewrite.react.19.replace-use-form-state";
|
|
19
|
-
this.displayName = "Replace `useFormState` with `useActionState`";
|
|
20
|
-
this.description = "In React 19, `useFormState` from `react-dom` has been renamed to `useActionState` and moved to `react`.";
|
|
21
|
-
}
|
|
22
|
-
editor() {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
const reactDomOptions = {
|
|
25
|
-
context: ['import { useFormState } from "react-dom";'],
|
|
26
|
-
dependencies: { '@types/react-dom': '^18.0.0' },
|
|
27
|
-
lenientTypeMatching: false
|
|
28
|
-
};
|
|
29
|
-
const args = (0, javascript_1.capture)({ variadic: true });
|
|
30
|
-
const rule = (0, javascript_1.rewrite)(() => ({
|
|
31
|
-
before: (0, javascript_1.pattern) `useFormState(${args})`.configure(reactDomOptions),
|
|
32
|
-
after: (0, javascript_1.template) `useActionState(${args})`.configure({
|
|
33
|
-
context: ['import { useActionState } from "react";'],
|
|
34
|
-
dependencies: { '@types/react': '^19.0.0' }
|
|
35
|
-
})
|
|
36
|
-
}));
|
|
37
|
-
return (0, rewrite_1.check)((0, rewrite_1.not)((0, javascript_1.isVendoredOrBundled)()), new class extends javascript_1.JavaScriptVisitor {
|
|
38
|
-
visitMethodInvocation(method, p) {
|
|
39
|
-
const _super = Object.create(null, {
|
|
40
|
-
visitMethodInvocation: { get: () => super.visitMethodInvocation }
|
|
41
|
-
});
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
let m = yield _super.visitMethodInvocation.call(this, method, p);
|
|
44
|
-
const result = yield rule.tryOn(this.cursor, m, { visitor: this });
|
|
45
|
-
if (result) {
|
|
46
|
-
(0, javascript_1.maybeRemoveImport)(this, "react-dom", "useFormState");
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
return m;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}());
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.ReplaceUseFormState = ReplaceUseFormState;
|
|
57
|
-
//# sourceMappingURL=replace-use-form-state.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replace-use-form-state.js","sourceRoot":"","sources":["../../src/react19/replace-use-form-state.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAuF;AACvF,gEAQyC;AAuBzC,MAAa,mBAAoB,SAAQ,gBAAM;IAA/C;;QACa,SAAI,GAAG,iDAAiD,CAAC;QACzD,gBAAW,GAAW,8CAA8C,CAAC;QACrE,gBAAW,GAAW,yGAAyG,CAAC;IAiC7I,CAAC;IA/BS,MAAM;;YACR,MAAM,eAAe,GAAG;gBACpB,OAAO,EAAE,CAAC,2CAA2C,CAAC;gBACtD,YAAY,EAAE,EAAC,kBAAkB,EAAE,SAAS,EAAC;gBAC7C,mBAAmB,EAAE,KAAK;aAC7B,CAAC;YAEF,MAAM,IAAI,GAAG,IAAA,oBAAO,EAAa,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;YAEnD,MAAM,IAAI,GAAG,IAAA,oBAAO,EAAC,GAAG,EAAE,CAAC,CAAC;gBACxB,MAAM,EAAE,IAAA,oBAAO,EAAA,gBAAgB,IAAI,GAAG,CAAC,SAAS,CAAC,eAAe,CAAC;gBACjE,KAAK,EAAE,IAAA,qBAAQ,EAAA,kBAAkB,IAAI,GAAG,CAAC,SAAS,CAAC;oBAC/C,OAAO,EAAE,CAAC,yCAAyC,CAAC;oBACpD,YAAY,EAAE,EAAC,cAAc,EAAE,SAAS,EAAC;iBAC5C,CAAC;aACL,CAAC,CAAC,CAAC;YAEJ,OAAO,IAAA,eAAK,EAAC,IAAA,aAAG,EAAC,IAAA,gCAAmB,GAAE,CAAC,EAAE,IAAI,KAAM,SAAQ,8BAAmC;gBAC3E,qBAAqB,CAAC,MAA0B,EAAE,CAAmB;;;;;wBAChF,IAAI,CAAC,GAAG,MAAM,OAAM,qBAAqB,YAAC,MAAM,EAAE,CAAC,CAAuB,CAAC;wBAE3E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAE,EAAE,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC;wBAClE,IAAI,MAAM,EAAE,CAAC;4BACT,IAAA,8BAAiB,EAAC,IAAI,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;4BACrD,OAAO,MAAM,CAAC;wBAClB,CAAC;wBAED,OAAO,CAAC,CAAC;oBACb,CAAC;iBAAA;aACJ,EAAE,CAAC,CAAC;QACT,CAAC;KAAA;CACJ;AApCD,kDAoCC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {check, ExecutionContext, not, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
-
import {ChangeImport, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Migrates `act` imports from `react-dom/test-utils` to `react`.
|
|
6
|
-
*
|
|
7
|
-
* In React 19, the `act` function has been moved from `react-dom/test-utils`
|
|
8
|
-
* to `react` itself. This recipe automatically updates imports.
|
|
9
|
-
*
|
|
10
|
-
* Before:
|
|
11
|
-
* ```tsx
|
|
12
|
-
* import { act } from 'react-dom/test-utils';
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* After:
|
|
16
|
-
* ```tsx
|
|
17
|
-
* import { act } from 'react';
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-react-dom-test-utils
|
|
21
|
-
*/
|
|
22
|
-
export class ReplaceActImport extends Recipe {
|
|
23
|
-
readonly name = "org.openrewrite.react.19.replace-act-import";
|
|
24
|
-
readonly displayName: string = "Replace `act` import from react-dom/test-utils";
|
|
25
|
-
readonly description: string = "In React 19, `act` has been moved from `react-dom/test-utils` to `react`. This recipe updates the import statement.";
|
|
26
|
-
|
|
27
|
-
private changeImport = new ChangeImport({
|
|
28
|
-
oldModule: "react-dom/test-utils",
|
|
29
|
-
oldMember: "act",
|
|
30
|
-
newModule: "react"
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
34
|
-
return check(not(isVendoredOrBundled()), this.changeImport.editor());
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor, check, mapAsync, not, updateIfChanged} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS, isVendoredOrBundled, withStringValue} from "@openrewrite/rewrite/javascript";
|
|
3
|
-
import {J} from "@openrewrite/rewrite/java";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Replaces `react-test-renderer/shallow` imports with `react-shallow-renderer`.
|
|
7
|
-
*
|
|
8
|
-
* In React 19, the shallow renderer has been removed from `react-test-renderer`.
|
|
9
|
-
* This recipe updates imports to use the standalone `react-shallow-renderer` package.
|
|
10
|
-
*
|
|
11
|
-
* Before:
|
|
12
|
-
* ```tsx
|
|
13
|
-
* import ShallowRenderer from 'react-test-renderer/shallow';
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* After:
|
|
17
|
-
* ```tsx
|
|
18
|
-
* import ShallowRenderer from 'react-shallow-renderer';
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-react-test-renderer-shallow
|
|
22
|
-
*/
|
|
23
|
-
export class ReplaceReactShallowRenderer extends Recipe {
|
|
24
|
-
readonly name = "org.openrewrite.react.19.replace-react-shallow-renderer";
|
|
25
|
-
readonly displayName: string = "Replace `react-test-renderer/shallow` import";
|
|
26
|
-
readonly description: string = "Changes import of shallow renderer from `react-test-renderer/shallow` to the standalone `react-shallow-renderer` package, as it was removed from React 19.";
|
|
27
|
-
|
|
28
|
-
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
29
|
-
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
30
|
-
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
31
|
-
const result = await super.visitJsCompilationUnit(cu, ctx) as JS.CompilationUnit;
|
|
32
|
-
return updateIfChanged(result, {
|
|
33
|
-
statements: await mapAsync(result.statements, async paddedStmt => {
|
|
34
|
-
const imp = paddedStmt.element as JS.Import;
|
|
35
|
-
const moduleSpecifier = imp.kind === JS.Kind.Import ? imp.moduleSpecifier : undefined;
|
|
36
|
-
const literal = moduleSpecifier?.element as J.Literal | undefined;
|
|
37
|
-
if (literal?.kind !== J.Kind.Literal || literal.value !== 'react-test-renderer/shallow') return paddedStmt;
|
|
38
|
-
return {
|
|
39
|
-
...paddedStmt,
|
|
40
|
-
element: {...imp, moduleSpecifier: {...moduleSpecifier!, element: withStringValue(literal, 'react-shallow-renderer')}}
|
|
41
|
-
};
|
|
42
|
-
})
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}());
|
|
46
|
-
}
|
|
47
|
-
}
|