@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,6 +1,7 @@
|
|
|
1
1
|
import {Column, DataTable, ExecutionContext, foundSearchResult, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
2
|
import {JavaScriptVisitor, JS, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
4
|
+
import {anyOf, CallMatcher, reactFunction, typedOrNamedCall} from "../util/react-matchers";
|
|
4
5
|
|
|
5
6
|
class DeprecatedReactDomRow {
|
|
6
7
|
@Column({displayName: "File path", description: "The file path where the deprecated API is used"})
|
|
@@ -13,26 +14,20 @@ class DeprecatedReactDomRow {
|
|
|
13
14
|
replacement!: string;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
['
|
|
22
|
-
]
|
|
17
|
+
const REACT_DOM_SERVER = (api: string) =>
|
|
18
|
+
// A namespace or default import of `react-dom/server` is declared on `react-dom` (openrewrite/rewrite#9994)
|
|
19
|
+
anyOf(`react-dom/server ${api}(..)`, `react-dom ${api}(..)`);
|
|
20
|
+
|
|
21
|
+
const DEPRECATED_CALLS = ([
|
|
22
|
+
['findDOMNode', anyOf('react-dom findDOMNode(..)'), 'ReactDOM', 'Use refs instead of ReactDOM.findDOMNode()'],
|
|
23
|
+
['unmountComponentAtNode', anyOf('react-dom unmountComponentAtNode(..)'), 'ReactDOM', 'Use root.unmount() from createRoot() instead'],
|
|
24
|
+
['createFactory', reactFunction('createFactory'), 'React', 'Use JSX or React.createElement() instead'],
|
|
25
|
+
['renderToNodeStream', REACT_DOM_SERVER('renderToNodeStream'), 'ReactDOMServer', 'Use renderToPipeableStream instead'],
|
|
26
|
+
['renderToStaticNodeStream', REACT_DOM_SERVER('renderToStaticNodeStream'), 'ReactDOMServer', 'Use renderToReadableStream or renderToPipeableStream instead'],
|
|
27
|
+
] as [string, CallMatcher, string, string][]).map(([api, matcher, receiver, replacement]) =>
|
|
28
|
+
({api, replacement, matches: typedOrNamedCall(matcher, receiver, api)}));
|
|
23
29
|
|
|
24
30
|
/**
|
|
25
|
-
* Finds usage of deprecated or removed ReactDOM APIs in React 19.
|
|
26
|
-
*
|
|
27
|
-
* Detects:
|
|
28
|
-
* - `ReactDOM.findDOMNode(component)` — removed, use refs instead
|
|
29
|
-
* - `ReactDOM.unmountComponentAtNode(container)` — removed, use `root.unmount()`
|
|
30
|
-
* - `React.createFactory(type)` — removed, use JSX or `createElement`
|
|
31
|
-
* - `ReactDOMServer.renderToNodeStream()` — removed, use `renderToPipeableStream`
|
|
32
|
-
* - `ReactDOMServer.renderToStaticNodeStream()` — removed
|
|
33
|
-
*
|
|
34
|
-
* Also detects named imports of these functions.
|
|
35
|
-
*
|
|
36
31
|
* @see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-deprecated-react-dom-apis
|
|
37
32
|
*/
|
|
38
33
|
export class FindDeprecatedReactDomAPIs extends Recipe {
|
|
@@ -52,75 +47,20 @@ export class FindDeprecatedReactDomAPIs extends Recipe {
|
|
|
52
47
|
|
|
53
48
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
54
49
|
private filePath = "";
|
|
55
|
-
private importedDeprecatedApis = new Set<string>();
|
|
56
50
|
|
|
57
51
|
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
58
52
|
this.filePath = cu.sourcePath ?? "";
|
|
59
|
-
this.importedDeprecatedApis.clear();
|
|
60
53
|
return super.visitJsCompilationUnit(cu, ctx);
|
|
61
54
|
}
|
|
62
55
|
|
|
63
|
-
// Detect imports of deprecated APIs
|
|
64
|
-
override async visitImportSpecifier(spec: JS.ImportSpecifier, ctx: ExecutionContext): Promise<J | undefined> {
|
|
65
|
-
const specifier = spec.specifier;
|
|
66
|
-
|
|
67
|
-
let importedName: string | undefined;
|
|
68
|
-
if (specifier.kind === JS.Kind.Alias) {
|
|
69
|
-
const alias = specifier as JS.Alias;
|
|
70
|
-
const propName = alias.propertyName.element;
|
|
71
|
-
if (isIdentifier(propName)) {
|
|
72
|
-
importedName = propName.simpleName;
|
|
73
|
-
}
|
|
74
|
-
} else if (isIdentifier(specifier)) {
|
|
75
|
-
importedName = specifier.simpleName;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const importReplacement = importedName ? DEPRECATED_APIS.get(importedName) : undefined;
|
|
79
|
-
if (importedName && importReplacement) {
|
|
80
|
-
this.importedDeprecatedApis.add(importedName);
|
|
81
|
-
dataTable.insertRow(ctx, {
|
|
82
|
-
filePath: this.filePath,
|
|
83
|
-
apiName: importedName,
|
|
84
|
-
replacement: importReplacement
|
|
85
|
-
});
|
|
86
|
-
return foundSearchResult(spec, `Deprecated API: ${importedName}`);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return super.visitImportSpecifier(spec, ctx);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Detect method calls: ReactDOM.findDOMNode(), ReactDOM.unmountComponentAtNode(), etc.
|
|
93
56
|
override async visitMethodInvocation(method: J.MethodInvocation, ctx: ExecutionContext): Promise<J | undefined> {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// Direct call from named import: findDOMNode(...)
|
|
102
|
-
if (!m.select && this.importedDeprecatedApis.has(methodName)) {
|
|
103
|
-
// Already marked at import level, just mark the call too
|
|
104
|
-
return foundSearchResult(m, `Deprecated API: ${methodName}`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Namespace call: ReactDOM.findDOMNode(...), React.createFactory(...)
|
|
108
|
-
if (m.select) {
|
|
109
|
-
const select = (m.select as any).element ?? m.select;
|
|
110
|
-
if (isIdentifier(select)) {
|
|
111
|
-
const ns = select.simpleName;
|
|
112
|
-
if (ns === 'ReactDOM' || ns === 'React' || ns === 'ReactDOMServer') {
|
|
113
|
-
dataTable.insertRow(ctx, {
|
|
114
|
-
filePath: this.filePath,
|
|
115
|
-
apiName: `${ns}.${methodName}`,
|
|
116
|
-
replacement
|
|
117
|
-
});
|
|
118
|
-
return foundSearchResult(m, `Deprecated API: ${ns}.${methodName}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return m;
|
|
57
|
+
const m = await super.visitMethodInvocation(method, ctx) as J.MethodInvocation;
|
|
58
|
+
const call = DEPRECATED_CALLS.find(c => c.matches(m));
|
|
59
|
+
if (!call) return m;
|
|
60
|
+
const select = m.select?.element;
|
|
61
|
+
const apiName = select && isIdentifier(select) ? `${select.simpleName}.${call.api}` : call.api;
|
|
62
|
+
dataTable.insertRow(ctx, {filePath: this.filePath, apiName, replacement: call.replacement});
|
|
63
|
+
return foundSearchResult(m, `Deprecated API: ${apiName}`);
|
|
124
64
|
}
|
|
125
65
|
}());
|
|
126
66
|
}
|
|
@@ -11,21 +11,6 @@ class ElementRefRow {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Finds direct access of `element.ref` on React elements.
|
|
15
|
-
*
|
|
16
|
-
* In React 19, `element.ref` is deprecated and will be removed in a future version.
|
|
17
|
-
* Use `element.props.ref` instead.
|
|
18
|
-
*
|
|
19
|
-
* Before:
|
|
20
|
-
* ```tsx
|
|
21
|
-
* const ref = element.ref;
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* After (manual fix):
|
|
25
|
-
* ```tsx
|
|
26
|
-
* const ref = element.props.ref;
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
14
|
* @see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#deprecated-element-ref
|
|
30
15
|
*/
|
|
31
16
|
export class FindElementRef extends Recipe {
|
|
@@ -14,18 +14,6 @@ class LegacyContextRow {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Finds usage of the legacy Context API that was removed in React 19.
|
|
18
|
-
*
|
|
19
|
-
* Detects:
|
|
20
|
-
* - `static contextTypes = { ... }` in class components
|
|
21
|
-
* - `Component.contextTypes = { ... }` static assignments
|
|
22
|
-
* - `static childContextTypes = { ... }` in class components
|
|
23
|
-
* - `Component.childContextTypes = { ... }` static assignments
|
|
24
|
-
* - `getChildContext()` method definitions in class components
|
|
25
|
-
*
|
|
26
|
-
* These should be migrated to `React.createContext()` with the
|
|
27
|
-
* `<Context.Provider>` / `useContext()` API.
|
|
28
|
-
*
|
|
29
17
|
* @see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-removing-legacy-context
|
|
30
18
|
*/
|
|
31
19
|
export class FindLegacyContextAPI extends Recipe {
|
|
@@ -24,30 +24,12 @@ function returnsFunction(body: J): boolean {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Converts implicit returns in ref callbacks to block bodies.
|
|
28
|
-
*
|
|
29
|
-
* In React 19, ref callbacks can return a cleanup function.
|
|
30
|
-
* Arrow functions with expression bodies implicitly return a value,
|
|
31
|
-
* which React would incorrectly interpret as a cleanup function.
|
|
32
|
-
*
|
|
33
|
-
* Before:
|
|
34
|
-
* ```tsx
|
|
35
|
-
* <div ref={current => (instance = current)} />
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* After:
|
|
39
|
-
* ```tsx
|
|
40
|
-
* <div ref={current => { instance = current; }} />
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* A body that returns a function is left alone, since React 19 runs that function as the ref's cleanup.
|
|
44
|
-
*
|
|
45
27
|
* @see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#ref-cleanup-required
|
|
46
28
|
*/
|
|
47
29
|
export class NoImplicitRefCallbackReturn extends Recipe {
|
|
48
30
|
readonly name = "org.openrewrite.react.19.no-implicit-ref-callback-return";
|
|
49
31
|
readonly displayName: string = "Remove implicit ref callback returns";
|
|
50
|
-
readonly description: string = "In React 19, ref callbacks can return cleanup functions. Arrow functions with expression bodies implicitly return values, which React would interpret as cleanup functions. This recipe wraps them in block bodies.";
|
|
32
|
+
readonly description: string = "In React 19, ref callbacks can return cleanup functions. Arrow functions with expression bodies implicitly return values, which React would interpret as cleanup functions. This recipe wraps them in block bodies. A body that returns a function is left alone, since React 19 runs that function as the ref's cleanup.";
|
|
51
33
|
|
|
52
34
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
53
35
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
@@ -4,25 +4,6 @@ import {isIdentifier, J, Type} from "@openrewrite/rewrite/java";
|
|
|
4
4
|
import {JS, JSX} from "@openrewrite/rewrite/javascript";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Removes `.Provider` from Context JSX elements.
|
|
8
|
-
*
|
|
9
|
-
* In React 19, `<Context.Provider>` is deprecated in favor of
|
|
10
|
-
* rendering `<Context>` directly as a provider.
|
|
11
|
-
*
|
|
12
|
-
* Before:
|
|
13
|
-
* ```tsx
|
|
14
|
-
* <ThemeContext.Provider value={theme}>
|
|
15
|
-
* {children}
|
|
16
|
-
* </ThemeContext.Provider>
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* After:
|
|
20
|
-
* ```tsx
|
|
21
|
-
* <ThemeContext value={theme}>
|
|
22
|
-
* {children}
|
|
23
|
-
* </ThemeContext>
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
7
|
* @see https://react.dev/blog/2024/12/05/react-19#context-as-a-provider
|
|
27
8
|
*/
|
|
28
9
|
export class RemoveContextProvider extends Recipe {
|
|
@@ -92,10 +73,5 @@ export class RemoveContextProvider extends Recipe {
|
|
|
92
73
|
|
|
93
74
|
/** Only React contexts have the React 19 provider shorthand. */
|
|
94
75
|
function isReactContext(type: Type | undefined): boolean {
|
|
95
|
-
|
|
96
|
-
return isReactContext((type as Type.Parameterized).type);
|
|
97
|
-
}
|
|
98
|
-
if (type?.kind !== Type.Kind.Class && type?.kind !== Type.Kind.ShallowClass) return false;
|
|
99
|
-
const name = (type as Type.Class).fullyQualifiedName;
|
|
100
|
-
return name === 'React.Context' || name === 'react.Context';
|
|
76
|
+
return Type.isOfTypeWithName(type, false, name => name === 'React.Context' || name === 'react.Context');
|
|
101
77
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
capture,
|
|
4
4
|
fromRecipe,
|
|
5
5
|
JavaScriptVisitor,
|
|
6
|
-
|
|
6
|
+
maybeUnbind,
|
|
7
7
|
pattern,
|
|
8
8
|
rewrite,
|
|
9
9
|
template,
|
|
@@ -14,21 +14,6 @@ import {Expression, J} from "@openrewrite/rewrite/java";
|
|
|
14
14
|
import {SimplifyObjectPatternProperty} from "../simplify-object-pattern-property";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Replaces `forwardRef` wrappers with a function component that takes `ref` as a prop.
|
|
18
|
-
*
|
|
19
|
-
* In React 19, function components receive `ref` as a regular prop, so
|
|
20
|
-
* `forwardRef` is no longer needed.
|
|
21
|
-
*
|
|
22
|
-
* Before:
|
|
23
|
-
* ```tsx
|
|
24
|
-
* const Input = forwardRef((props, ref) => <input ref={ref} {...props} />);
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* After:
|
|
28
|
-
* ```tsx
|
|
29
|
-
* const Input = ({ ref, ...props }) => <input ref={ref} {...props} />;
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
17
|
* @see https://react.dev/blog/2024/12/05/react-19#ref-as-a-prop
|
|
33
18
|
*/
|
|
34
19
|
export class RemoveForwardRef extends Recipe {
|
|
@@ -83,8 +68,8 @@ export class RemoveForwardRef extends Recipe {
|
|
|
83
68
|
.andThen(fromRecipe(new SimplifyObjectPatternProperty(), p))
|
|
84
69
|
.tryOn(this.cursor, m!);
|
|
85
70
|
if (result) {
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
maybeUnbind(this, {module: "react", member: "default"});
|
|
72
|
+
maybeUnbind(this, {module: "react", member: "forwardRef"});
|
|
88
73
|
|
|
89
74
|
return result;
|
|
90
75
|
}
|
|
@@ -4,30 +4,6 @@ import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
|
4
4
|
import {create} from "mutative";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Removes `Component.propTypes` assignments.
|
|
8
|
-
*
|
|
9
|
-
* In React 19, PropTypes are silently ignored at runtime.
|
|
10
|
-
* This recipe removes the `propTypes` assignments to clean up code.
|
|
11
|
-
*
|
|
12
|
-
* Before:
|
|
13
|
-
* ```tsx
|
|
14
|
-
* import PropTypes from 'prop-types';
|
|
15
|
-
*
|
|
16
|
-
* function Greeting({name}) {
|
|
17
|
-
* return <div>Hello {name}</div>;
|
|
18
|
-
* }
|
|
19
|
-
* Greeting.propTypes = {
|
|
20
|
-
* name: PropTypes.string.isRequired
|
|
21
|
-
* };
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* After:
|
|
25
|
-
* ```tsx
|
|
26
|
-
* function Greeting({name}) {
|
|
27
|
-
* return <div>Hello {name}</div>;
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
7
|
* @see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-proptypes-and-defaultprops
|
|
32
8
|
*/
|
|
33
9
|
export class RemovePropTypes extends Recipe {
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
pattern,
|
|
6
6
|
rewrite,
|
|
7
7
|
template,
|
|
8
|
-
|
|
8
|
+
maybeUnbind,
|
|
9
9
|
isVendoredOrBundled
|
|
10
10
|
} from "@openrewrite/rewrite/javascript";
|
|
11
11
|
import {Expression, J, singleSpace, emptySpace} from "@openrewrite/rewrite/java";
|
|
@@ -105,8 +105,8 @@ export class RemoveReactFC extends Recipe {
|
|
|
105
105
|
: arrowFn;
|
|
106
106
|
|
|
107
107
|
// Remove the type expression and update the initializer
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
maybeUnbind(this, {module: "react", member: "FC"});
|
|
109
|
+
maybeUnbind(this, {module: "react", member: "FunctionComponent"});
|
|
110
110
|
|
|
111
111
|
const updatedVarDecl: J.VariableDeclarations = {
|
|
112
112
|
...v,
|
|
@@ -1,64 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {JavaScriptVisitor, JS,
|
|
3
|
-
import {
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, and, check, not} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, JS, MethodMatcher, maybeUnbind, isVendoredOrBundled, usesMethod} from "@openrewrite/rewrite/javascript";
|
|
3
|
+
import {J, Statement} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {create} from "mutative";
|
|
5
5
|
import {reindent} from "../util/reindent";
|
|
6
6
|
|
|
7
7
|
const REACT_DOM = "react-dom";
|
|
8
8
|
const BATCHED_UPDATES = "unstable_batchedUpdates";
|
|
9
|
+
const BATCHED_UPDATES_PATTERN = `${REACT_DOM} ${BATCHED_UPDATES}(..)`;
|
|
10
|
+
const BATCHED_UPDATES_CALL = new MethodMatcher(BATCHED_UPDATES_PATTERN);
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* making `unstable_batchedUpdates` unnecessary. This recipe
|
|
15
|
-
* unwraps the callback body and removes the wrapping call.
|
|
16
|
-
*
|
|
17
|
-
* Automatic batching only applies to roots created with `createRoot` or
|
|
18
|
-
* `hydrateRoot`; a legacy `ReactDOM.render` or `hydrate` root still needs the
|
|
19
|
-
* wrapper. React 19 removes the legacy APIs, so this recipe runs in the
|
|
20
|
-
* React 18 to 19 migration rather than the 17 to 18 one.
|
|
21
|
-
*
|
|
22
|
-
* Before:
|
|
23
|
-
* ```tsx
|
|
24
|
-
* import { unstable_batchedUpdates } from 'react-dom';
|
|
25
|
-
*
|
|
26
|
-
* unstable_batchedUpdates(() => {
|
|
27
|
-
* setCount(1);
|
|
28
|
-
* setFlag(true);
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* After:
|
|
33
|
-
* ```tsx
|
|
34
|
-
* setCount(1);
|
|
35
|
-
* setFlag(true);
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* Only calls that resolve to `react-dom` through an import or `require` are
|
|
39
|
-
* unwrapped, so a local helper of the same name and the `react-native` export
|
|
40
|
-
* are left alone. A call is also left in place, which is harmless in React 18,
|
|
41
|
-
* when the body would mean something else in the enclosing scope: it uses
|
|
42
|
-
* `return`, `this` or `arguments`, the callback is `async`, or the body declares
|
|
43
|
-
* a variable, function or class.
|
|
13
|
+
* Automatic batching only applies to roots created with `createRoot` or `hydrateRoot`; a legacy `ReactDOM.render`
|
|
14
|
+
* or `hydrate` root still needs the wrapper. React 19 removes the legacy APIs, so this runs in the React 18 to 19
|
|
15
|
+
* migration rather than the 17 to 18 one.
|
|
44
16
|
*
|
|
45
17
|
* @see https://react.dev/blog/2022/03/29/react-v18#new-feature-automatic-batching
|
|
46
18
|
*/
|
|
47
19
|
export class RemoveUnstableBatchedUpdates extends Recipe {
|
|
48
20
|
readonly name = "org.openrewrite.react.19.remove-unstable-batched-updates";
|
|
49
21
|
readonly displayName = "Remove `unstable_batchedUpdates`";
|
|
50
|
-
readonly description = "Removes `unstable_batchedUpdates` wrappers from `react-dom`. React 18 automatically batches all state updates on roots created with `createRoot` or `hydrateRoot`, the only roots React 19 supports, making this function unnecessary."
|
|
22
|
+
readonly description = "Removes `unstable_batchedUpdates` wrappers from `react-dom`. React 18 automatically batches all state updates on roots created with `createRoot` or `hydrateRoot`, the only roots React 19 supports, making this function unnecessary. " +
|
|
23
|
+
"A call is left in place, which is harmless, when its body would mean something else unwrapped: it uses `return`, `this` or `arguments`, the callback is `async`, or the body declares a variable, function or class.";
|
|
51
24
|
|
|
52
25
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
53
|
-
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
54
|
-
private changed = false;
|
|
55
|
-
private names: ReadonlySet<string> = new Set();
|
|
56
|
-
|
|
26
|
+
return check(and(not(isVendoredOrBundled()), usesMethod(BATCHED_UPDATES_PATTERN)), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
57
27
|
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
58
|
-
this.changed = false;
|
|
59
|
-
this.names = batchedUpdatesNames(cu);
|
|
60
|
-
if (this.names.size === 0 && moduleBindings(this).moduleSystem === "none") return cu;
|
|
61
|
-
|
|
62
28
|
let result = await super.visitJsCompilationUnit(cu, ctx) as JS.CompilationUnit;
|
|
63
29
|
|
|
64
30
|
const statements = await this.spliceStatements(result.statements);
|
|
@@ -68,8 +34,8 @@ export class RemoveUnstableBatchedUpdates extends Recipe {
|
|
|
68
34
|
});
|
|
69
35
|
}
|
|
70
36
|
|
|
71
|
-
if (
|
|
72
|
-
|
|
37
|
+
if (result !== cu) {
|
|
38
|
+
maybeUnbind(this, {module: REACT_DOM, member: BATCHED_UPDATES});
|
|
73
39
|
}
|
|
74
40
|
|
|
75
41
|
return result;
|
|
@@ -86,7 +52,6 @@ export class RemoveUnstableBatchedUpdates extends Recipe {
|
|
|
86
52
|
|
|
87
53
|
private async spliceStatements(statements: J.RightPadded<Statement>[]): Promise<J.RightPadded<Statement>[] | null> {
|
|
88
54
|
const newStatements: J.RightPadded<Statement>[] = [];
|
|
89
|
-
let changed = false;
|
|
90
55
|
|
|
91
56
|
for (const paddedStmt of statements) {
|
|
92
57
|
const stmt = paddedStmt.element;
|
|
@@ -102,11 +67,9 @@ export class RemoveUnstableBatchedUpdates extends Recipe {
|
|
|
102
67
|
const element = await reindent(bodyStmt.element, innerIndent, outerIndent);
|
|
103
68
|
newStatements.push({...bodyStmt, element: i === 0 ? {...element, prefix: joinPrefixes(stmt.prefix, element.prefix)} : element});
|
|
104
69
|
}
|
|
105
|
-
changed = true;
|
|
106
|
-
this.changed = true;
|
|
107
70
|
}
|
|
108
71
|
|
|
109
|
-
return
|
|
72
|
+
return newStatements.length === statements.length && newStatements.every((s, i) => s === statements[i]) ? null : newStatements;
|
|
110
73
|
}
|
|
111
74
|
|
|
112
75
|
private async extractBatchedUpdatesBody(stmt: Statement): Promise<J.RightPadded<Statement>[] | null> {
|
|
@@ -121,7 +84,7 @@ export class RemoveUnstableBatchedUpdates extends Recipe {
|
|
|
121
84
|
if (!expr || expr.kind !== J.Kind.MethodInvocation) return null;
|
|
122
85
|
|
|
123
86
|
const method = expr as J.MethodInvocation;
|
|
124
|
-
if (!
|
|
87
|
+
if (!BATCHED_UPDATES_CALL.matches(method.methodType)) return null;
|
|
125
88
|
|
|
126
89
|
const callback = method.arguments?.elements[0]?.element as J | undefined;
|
|
127
90
|
if (callback?.kind !== JS.Kind.ArrowFunction) return null;
|
|
@@ -213,83 +176,6 @@ class ScopeEscapeFinder extends JavaScriptVisitor<ExecutionContext> {
|
|
|
213
176
|
}
|
|
214
177
|
}
|
|
215
178
|
|
|
216
|
-
/**
|
|
217
|
-
* Local names of `unstable_batchedUpdates` that `react-dom` binds at the top level of the file:
|
|
218
|
-
* `import {unstable_batchedUpdates as batch}` and `const {unstable_batchedUpdates: batch} = require(...)`.
|
|
219
|
-
* Whole-module bindings (`import X`, `import * as X`, `const X = require(...)`) are
|
|
220
|
-
* `moduleBindings(...).moduleOf`'s to answer.
|
|
221
|
-
*/
|
|
222
|
-
function batchedUpdatesNames(cu: JS.CompilationUnit): Set<string> {
|
|
223
|
-
const names = new Set<string>();
|
|
224
|
-
for (const padded of cu.statements) {
|
|
225
|
-
const stmt = padded.element as J;
|
|
226
|
-
if (stmt.kind === JS.Kind.Import) {
|
|
227
|
-
const imp = stmt as JS.Import;
|
|
228
|
-
const named = imp.importClause?.namedBindings as J | undefined;
|
|
229
|
-
if (!isReactDomLiteral(unwrap(imp.moduleSpecifier)) || named?.kind !== JS.Kind.NamedImports) continue;
|
|
230
|
-
for (const el of (named as JS.NamedImports).elements.elements) {
|
|
231
|
-
const specifier = el.element.specifier as J;
|
|
232
|
-
if (isIdentifier(specifier)) {
|
|
233
|
-
if (specifier.simpleName === BATCHED_UPDATES) names.add(BATCHED_UPDATES);
|
|
234
|
-
} else if (specifier.kind === JS.Kind.Alias) {
|
|
235
|
-
const alias = specifier as JS.Alias;
|
|
236
|
-
const imported = alias.propertyName.element;
|
|
237
|
-
if (isIdentifier(imported) && imported.simpleName === BATCHED_UPDATES && isIdentifier(alias.alias)) {
|
|
238
|
-
names.add(alias.alias.simpleName);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
} else {
|
|
243
|
-
for (const decl of declarationsOf(stmt)) {
|
|
244
|
-
for (const v of decl.variables) {
|
|
245
|
-
if (!isRequireOfReactDom(unwrap(v.element.initializer as J | { element: J } | undefined))) continue;
|
|
246
|
-
for (const {name, member} of bindingNames(v.element.name as J)) {
|
|
247
|
-
if (member === BATCHED_UPDATES) names.add(name);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return names;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Whether the call is `react-dom`'s `unstable_batchedUpdates`: its callee resolves to the
|
|
258
|
-
* compilation unit, so a parameter or local of the same name does not count.
|
|
259
|
-
*/
|
|
260
|
-
function isBatchedUpdatesCall(visitor: JavaScriptVisitor<ExecutionContext>, names: ReadonlySet<string>, cursor: Cursor, method: J.MethodInvocation): boolean {
|
|
261
|
-
const select = method.select ? unwrap(method.select as J | { element: J }) : undefined;
|
|
262
|
-
if (!select) {
|
|
263
|
-
return names.has(method.name.simpleName) && resolvesToFile(cursor, method.name);
|
|
264
|
-
}
|
|
265
|
-
return method.name.simpleName === BATCHED_UPDATES
|
|
266
|
-
&& isIdentifier(select)
|
|
267
|
-
&& moduleBindings(visitor).moduleOf(select.simpleName) === REACT_DOM
|
|
268
|
-
&& resolvesToFile(cursor, select);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function resolvesToFile(cursor: Cursor, identifier: J.Identifier): boolean {
|
|
272
|
-
return resolve(new Cursor(identifier, cursor), identifier)?.kind === JS.Kind.CompilationUnit;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function isReactDomLiteral(expr: unknown): boolean {
|
|
276
|
-
const literal = expr as J.Literal | undefined;
|
|
277
|
-
return literal?.kind === J.Kind.Literal && literal.value === REACT_DOM;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function isRequireOfReactDom(expr: J | undefined): boolean {
|
|
281
|
-
if (expr?.kind !== J.Kind.MethodInvocation) return false;
|
|
282
|
-
const call = expr as J.MethodInvocation;
|
|
283
|
-
return !call.select
|
|
284
|
-
&& call.name.simpleName === "require"
|
|
285
|
-
&& isReactDomLiteral(call.arguments.elements[0]?.element);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/** LST fields are sometimes wrapped in a `LeftPadded`/`RightPadded`; reads the node either way. */
|
|
289
|
-
function unwrap<T>(value: T | { element: T } | undefined): T | undefined {
|
|
290
|
-
return value && typeof value === "object" && "element" in value ? value.element : value as T | undefined;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
179
|
/** The call's line break and comments, then those of the first statement that replaces it. */
|
|
294
180
|
function joinPrefixes(call: J.Space, first: J.Space): J.Space {
|
|
295
181
|
return {...call, comments: [...call.comments, ...first.comments]};
|
|
@@ -1,29 +1,17 @@
|
|
|
1
1
|
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
2
|
import {JavaScriptVisitor, JS, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J, singleSpace} from "@openrewrite/rewrite/java";
|
|
4
|
+
import {reactFunction, typedOrNamedCall} from "../util/react-matchers";
|
|
5
|
+
|
|
6
|
+
const CREATE_FACTORY = typedOrNamedCall(reactFunction("createFactory"), "React", "createFactory");
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
|
-
*
|
|
7
|
-
* `React.createElement(type, props, children)`.
|
|
8
|
-
*
|
|
9
|
-
* `React.createFactory` was deprecated in React 15.6 and removed in React 16.
|
|
10
|
-
* This recipe handles the case where the factory is immediately invoked inline
|
|
11
|
-
* (chained call), transforming it into the equivalent `createElement` call.
|
|
12
|
-
*
|
|
13
|
-
* Before:
|
|
14
|
-
* ```tsx
|
|
15
|
-
* const el = React.createFactory('div')({className: 'foo'}, 'Hello');
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* After:
|
|
19
|
-
* ```tsx
|
|
20
|
-
* const el = React.createElement('div', {className: 'foo'}, 'Hello');
|
|
21
|
-
* ```
|
|
9
|
+
* @see https://legacy.reactjs.org/blog/2020/02/26/react-v16.13.0.html#deprecating-reactcreatefactory
|
|
22
10
|
*/
|
|
23
11
|
export class ReplaceCreateFactory extends Recipe {
|
|
24
|
-
readonly name = "org.openrewrite.react.
|
|
12
|
+
readonly name = "org.openrewrite.react.19.replace-create-factory";
|
|
25
13
|
readonly displayName: string = "Replace `React.createFactory` with `React.createElement`";
|
|
26
|
-
readonly description: string = "Replaces `React.createFactory(type)(props, children)` with `React.createElement(type, props, children)`. React.createFactory was deprecated in React
|
|
14
|
+
readonly description: string = "Replaces `React.createFactory(type)(props, children)` with `React.createElement(type, props, children)`. `React.createFactory` was deprecated in React 16.13 and removed in React 19. Only a factory that is called right away is replaced.";
|
|
27
15
|
|
|
28
16
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
29
17
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
@@ -37,9 +25,8 @@ export class ReplaceCreateFactory extends Recipe {
|
|
|
37
25
|
if (callee.kind !== J.Kind.MethodInvocation) return fc;
|
|
38
26
|
const innerCall = callee as J.MethodInvocation;
|
|
39
27
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (!innerCall.select) return fc;
|
|
28
|
+
// Without a receiver, the `createElement` the result would call is not imported
|
|
29
|
+
if (!innerCall.select || !CREATE_FACTORY(innerCall)) return fc;
|
|
43
30
|
|
|
44
31
|
const innerArgs = innerCall.arguments?.elements;
|
|
45
32
|
if (!innerArgs || innerArgs.length !== 1) return fc;
|
|
@@ -2,7 +2,7 @@ import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/re
|
|
|
2
2
|
import {
|
|
3
3
|
capture,
|
|
4
4
|
JavaScriptVisitor,
|
|
5
|
-
|
|
5
|
+
maybeUnbind,
|
|
6
6
|
pattern,
|
|
7
7
|
rewrite,
|
|
8
8
|
template,
|
|
@@ -11,23 +11,6 @@ import {
|
|
|
11
11
|
import {Expression, J} from "@openrewrite/rewrite/java";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Replaces `ReactDOM.hydrate()` with `hydrateRoot()`.
|
|
15
|
-
*
|
|
16
|
-
* In React 18+, `ReactDOM.hydrate()` is deprecated in favor of
|
|
17
|
-
* `hydrateRoot()` from `react-dom/client`.
|
|
18
|
-
*
|
|
19
|
-
* Before:
|
|
20
|
-
* ```tsx
|
|
21
|
-
* import ReactDOM from 'react-dom';
|
|
22
|
-
* ReactDOM.hydrate(<App />, document.getElementById('root'));
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* After:
|
|
26
|
-
* ```tsx
|
|
27
|
-
* import { hydrateRoot } from 'react-dom/client';
|
|
28
|
-
* hydrateRoot(document.getElementById('root'), <App />);
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
14
|
* @see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-reactdom-hydrate
|
|
32
15
|
*/
|
|
33
16
|
export class ReplaceReactDomHydrate extends Recipe {
|
|
@@ -58,7 +41,7 @@ export class ReplaceReactDomHydrate extends Recipe {
|
|
|
58
41
|
|
|
59
42
|
const result = await rule.tryOn(this.cursor, m!, {visitor: this});
|
|
60
43
|
if (result) {
|
|
61
|
-
|
|
44
|
+
maybeUnbind(this, {module: "react-dom", member: "hydrate"});
|
|
62
45
|
return result;
|
|
63
46
|
}
|
|
64
47
|
|
|
@@ -4,20 +4,6 @@ import {J} from "@openrewrite/rewrite/java";
|
|
|
4
4
|
import {JS, JSX} from "@openrewrite/rewrite/javascript";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Replaces deprecated string refs with callback refs.
|
|
8
|
-
*
|
|
9
|
-
* String refs have been deprecated in React and are removed in React 19.
|
|
10
|
-
*
|
|
11
|
-
* Before:
|
|
12
|
-
* ```tsx
|
|
13
|
-
* <input ref="myInput" />
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* After:
|
|
17
|
-
* ```tsx
|
|
18
|
-
* <input ref={(ref) => { this.myInput = ref; }} />
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
7
|
* @see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-string-refs
|
|
22
8
|
*/
|
|
23
9
|
export class ReplaceStringRef extends Recipe {
|