@openrewrite/recipes-react 0.26.0 → 0.28.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.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 +2 -27
- 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,5 +1,5 @@
|
|
|
1
1
|
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
-
import {isObjectLiteral, isTypeScript, isVendoredOrBundled, JavaScriptVisitor, JS,
|
|
2
|
+
import {isObjectLiteral, isTypeScript, isVendoredOrBundled, JavaScriptVisitor, JS, maybeBind, raw, template} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {emptySpace, J, singleSpace} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
/** `PropTypes.<name>` validators with a fixed TypeScript type, and the `react` type each one needs. */
|
|
@@ -208,41 +208,10 @@ async function identifierNames(cu: JS.CompilationUnit): Promise<Set<string>> {
|
|
|
208
208
|
return names;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
/**
|
|
212
|
-
* Declares a props type from `Component.propTypes` and annotates the component's parameter with it.
|
|
213
|
-
*
|
|
214
|
-
* Before:
|
|
215
|
-
* ```tsx
|
|
216
|
-
* function Greeting({name, onDone}) { ... }
|
|
217
|
-
* Greeting.propTypes = {
|
|
218
|
-
* name: PropTypes.string.isRequired,
|
|
219
|
-
* onDone: PropTypes.func,
|
|
220
|
-
* };
|
|
221
|
-
* ```
|
|
222
|
-
*
|
|
223
|
-
* After:
|
|
224
|
-
* ```tsx
|
|
225
|
-
* interface GreetingProps {
|
|
226
|
-
* name: string;
|
|
227
|
-
* onDone?: (...args: any[]) => any;
|
|
228
|
-
* }
|
|
229
|
-
*
|
|
230
|
-
* function Greeting({name, onDone}: GreetingProps) { ... }
|
|
231
|
-
* Greeting.propTypes = { ... };
|
|
232
|
-
* ```
|
|
233
|
-
*
|
|
234
|
-
* The `propTypes` assignment is kept, so the runtime checks still run; follow with `RemovePropTypes`
|
|
235
|
-
* when they are no longer wanted. A component is converted only when it is a function declaration or
|
|
236
|
-
* an arrow function assigned to a `const`, its first parameter has no type, and every `propTypes`
|
|
237
|
-
* entry maps to a TypeScript type (an optional prop also admits `null`, as `PropTypes` does, and
|
|
238
|
-
* `PropTypes.object` becomes `Record<string, any>`). A component that reads a prop `propTypes` does not
|
|
239
|
-
* declare, such as `children`, is left alone, since the interface would not cover it. Anything else is left alone. Only `.ts` and `.tsx` files
|
|
240
|
-
* are changed.
|
|
241
|
-
*/
|
|
242
211
|
export class PropTypesToTypeScript extends Recipe {
|
|
243
212
|
readonly name = "org.openrewrite.react.refactoring.prop-types-to-typescript";
|
|
244
213
|
readonly displayName = "Convert `propTypes` to a TypeScript props type";
|
|
245
|
-
readonly description = "Declares an `interface` from a function component's `propTypes` and annotates the component's props parameter with it, keeping the `propTypes` assignment. Components with an unsupported `propTypes` entry are left alone.";
|
|
214
|
+
readonly description = "Declares an `interface` from a function component's `propTypes` and annotates the component's props parameter with it, keeping the `propTypes` assignment. Components with an unsupported `propTypes` entry are left alone, as is one that reads a prop `propTypes` does not declare, such as `children`. Only function declarations and arrow functions assigned to a `const` in `.ts` and `.tsx` files, whose props parameter has no type yet, are converted.";
|
|
246
215
|
|
|
247
216
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
248
217
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
@@ -286,7 +255,7 @@ export class PropTypesToTypeScript extends Recipe {
|
|
|
286
255
|
{...original, element: {...declared, prefix: {...space, comments: []}}, markers: {...original.markers, markers: []}},
|
|
287
256
|
{...original, element: {...typed, prefix: {...space, whitespace: "\n\n"}}});
|
|
288
257
|
}
|
|
289
|
-
reactTypes.forEach(member =>
|
|
258
|
+
reactTypes.forEach(member => maybeBind(this, {module: 'react', member, onlyIfReferenced: false}));
|
|
290
259
|
return {...cu, statements} as JS.CompilationUnit;
|
|
291
260
|
}
|
|
292
261
|
|
|
@@ -1,30 +1,8 @@
|
|
|
1
1
|
import {Cursor, ExecutionContext, findMarker, Marker, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
-
import {isObjectLiteral, JavaScriptVisitor, JS,
|
|
2
|
+
import {isObjectLiteral, JavaScriptVisitor, JS, maybeUnbind, template, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J, TextComment} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Removes `PureRenderMixin` from `React.createClass` components and replaces it
|
|
7
|
-
* with an explicit `shouldComponentUpdate` method using `shallowCompare`.
|
|
8
|
-
*
|
|
9
|
-
* Before:
|
|
10
|
-
* ```tsx
|
|
11
|
-
* var PureRenderMixin = require('react-addons-pure-render-mixin');
|
|
12
|
-
* var MyComponent = React.createClass({
|
|
13
|
-
* mixins: [PureRenderMixin],
|
|
14
|
-
* render() { return <div />; }
|
|
15
|
-
* });
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* After:
|
|
19
|
-
* ```tsx
|
|
20
|
-
* var MyComponent = React.createClass({
|
|
21
|
-
* shouldComponentUpdate(nextProps, nextState) {
|
|
22
|
-
* return React.addons.shallowCompare(this, nextProps, nextState);
|
|
23
|
-
* },
|
|
24
|
-
* render() { return <div />; }
|
|
25
|
-
* });
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
6
|
* @see https://github.com/reactjs/react-codemod#pure-render-mixin
|
|
29
7
|
*/
|
|
30
8
|
export class PureRenderMixin extends Recipe {
|
|
@@ -34,13 +12,10 @@ export class PureRenderMixin extends Recipe {
|
|
|
34
12
|
|
|
35
13
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
36
14
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
37
|
-
private transformed = false;
|
|
38
|
-
|
|
39
15
|
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
40
|
-
this.transformed = false;
|
|
41
16
|
const result = await super.visitJsCompilationUnit(cu, ctx);
|
|
42
|
-
if (
|
|
43
|
-
|
|
17
|
+
if (result !== cu) {
|
|
18
|
+
maybeUnbind(this, {module: "react-addons-pure-render-mixin", member: "default"});
|
|
44
19
|
}
|
|
45
20
|
return result;
|
|
46
21
|
}
|
|
@@ -76,8 +51,6 @@ export class PureRenderMixin extends Recipe {
|
|
|
76
51
|
scuMethod
|
|
77
52
|
);
|
|
78
53
|
|
|
79
|
-
this.transformed = true;
|
|
80
|
-
|
|
81
54
|
// Return updated method invocation with modified spec object
|
|
82
55
|
return {
|
|
83
56
|
...m,
|
|
@@ -31,22 +31,12 @@ const LIFECYCLE_METHODS = [
|
|
|
31
31
|
];
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Reorders React component methods to match ESLint `react/sort-comp` ordering.
|
|
35
|
-
*
|
|
36
|
-
* Default order:
|
|
37
|
-
* 1. Static methods and properties
|
|
38
|
-
* 2. Lifecycle methods
|
|
39
|
-
* 3. Event handlers (on*)
|
|
40
|
-
* 4. Getter/setter methods
|
|
41
|
-
* 5. Other instance methods
|
|
42
|
-
* 6. render()
|
|
43
|
-
*
|
|
44
34
|
* @see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
|
|
45
35
|
*/
|
|
46
36
|
export class SortComp extends Recipe {
|
|
47
37
|
readonly name = "org.openrewrite.react.refactoring.sort-comp";
|
|
48
38
|
readonly displayName: string = "Sort React component methods";
|
|
49
|
-
readonly description: string = "Reorders React component methods to follow the recommended lifecycle ordering convention
|
|
39
|
+
readonly description: string = "Reorders React component methods to follow the recommended lifecycle ordering convention of ESLint's `react/sort-comp`: statics, lifecycle methods, `on*` event handlers, getters and setters, other methods, then `render`.";
|
|
50
40
|
|
|
51
41
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
52
42
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Column, DataTable, ExecutionContext, foundSearchResult, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
2
|
import {isVendoredOrBundled, JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
|
-
import {
|
|
4
|
+
import {extendsReactComponent} from "../util/react-class";
|
|
5
5
|
|
|
6
6
|
class DeprecatedLifecycleRow {
|
|
7
7
|
@Column({displayName: "File path", description: "The file where the lifecycle is declared"})
|
|
@@ -23,15 +23,12 @@ export const DEPRECATED_LIFECYCLE_STEP = 'org.openrewrite.react.migrate.react-16
|
|
|
23
23
|
export const DEPRECATED_LIFECYCLE_MIGRATORS = ['org.openrewrite.react.17.rename-unsafe-lifecycles', 'org.openrewrite.react.17.migrate-deprecated-lifecycles'];
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Finds the `componentWillMount`, `componentWillReceiveProps` and `componentWillUpdate` lifecycles declared on a class
|
|
27
|
-
* component. The `UNSAFE_` forms are not reported, since they are what the migration produces.
|
|
28
|
-
*
|
|
29
26
|
* @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html
|
|
30
27
|
*/
|
|
31
28
|
export class FindDeprecatedLifecycles extends Recipe {
|
|
32
29
|
readonly name = "org.openrewrite.react.search.find-deprecated-lifecycles";
|
|
33
30
|
readonly displayName = "Find deprecated component lifecycles";
|
|
34
|
-
readonly description = "Finds `componentWillMount`, `componentWillReceiveProps` and `componentWillUpdate` on class components, and records the step recipe that migrates them in a data table.";
|
|
31
|
+
readonly description = "Finds `componentWillMount`, `componentWillReceiveProps` and `componentWillUpdate` on class components, and records the step recipe that migrates them in a data table. The `UNSAFE_` forms are not reported, since they are what the migration produces.";
|
|
35
32
|
|
|
36
33
|
private dataTable = new DataTable<DeprecatedLifecycleRow>(
|
|
37
34
|
"org.openrewrite.react.search.DeprecatedLifecyclesTable",
|
|
@@ -55,7 +52,7 @@ export class FindDeprecatedLifecycles extends Recipe {
|
|
|
55
52
|
const m = await super.visitMethodDeclaration(method, ctx) as J.MethodDeclaration;
|
|
56
53
|
if (!DEPRECATED_LIFECYCLES.has(m.name.simpleName)) return m;
|
|
57
54
|
const owner = this.cursor.firstEnclosing((n: any): n is J.ClassDeclaration => n?.kind === J.Kind.ClassDeclaration);
|
|
58
|
-
if (!owner || !
|
|
55
|
+
if (!owner || !extendsReactComponent(owner)) return m;
|
|
59
56
|
dataTable.insertRow(ctx, {filePath: this.filePath, className: owner.name.simpleName, lifecycle: m.name.simpleName, upgradeStep: DEPRECATED_LIFECYCLE_STEP});
|
|
60
57
|
return foundSearchResult(m, m.name.simpleName) as J.MethodDeclaration;
|
|
61
58
|
}
|
|
@@ -2,6 +2,7 @@ import {Column, DataTable, ExecutionContext, foundSearchResult, Recipe, TreeVisi
|
|
|
2
2
|
import {JavaScriptVisitor, JS, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {firstResult} from "../util/tree-search";
|
|
5
|
+
import {reactFunction} from "../util/react-matchers";
|
|
5
6
|
|
|
6
7
|
class EffectRow {
|
|
7
8
|
@Column({displayName: "File path", description: "The file containing the effect"})
|
|
@@ -14,7 +15,7 @@ class EffectRow {
|
|
|
14
15
|
call!: string;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
const EFFECT_HOOKS =
|
|
18
|
+
const EFFECT_HOOKS = [reactFunction("useEffect"), reactFunction("useLayoutEffect")];
|
|
18
19
|
/** Calls that register something that must be undone, so an effect that makes one needs a cleanup. */
|
|
19
20
|
const SETUP_CALLS = new Set(['addEventListener', 'setInterval', 'subscribe', 'observe', 'addListener', 'on', 'connect']);
|
|
20
21
|
|
|
@@ -53,18 +54,10 @@ const returnsValue = async (body: J): Promise<boolean> => {
|
|
|
53
54
|
return found;
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
/**
|
|
57
|
-
* Finds effects that register a listener, timer or subscription but return no cleanup function.
|
|
58
|
-
*
|
|
59
|
-
* React 18's `StrictMode` runs every effect's setup, cleanup and setup again in development, so an
|
|
60
|
-
* effect without a cleanup registers twice and exposes leaks and double subscriptions. This is a
|
|
61
|
-
* heuristic over call names: only effects with a block-bodied arrow function callback are considered,
|
|
62
|
-
* and an effect whose callback returns a value anywhere outside nested functions counts as having a cleanup.
|
|
63
|
-
*/
|
|
64
57
|
export class FindEffectsWithoutCleanup extends Recipe {
|
|
65
58
|
readonly name = "org.openrewrite.react.search.find-effects-without-cleanup";
|
|
66
59
|
readonly displayName = "Find effects that subscribe without cleanup";
|
|
67
|
-
readonly description = "Finds `useEffect` and `useLayoutEffect` callbacks that add an event listener, interval, observer or subscription but return no cleanup function, which React 18 `StrictMode` surfaces by running effects twice in development.";
|
|
60
|
+
readonly description = "Finds `useEffect` and `useLayoutEffect` callbacks that add an event listener, interval, observer or subscription but return no cleanup function, which React 18 `StrictMode` surfaces by running effects twice in development. It is a heuristic over call names: only callbacks that are block-bodied arrow functions are checked, and one that returns a value anywhere outside nested functions counts as having a cleanup.";
|
|
68
61
|
|
|
69
62
|
private dataTable = new DataTable<EffectRow>(
|
|
70
63
|
"org.openrewrite.react.search.EffectsWithoutCleanupTable",
|
|
@@ -86,11 +79,8 @@ export class FindEffectsWithoutCleanup extends Recipe {
|
|
|
86
79
|
|
|
87
80
|
override async visitMethodInvocation(method: J.MethodInvocation, ctx: ExecutionContext): Promise<J | undefined> {
|
|
88
81
|
const m = await super.visitMethodInvocation(method, ctx) as J.MethodInvocation;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// Only the bare hook or `React.useEffect`; `scheduler.useEffect` is something else.
|
|
92
|
-
const select = m.select?.element;
|
|
93
|
-
if (select && !(select.kind === J.Kind.Identifier && (select as J.Identifier).simpleName === 'React')) return m;
|
|
82
|
+
if (!EFFECT_HOOKS.some(matcher => matcher.matches(m.methodType))) return m;
|
|
83
|
+
const hook = m.methodType!.name;
|
|
94
84
|
|
|
95
85
|
const callback = m.arguments.elements[0]?.element;
|
|
96
86
|
if (callback?.kind !== JS.Kind.ArrowFunction) return m;
|
|
@@ -121,9 +121,6 @@ export function importAction(locals: readonly string[], references: ReadonlyMap<
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
|
-
* Inventories imports/setup even when types are unavailable; calls and wrapper fields are
|
|
125
|
-
* attributed to Enzyme by declaring type, not by names such as `find` or `state`.
|
|
126
|
-
*
|
|
127
124
|
* @see https://testing-library.com/docs/react-testing-library/migrate-from-enzyme/#how-to-migrate-from-enzyme-to-react-testing-library
|
|
128
125
|
*/
|
|
129
126
|
export class FindEnzymeUsage extends Recipe {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Column, DataTable, ExecutionContext, foundSearchResult, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
2
|
import {isVendoredOrBundled, JavaScriptVisitor, JS, referencesOf} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
|
-
import {
|
|
4
|
+
import {extendsReactComponent} from "../util/react-class";
|
|
5
5
|
|
|
6
6
|
class DefaultPropsRow {
|
|
7
7
|
@Column({displayName: "File path", description: "The file where `defaultProps` is assigned"})
|
|
@@ -18,16 +18,12 @@ export const DEFAULT_PROPS_STEP = 'org.openrewrite.react.migrate.react-18-to-19'
|
|
|
18
18
|
export const DEFAULT_PROPS_MIGRATOR = 'org.openrewrite.react.19.replace-default-props';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Finds `Component.defaultProps = ...` on a component that is not a class declared in the same file. React 19 removed
|
|
22
|
-
* `defaultProps` for function components only; a class component keeps it. The receiver must be capitalized, so
|
|
23
|
-
* `Object.keys(schema.defaultProps)` is not reported.
|
|
24
|
-
*
|
|
25
21
|
* @see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-proptypes-and-defaultprops
|
|
26
22
|
*/
|
|
27
23
|
export class FindFunctionComponentDefaultProps extends Recipe {
|
|
28
24
|
readonly name = "org.openrewrite.react.search.find-function-component-default-props";
|
|
29
25
|
readonly displayName = "Find `defaultProps` on function components";
|
|
30
|
-
readonly description = "Finds assignments to `defaultProps` on a function component, which React 19 removed, and records the step recipe that migrates them in a data table.";
|
|
26
|
+
readonly description = "Finds assignments to `defaultProps` on a function component, which React 19 removed, and records the step recipe that migrates them in a data table. A class declared in the same file keeps its `defaultProps`, and a lowercase receiver such as `schema.defaultProps` is not reported.";
|
|
31
27
|
|
|
32
28
|
private dataTable = new DataTable<DefaultPropsRow>(
|
|
33
29
|
"org.openrewrite.react.search.FunctionComponentDefaultPropsTable",
|
|
@@ -50,7 +46,7 @@ export class FindFunctionComponentDefaultProps extends Recipe {
|
|
|
50
46
|
/** Resolved rather than matched by name, so a parameter or local that shadows a class component still counts. */
|
|
51
47
|
private isClassComponent(name: string): boolean {
|
|
52
48
|
const declaration = referencesOf(this.cursor, name, 'value').find(r => r.declares)?.cursor.parent?.value;
|
|
53
|
-
return declaration?.kind === J.Kind.ClassDeclaration &&
|
|
49
|
+
return declaration?.kind === J.Kind.ClassDeclaration && extendsReactComponent(declaration as J.ClassDeclaration);
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
override async visitFieldAccess(fieldAccess: J.FieldAccess, ctx: ExecutionContext): Promise<J | undefined> {
|
|
@@ -256,15 +256,6 @@ const IDENTIFIER_LIKE = /^(?:[a-z]+(?:[A-Z][a-z\d]*)+|[a-z\d]+(?:_[a-z\d]+)+|[A-
|
|
|
256
256
|
const ENTITY = /&(?:#\d+|#x[\da-f]+|[a-z][a-z\d]*);/gi;
|
|
257
257
|
const URL_EMAIL_DOMAIN_OR_PATH = /^(?:[a-z][\w+.-]*:\/\/\S*|[^\s@]+@[^\s@]+\.[^\s@]+|\.?[\w-]+(?:\.[\w-]+)+\/?|\/[\w./-]*|#[\da-f]{3,8})$/i;
|
|
258
258
|
|
|
259
|
-
/**
|
|
260
|
-
* Finds hard-coded strings that React components render to users, as a first step toward internationalization.
|
|
261
|
-
*
|
|
262
|
-
* @example
|
|
263
|
-
* <h1>Welcome</h1> // found: TEXT
|
|
264
|
-
* <img alt="Company logo" /> // found: ATTRIBUTE
|
|
265
|
-
* <p>Hello {name}!</p> // found: MIXED
|
|
266
|
-
* <div className="primary" /> // not found
|
|
267
|
-
*/
|
|
268
259
|
export class FindHardCodedStrings extends ScanningRecipe<ImportedRenders> {
|
|
269
260
|
readonly name = "org.openrewrite.react.search.find-hard-coded-strings";
|
|
270
261
|
readonly displayName = "Find hard-coded user-facing strings";
|
|
@@ -47,16 +47,6 @@ class FindHookUsageRow {
|
|
|
47
47
|
isInLoop!: boolean;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
/**
|
|
51
|
-
* Finds React hook usage across source files.
|
|
52
|
-
*
|
|
53
|
-
* Detects both built-in hooks (useState, useEffect, etc.) and custom hooks
|
|
54
|
-
* (functions starting with "use" followed by an uppercase letter).
|
|
55
|
-
*
|
|
56
|
-
* Reports violations of the Rules of Hooks:
|
|
57
|
-
* - Hooks called inside conditionals
|
|
58
|
-
* - Hooks called inside loops
|
|
59
|
-
*/
|
|
60
50
|
export class FindHookUsage extends Recipe {
|
|
61
51
|
readonly name = "org.openrewrite.react.search.find-hook-usage";
|
|
62
52
|
readonly displayName: string = "Find React hook usage";
|
|
@@ -6,27 +6,10 @@ import {FindReactDomRootApis} from "./find-reactdom-root-apis";
|
|
|
6
6
|
import {FindDeprecatedLifecycles} from "./find-deprecated-lifecycles";
|
|
7
7
|
import {FindFunctionComponentDefaultProps} from "./find-function-component-default-props";
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Finds the legacy React APIs that block an upgrade to React 19, by running the finders that each cover one family
|
|
11
|
-
* of them. Every finder keeps its own marker and data table, so a call is reported once, by the finder that owns it:
|
|
12
|
-
*
|
|
13
|
-
* - `FindDeprecatedReactDomAPIs`: `findDOMNode`, `unmountComponentAtNode`, `createFactory`, `renderToNodeStream`.
|
|
14
|
-
* - `FindLegacyContextAPI`: `contextTypes`, `childContextTypes` and `getChildContext`.
|
|
15
|
-
* - `FindServerRenderingUsage`: server rendering entry points.
|
|
16
|
-
* - `FindReactDomRootApis`: `ReactDOM.render` and `ReactDOM.hydrate`, matched by import.
|
|
17
|
-
* - `FindDeprecatedLifecycles`: `componentWillMount`, `componentWillReceiveProps`, `componentWillUpdate`.
|
|
18
|
-
* - `FindFunctionComponentDefaultProps`: `defaultProps` on function components.
|
|
19
|
-
*
|
|
20
|
-
* It does not report string refs, `Context.Provider`, the `act` import, `unstable_batchedUpdates` or
|
|
21
|
-
* `react-test-renderer/shallow`; the step recipes migrate those without a finder.
|
|
22
|
-
*
|
|
23
|
-
* To see which React version a repository is on, use the `DevCenterReactStarter` card in DevCenter, which reads
|
|
24
|
-
* the resolved versions.
|
|
25
|
-
*/
|
|
26
9
|
export class FindLegacyReactApis extends Recipe {
|
|
27
10
|
readonly name = "org.openrewrite.react.search.find-legacy-react-apis";
|
|
28
11
|
readonly displayName = "Find legacy React API usage";
|
|
29
|
-
readonly description = "Finds the removed and deprecated React APIs that block an upgrade to React 19 (`ReactDOM.render` and `hydrate`, `findDOMNode`, legacy context, `componentWill*` lifecycles, function component `defaultProps` and more) by running one finder for each family, each with its own data table. For where a repository sits on the upgrade path by version, see the `DevCenterReactStarter` card in DevCenter.";
|
|
12
|
+
readonly description = "Finds the removed and deprecated React APIs that block an upgrade to React 19 (`ReactDOM.render` and `hydrate`, `findDOMNode`, legacy context, `componentWill*` lifecycles, function component `defaultProps` and more) by running one finder for each family, each with its own data table. String refs, `Context.Provider`, the `act` import, `unstable_batchedUpdates` and `react-test-renderer/shallow` are not reported, since the upgrade migrates them without a finder. For where a repository sits on the upgrade path by version, see the `DevCenterReactStarter` card in DevCenter.";
|
|
30
13
|
|
|
31
14
|
async recipeList(): Promise<Recipe[]> {
|
|
32
15
|
return [
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {Column, DataTable, ExecutionContext, foundSearchResult, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
2
|
+
import {JavaScriptVisitor, JS, MethodMatcher, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
|
-
import {
|
|
4
|
+
import {extendsReactComponent} from "../util/react-class";
|
|
5
|
+
import {reactFunction} from "../util/react-matchers";
|
|
5
6
|
|
|
6
7
|
class MissingDirectiveRow {
|
|
7
8
|
@Column({displayName: "File path", description: "The component file with no `'use client'` directive"})
|
|
@@ -11,11 +12,14 @@ class MissingDirectiveRow {
|
|
|
11
12
|
reasons!: string;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
const CLIENT_HOOKS =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const CLIENT_HOOKS = [
|
|
16
|
+
...[
|
|
17
|
+
'useState', 'useEffect', 'useLayoutEffect', 'useReducer', 'useRef', 'useContext', 'useCallback', 'useMemo',
|
|
18
|
+
'useTransition', 'useDeferredValue', 'useImperativeHandle', 'useSyncExternalStore', 'useInsertionEffect',
|
|
19
|
+
'useActionState', 'useOptimistic',
|
|
20
|
+
].map(reactFunction),
|
|
21
|
+
new MethodMatcher("react-dom useFormState(..)"),
|
|
22
|
+
];
|
|
19
23
|
const BROWSER_GLOBALS = new Set(['window', 'document', 'localStorage', 'sessionStorage', 'navigator']);
|
|
20
24
|
|
|
21
25
|
/** Directives are the string-literal statements at the top of a file. */
|
|
@@ -29,14 +33,6 @@ export function hasDirective(cu: JS.CompilationUnit, directive: string): boolean
|
|
|
29
33
|
return false;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
/**
|
|
33
|
-
* Finds component files that use client-only features but have no `'use client'` directive.
|
|
34
|
-
*
|
|
35
|
-
* In the Next.js App Router and other React Server Components setups, a file that uses state,
|
|
36
|
-
* effects, class components or browser globals fails unless it, or a file above it, is marked as a
|
|
37
|
-
* client boundary. This is a find-only recipe: the right boundary is usually the component that
|
|
38
|
-
* owns the interaction, which a recipe cannot tell. Only `.tsx` and `.jsx` files are considered.
|
|
39
|
-
*/
|
|
40
36
|
export class FindMissingUseClientDirective extends Recipe {
|
|
41
37
|
readonly name = "org.openrewrite.react.search.find-missing-use-client-directive";
|
|
42
38
|
readonly displayName = "Find client components missing a `'use client'` directive";
|
|
@@ -78,14 +74,12 @@ export class FindMissingUseClientDirective extends Recipe {
|
|
|
78
74
|
|
|
79
75
|
override async visitMethodInvocation(method: J.MethodInvocation, ctx: ExecutionContext): Promise<J | undefined> {
|
|
80
76
|
const m = await super.visitMethodInvocation(method, ctx) as J.MethodInvocation;
|
|
81
|
-
|
|
82
|
-
const reactReceiver = select?.kind === J.Kind.Identifier && (select as J.Identifier).simpleName === 'React';
|
|
83
|
-
return CLIENT_HOOKS.has(m.name.simpleName) && (!select || reactReceiver) ? this.note(m, m.name.simpleName) : m;
|
|
77
|
+
return CLIENT_HOOKS.some(matcher => matcher.matches(m.methodType)) ? this.note(m, m.methodType!.name) : m;
|
|
84
78
|
}
|
|
85
79
|
|
|
86
80
|
override async visitClassDeclaration(decl: J.ClassDeclaration, ctx: ExecutionContext): Promise<J | undefined> {
|
|
87
81
|
const c = await super.visitClassDeclaration(decl, ctx) as J.ClassDeclaration;
|
|
88
|
-
return
|
|
82
|
+
return extendsReactComponent(c) ? this.note(c, 'class component') : c;
|
|
89
83
|
}
|
|
90
84
|
|
|
91
85
|
override async visitFieldAccess(fieldAccess: J.FieldAccess, ctx: ExecutionContext): Promise<J | undefined> {
|
|
@@ -22,17 +22,6 @@ class FindPropUsageRow {
|
|
|
22
22
|
isSpread!: boolean;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* Finds prop usages across React components.
|
|
27
|
-
*
|
|
28
|
-
* Detects:
|
|
29
|
-
* - String literal props: `<Button variant="primary" />`
|
|
30
|
-
* - Expression props: `<Button onClick={handler} />`
|
|
31
|
-
* - Boolean shorthand props: `<Button disabled />`
|
|
32
|
-
* - Spread props: `<Button {...props} />`
|
|
33
|
-
*
|
|
34
|
-
* Can optionally filter by component name and/or prop name.
|
|
35
|
-
*/
|
|
36
25
|
export class FindPropUsage extends Recipe {
|
|
37
26
|
readonly name = "org.openrewrite.react.search.find-prop-usage";
|
|
38
27
|
readonly displayName: string = "Find React prop usage";
|
|
@@ -22,17 +22,6 @@ class FindReactComponentRow {
|
|
|
22
22
|
aliasName!: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* Finds usages of a specific React component across source files.
|
|
27
|
-
*
|
|
28
|
-
* Detects:
|
|
29
|
-
* - Named imports: `import { Button } from 'lib'`
|
|
30
|
-
* - Default imports: `import Button from 'lib'`
|
|
31
|
-
* - Aliased imports: `import { Button as Btn } from 'lib'`
|
|
32
|
-
* - Namespace access: `<Lib.Button />`
|
|
33
|
-
* - JSX elements: `<Button />` and `<Button>...</Button>`
|
|
34
|
-
* - Re-exports: `export { Button } from 'lib'`
|
|
35
|
-
*/
|
|
36
25
|
export class FindReactComponent extends Recipe {
|
|
37
26
|
readonly name = "org.openrewrite.react.search.find-react-component";
|
|
38
27
|
readonly displayName: string = "Find React component";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Column, DataTable, ExecutionContext, foundSearchResult, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
-
import {isVendoredOrBundled, JavaScriptVisitor, JS,
|
|
2
|
+
import {isVendoredOrBundled, JavaScriptVisitor, JS, MethodMatcher} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
class ReactDomRootApiRow {
|
|
@@ -19,13 +19,10 @@ export const REACTDOM_ROOT_APIS = new Map<string, { api: string; upgradeStep: st
|
|
|
19
19
|
['hydrate', {api: 'ReactDOM.hydrate', upgradeStep: 'org.openrewrite.react.migrate.react-18-to-19', migratedBy: 'org.openrewrite.react.19.replace-reactdom-hydrate'}],
|
|
20
20
|
]);
|
|
21
21
|
|
|
22
|
+
const ROOT_API_CALLS = [...REACTDOM_ROOT_APIS.entries()].map(([member, found]) =>
|
|
23
|
+
({matcher: new MethodMatcher(`react-dom ${member}(..)`), found}));
|
|
24
|
+
|
|
22
25
|
/**
|
|
23
|
-
* Finds calls of `ReactDOM.render` and `ReactDOM.hydrate`, which React 19 removed.
|
|
24
|
-
*
|
|
25
|
-
* A call is matched by where its callee was imported from, not by how it is spelled: `ReactDOM.render` through a
|
|
26
|
-
* default, namespace or `require` binding of `react-dom` under any local name, and `render` or `hydrate` imported by
|
|
27
|
-
* name, renamed or not. A local function that happens to be called `render` is not reported.
|
|
28
|
-
*
|
|
29
26
|
* @see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-reactdom-render
|
|
30
27
|
*/
|
|
31
28
|
export class FindReactDomRootApis extends Recipe {
|
|
@@ -45,55 +42,19 @@ export class FindReactDomRootApis extends Recipe {
|
|
|
45
42
|
|
|
46
43
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
47
44
|
private filePath = "";
|
|
48
|
-
/** Local name to the `react-dom` member it was imported by name, for `import {render as r} from 'react-dom'`. */
|
|
49
|
-
private named = new Map<string, string>();
|
|
50
45
|
|
|
51
46
|
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
52
47
|
this.filePath = cu.sourcePath ?? "";
|
|
53
|
-
this.named.clear();
|
|
54
48
|
return super.visitJsCompilationUnit(cu, ctx);
|
|
55
49
|
}
|
|
56
50
|
|
|
57
|
-
protected override async visitImportSpecifier(spec: JS.ImportSpecifier, ctx: ExecutionContext): Promise<J | undefined> {
|
|
58
|
-
const imp = this.cursor.firstEnclosing((n: any): n is JS.Import => n?.kind === JS.Kind.Import);
|
|
59
|
-
const module = (imp?.moduleSpecifier?.element as J.Literal | undefined)?.value;
|
|
60
|
-
if (module === 'react-dom') {
|
|
61
|
-
const specifier = spec.specifier as J;
|
|
62
|
-
if (specifier.kind === JS.Kind.Alias) {
|
|
63
|
-
const alias = specifier as JS.Alias;
|
|
64
|
-
const imported = alias.propertyName.element as J;
|
|
65
|
-
if (imported.kind === J.Kind.Identifier && alias.alias.kind === J.Kind.Identifier) {
|
|
66
|
-
this.named.set((alias.alias as J.Identifier).simpleName, (imported as J.Identifier).simpleName);
|
|
67
|
-
}
|
|
68
|
-
} else if (specifier.kind === J.Kind.Identifier) {
|
|
69
|
-
this.named.set((specifier as J.Identifier).simpleName, (specifier as J.Identifier).simpleName);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return super.visitImportSpecifier(spec, ctx);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
51
|
override async visitMethodInvocation(method: J.MethodInvocation, ctx: ExecutionContext): Promise<J | undefined> {
|
|
76
52
|
const m = await super.visitMethodInvocation(method, ctx) as J.MethodInvocation;
|
|
77
|
-
const
|
|
78
|
-
let member: string | undefined;
|
|
79
|
-
if (select) {
|
|
80
|
-
if (select.kind === J.Kind.Identifier && moduleBindings(this).moduleOf((select as J.Identifier).simpleName) === 'react-dom') {
|
|
81
|
-
member = m.name.simpleName;
|
|
82
|
-
}
|
|
83
|
-
} else if (this.named.has(m.name.simpleName) && this.boundByTheImport(m.name)) {
|
|
84
|
-
member = this.named.get(m.name.simpleName);
|
|
85
|
-
}
|
|
86
|
-
const found = member ? REACTDOM_ROOT_APIS.get(member) : undefined;
|
|
53
|
+
const found = ROOT_API_CALLS.find(({matcher}) => matcher.matches(m.methodType))?.found;
|
|
87
54
|
if (!found) return m;
|
|
88
55
|
dataTable.insertRow(ctx, {filePath: this.filePath, api: found.api, upgradeStep: found.upgradeStep});
|
|
89
56
|
return foundSearchResult(m, found.api) as J.MethodInvocation;
|
|
90
57
|
}
|
|
91
|
-
|
|
92
|
-
/** Whether the name still reads the import, rather than a parameter or local declaration that shadows it. */
|
|
93
|
-
private boundByTheImport(name: J.Identifier): boolean {
|
|
94
|
-
const owner = resolve(this.cursor, name);
|
|
95
|
-
return owner === undefined || owner.kind === JS.Kind.CompilationUnit;
|
|
96
|
-
}
|
|
97
58
|
}());
|
|
98
59
|
}
|
|
99
60
|
}
|
|
@@ -6,20 +6,12 @@ import {
|
|
|
6
6
|
} from "../zustand/redux-stores";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Inventories the Redux stores of a repository for a migration to zustand. A store is a candidate when it is a
|
|
10
|
-
* `configureStore` call whose `reducer` is an object of `createSlice` reducers, in the same source or imported from
|
|
11
|
-
* a relative module, and whose options are only `reducer`. Every other store gets a row for each reason it is not,
|
|
12
|
-
* such as a legacy `createStore`, custom middleware or a hand-written reducer. Stores are attributed by what the
|
|
13
|
-
* source imports from `redux` or `@reduxjs/toolkit`; namespace imports and `require` are not followed.
|
|
14
|
-
*
|
|
15
|
-
* Only the store's setup is checked; the components and modules that read or dispatch to it are not.
|
|
16
|
-
*
|
|
17
9
|
* @see https://zustand.docs.pmnd.rs/guides/migrating-to-zustand
|
|
18
10
|
*/
|
|
19
11
|
export class FindReduxStores extends ScanningRecipe<Map<string, SliceModule>> {
|
|
20
12
|
readonly name = "org.openrewrite.react.search.find-redux-stores";
|
|
21
13
|
readonly displayName = "Find Redux stores";
|
|
22
|
-
readonly description = "Finds the Redux stores created with `createStore` or Redux Toolkit's `configureStore` and records whether each one's setup can move to zustand: a `configureStore` call whose `reducer` is an object of `createSlice` reducers without `extraReducers`, and no other option, is a candidate. Every other store is recorded with the reasons it is not, such as a legacy `createStore`, custom middleware, enhancers, preloaded state or a hand-written reducer. The components and modules that use a store are not checked.";
|
|
14
|
+
readonly description = "Finds the Redux stores created with `createStore` or Redux Toolkit's `configureStore` and records whether each one's setup can move to zustand: a `configureStore` call whose `reducer` is an object of `createSlice` reducers without `extraReducers`, and no other option, is a candidate. Every other store is recorded with the reasons it is not, such as a legacy `createStore`, custom middleware, enhancers, preloaded state or a hand-written reducer. The components and modules that use a store are not checked. Stores are found through what a source imports from `redux` or `@reduxjs/toolkit`; namespace imports and `require` are not followed.";
|
|
23
15
|
|
|
24
16
|
private readonly stores = new DataTable<ReduxStoreRow>(
|
|
25
17
|
REDUX_STORES_TABLE, "Redux stores",
|