Skip to content

Conversation

@Daniel-Mendes
Copy link

@Daniel-Mendes Daniel-Mendes commented Oct 27, 2025

Summary

I followed the official instructions from the react blog: https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html

I tried keeping the minimum changes, but the codemod impacts a lot of files.

Test plan

I build the project and run the test:ci locally.

Checklist

Please add a x inside each checkbox:

A picture of a cute animal (not mandatory but encouraged)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request migrates the codebase from React's classic JSX runtime to the new automatic JSX runtime, following the official React guidance. This modernization removes the need to import React in every file that uses JSX and enables better integration with Emotion's CSS-in-JS functionality.

Key changes:

  • Configured the new JSX runtime with automatic imports via @babel/preset-react and TypeScript settings
  • Replaced @emotion/babel-preset-css-prop with @emotion/babel-plugin for better Emotion integration
  • Removed unnecessary React imports and replaced them with specific named imports (Component, createElement, Fragment, useState, etc.) where needed
  • Updated ESLint rules to disable checks that are no longer needed with the new JSX transform

Reviewed Changes

Copilot reviewed 139 out of 142 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tsconfig.json Configured JSX runtime to use react-jsx with @emotion/react as import source
babel.config.js Updated React preset to use automatic runtime, replaced emotion preset with plugin, added override for slate tests
.eslintrc.js Disabled react/jsx-uses-react and react/react-in-jsx-scope rules for new JSX transform
package.json Moved @emotion/babel-plugin to devDependencies, removed @emotion/babel-preset-css-prop, updated lint-quiet script
package-lock.json Updated dependency tree to reflect package.json changes
packages/decap-cms/src/index.js Changed from importing React to importing createElement directly
packages/decap-cms-widget-/src/.js Removed unused React imports, replaced React.Component with Component import
packages/decap-cms-core/src/components/**/*.js Replaced full React imports with specific named imports, updated Fragment usage
packages/decap-cms-ui-/src/.js Similar React import optimizations across UI components
packages/decap-cms-backend-/src/.js Updated authentication pages to use Fragment and Component imports
packages/decap-cms-backend-/-lfs-client.ts Updated minimatch imports to use named export (correct for v7+)
packages/decap-cms-default-exports/src/index.js Changed React import to namespace import to maintain export compatibility
test snapshots Updated to reflect simplified SVG output from React rendering changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

export class Modal extends Component {
static propTypes = {
children: PropTypes.node.isRequired,
children: PropTypes.any.isRequired,
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change from PropTypes.node to PropTypes.any for the children prop is too permissive. PropTypes.node is more specific and appropriate for React children, which can be strings, numbers, elements, fragments, or arrays of these. Using PropTypes.any removes type safety without a clear benefit.

Consider keeping PropTypes.node.isRequired instead of PropTypes.any.isRequired to maintain better prop type validation.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Daniel-Mendes I agree, is there a reason you switched to any?

export class ErrorBoundary extends Component {
static propTypes = {
children: PropTypes.node,
children: PropTypes.any,
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change from PropTypes.node to PropTypes.any for the children prop is too permissive. PropTypes.node is more specific and appropriate for React children, which can be strings, numbers, elements, fragments, or arrays of these. Using PropTypes.any removes type safety without a clear benefit.

Consider keeping PropTypes.node instead of PropTypes.any to maintain better prop type validation.

Copilot uses AI. Check for mistakes.
const IMAGE_EXTENSIONS = [...IMAGE_EXTENSIONS_VIEWABLE];

class MediaLibrary extends React.Component {
class MediaLibrary extends Component {
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Component state property 'sortFields' is read, but it is never written.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems unrelated

"mock:server:stop": "node -e 'require(\"./cypress/utils/mock-server\").stop()'",
"lint": "run-p -c --aggregate-output \"lint:*\"",
"lint-quiet": "run-p -c --aggregate-output \"lint:* --quiet\"",
"lint-quiet": "run-p -c --aggregate-output \"lint:*\"",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put back --quiet. Use lint for the non-quiet mode.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yes, I removed it because the npm run test:all failed on windows

width="16"
xmlns="http://www.w3.org/2000/svg"
>
<svg>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are attributes removed from svgs?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's the new @emotion/babel-plugin that doesn't copy the attributes. I need to check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants