@openrewrite/recipes-react 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/i18n/translate-hard-coded-strings.d.ts.map +1 -1
- package/dist/i18n/translate-hard-coded-strings.js +3 -2
- package/dist/i18n/translate-hard-coded-strings.js.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -18
- package/dist/index.js.map +1 -1
- package/dist/migration/change-component-prop-value.d.ts.map +1 -1
- package/dist/migration/change-component-prop-value.js.map +1 -1
- package/dist/migration/cra-to-vite/add-vite-config.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/add-vite-config.js.map +1 -1
- package/dist/migration/cra-to-vite/cra-to-vite.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/cra-to-vite.js.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-config-blockers.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-config-blockers.js.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-env-file-blockers.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-env-file-blockers.js.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-source-blockers.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-source-blockers.js.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-to-vite-blockers.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/find-cra-to-vite-blockers.js.map +1 -1
- package/dist/migration/cra-to-vite/migrate-cra-package.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/migrate-cra-package.js.map +1 -1
- package/dist/migration/cra-to-vite/migrate-cra-svg-imports.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/migrate-cra-svg-imports.js +3 -3
- package/dist/migration/cra-to-vite/migrate-cra-svg-imports.js.map +1 -1
- package/dist/migration/cra-to-vite/migrate-cra-tests-to-vitest.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/migrate-cra-tests-to-vitest.js.map +1 -1
- package/dist/migration/cra-to-vite/move-public-index-html.d.ts +1 -1
- package/dist/migration/cra-to-vite/move-public-index-html.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/move-public-index-html.js +1 -1
- package/dist/migration/cra-to-vite/move-public-index-html.js.map +1 -1
- package/dist/migration/cra-to-vite/remove-cra-configuration.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/remove-cra-configuration.js.map +1 -1
- package/dist/migration/cra-to-vite/rename-jsx-files.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/rename-jsx-files.js.map +1 -1
- package/dist/migration/cra-to-vite/rename-process-env-react-app.d.ts +1 -1
- package/dist/migration/cra-to-vite/rename-process-env-react-app.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/rename-process-env-react-app.js +1 -1
- package/dist/migration/cra-to-vite/rename-process-env-react-app.js.map +1 -1
- package/dist/migration/cra-to-vite/rename-react-app-env-vars-in-env-files.d.ts +1 -1
- package/dist/migration/cra-to-vite/rename-react-app-env-vars-in-env-files.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/rename-react-app-env-vars-in-env-files.js +1 -1
- package/dist/migration/cra-to-vite/rename-react-app-env-vars-in-env-files.js.map +1 -1
- package/dist/migration/cra-to-vite/replace-react-scripts-dependency.d.ts +1 -1
- package/dist/migration/cra-to-vite/replace-react-scripts-dependency.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/replace-react-scripts-dependency.js +1 -1
- package/dist/migration/cra-to-vite/replace-react-scripts-dependency.js.map +1 -1
- package/dist/migration/cra-to-vite/update-react-app-env-types.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/update-react-app-env-types.js.map +1 -1
- package/dist/migration/cra-to-vite/update-react-scripts-scripts.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/update-react-scripts-scripts.js.map +1 -1
- package/dist/migration/cra-to-vite/update-tsconfig-for-vite.d.ts.map +1 -1
- package/dist/migration/cra-to-vite/update-tsconfig-for-vite.js.map +1 -1
- package/dist/mui/adapt-v4-theme.d.ts.map +1 -1
- package/dist/mui/adapt-v4-theme.js +1 -1
- package/dist/mui/adapt-v4-theme.js.map +1 -1
- package/dist/mui/add-component-prop.d.ts.map +1 -1
- package/dist/mui/add-component-prop.js.map +1 -1
- package/dist/mui/add-emotion-prepend.d.ts.map +1 -1
- package/dist/mui/add-emotion-prepend.js +3 -16
- package/dist/mui/add-emotion-prepend.js.map +1 -1
- package/dist/mui/convert-mui-imports.d.ts.map +1 -1
- package/dist/mui/convert-mui-imports.js +1 -1
- package/dist/mui/convert-mui-imports.js.map +1 -1
- package/dist/mui/convert-prop-to-sx.d.ts.map +1 -1
- package/dist/mui/convert-prop-to-sx.js +1 -1
- package/dist/mui/convert-prop-to-sx.js.map +1 -1
- package/dist/mui/mark-manual-migration.d.ts.map +1 -1
- package/dist/mui/mark-manual-migration.js.map +1 -1
- package/dist/mui/mark-palette-mode-usage.d.ts.map +1 -1
- package/dist/mui/mark-palette-mode-usage.js.map +1 -1
- package/dist/mui/move-component-prop-to-slot.d.ts.map +1 -1
- package/dist/mui/move-component-prop-to-slot.js.map +1 -1
- package/dist/mui/move-primary-text-to-children.d.ts.map +1 -1
- package/dist/mui/move-primary-text-to-children.js.map +1 -1
- package/dist/mui/move-system-props-to-sx.d.ts.map +1 -1
- package/dist/mui/move-system-props-to-sx.js +1 -1
- package/dist/mui/move-system-props-to-sx.js.map +1 -1
- package/dist/mui/remove-component-prop.d.ts.map +1 -1
- package/dist/mui/remove-component-prop.js.map +1 -1
- package/dist/mui/remove-root-ref.d.ts.map +1 -1
- package/dist/mui/remove-root-ref.js +1 -1
- package/dist/mui/remove-root-ref.js.map +1 -1
- package/dist/mui/remove-spacing-px-suffix.d.ts.map +1 -1
- package/dist/mui/remove-spacing-px-suffix.js +7 -10
- package/dist/mui/remove-spacing-px-suffix.js.map +1 -1
- package/dist/mui/rename-component-prop.d.ts.map +1 -1
- package/dist/mui/rename-component-prop.js.map +1 -1
- package/dist/mui/rename-joy-css-variables.d.ts.map +1 -1
- package/dist/mui/rename-joy-css-variables.js.map +1 -1
- package/dist/mui/rename-theme-palette-type.d.ts.map +1 -1
- package/dist/mui/rename-theme-palette-type.js.map +1 -1
- package/dist/mui/replace-box-border-radius.d.ts.map +1 -1
- package/dist/mui/replace-box-border-radius.js.map +1 -1
- package/dist/mui/replace-breakpoints-width.d.ts.map +1 -1
- package/dist/mui/replace-breakpoints-width.js.map +1 -1
- package/dist/mui/replace-component-class.d.ts.map +1 -1
- package/dist/mui/replace-component-class.js.map +1 -1
- package/dist/mui/replace-components-with-slots.d.ts.map +1 -1
- package/dist/mui/replace-components-with-slots.js.map +1 -1
- package/dist/mui/replace-import-paths.d.ts.map +1 -1
- package/dist/mui/replace-import-paths.js.map +1 -1
- package/dist/mui/replace-in-string-literals.d.ts.map +1 -1
- package/dist/mui/replace-in-string-literals.js.map +1 -1
- package/dist/mui/replace-list-item-button-prop.d.ts.map +1 -1
- package/dist/mui/replace-list-item-button-prop.js +2 -2
- package/dist/mui/replace-list-item-button-prop.js.map +1 -1
- package/dist/mui/replace-tabs-scroll-buttons.d.ts.map +1 -1
- package/dist/mui/replace-tabs-scroll-buttons.js.map +1 -1
- package/dist/mui/replace-theme-color-functions.d.ts.map +1 -1
- package/dist/mui/replace-theme-color-functions.js +7 -21
- package/dist/mui/replace-theme-color-functions.js.map +1 -1
- package/dist/mui/replace-theme-spacing-unit.d.ts.map +1 -1
- package/dist/mui/replace-theme-spacing-unit.js.map +1 -1
- package/dist/mui/replace-typography-round.d.ts.map +1 -1
- package/dist/mui/replace-typography-round.js.map +1 -1
- package/dist/mui/shift-hidden-down-props.d.ts.map +1 -1
- package/dist/mui/shift-hidden-down-props.js +4 -5
- package/dist/mui/shift-hidden-down-props.js.map +1 -1
- package/dist/mui/update-theme-breakpoints.d.ts.map +1 -1
- package/dist/mui/update-theme-breakpoints.js.map +1 -1
- package/dist/mui/upgrade-grid-props.d.ts.map +1 -1
- package/dist/mui/upgrade-grid-props.js +1 -1
- package/dist/mui/upgrade-grid-props.js.map +1 -1
- package/dist/react-native/view-prop-types.d.ts.map +1 -1
- package/dist/react-native/view-prop-types.js +3 -9
- package/dist/react-native/view-prop-types.js.map +1 -1
- package/dist/react16/error-boundaries.d.ts.map +1 -1
- package/dist/react16/error-boundaries.js +1 -1
- package/dist/react16/error-boundaries.js.map +1 -1
- package/dist/react16/find-dom-node.d.ts.map +1 -1
- package/dist/react16/find-dom-node.js.map +1 -1
- package/dist/react16/react-dom-factories.d.ts.map +1 -1
- package/dist/react16/react-dom-factories.js.map +1 -1
- package/dist/react16/react-prop-types.d.ts.map +1 -1
- package/dist/react16/react-prop-types.js +3 -9
- package/dist/react16/react-prop-types.js.map +1 -1
- package/dist/react16/react-to-react-dom.d.ts.map +1 -1
- package/dist/react16/react-to-react-dom.js +2 -2
- package/dist/react16/react-to-react-dom.js.map +1 -1
- package/dist/react17/migrate-deprecated-lifecycles.d.ts +1 -1
- package/dist/react17/migrate-deprecated-lifecycles.d.ts.map +1 -1
- package/dist/react17/migrate-deprecated-lifecycles.js +5 -6
- package/dist/react17/migrate-deprecated-lifecycles.js.map +1 -1
- package/dist/react17/remove-event-persist.d.ts.map +1 -1
- package/dist/react17/remove-event-persist.js.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
|
@@ -236,7 +236,6 @@ class AddVitestDependency extends JavaDependencyRecipe {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
|
-
* Converts `react-scripts test` to `vitest`, using a separate jsdom config and explicit `vi` imports.
|
|
240
239
|
* Dependencies must already support Vitest 4; the standalone composite installs them first.
|
|
241
240
|
* @see https://v4.vitest.dev/guide/migration.html#migrating-from-jest
|
|
242
241
|
*/
|
|
@@ -359,8 +358,7 @@ export default mergeConfig(viteConfig, defineConfig({
|
|
|
359
358
|
}
|
|
360
359
|
|
|
361
360
|
/**
|
|
362
|
-
*
|
|
363
|
-
* Requires Node 20.19+ (the Vite 7 baseline); jsdom 26 supports Node 20 without jsdom 27's higher patch floor.
|
|
361
|
+
* jsdom 26 supports Node 20 without jsdom 27's higher patch floor.
|
|
364
362
|
* @see https://v4.vitest.dev/guide/migration.html#migrating-from-jest
|
|
365
363
|
*/
|
|
366
364
|
export class MigrateCraTestsToVitest extends Recipe {
|
|
@@ -74,18 +74,6 @@ function computePlan(acc: CraProjects, renames: ReadonlySet<string>): Plan {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* Moves `public/index.html` to the project root, where Vite looks for it, and adds the module script for
|
|
78
|
-
* the entry file.
|
|
79
|
-
*
|
|
80
|
-
* ```html
|
|
81
|
-
* <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> -> <link rel="icon" href="/favicon.ico" />
|
|
82
|
-
* </body> -> <script type="module" src="/src/index.tsx"></script></body>
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
* `%PUBLIC_URL%/` becomes `/`, which Vite serves from `public/`, and `%REACT_APP_*%` becomes `%VITE_*%`.
|
|
86
|
-
* The page stays where it is when the project already has a root `index.html`, has no `src/index.*` entry
|
|
87
|
-
* file, or uses a placeholder Vite does not know, and the blockers data table says which. A package whose `public/index.html` is not in the LST is recorded too.
|
|
88
|
-
*
|
|
89
77
|
* @see https://vite.dev/guide/#index-html-and-project-root
|
|
90
78
|
*/
|
|
91
79
|
export class MovePublicIndexHtml extends CraScanningRecipe {
|
|
@@ -94,7 +82,7 @@ export class MovePublicIndexHtml extends CraScanningRecipe {
|
|
|
94
82
|
withRenamedEntries(paths: ReadonlySet<string>): this { this.entryRenames = paths; return this; }
|
|
95
83
|
readonly name = "org.openrewrite.react.cra-to-vite.move-public-index-html";
|
|
96
84
|
readonly displayName = "Move `public/index.html` to the project root for Vite";
|
|
97
|
-
readonly description = "Moves `public/index.html` of a Create React App project to the project root, replaces `%PUBLIC_URL%` and `%REACT_APP_*%` placeholders, and adds a module script for `src/index`.
|
|
85
|
+
readonly description = "Moves `public/index.html` of a Create React App project to the project root, replaces `%PUBLIC_URL%` and `%REACT_APP_*%` placeholders, and adds a module script for `src/index`. A page stays in place, recorded in the blockers data table, when the project already has a root `index.html`, has no `src/index.*` entry file, or uses a placeholder Vite does not know.";
|
|
98
86
|
|
|
99
87
|
async editorWithData(acc: CraProjects): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
100
88
|
const {moved, declined} = plan(acc, this.entryRenames);
|
|
@@ -8,7 +8,6 @@ const STOCK_BROWSERS = {
|
|
|
8
8
|
development: ["last 1 chrome version", "last 1 firefox version", "last 1 safari version"]
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
/** Drop only CRA template settings whose consumer goes away with react-scripts. */
|
|
12
11
|
export class RemoveCraConfiguration extends CraScanningRecipe {
|
|
13
12
|
readonly name = "org.openrewrite.react.cra-to-vite.remove-cra-configuration";
|
|
14
13
|
readonly displayName = "Remove unused Create React App template configuration";
|
|
@@ -14,10 +14,6 @@ class JsxProjects extends CraProjects {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* `src/App.js` containing `<App />` becomes `src/App.jsx`; `import './App.js'` becomes `import './App.jsx'`.
|
|
18
|
-
* Extensionless imports keep resolving without an edit. Only parsed JSX in eligible CRA client sources triggers
|
|
19
|
-
* a rename; JSX text in comments or strings does not. Imports are updated only within the owning package.
|
|
20
|
-
*
|
|
21
17
|
* @see https://vite.dev/guide/features.html#jsx
|
|
22
18
|
*/
|
|
23
19
|
export class RenameJsxFiles extends CraScanningRecipe {
|
|
@@ -26,28 +26,12 @@ function isProcessEnv(expr: J): expr is J.FieldAccess {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* Rewrites `process.env.REACT_APP_NAME` to `import.meta.env.VITE_NAME`.
|
|
30
|
-
*
|
|
31
|
-
* ```ts
|
|
32
|
-
* const url = process.env.REACT_APP_API_URL; -> const url = import.meta.env.VITE_API_URL;
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* Only files below the `src/` of a Create React App package change, which is all that CRA bundles; a `server.js`,
|
|
36
|
-
* `scripts/` or `cypress.config.js` beside it may run in Node, where `import.meta` is a syntax error. Only the global `process` is rewritten: a file that declares or imports its own `process` is skipped, as are
|
|
37
|
-
* computed access (`process.env['REACT_APP_X']`), destructuring and Node-side config files, which
|
|
38
|
-
* `FindCraToViteBlockers` reports. `import.meta` is a syntax error under Jest, so code that a Jest test imports
|
|
39
|
-
* needs the tests moved to Vitest.
|
|
40
|
-
*
|
|
41
|
-
* Values that are set outside the `.env` files in the repository (a Dockerfile, CI, a hosting dashboard) still arrive as
|
|
42
|
-
* `REACT_APP_*` and would read as `undefined`, so each renamed variable is recorded once per package in the
|
|
43
|
-
* `CraToViteBlockers` data table with the instruction to define it under its new name.
|
|
44
|
-
*
|
|
45
29
|
* @see https://vite.dev/guide/env-and-mode
|
|
46
30
|
*/
|
|
47
31
|
export class RenameProcessEnvReactApp extends CraScanningRecipe {
|
|
48
32
|
readonly name = "org.openrewrite.react.cra-to-vite.rename-process-env-react-app";
|
|
49
33
|
readonly displayName = "Replace `process.env.REACT_APP_*` with `import.meta.env.VITE_*`";
|
|
50
|
-
readonly description = "Rewrites reads of `process.env.REACT_APP_*` to `import.meta.env.VITE_*`, which is how Vite exposes client environment variables. Files that declare their own `process`, computed or destructured access, and Node-side config files, and files outside the package's `src/` folder, are left unchanged. Each renamed variable is recorded in a data table, because values set outside the repository's `.env` files must be renamed too.";
|
|
34
|
+
readonly description = "Rewrites reads of `process.env.REACT_APP_*` to `import.meta.env.VITE_*`, which is how Vite exposes client environment variables. Files that declare their own `process`, computed or destructured access, and Node-side config files, and files outside the package's `src/` folder, are left unchanged. Each renamed variable is recorded in a data table, because values set outside the repository's `.env` files must be renamed too. `import.meta` is a syntax error under Jest, so code that a Jest test imports needs its tests moved to Vitest.";
|
|
51
35
|
|
|
52
36
|
async editorWithData(acc: CraProjects): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
53
37
|
const table = craToViteBlockersTable();
|
|
@@ -8,22 +8,12 @@ const ASSIGNMENT = new RegExp(`^(\\s*(?:export\\s+)?)${CRA_ENV_PREFIX}([A-Za-z0-
|
|
|
8
8
|
const EXPANSION = /(?<!\\)(\$\{?)REACT_APP_([A-Za-z0-9_]+)/g;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Renames `REACT_APP_*` variables to `VITE_*` in `.env` files, including `${REACT_APP_*}` expansions.
|
|
12
|
-
*
|
|
13
|
-
* ```
|
|
14
|
-
* REACT_APP_API_URL=https://example.com -> VITE_API_URL=https://example.com
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* A variable is left alone and recorded in the blockers data table when the same file already defines the
|
|
18
|
-
* `VITE_` name, so no value is overwritten.
|
|
19
|
-
* Only `.env` files of Create React App packages change. Vite only reads `.env` files in the project root, and they are not moved.
|
|
20
|
-
*
|
|
21
11
|
* @see https://vite.dev/guide/env-and-mode
|
|
22
12
|
*/
|
|
23
13
|
export class RenameReactAppEnvVarsInEnvFiles extends CraScanningRecipe {
|
|
24
14
|
readonly name = "org.openrewrite.react.cra-to-vite.rename-env-file-variables";
|
|
25
15
|
readonly displayName = "Rename `REACT_APP_` variables in `.env` files to `VITE_`";
|
|
26
|
-
readonly description = "Renames `REACT_APP_*` variables in `.env` files to the `VITE_*` prefix that Vite exposes to client code, including `${REACT_APP_*}` expansions. Variables whose `VITE_` name is already defined in the same file are left unchanged and recorded in a data table.";
|
|
16
|
+
readonly description = "Renames `REACT_APP_*` variables in `.env` files to the `VITE_*` prefix that Vite exposes to client code, including `${REACT_APP_*}` expansions. Variables whose `VITE_` name is already defined in the same file are left unchanged and recorded in a data table. Vite only reads `.env` files in the project root, and they are not moved.";
|
|
27
17
|
|
|
28
18
|
async editorWithData(acc: CraProjects): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
29
19
|
const table = craToViteBlockersTable();
|
|
@@ -4,23 +4,12 @@ import {getMemberKeyName, Json, membersOf} from "@openrewrite/rewrite/json";
|
|
|
4
4
|
import {hasDependency, memberObject, runsOnVite, isPackageJson, rootObject, stringValue, VITE, VITE_PLUGIN_REACT} from "./shared";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Adds `vite` and `@vitejs/plugin-react` to `devDependencies` of a package that depends on `react-scripts`,
|
|
8
|
-
* and removes `react-scripts` once no script invokes it any more.
|
|
9
|
-
*
|
|
10
|
-
* ```json
|
|
11
|
-
* "dependencies": {"react-scripts": "5.0.1"} -> "devDependencies": {"@vitejs/plugin-react": "^5.2.0", "vite": "^7.0.0"}
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* The default versions are a peer-consistent pair that both need Node 20.19 or later. `react-scripts` stays
|
|
15
|
-
* while a script such as `test` still runs it, because it provides Jest. The `eject` script also retains the dependency until script migration removes it.
|
|
16
|
-
* Packages using `craco`, `react-app-rewired` or wrapped `start` or `build` scripts are left to the finders.
|
|
17
|
-
*
|
|
18
7
|
* @see https://react.dev/blog/2025/02/14/sunsetting-create-react-app#how-to-migrate-to-a-build-tool
|
|
19
8
|
*/
|
|
20
9
|
export class ReplaceReactScriptsDependency extends JavaDependencyRecipe {
|
|
21
10
|
readonly name = "org.openrewrite.react.cra-to-vite.replace-react-scripts-dependency";
|
|
22
11
|
readonly displayName = "Replace `react-scripts` dependency with Vite";
|
|
23
|
-
readonly description = "Adds `vite` and `@vitejs/plugin-react` together as dev dependencies and removes `react-scripts` or scoped forks only when no script still invokes them. Regenerates the lock natively; declined dependency edits leave the manifest and lock consistent. Wrapped CRA packages are left unchanged.";
|
|
12
|
+
readonly description = "Adds `vite` and `@vitejs/plugin-react` together as dev dependencies and removes `react-scripts` or scoped forks only when no script still invokes them. Regenerates the lock natively; declined dependency edits leave the manifest and lock consistent. Wrapped CRA packages are left unchanged. The default versions need Node 20.19 or later.";
|
|
24
13
|
|
|
25
14
|
@Option({
|
|
26
15
|
displayName: "Vite version",
|
|
@@ -9,15 +9,6 @@ const REACT_SCRIPTS_REFERENCE = /^\/\s*<reference\s+types=["'](?:@[^/"']+\/)?rea
|
|
|
9
9
|
const VITE_CLIENT_REFERENCE = '/ <reference types="vite/client" />';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Points the triple-slash type reference that Create React App generates at Vite's client types.
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* /// <reference types="react-scripts" /> -> /// <reference types="vite/client" />
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* The `react-scripts` package types no longer resolve once `react-scripts` is removed. `vite/client` declares
|
|
19
|
-
* `import.meta.env`, asset imports and CSS modules.
|
|
20
|
-
*
|
|
21
12
|
* @see https://vite.dev/guide/features#client-types
|
|
22
13
|
*/
|
|
23
14
|
export class UpdateReactAppEnvTypes extends CraScanningRecipe {
|
|
@@ -6,21 +6,6 @@ import {dirName, isPackageJson, joinPath, memberObject, stringValue} from "./sha
|
|
|
6
6
|
import {CRA_TYPECHECK_PATH, CRA_TYPECHECK_SCRIPT} from './cra-typecheck';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Rewrites CRA start/build commands and literal HOST, PORT, PUBLIC_URL and BUILD_PATH controls.
|
|
10
|
-
*
|
|
11
|
-
* ```json
|
|
12
|
-
* "start": "react-scripts start" -> "start": "vite"
|
|
13
|
-
* "build": "react-scripts build" -> "build": "vite build"
|
|
14
|
-
* "build": "react-scripts build" -> "build": "node scripts/vite-typecheck.cjs && vite build" (when there is a tsconfig.json)
|
|
15
|
-
* "eject": "react-scripts eject" -> (removed)
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* `react-scripts build` failed on type errors and `vite build` does not type-check, so a package with a `tsconfig.json`
|
|
19
|
-
* keeps a checker that reports production diagnostics under `src/`, matching CRA's scope.
|
|
20
|
-
*
|
|
21
|
-
* Custom shell commands, HTTPS configuration, unknown flags and wrapper tools require manual review.
|
|
22
|
-
* Tests are left for the separate Vitest migration.
|
|
23
|
-
*
|
|
24
9
|
* @see https://react.dev/blog/2025/02/14/sunsetting-create-react-app#how-to-migrate-to-a-build-tool
|
|
25
10
|
*/
|
|
26
11
|
export class UpdateReactScriptsScripts extends CraScanningRecipe {
|
|
@@ -10,17 +10,6 @@ export function isTsConfig(sourcePath: string): boolean {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Adds `vite/client` to an existing `compilerOptions.types` list in `tsconfig.json`, so `import.meta.env` and
|
|
14
|
-
* asset imports type-check.
|
|
15
|
-
*
|
|
16
|
-
* ```json
|
|
17
|
-
* "types": ["node"] -> "types": ["node", "vite/client"]
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* Only tsconfig files of Create React App packages change. A tsconfig without a `types` list is left alone, because adding one would stop TypeScript from including
|
|
21
|
-
* every `@types/*` package automatically; `UpdateReactAppEnvTypes` points `src/react-app-env.d.ts` at
|
|
22
|
-
* `vite/client` for those projects.
|
|
23
|
-
*
|
|
24
13
|
* @see https://vite.dev/guide/features#client-types
|
|
25
14
|
*/
|
|
26
15
|
export class UpdateTsconfigForVite extends CraScanningRecipe {
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS, isVendoredOrBundled,
|
|
2
|
+
import {JavaScriptVisitor, JS, isVendoredOrBundled, maybeBind, raw, template} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {importBindings} from "../util/module-imports";
|
|
5
5
|
import {MUI_PACKAGES} from "./mui-components";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Wraps the options of `createTheme` and `createMuiTheme` in `adaptV4Theme()`, which turns a v4 theme into a v5 one.
|
|
9
|
-
*
|
|
10
|
-
* Before: `createMuiTheme({ palette: { type: 'dark' } })`
|
|
11
|
-
* After: `createMuiTheme(adaptV4Theme({ palette: { type: 'dark' } }))`
|
|
12
|
-
*
|
|
13
8
|
* @see https://mui.com/material-ui/migration/v5-component-changes/#theme
|
|
14
9
|
*/
|
|
15
10
|
export class AdaptV4Theme extends Recipe {
|
|
@@ -34,7 +29,7 @@ export class AdaptV4Theme extends Recipe {
|
|
|
34
29
|
if (visited.select || !module || !options || visited.arguments.elements.length !== 1) return visited;
|
|
35
30
|
const argument = options.element;
|
|
36
31
|
if (argument.kind === J.Kind.MethodInvocation && (argument as J.MethodInvocation).name.simpleName === "adaptV4Theme") return visited;
|
|
37
|
-
|
|
32
|
+
maybeBind(this, {module: module.replace(/\/styles\/.*/, "/styles"), member: "adaptV4Theme", onlyIfReferenced: false});
|
|
38
33
|
const wrapped = await template`${raw(visited.name.simpleName)}(${raw("adaptV4Theme")}(${argument}))`.apply(visited, this.cursor);
|
|
39
34
|
return wrapped ? {...wrapped, prefix: visited.prefix} as J : visited;
|
|
40
35
|
}
|
|
@@ -3,13 +3,6 @@ import {appendAttribute, findAttribute, hasSpread, newAttribute} from "./jsx-att
|
|
|
3
3
|
import {muiTagEditor} from "./mui-tag-visitor";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Adds a prop to a Material UI component that does not set it, for keeping a default that changed.
|
|
7
|
-
*
|
|
8
|
-
* Before: `<IconButton />`
|
|
9
|
-
* After: `<IconButton size="large" />`
|
|
10
|
-
*
|
|
11
|
-
* A tag with a spread attribute is left alone, since the spread may already set the prop.
|
|
12
|
-
*
|
|
13
6
|
* @see https://mui.com/material-ui/migration/v5-component-changes/#iconbutton
|
|
14
7
|
*/
|
|
15
8
|
export class AddComponentProp extends Recipe {
|
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor,
|
|
2
|
+
import {JavaScriptVisitor, isVendoredOrBundled, MethodMatcher} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
|
-
import {importBindings} from "../util/module-imports";
|
|
5
4
|
import {appendProperty, findProperty, isObjectLiteral, newPropertyFromSource} from "./jsx-attributes";
|
|
6
5
|
|
|
6
|
+
const CREATE_CACHE = new MethodMatcher("@emotion/cache <default>(..)");
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
|
-
* Adds `prepend: true` to the options of Emotion's `createCache`, so Emotion's styles come before other CSS and can be
|
|
9
|
-
* overridden, as they could in v4.
|
|
10
|
-
*
|
|
11
|
-
* Before: `createCache({ key: 'css' })`
|
|
12
|
-
* After: `createCache({ key: 'css', prepend: true })`
|
|
13
|
-
*
|
|
14
9
|
* @see https://mui.com/material-ui/migration/v5-style-changes/#if-you-are-using-emotion
|
|
15
10
|
*/
|
|
16
11
|
export class AddEmotionPrepend extends Recipe {
|
|
17
12
|
readonly name = "org.openrewrite.react.mui.add-emotion-prepend";
|
|
18
13
|
readonly displayName: string = "Add `prepend: true` to Emotion's `createCache`";
|
|
19
|
-
readonly description: string = "Adds `prepend: true` to the options object of Emotion's `createCache`, and turns `prepend: false` into `true
|
|
14
|
+
readonly description: string = "Adds `prepend: true` to the options object of Emotion's `createCache`, and turns `prepend: false` into `true`, so Emotion's styles come before other CSS and can be overridden, as they could in v4.";
|
|
20
15
|
|
|
21
16
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
22
17
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
23
|
-
private names = new Set<string>();
|
|
24
|
-
|
|
25
|
-
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
26
|
-
this.names = new Set(importBindings(cu).filter(b => b.module === "@emotion/cache" && b.name === "default").map(b => b.local));
|
|
27
|
-
return this.names.size ? super.visitJsCompilationUnit(cu, ctx) : cu;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
18
|
override async visitMethodInvocation(invocation: J.MethodInvocation, ctx: ExecutionContext): Promise<J | undefined> {
|
|
31
19
|
const visited = await super.visitMethodInvocation(invocation, ctx) as J.MethodInvocation;
|
|
32
20
|
const options = visited.arguments.elements[0]?.element;
|
|
33
|
-
if (visited.select || !
|
|
21
|
+
if (visited.select || !CREATE_CACHE.matches(visited.methodType) || !isObjectLiteral(options)) return visited;
|
|
34
22
|
const existing = findProperty(options, "prepend");
|
|
35
23
|
let updated: J.NewClass;
|
|
36
24
|
if (!existing) {
|
|
@@ -68,23 +68,12 @@ async function build(cursor: Cursor, like: JS.Import, source: string): Promise<J
|
|
|
68
68
|
type Mode = "path" | "top-level" | "optimal";
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
* Rewrites how a file imports Material UI: from the package root to one module per component (`path`), from one module
|
|
72
|
-
* per component to the package root (`top-level`), or from private paths deeper than the package's public ones to them
|
|
73
|
-
* (`optimal`).
|
|
74
|
-
*
|
|
75
|
-
* `path`: `import { List } from '@mui/material';` becomes `import List from '@mui/material/List';`.
|
|
76
|
-
* `top-level`: `import List from '@mui/material/List';` becomes `import { List } from '@mui/material';`.
|
|
77
|
-
* `optimal`: `import red from '@material-ui/core/colors/red';` becomes `import { red } from '@material-ui/core/colors';`.
|
|
78
|
-
*
|
|
79
|
-
* The package exports are not read, so a default import whose module name is not an export of the package root is
|
|
80
|
-
* moved all the same in `top-level`; run it on code that imports Material UI's own components.
|
|
81
|
-
*
|
|
82
71
|
* @see https://mui.com/material-ui/guides/minimizing-bundle-size/
|
|
83
72
|
*/
|
|
84
73
|
export class ConvertMuiImports extends Recipe {
|
|
85
74
|
readonly name = "org.openrewrite.react.mui.convert-mui-imports";
|
|
86
75
|
readonly displayName: string = "Convert how Material UI is imported";
|
|
87
|
-
readonly description: string = "Rewrites imports of a Material UI package between the package root and one module per component, or from private deep paths to public ones. Type-only imports and namespace imports are left alone.";
|
|
76
|
+
readonly description: string = "Rewrites imports of a Material UI package between the package root and one module per component, or from private deep paths to public ones. Type-only imports and namespace imports are left alone. The package's exports are not read, so with `top-level` a default import from a module that is not a component of the package root is moved all the same.";
|
|
88
77
|
|
|
89
78
|
@Option({displayName: "Mode", description: "`path` for one module per component, `top-level` for the package root, `optimal` for public module paths.", example: "path", valid: ["path", "top-level", "optimal"]})
|
|
90
79
|
mode!: string;
|
|
@@ -21,20 +21,12 @@ function withSpacedObject(attribute: JSX.Attribute): JSX.Attribute {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* Replaces a prop that the component no longer has with the style it used to apply, in the `sx` prop.
|
|
25
|
-
*
|
|
26
|
-
* Before: `<Divider light />`, `<Typography paragraph />`
|
|
27
|
-
* After: `<Divider sx={{ opacity: '0.6' }} />`, `<Typography sx={{ marginBottom: '16px' }} />`
|
|
28
|
-
*
|
|
29
|
-
* A prop set to `false` is only removed. A prop set to another expression becomes a conditional style when the
|
|
30
|
-
* element has no `sx` yet. An existing `sx` that is not an object literal is left alone, with the prop in place.
|
|
31
|
-
*
|
|
32
24
|
* @see https://mui.com/material-ui/migration/migrating-from-deprecated-apis/
|
|
33
25
|
*/
|
|
34
26
|
export class ConvertPropToSx extends Recipe {
|
|
35
27
|
readonly name = "org.openrewrite.react.mui.convert-prop-to-sx";
|
|
36
28
|
readonly displayName: string = "Replace a component prop with an `sx` style";
|
|
37
|
-
readonly description: string = "Replaces a prop of a Material UI component with a property of its `sx` prop, such as `<Divider light />` with `<Divider sx={{ opacity: '0.6' }} />`. The style is not added when the `sx` already sets it.";
|
|
29
|
+
readonly description: string = "Replaces a prop of a Material UI component with a property of its `sx` prop, such as `<Divider light />` with `<Divider sx={{ opacity: '0.6' }} />`. The style is not added when the `sx` already sets it. A prop set to `false` is only removed, one set to another expression becomes a conditional style, and an `sx` that is not an object literal is left alone with the prop in place.";
|
|
38
30
|
|
|
39
31
|
@Option({displayName: "Component name", description: "The Material UI component.", example: "Divider"})
|
|
40
32
|
componentName!: string;
|
|
@@ -5,12 +5,6 @@ import {importBindings} from "../util/module-imports";
|
|
|
5
5
|
import {packagePattern} from "./mui-tag-visitor";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Marks the imports of an API of Material UI that has to be migrated by hand, because no mechanical rewrite of its
|
|
9
|
-
* call sites is safe, with a comment that says what to do.
|
|
10
|
-
*
|
|
11
|
-
* Before: `import { makeStyles } from '@material-ui/core/styles';`
|
|
12
|
-
* After: the same import, marked with the message.
|
|
13
|
-
*
|
|
14
8
|
* @see https://mui.com/material-ui/migration/migrating-from-jss/
|
|
15
9
|
*/
|
|
16
10
|
export class MarkManualMigration extends Recipe {
|
|
@@ -4,12 +4,6 @@ import {J} from "@openrewrite/rewrite/java";
|
|
|
4
4
|
import {endsWithName} from "./theme-access";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Marks the reads of `theme.palette.mode`, which v6 styles should replace with `theme.applyStyles()` so that dark
|
|
8
|
-
* mode works with CSS variables. No mechanical rewrite of the surrounding style object is safe.
|
|
9
|
-
*
|
|
10
|
-
* Before: `({ theme }) => ({ color: theme.palette.mode === 'dark' ? 'white' : 'black' })`
|
|
11
|
-
* After: the same, with the read of `theme.palette.mode` marked.
|
|
12
|
-
*
|
|
13
7
|
* @see https://mui.com/material-ui/migration/upgrade-to-v6/#migrate-theme-styles-to-support-css-variables-and-color-schemes
|
|
14
8
|
*/
|
|
15
9
|
export class MarkPaletteModeUsage extends Recipe {
|
|
@@ -9,15 +9,6 @@ import {JS, JSX} from "@openrewrite/rewrite/javascript";
|
|
|
9
9
|
import {J} from "@openrewrite/rewrite/java";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Moves a deprecated prop of a Material UI component into its `slots` or `slotProps` prop.
|
|
13
|
-
*
|
|
14
|
-
* Before: `<Dialog TransitionComponent={Fade} PaperProps={{elevation: 1}} />`
|
|
15
|
-
* After: `<Dialog slots={{ transition: Fade }} slotProps={{ paper: {elevation: 1} }} />`
|
|
16
|
-
*
|
|
17
|
-
* With `slotPropName`, the value goes one level deeper, as in `tooltipTitle` becoming `slotProps.tooltip.title`.
|
|
18
|
-
* A tag whose `slots`, `slotProps` or slot is already set to something other than an object literal, or to a slot
|
|
19
|
-
* that is set already, is left alone, since merging it would change what the code does.
|
|
20
|
-
*
|
|
21
12
|
* @see https://mui.com/material-ui/migration/migrating-from-deprecated-apis/
|
|
22
13
|
*/
|
|
23
14
|
export class MoveComponentPropToSlot extends Recipe {
|
|
@@ -5,11 +5,6 @@ import {attributeExpression, bare, findAttribute, replaceAttribute} from "./jsx-
|
|
|
5
5
|
import {muiTagEditor} from "./mui-tag-visitor";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Moves the `primaryText` of a self-closing `MenuItem` into its children, which is where v1 reads the text from.
|
|
9
|
-
*
|
|
10
|
-
* Before: `<MenuItem primaryText="Profile" />`
|
|
11
|
-
* After: `<MenuItem>Profile</MenuItem>`
|
|
12
|
-
*
|
|
13
8
|
* @see https://github.com/mui/material-ui/tree/master/packages/mui-codemod/src/v1.0.0/menu-item-primary-text
|
|
14
9
|
*/
|
|
15
10
|
export class MovePrimaryTextToChildren extends Recipe {
|
|
@@ -30,22 +30,12 @@ const isSxColor = (value: J, keepInherit: boolean): boolean => {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Moves the system props of a component, such as `mt` and `color`, into its `sx` prop, since they are removed in
|
|
34
|
-
* Material UI v6 and v9.
|
|
35
|
-
*
|
|
36
|
-
* Before: `<Box ml="2px" py={1} color="primary.main" />`
|
|
37
|
-
* After: `<Box sx={{ ml: "2px", py: 1, color: "primary.main" }} />`
|
|
38
|
-
*
|
|
39
|
-
* A tag with a spread attribute, or with an `sx` that is not an object literal, is left alone, since where the
|
|
40
|
-
* props go then depends on what is spread. Of `Typography` and `Link` the `color` stays when it names a color of the
|
|
41
|
-
* component, such as `primary`, and `Link` keeps `color` altogether in v6.
|
|
42
|
-
*
|
|
43
33
|
* @see https://mui.com/material-ui/migration/upgrade-to-v6/#system-props
|
|
44
34
|
*/
|
|
45
35
|
export class MoveSystemPropsToSx extends Recipe {
|
|
46
36
|
readonly name = "org.openrewrite.react.mui.move-system-props-to-sx";
|
|
47
37
|
readonly displayName: string = "Move system props into the `sx` prop";
|
|
48
|
-
readonly description: string = "Moves the system props of Box, Stack, Typography, Link, Grid and the like into their `sx` prop. Tags with a spread attribute, or an `sx` that is not an object literal, are left alone.";
|
|
38
|
+
readonly description: string = "Moves the system props of Box, Stack, Typography, Link, Grid and the like into their `sx` prop. Tags with a spread attribute, or an `sx` that is not an object literal, are left alone. On `Typography` and `Link`, a `color` that names a color of the component, such as `primary`, stays a prop, and on v6 `Link` keeps `color` altogether.";
|
|
49
39
|
|
|
50
40
|
@Option({displayName: "Component names", description: "The components to migrate, separated by commas.", example: "Box,Stack,Typography,Link,Grid"})
|
|
51
41
|
componentNames!: string;
|
|
@@ -4,11 +4,6 @@ import {attributeString} from "./mui-components";
|
|
|
4
4
|
import {muiTagEditor} from "./mui-tag-visitor";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Removes a prop of a Material UI component, optionally only when it is set to a given string.
|
|
8
|
-
*
|
|
9
|
-
* Before: `<Dialog disableBackdropClick />`
|
|
10
|
-
* After: `<Dialog />`
|
|
11
|
-
*
|
|
12
7
|
* @see https://mui.com/material-ui/migration/migration-v4/
|
|
13
8
|
*/
|
|
14
9
|
export class RemoveComponentProp extends Recipe {
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
2
|
-
import {JavaScriptVisitor, JS, JSX, isVendoredOrBundled,
|
|
2
|
+
import {JavaScriptVisitor, JS, JSX, isVendoredOrBundled, maybeUnbind} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {emptySpace} from "@openrewrite/rewrite/java";
|
|
5
5
|
import {MUI_PACKAGES, muiComponents, tagComponent} from "./mui-components";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Removes `RootRef`, which v5 removed, leaving a fragment around what it wrapped. The `rootRef` it set has to be
|
|
9
|
-
* passed to the child as `ref` by hand.
|
|
10
|
-
*
|
|
11
|
-
* Before: `<RootRef rootRef={ref}><div /></RootRef>`
|
|
12
|
-
* After: `<><div /></>`
|
|
13
|
-
*
|
|
14
8
|
* @see https://mui.com/material-ui/migration/v5-component-changes/#rootref
|
|
15
9
|
*/
|
|
16
10
|
export class RemoveRootRef extends Recipe {
|
|
@@ -31,7 +25,7 @@ export class RemoveRootRef extends Recipe {
|
|
|
31
25
|
const visited = await super.visitJsxTag(tag, ctx) as JSX.Tag;
|
|
32
26
|
if (tagComponent(visited, this.components) !== "RootRef" || !visited.children) return visited;
|
|
33
27
|
const local = (visited.openName.element as J.Identifier).simpleName;
|
|
34
|
-
for (const module of ["@material-ui/core", "@material-ui/core/RootRef", "@mui/material"])
|
|
28
|
+
for (const module of ["@material-ui/core", "@material-ui/core/RootRef", "@mui/material"]) maybeUnbind(this, {module: module, member: module.endsWith("RootRef") ? "default" : "RootRef"});
|
|
35
29
|
const empty = {kind: J.Kind.Empty, id: visited.id, prefix: emptySpace, markers: visited.markers} as J.Empty;
|
|
36
30
|
return {...visited, openName: {...visited.openName, element: empty}, afterName: emptySpace, attributes: [],
|
|
37
31
|
closingName: {...visited.closingName, element: empty}} as JSX.Tag;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ExecutionContext, Recipe, TreeVisitor, check, not} from "@openrewrite/rewrite";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor, check, mapAsync, not, updateIfChanged} from "@openrewrite/rewrite";
|
|
2
2
|
import {JavaScriptVisitor, JS, isVendoredOrBundled} from "@openrewrite/rewrite/javascript";
|
|
3
3
|
import {J} from "@openrewrite/rewrite/java";
|
|
4
4
|
import {stringValue} from "./theme-access";
|
|
@@ -6,11 +6,6 @@ import {stringValue} from "./theme-access";
|
|
|
6
6
|
const isSpacingCall = (e: J | undefined): boolean => e?.kind === J.Kind.MethodInvocation && (e as J.MethodInvocation).name.simpleName === "spacing";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Removes the `px` that is added after `theme.spacing()`, which returns a string with its unit since v5.
|
|
10
|
-
*
|
|
11
|
-
* Before: `` `${theme.spacing(2)}px` ``, `theme.spacing(2) + 'px'`
|
|
12
|
-
* After: `` `${theme.spacing(2)}` ``, `theme.spacing(2)`
|
|
13
|
-
*
|
|
14
9
|
* @see https://mui.com/material-ui/migration/v5-component-changes/#theme
|
|
15
10
|
*/
|
|
16
11
|
export class RemoveSpacingPxSuffix extends Recipe {
|
|
@@ -22,15 +17,12 @@ export class RemoveSpacingPxSuffix extends Recipe {
|
|
|
22
17
|
return check(not(isVendoredOrBundled()), new class extends JavaScriptVisitor<ExecutionContext> {
|
|
23
18
|
override async visitTemplateExpression(template: JS.TemplateExpression, ctx: ExecutionContext): Promise<J | undefined> {
|
|
24
19
|
const visited = await super.visitTemplateExpression(template, ctx) as JS.TemplateExpression;
|
|
25
|
-
|
|
26
|
-
const spans = visited.spans.map(span => {
|
|
20
|
+
return updateIfChanged(visited, {spans: await mapAsync(visited.spans, async span => {
|
|
27
21
|
const tail = span.element.tail;
|
|
28
22
|
// The source of a tail starts at the `}` that closes the substitution.
|
|
29
23
|
if (!isSpacingCall(span.element.expression) || typeof tail.value !== "string" || !tail.value.startsWith("px") || !tail.valueSource?.startsWith("}px")) return span;
|
|
30
|
-
changed = true;
|
|
31
24
|
return {...span, element: {...span.element, tail: {...tail, value: tail.value.slice(2), valueSource: `}${tail.valueSource.slice(3)}`}}};
|
|
32
|
-
});
|
|
33
|
-
return changed ? {...visited, spans} as JS.TemplateExpression : visited;
|
|
25
|
+
})});
|
|
34
26
|
}
|
|
35
27
|
|
|
36
28
|
override async visitBinary(binary: J.Binary, ctx: ExecutionContext): Promise<J | undefined> {
|
|
@@ -5,13 +5,6 @@ import {attributeExpression, newAttribute, replaceAttribute} from "./jsx-attribu
|
|
|
5
5
|
import {muiTagEditor} from "./mui-tag-visitor";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Renames a prop of a Material UI component.
|
|
9
|
-
*
|
|
10
|
-
* Before: `<Autocomplete closeIcon={icon} />`
|
|
11
|
-
* After: `<Autocomplete clearIcon={icon} />`
|
|
12
|
-
*
|
|
13
|
-
* A tag that already sets the new name is left alone, since renaming would set the prop twice.
|
|
14
|
-
*
|
|
15
8
|
* @see https://mui.com/material-ui/migration/migration-v4/
|
|
16
9
|
*/
|
|
17
10
|
export class RenameComponentProp extends Recipe {
|
|
@@ -11,12 +11,6 @@ const JOY_COMPONENTS = new Set(["Alert", "AspectRatio", "Autocomplete", "Autocom
|
|
|
11
11
|
const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Renames the CSS variables of Joy UI components to the naming standard of v5: `--Component-slot-property` becomes
|
|
15
|
-
* `--Component-slotProperty`.
|
|
16
|
-
*
|
|
17
|
-
* Before: `'--List-item-paddingY'`
|
|
18
|
-
* After: `'--ListItem-paddingY'`
|
|
19
|
-
*
|
|
20
14
|
* @see https://mui.com/joy-ui/migration/migrating-default-theme/
|
|
21
15
|
*/
|
|
22
16
|
export class RenameJoyCssVariables extends Recipe {
|
|
@@ -5,11 +5,6 @@ import {isObjectLiteral, objectProperties, propertyKey} from "./jsx-attributes";
|
|
|
5
5
|
import {endsWithName} from "./theme-access";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Renames the palette's `type` to `mode`, in a theme's `palette` object and in reads of `theme.palette.type`.
|
|
9
|
-
*
|
|
10
|
-
* Before: `createTheme({ palette: { type: 'dark' } })`, `theme.palette.type === 'dark'`
|
|
11
|
-
* After: `createTheme({ palette: { mode: 'dark' } })`, `theme.palette.mode === 'dark'`
|
|
12
|
-
*
|
|
13
8
|
* @see https://mui.com/material-ui/migration/v5-component-changes/#theme
|
|
14
9
|
*/
|
|
15
10
|
export class RenameThemePaletteType extends Recipe {
|
|
@@ -7,11 +7,6 @@ import {attributeString} from "./mui-components";
|
|
|
7
7
|
import {muiTagEditor} from "./mui-tag-visitor";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Updates the `borderRadius` of `Box` for the sizing of v5, where a number is a multiple of the theme's radius.
|
|
11
|
-
*
|
|
12
|
-
* Before: `<Box borderRadius="borderRadius" />`, `<Box borderRadius={16} />`
|
|
13
|
-
* After: `<Box borderRadius={1} />`, `<Box borderRadius="16px" />`
|
|
14
|
-
*
|
|
15
10
|
* @see https://mui.com/material-ui/migration/v5-component-changes/#box
|
|
16
11
|
*/
|
|
17
12
|
export class ReplaceBoxBorderRadius extends PreV5Recipe {
|
|
@@ -4,8 +4,6 @@ import {J} from "@openrewrite/rewrite/java";
|
|
|
4
4
|
import {endsWithName, stringValue} from "./theme-access";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Replaces `theme.breakpoints.width('md')` with `theme.breakpoints.values.md`.
|
|
8
|
-
*
|
|
9
7
|
* @see https://mui.com/material-ui/migration/v5-component-changes/#theme
|
|
10
8
|
*/
|
|
11
9
|
export class ReplaceBreakpointsWidth extends Recipe {
|
|
@@ -8,16 +8,6 @@ import {packagePattern} from "./mui-tag-visitor";
|
|
|
8
8
|
const lowerFirst = (s: string) => s.charAt(0).toLowerCase() + s.slice(1);
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Replaces a class key of a Material UI component: the key of its `classes` prop, a `xClasses.key` member, and
|
|
12
|
-
* `.MuiComponent-key` in a style selector.
|
|
13
|
-
*
|
|
14
|
-
* Before: `<Avatar classes={{ circle: c }} />`, `avatarClasses.circle`, `'& .MuiAvatar-circle'`
|
|
15
|
-
* After: `<Avatar classes={{ circular: c }} />`, `avatarClasses.circular`, `'& .MuiAvatar-circular'`
|
|
16
|
-
*
|
|
17
|
-
* With several `newClasses`, a style selector and the `classes` prop's key cannot name them all in one place, so
|
|
18
|
-
* only a selector string is rewritten, to `.MuiButton-text.MuiButton-colorInherit`; `classes` keys and members
|
|
19
|
-
* stay as they are.
|
|
20
|
-
*
|
|
21
11
|
* @see https://mui.com/material-ui/migration/migrating-from-deprecated-apis/
|
|
22
12
|
*/
|
|
23
13
|
export class ReplaceComponentClass extends Recipe {
|
|
@@ -7,14 +7,6 @@ import {muiTagEditor} from "./mui-tag-visitor";
|
|
|
7
7
|
const lowerFirst = (s: string) => s.charAt(0).toLowerCase() + s.slice(1);
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Renames the `components` and `componentsProps` props of a component to `slots` and `slotProps`, and the keys of
|
|
11
|
-
* `components` to camelCase.
|
|
12
|
-
*
|
|
13
|
-
* Before: `<Alert components={{ CloseButton: B }} componentsProps={{ closeButton: p }} />`
|
|
14
|
-
* After: `<Alert slots={{ closeButton: B }} slotProps={{ closeButton: p }} />`
|
|
15
|
-
*
|
|
16
|
-
* A tag that already sets `slots` or `slotProps` keeps the old prop, since merging two objects is not safe to guess.
|
|
17
|
-
*
|
|
18
10
|
* @see https://mui.com/material-ui/migration/migrating-from-deprecated-apis/
|
|
19
11
|
*/
|
|
20
12
|
export class ReplaceComponentsWithSlots extends Recipe {
|