@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
|
@@ -4,11 +4,6 @@ import {literalEditor} from "./replace-in-string-literals";
|
|
|
4
4
|
const capitalize = (s: string): string => s ? s[0].toUpperCase() + s.slice(1) : s;
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Points the `material-ui/svg-icons/<set>/<icon-name>` imports of v0.x at `@material-ui/icons/<IconName>`.
|
|
8
|
-
*
|
|
9
|
-
* Before: `import AccessAlarm from 'material-ui/svg-icons/device/access-alarm';`
|
|
10
|
-
* After: `import AccessAlarm from '@material-ui/icons/AccessAlarm';`
|
|
11
|
-
*
|
|
12
7
|
* @see https://github.com/mui/material-ui/tree/master/packages/mui-codemod/src/v1.0.0/svg-icon-imports
|
|
13
8
|
*/
|
|
14
9
|
export class ReplaceSvgIconImports extends Recipe {
|
|
@@ -80,12 +75,6 @@ const PATH_CONVERSION: Record<string, string> = {
|
|
|
80
75
|
};
|
|
81
76
|
|
|
82
77
|
/**
|
|
83
|
-
* Moves the `material-ui/lib/*` and `material-ui/src/*` imports of v0.15 to the module paths of v0.15's later
|
|
84
|
-
* layout, such as `material-ui/lib/app-bar` to `material-ui/AppBar`.
|
|
85
|
-
*
|
|
86
|
-
* Before: `import AppBar from 'material-ui/lib/app-bar';`
|
|
87
|
-
* After: `import AppBar from 'material-ui/AppBar';`
|
|
88
|
-
*
|
|
89
78
|
* @see https://github.com/mui/material-ui/tree/master/packages/mui-codemod/src/v0.15.0/import-path
|
|
90
79
|
*/
|
|
91
80
|
export class ReplaceMaterialUiImportPaths extends Recipe {
|
|
@@ -14,13 +14,6 @@ export async function literalEditor(change: (text: string) => string): Promise<T
|
|
|
14
14
|
}());
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Replaces text in the string literals of a file with a regular expression, for names that live in strings, such as
|
|
19
|
-
* style selectors.
|
|
20
|
-
*
|
|
21
|
-
* Before: `'& .JoyButton-root'`
|
|
22
|
-
* After: `'& .MuiButton-root'`
|
|
23
|
-
*/
|
|
24
17
|
export class ReplaceInStringLiterals extends Recipe {
|
|
25
18
|
readonly name = "org.openrewrite.react.mui.replace-in-string-literals";
|
|
26
19
|
readonly displayName: string = "Replace text in string literals";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {ExecutionContext, Option, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS, JSX, isVendoredOrBundled,
|
|
2
|
+
import {JavaScriptVisitor, JS, JSX, isVendoredOrBundled, maybeBind, maybeUnbind} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {importBindings} from "../util/module-imports";
|
|
5
5
|
import {findAttribute, renameTag, replaceAttribute} from "./jsx-attributes";
|
|
@@ -7,13 +7,6 @@ import {muiComponents, tagComponent} from "./mui-components";
|
|
|
7
7
|
import {packagePattern} from "./mui-tag-visitor";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Replaces `<ListItem button>` with `<ListItemButton>`, since v6 removes the `button` prop of `ListItem`.
|
|
11
|
-
*
|
|
12
|
-
* Before: `<ListItem button onClick={go}>x</ListItem>`
|
|
13
|
-
* After: `<ListItemButton onClick={go}>x</ListItemButton>`
|
|
14
|
-
*
|
|
15
|
-
* The import of `ListItemButton` is added next to the one of `ListItem`, which goes when nothing else uses it.
|
|
16
|
-
*
|
|
17
10
|
* @see https://mui.com/material-ui/migration/upgrade-to-v6/#listitem
|
|
18
11
|
*/
|
|
19
12
|
export class ReplaceListItemButtonProp extends Recipe {
|
|
@@ -50,8 +43,8 @@ export class ReplaceListItemButtonProp extends Recipe {
|
|
|
50
43
|
const isOn = button && (!value || (value.kind === JS.Kind.JsxEmbeddedExpression
|
|
51
44
|
&& ((value as JSX.EmbeddedExpression).expression.element as J.Literal).value === true));
|
|
52
45
|
if (!button || !isOn) return visited;
|
|
53
|
-
const local =
|
|
54
|
-
|
|
46
|
+
const local = maybeBind(this, {module: this.module, member: "ListItemButton"}) ?? "ListItemButton";
|
|
47
|
+
maybeUnbind(this, {module: this.module, member: "ListItem"});
|
|
55
48
|
return renameTag(replaceAttribute(visited, button, undefined), local);
|
|
56
49
|
}
|
|
57
50
|
}());
|
|
@@ -5,11 +5,6 @@ import {attributeString} from "./mui-components";
|
|
|
5
5
|
import {muiTagEditor} from "./mui-tag-visitor";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Replaces the string values of the `scrollButtons` prop of `Tabs` with the booleans of v5.
|
|
9
|
-
*
|
|
10
|
-
* Before: `<Tabs scrollButtons="on" />`, `<Tabs scrollButtons="desktop" />`, `<Tabs scrollButtons="off" />`
|
|
11
|
-
* After: `<Tabs scrollButtons allowScrollButtonsMobile />`, `<Tabs scrollButtons />`, `<Tabs scrollButtons={false} />`
|
|
12
|
-
*
|
|
13
8
|
* @see https://mui.com/material-ui/migration/v5-component-changes/#tabs
|
|
14
9
|
*/
|
|
15
10
|
export class ReplaceTabsScrollButtons extends Recipe {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor,
|
|
3
|
-
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
4
|
-
import {importBindings} from "../util/module-imports";
|
|
2
|
+
import {JavaScriptVisitor, isVendoredOrBundled, maybeUnbind, MethodMatcher, raw, template} from "@openrewrite/rewrite/javascript";
|
|
3
|
+
import {isIdentifier, J, Type} from "@openrewrite/rewrite/java";
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
const COLOR_FUNCTIONS = ["@mui/system", "@mui/material", "@mui/system/colorManipulator", "@mui/material/styles"]
|
|
6
|
+
.flatMap(module => ["alpha", "lighten", "darken"].map(fn => new MethodMatcher(`${module} ${fn}(..)`)));
|
|
8
7
|
|
|
9
8
|
const rootOf = (e: J): string | undefined => {
|
|
10
9
|
let current: J = e;
|
|
@@ -13,15 +12,6 @@ const rootOf = (e: J): string | undefined => {
|
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
|
-
* Replaces the color functions `alpha()`, `lighten()` and `darken()` with the ones on the theme, which understand
|
|
17
|
-
* CSS variables.
|
|
18
|
-
*
|
|
19
|
-
* Before: `alpha(theme.palette.primary.main, 0.8)`
|
|
20
|
-
* After: `theme.alpha(theme.palette.primary.main, 0.8)`
|
|
21
|
-
*
|
|
22
|
-
* Only a call whose color is read from a variable called `theme` is rewritten, since the call has to be made on
|
|
23
|
-
* a theme that is in scope. The import goes when nothing else uses the function.
|
|
24
|
-
*
|
|
25
15
|
* @see https://mui.com/material-ui/migration/upgrade-to-native-color/
|
|
26
16
|
*/
|
|
27
17
|
export class ReplaceThemeColorFunctions extends Recipe {
|
|
@@ -31,23 +21,16 @@ export class ReplaceThemeColorFunctions extends Recipe {
|
|
|
31
21
|
|
|
32
22
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
33
23
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
34
|
-
private functions = new Map<string, {name: string; module: string}>();
|
|
35
|
-
|
|
36
|
-
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
37
|
-
this.functions = new Map(importBindings(cu).filter(b => MODULES.test(b.module) && FUNCTIONS.has(b.name)).map(b => [b.local, {name: b.name, module: b.module}]));
|
|
38
|
-
return this.functions.size ? super.visitJsCompilationUnit(cu, ctx) : cu;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
24
|
override async visitMethodInvocation(invocation: J.MethodInvocation, ctx: ExecutionContext): Promise<J | undefined> {
|
|
42
25
|
const visited = await super.visitMethodInvocation(invocation, ctx) as J.MethodInvocation;
|
|
43
|
-
const fn = this.functions.get(visited.name.simpleName);
|
|
44
26
|
const [color, ...rest] = visited.arguments.elements;
|
|
45
|
-
|
|
27
|
+
const type = visited.methodType;
|
|
28
|
+
if (visited.select || !type || !COLOR_FUNCTIONS.some(fn => fn.matches(type)) || !color || rootOf(color.element) !== "theme") return visited;
|
|
46
29
|
const replaced = rest.length
|
|
47
|
-
? await template`theme.${raw(
|
|
48
|
-
: await template`theme.${raw(
|
|
30
|
+
? await template`theme.${raw(type.name)}(${color.element}, ${rest[0].element})`.apply(visited, this.cursor)
|
|
31
|
+
: await template`theme.${raw(type.name)}(${color.element})`.apply(visited, this.cursor);
|
|
49
32
|
if (!replaced) return visited;
|
|
50
|
-
|
|
33
|
+
maybeUnbind(this, {module: Type.FullyQualified.getFullyQualifiedName(type.declaringType), member: type.name});
|
|
51
34
|
return {...replaced, prefix: visited.prefix} as J;
|
|
52
35
|
}
|
|
53
36
|
}());
|
|
@@ -17,12 +17,6 @@ async function spacingCall(unit: J.FieldAccess, argument: string, anchor: J, cur
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Replaces `theme.spacing.unit`, which v4 removed, with the `theme.spacing()` function, folding a multiplication or
|
|
21
|
-
* division by a number into its argument.
|
|
22
|
-
*
|
|
23
|
-
* Before: `theme.spacing.unit`, `theme.spacing.unit * 5`, `theme.spacing.unit / 5`
|
|
24
|
-
* After: `theme.spacing(1)`, `theme.spacing(5)`, `theme.spacing(0.2)`
|
|
25
|
-
*
|
|
26
20
|
* @see https://mui.com/material-ui/migration/migration-v3/#theme
|
|
27
21
|
*/
|
|
28
22
|
export class ReplaceThemeSpacingUnit extends Recipe {
|
|
@@ -4,11 +4,6 @@ import {J} from "@openrewrite/rewrite/java";
|
|
|
4
4
|
import {endsWithName} from "./theme-access";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Replaces `theme.typography.round(x)`, which v5 removed, with its definition.
|
|
8
|
-
*
|
|
9
|
-
* Before: `theme.typography.round(16 / 14)`
|
|
10
|
-
* After: `Math.round(16 / 14 * 1e5) / 1e5`
|
|
11
|
-
*
|
|
12
7
|
* @see https://mui.com/material-ui/migration/v5-component-changes/#theme
|
|
13
8
|
*/
|
|
14
9
|
export class ReplaceTypographyRound extends Recipe {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ExecutionContext, TreeVisitor} from "@openrewrite/rewrite";
|
|
1
|
+
import {ExecutionContext, mapAsync, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
2
|
import {PreV5Recipe} from "./pre-v5-recipe";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {attributeName} from "./mui-components";
|
|
@@ -7,13 +7,6 @@ import {muiTagEditor} from "./mui-tag-visitor";
|
|
|
7
7
|
const SHIFT: Record<string, string> = {xsDown: "smDown", smDown: "mdDown", mdDown: "lgDown", lgDown: "xlDown"};
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Shifts the `...Down` props of `Hidden` one breakpoint up, since v5 reads them as "below" where v4 read "up to".
|
|
11
|
-
*
|
|
12
|
-
* Before: `<Hidden xsDown />`, `<Hidden lgDown />`
|
|
13
|
-
* After: `<Hidden smDown />`, `<Hidden xlDown />`
|
|
14
|
-
*
|
|
15
|
-
* Every prop of a tag is shifted once, in one step, so that `smDown` that was `xsDown` is not shifted again.
|
|
16
|
-
*
|
|
17
10
|
* @see https://mui.com/material-ui/migration/v5-component-changes/#hidden
|
|
18
11
|
*/
|
|
19
12
|
export class ShiftHiddenDownProps extends PreV5Recipe {
|
|
@@ -28,15 +21,13 @@ export class ShiftHiddenDownProps extends PreV5Recipe {
|
|
|
28
21
|
const shifted = this.shifted;
|
|
29
22
|
return muiTagEditor("Hidden", undefined, async tag => {
|
|
30
23
|
if (shifted.has(tag.id)) return tag;
|
|
31
|
-
|
|
32
|
-
const attributes = tag.attributes.map(a => {
|
|
24
|
+
const attributes = await mapAsync(tag.attributes, async a => {
|
|
33
25
|
const name = attributeName(a.element);
|
|
34
26
|
if (!name || !(name in SHIFT) || a.element.kind !== "org.openrewrite.javascript.tree.JSX$Attribute") return a;
|
|
35
|
-
changed = true;
|
|
36
27
|
const attribute = a.element as any;
|
|
37
28
|
return {...a, element: {...attribute, key: {...(attribute.key as J.Identifier), simpleName: SHIFT[name]}}};
|
|
38
29
|
});
|
|
39
|
-
if (
|
|
30
|
+
if (attributes === tag.attributes) return tag;
|
|
40
31
|
shifted.add(tag.id);
|
|
41
32
|
return {...tag, attributes} as typeof tag;
|
|
42
33
|
});
|
|
@@ -7,14 +7,6 @@ import {endsWithName, stringValue, withString} from "./theme-access";
|
|
|
7
7
|
const NEXT = new Map([["xs", "sm"], ["sm", "md"], ["md", "lg"], ["lg", "xl"], ["xl", "xl"]]);
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Moves the breakpoint values of `theme.breakpoints.down()` and the end of `between()` up one step, since v5 reads
|
|
11
|
-
* them as exclusive.
|
|
12
|
-
*
|
|
13
|
-
* Before: `theme.breakpoints.down('sm')`, `theme.breakpoints.between('sm', 'md')`
|
|
14
|
-
* After: `theme.breakpoints.down('md')`, `theme.breakpoints.between('sm', 'lg')`
|
|
15
|
-
*
|
|
16
|
-
* It is not idempotent: run it once.
|
|
17
|
-
*
|
|
18
10
|
* @see https://mui.com/material-ui/migration/v5-component-changes/#theme
|
|
19
11
|
*/
|
|
20
12
|
export class UpdateThemeBreakpoints extends PreV5Recipe {
|
|
@@ -10,20 +10,12 @@ import {muiTagEditor} from "./mui-tag-visitor";
|
|
|
10
10
|
const DEFAULT_BREAKPOINTS = ["xs", "sm", "md", "lg", "xl"];
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Moves the breakpoint props of the responsive `Grid` into its `size` and `offset` props, and drops `item` and
|
|
14
|
-
* `zeroMinWidth`.
|
|
15
|
-
*
|
|
16
|
-
* Before: `<Grid item xs={12} sm={6} xsOffset={2} />`
|
|
17
|
-
* After: `<Grid size={{ xs: 12, sm: 6 }} offset={2} />`
|
|
18
|
-
*
|
|
19
|
-
* A prop without a value, such as a bare `xs`, becomes `"grow"`. A tag with a spread attribute is left alone.
|
|
20
|
-
*
|
|
21
13
|
* @see https://mui.com/material-ui/migration/upgrade-to-grid-v2/
|
|
22
14
|
*/
|
|
23
15
|
export class UpgradeGridProps extends Recipe {
|
|
24
16
|
readonly name = "org.openrewrite.react.mui.upgrade-grid-props";
|
|
25
17
|
readonly displayName: string = "Upgrade the props of Grid to `size` and `offset`";
|
|
26
|
-
readonly description: string = "Moves the breakpoint props of the responsive Grid, `xs={12}` and `xsOffset={2}`, into its `size` and `offset` props, and removes `item` and `zeroMinWidth`. Tags with a spread attribute are left alone.";
|
|
18
|
+
readonly description: string = "Moves the breakpoint props of the responsive Grid, `xs={12}` and `xsOffset={2}`, into its `size` and `offset` props, and removes `item` and `zeroMinWidth`. A breakpoint prop without a value, such as a bare `xs`, becomes `\"grow\"`. Tags with a spread attribute are left alone.";
|
|
27
19
|
|
|
28
20
|
@Option({displayName: "Component name", description: "The Grid component, `Grid` or `Grid2`.", example: "Grid"})
|
|
29
21
|
componentName!: string;
|
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor,
|
|
2
|
+
import {JavaScriptVisitor, maybeBind, maybeUnbind, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Replaces `View.propTypes` with `ViewPropTypes` from the `deprecated-react-native-prop-types` package.
|
|
7
|
-
*
|
|
8
|
-
* React Native removed `View.propTypes` in newer versions. This recipe
|
|
9
|
-
* replaces references to `View.propTypes` with the `ViewPropTypes` export.
|
|
10
|
-
*
|
|
11
|
-
* Before:
|
|
12
|
-
* ```tsx
|
|
13
|
-
* import { View } from 'react-native';
|
|
14
|
-
* const styles = View.propTypes;
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* After:
|
|
18
|
-
* ```tsx
|
|
19
|
-
* import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
20
|
-
* const styles = ViewPropTypes;
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
6
|
* @see https://github.com/reactjs/react-codemod#reactnative-view-proptypes
|
|
24
7
|
*/
|
|
25
8
|
export class ViewPropTypes extends Recipe {
|
|
@@ -29,14 +12,11 @@ export class ViewPropTypes extends Recipe {
|
|
|
29
12
|
|
|
30
13
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
31
14
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
32
|
-
private transformed = false;
|
|
33
|
-
|
|
34
15
|
override async visitJsCompilationUnit(cu: any, ctx: ExecutionContext): Promise<J | undefined> {
|
|
35
|
-
this.transformed = false;
|
|
36
16
|
let result = await super.visitJsCompilationUnit(cu, ctx);
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
if (result !== cu) {
|
|
18
|
+
maybeBind(this, {module: "deprecated-react-native-prop-types", member: "ViewPropTypes", onlyIfReferenced: false});
|
|
19
|
+
maybeUnbind(this, {module: "react-native", member: "View"});
|
|
40
20
|
}
|
|
41
21
|
return result;
|
|
42
22
|
}
|
|
@@ -49,8 +29,6 @@ export class ViewPropTypes extends Recipe {
|
|
|
49
29
|
if ((fa.target as J.Identifier).simpleName !== 'View') return fa;
|
|
50
30
|
if (fa.name.element.simpleName !== 'propTypes') return fa;
|
|
51
31
|
|
|
52
|
-
this.transformed = true;
|
|
53
|
-
|
|
54
32
|
// Replace View.propTypes with just ViewPropTypes
|
|
55
33
|
return {
|
|
56
34
|
...fa.target,
|
|
@@ -3,31 +3,12 @@ import {JavaScriptVisitor, isVendoredOrBundled} from "@openrewrite/rewrite/javas
|
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Renames `unstable_handleError` to `componentDidCatch`.
|
|
7
|
-
*
|
|
8
|
-
* React 16 introduced error boundaries with a stable API. This recipe
|
|
9
|
-
* renames the unstable API to the official one.
|
|
10
|
-
*
|
|
11
|
-
* Before:
|
|
12
|
-
* ```tsx
|
|
13
|
-
* class ErrorBoundary extends React.Component {
|
|
14
|
-
* unstable_handleError(error) { ... }
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* After:
|
|
19
|
-
* ```tsx
|
|
20
|
-
* class ErrorBoundary extends React.Component {
|
|
21
|
-
* componentDidCatch(error) { ... }
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
6
|
* @see https://legacy.reactjs.org/blog/2017/09/26/react-v16.0.html#breaking-changes
|
|
26
7
|
*/
|
|
27
8
|
export class ErrorBoundaries extends Recipe {
|
|
28
9
|
readonly name = "org.openrewrite.react.16.error-boundaries";
|
|
29
10
|
readonly displayName: string = "Rename `unstable_handleError` to `componentDidCatch`";
|
|
30
|
-
readonly description: string = "Renames the unstable error boundary method to
|
|
11
|
+
readonly description: string = "Renames the unstable error boundary method `unstable_handleError` to `componentDidCatch`, the API React 16 made official.";
|
|
31
12
|
|
|
32
13
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
33
14
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
@@ -10,23 +10,6 @@ import {
|
|
|
10
10
|
import {Expression, J} from "@openrewrite/rewrite/java";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Replaces `this.getDOMNode()` with `React.findDOMNode(this)`.
|
|
14
|
-
*
|
|
15
|
-
* In React 0.13+, `getDOMNode()` on component instances was deprecated
|
|
16
|
-
* in favor of `React.findDOMNode()`.
|
|
17
|
-
*
|
|
18
|
-
* Before:
|
|
19
|
-
* ```tsx
|
|
20
|
-
* this.getDOMNode()
|
|
21
|
-
* this.refs.myRef.getDOMNode()
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* After:
|
|
25
|
-
* ```tsx
|
|
26
|
-
* React.findDOMNode(this)
|
|
27
|
-
* React.findDOMNode(this.refs.myRef)
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
13
|
* @see https://legacy.reactjs.org/blog/2015/10/07/react-v0.14.html#dom-node-refs
|
|
31
14
|
*/
|
|
32
15
|
export class FindDomNode extends Recipe {
|
|
@@ -10,20 +10,6 @@ import {
|
|
|
10
10
|
import {emptySpace, J, rightPadded, singleSpace, Type} from "@openrewrite/rewrite/java";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Converts `React.DOM.xxx()` factory calls to `React.createElement('xxx', ...)`.
|
|
14
|
-
*
|
|
15
|
-
* React.DOM factories were deprecated in React 15.6 and removed in React 16.
|
|
16
|
-
*
|
|
17
|
-
* Before:
|
|
18
|
-
* ```tsx
|
|
19
|
-
* React.DOM.div({ className: 'foo' }, 'Hello')
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* After:
|
|
23
|
-
* ```tsx
|
|
24
|
-
* React.createElement('div', { className: 'foo' }, 'Hello')
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
13
|
* @see https://legacy.reactjs.org/blog/2017/09/26/react-v16.0.html#packaging
|
|
28
14
|
*/
|
|
29
15
|
export class ReactDomFactories extends Recipe {
|
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor,
|
|
2
|
+
import {JavaScriptVisitor, maybeBind, maybeUnbind, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Moves `React.PropTypes` to the separate `prop-types` package.
|
|
7
|
-
*
|
|
8
|
-
* Starting with React 15.5, PropTypes was extracted into its own package.
|
|
9
|
-
*
|
|
10
|
-
* Before:
|
|
11
|
-
* ```tsx
|
|
12
|
-
* import React from 'react';
|
|
13
|
-
* MyComponent.propTypes = {
|
|
14
|
-
* name: React.PropTypes.string
|
|
15
|
-
* };
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* After:
|
|
19
|
-
* ```tsx
|
|
20
|
-
* import React from 'react';
|
|
21
|
-
* import PropTypes from 'prop-types';
|
|
22
|
-
* MyComponent.propTypes = {
|
|
23
|
-
* name: PropTypes.string
|
|
24
|
-
* };
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
6
|
* @see https://legacy.reactjs.org/blog/2017/09/26/react-v16.0.html#packaging
|
|
28
7
|
*/
|
|
29
8
|
export class ReactPropTypes extends Recipe {
|
|
@@ -33,8 +12,6 @@ export class ReactPropTypes extends Recipe {
|
|
|
33
12
|
|
|
34
13
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
35
14
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
36
|
-
private transformed = false;
|
|
37
|
-
|
|
38
15
|
override async visitFieldAccess(fieldAccess: J.FieldAccess, ctx: ExecutionContext): Promise<J | undefined> {
|
|
39
16
|
let fa = await super.visitFieldAccess(fieldAccess, ctx) as J.FieldAccess;
|
|
40
17
|
|
|
@@ -49,11 +26,10 @@ export class ReactPropTypes extends Recipe {
|
|
|
49
26
|
return fa;
|
|
50
27
|
}
|
|
51
28
|
|
|
52
|
-
const local =
|
|
29
|
+
const local = maybeBind(this, {module: "prop-types", member: "default", preferredName: "PropTypes", onlyIfReferenced: false});
|
|
53
30
|
if (!local) {
|
|
54
31
|
return fa;
|
|
55
32
|
}
|
|
56
|
-
this.transformed = true;
|
|
57
33
|
|
|
58
34
|
return {
|
|
59
35
|
...fa.name.element,
|
|
@@ -63,10 +39,9 @@ export class ReactPropTypes extends Recipe {
|
|
|
63
39
|
}
|
|
64
40
|
|
|
65
41
|
override async visitJsCompilationUnit(cu: any, ctx: ExecutionContext): Promise<J | undefined> {
|
|
66
|
-
this.transformed = false;
|
|
67
42
|
let result = await super.visitJsCompilationUnit(cu, ctx);
|
|
68
|
-
if (
|
|
69
|
-
|
|
43
|
+
if (result !== cu) {
|
|
44
|
+
maybeUnbind(this, {module: "react", member: "PropTypes"});
|
|
70
45
|
}
|
|
71
46
|
return result;
|
|
72
47
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor,
|
|
2
|
+
import {JavaScriptVisitor, maybeBind, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
|
|
5
5
|
const SERVER_METHODS = new Set(['renderToString', 'renderToStaticMarkup']);
|
|
@@ -13,23 +13,6 @@ const DOM_METHODS = new Set([
|
|
|
13
13
|
]);
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Splits `React.render()` and other DOM methods to `ReactDOM`.
|
|
17
|
-
*
|
|
18
|
-
* In React 0.14+, DOM-specific methods were moved to the `react-dom` package.
|
|
19
|
-
*
|
|
20
|
-
* Before:
|
|
21
|
-
* ```tsx
|
|
22
|
-
* import React from 'react';
|
|
23
|
-
* React.render(<App />, document.getElementById('root'));
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* After:
|
|
27
|
-
* ```tsx
|
|
28
|
-
* import React from 'react';
|
|
29
|
-
* import ReactDOM from 'react-dom';
|
|
30
|
-
* ReactDOM.render(<App />, document.getElementById('root'));
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
16
|
* @see https://legacy.reactjs.org/blog/2015/10/07/react-v0.14.html#two-packages-react-and-react-dom
|
|
34
17
|
*/
|
|
35
18
|
export class ReactToReactDom extends Recipe {
|
|
@@ -41,8 +24,8 @@ export class ReactToReactDom extends Recipe {
|
|
|
41
24
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
42
25
|
private destination(methodName: string): string | undefined {
|
|
43
26
|
return SERVER_METHODS.has(methodName)
|
|
44
|
-
?
|
|
45
|
-
:
|
|
27
|
+
? maybeBind(this, {module: 'react-dom/server', member: '*', preferredName: 'ReactDOMServer', onlyIfReferenced: false})
|
|
28
|
+
: maybeBind(this, {module: 'react-dom', member: 'default', preferredName: 'ReactDOM', onlyIfReferenced: false});
|
|
46
29
|
}
|
|
47
30
|
|
|
48
31
|
override async visitFieldAccess(fieldAccess: J.FieldAccess, ctx: ExecutionContext): Promise<J | undefined> {
|
|
@@ -2,7 +2,7 @@ import {ExecutionContext, Recipe, TreeVisitor, check, not, randomId} from "@open
|
|
|
2
2
|
import {isObjectLiteral, isVendoredOrBundled, JavaScriptVisitor, JS, namesDeclaredWithin, namesUsedWithin, template} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {anyNode, isThis} from "../util/tree-search";
|
|
5
|
-
import {
|
|
5
|
+
import {extendsReactComponent} from "../util/react-class";
|
|
6
6
|
|
|
7
7
|
/** The lifecycle name without the `UNSAFE_` prefix. */
|
|
8
8
|
function lifecycleName(method: J.MethodDeclaration): string {
|
|
@@ -71,32 +71,18 @@ const readsThisProps = (n: J) => n.kind === J.Kind.FieldAccess && isThis((n as J
|
|
|
71
71
|
&& (n as J.FieldAccess).name.element.simpleName === 'props';
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* Migrates the deprecated `componentWillMount` and `componentWillReceiveProps` lifecycles where that
|
|
75
|
-
* is safe, and leaves everything else for the `UNSAFE_` prefix.
|
|
76
|
-
*
|
|
77
|
-
* - `componentWillMount() { this.setState({...}) }` becomes a `state = {...}` class field.
|
|
78
|
-
* - A `componentWillMount` that neither touches `this.state` nor calls `setState` or `return`s moves to
|
|
79
|
-
* `componentDidMount`, ahead of the existing body when there is one. It then runs after the first
|
|
80
|
-
* render instead of before it, which is the move React recommends for side effects.
|
|
81
|
-
* - A `componentWillReceiveProps(next)` whose whole body is one `if` comparing `next` with `this.props`
|
|
82
|
-
* and that never calls `setState` becomes `componentDidUpdate(prevProps)`, with `next` and `this.props`
|
|
83
|
-
* swapped. The guard keeps it from running on state-only updates, which `componentDidUpdate` also sees.
|
|
84
|
-
*
|
|
85
|
-
* A class that already has a constructor, a `state` field or a `componentDidUpdate` is not changed for the
|
|
86
|
-
* case that would collide with it.
|
|
87
|
-
*
|
|
88
74
|
* @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html
|
|
89
75
|
*/
|
|
90
76
|
export class MigrateDeprecatedLifecycles extends Recipe {
|
|
91
77
|
readonly name = "org.openrewrite.react.17.migrate-deprecated-lifecycles";
|
|
92
78
|
readonly displayName = "Migrate deprecated lifecycles where it is safe";
|
|
93
|
-
readonly description = "Moves `componentWillMount` to a `state` field or `componentDidMount`, and a guarded `componentWillReceiveProps` to `componentDidUpdate`, when the move does not change what the component does. Everything else is left for the `UNSAFE_` prefix
|
|
79
|
+
readonly description = "Moves `componentWillMount` to a `state` field or `componentDidMount`, and a guarded `componentWillReceiveProps` to `componentDidUpdate`, when the move does not change what the component does. Everything else is left for the `UNSAFE_` prefix, as is a move that would collide with an existing constructor, `state` field or `componentDidUpdate`.";
|
|
94
80
|
|
|
95
81
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
96
82
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
97
83
|
override async visitClassDeclaration(decl: J.ClassDeclaration, ctx: ExecutionContext): Promise<J | undefined> {
|
|
98
84
|
const cd = await super.visitClassDeclaration(decl, ctx) as J.ClassDeclaration;
|
|
99
|
-
if (!
|
|
85
|
+
if (!extendsReactComponent(cd)) return cd;
|
|
100
86
|
// React never calls the legacy lifecycles on a class with these, so moving them would make dead code live.
|
|
101
87
|
if (cd.body.statements.some(s => s.element.kind === J.Kind.MethodDeclaration
|
|
102
88
|
&& ['getDerivedStateFromProps', 'getSnapshotBeforeUpdate'].includes((s.element as J.MethodDeclaration).name.simpleName))) return cd;
|
|
@@ -105,14 +91,12 @@ export class MigrateDeprecatedLifecycles extends Recipe {
|
|
|
105
91
|
const find = (name: string) => statements.findIndex(s =>
|
|
106
92
|
s.element.kind === J.Kind.MethodDeclaration && lifecycleName(s.element as J.MethodDeclaration) === name);
|
|
107
93
|
const method = (i: number) => statements[i].element as J.MethodDeclaration;
|
|
108
|
-
let changed = false;
|
|
109
94
|
|
|
110
95
|
const willMount = find('componentWillMount');
|
|
111
96
|
if (willMount >= 0 && method(willMount).body) {
|
|
112
97
|
const replaced = await this.migrateWillMount(cd, statements, willMount, find('componentDidMount'));
|
|
113
98
|
if (replaced) {
|
|
114
99
|
statements = replaced;
|
|
115
|
-
changed = true;
|
|
116
100
|
}
|
|
117
101
|
}
|
|
118
102
|
|
|
@@ -122,11 +106,12 @@ export class MigrateDeprecatedLifecycles extends Recipe {
|
|
|
122
106
|
const migrated = await this.migrateWillReceiveProps(method(willReceive));
|
|
123
107
|
if (migrated) {
|
|
124
108
|
statements[willReceive] = {...statements[willReceive], element: migrated};
|
|
125
|
-
changed = true;
|
|
126
109
|
}
|
|
127
110
|
}
|
|
128
111
|
|
|
129
|
-
return
|
|
112
|
+
return statements.length === cd.body.statements.length && statements.every((s, i) => s === cd.body.statements[i])
|
|
113
|
+
? cd
|
|
114
|
+
: {...cd, body: {...cd.body, statements}} as J.ClassDeclaration;
|
|
130
115
|
}
|
|
131
116
|
|
|
132
117
|
/** The class members after moving `componentWillMount`, or `undefined` if it cannot be moved safely. */
|
|
@@ -130,33 +130,8 @@ function parametersOf(fn: J | undefined): J.RightPadded<J>[] {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* React 17 removed event pooling, so calling `persist()` on
|
|
136
|
-
* synthetic events is no longer necessary.
|
|
137
|
-
*
|
|
138
|
-
* Before:
|
|
139
|
-
* ```tsx
|
|
140
|
-
* function handleChange(e) {
|
|
141
|
-
* e.persist();
|
|
142
|
-
* setState(e.target.value);
|
|
143
|
-
* }
|
|
144
|
-
* ```
|
|
145
|
-
*
|
|
146
|
-
* After:
|
|
147
|
-
* ```tsx
|
|
148
|
-
* function handleChange(e) {
|
|
149
|
-
* setState(e.target.value);
|
|
150
|
-
* }
|
|
151
|
-
* ```
|
|
152
|
-
*
|
|
153
|
-
* Only `persist()` on a React synthetic event is removed. Without type attribution, the receiver has to
|
|
154
|
-
* be a parameter of an event handler, in a file that imports or requires `react`: annotated with an event
|
|
155
|
-
* type, of a function passed to a JSX `on*` prop, or read as an event is, as `e.target` or
|
|
156
|
-
* `e.preventDefault()` read it. `persistor.persist()`, `navigator.storage.persist()` or `store.persist()`
|
|
157
|
-
* in a `forEach` callback does real work and is kept.
|
|
158
|
-
* A `persist()` left behind is harmless, since React 17 keeps it as a no-op. Run it before a recipe that
|
|
159
|
-
* removes unused `react` imports, such as `UpdateReactImports`.
|
|
133
|
+
* Without types, an event handler is recognised by its file's `react` import, so composites run this before
|
|
134
|
+
* `UpdateReactImports`, which can remove that import.
|
|
160
135
|
*
|
|
161
136
|
* @see https://legacy.reactjs.org/blog/2020/08/10/react-v17-rc.html#no-event-pooling
|
|
162
137
|
*/
|
|
@@ -9,35 +9,12 @@ const UNSAFE_LIFECYCLE_MAP = new Map<string, string>([
|
|
|
9
9
|
]);
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Adds `UNSAFE_` prefix to deprecated lifecycle methods.
|
|
13
|
-
*
|
|
14
|
-
* React 16.3 deprecated `componentWillMount`, `componentWillReceiveProps`,
|
|
15
|
-
* and `componentWillUpdate`. React 17 requires the UNSAFE_ prefix.
|
|
16
|
-
*
|
|
17
|
-
* Before:
|
|
18
|
-
* ```tsx
|
|
19
|
-
* class MyComponent extends React.Component {
|
|
20
|
-
* componentWillMount() { ... }
|
|
21
|
-
* componentWillReceiveProps(nextProps) { ... }
|
|
22
|
-
* componentWillUpdate(nextProps, nextState) { ... }
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* After:
|
|
27
|
-
* ```tsx
|
|
28
|
-
* class MyComponent extends React.Component {
|
|
29
|
-
* UNSAFE_componentWillMount() { ... }
|
|
30
|
-
* UNSAFE_componentWillReceiveProps(nextProps) { ... }
|
|
31
|
-
* UNSAFE_componentWillUpdate(nextProps, nextState) { ... }
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
12
|
* @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html
|
|
36
13
|
*/
|
|
37
14
|
export class RenameUnsafeLifecycles extends Recipe {
|
|
38
15
|
readonly name = "org.openrewrite.react.17.rename-unsafe-lifecycles";
|
|
39
16
|
readonly displayName: string = "Add `UNSAFE_` prefix to deprecated lifecycle methods";
|
|
40
|
-
readonly description: string = "Renames `componentWillMount`, `componentWillReceiveProps`, and `componentWillUpdate` to their UNSAFE_ prefixed versions.";
|
|
17
|
+
readonly description: string = "Renames `componentWillMount`, `componentWillReceiveProps`, and `componentWillUpdate` to their `UNSAFE_` prefixed versions.";
|
|
41
18
|
|
|
42
19
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
43
20
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|