Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove React 16.4's obsolete React imports #28571

Merged
merged 10 commits into from
Jun 5, 2024

Conversation

hainenber
Copy link
Contributor

@hainenber hainenber commented May 18, 2024

chore: remove unused React imports

SUMMARY

React imports are no longer necessary starting from React 16.4.0 (source), I ran npx react-codemod update-react-imports. Afterwards, I executed this snippet to confirm everything stays intact

npm ci
npm run build
npm run test
npm run dev-server

Notable changes:

  • Added ESLint configs as recommended per React doc
  • Added Babel and Webpack configs to allow working with new automatic JSX runtime.
  • Fix a build warning due to a type import misdirected as normal import.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

All CI should be green

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Signed-off-by: hainenber <dotronghai96@gmail.com>
@dosubot dosubot bot added the change:frontend Requires changing the frontend label May 18, 2024
@github-actions github-actions bot added plugins packages and removed change:frontend Requires changing the frontend labels May 18, 2024
Signed-off-by: hainenber <dotronghai96@gmail.com>
@hainenber hainenber changed the title chore: remove unused React imports chore: remove obsolete React imports May 18, 2024
@hainenber
Copy link
Contributor Author

Converting this to draft as there are weird behaviors after removal

@hainenber hainenber marked this pull request as draft May 18, 2024 13:44
Signed-off-by: hainenber <dotronghai96@gmail.com>
@github-actions github-actions bot added the doc Namespace | Anything related to documentation label May 19, 2024
Signed-off-by: hainenber <dotronghai96@gmail.com>
…tic JSX runtime bundling

Signed-off-by: hainenber <dotronghai96@gmail.com>
This is required to pass corresponding Jest test.

Signed-off-by: hainenber <dotronghai96@gmail.com>
Signed-off-by: hainenber <dotronghai96@gmail.com>
@hainenber hainenber changed the title chore: remove obsolete React imports chore: remove React 16.4's obsolete React imports May 19, 2024
@hainenber
Copy link
Contributor Author

Phew! I've worked out all the edge cases and CI is green now, re-open for review :D

@hainenber hainenber marked this pull request as ready for review May 19, 2024 14:58
@dosubot dosubot bot added the change:frontend Requires changing the frontend label May 19, 2024
@michael-s-molina
Copy link
Member

Thank you for the PR @hainenber. Can we add a lint rule to prevent unused React imports?

Signed-off-by: hainenber <dotronghai96@gmail.com>
Signed-off-by: hainenber <dotronghai96@gmail.com>
Signed-off-by: hainenber <dotronghai96@gmail.com>
@hainenber
Copy link
Contributor Author

I've added the lint rule as requested :D

@@ -17,7 +17,8 @@
* under the License.
*/

import React from 'react';
// eslint-disable-next-line no-restricted-syntax -- whole React import is required for `reactify.test.tsx` Jest test passing.
Copy link
Member

Choose a reason for hiding this comment

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

Appreciate the comments!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I should clarify that I was unable to refactor the reactify.test.tsx to decouple it from whole React import :(

I hope someone much better than me can do the needful in the future.

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

Trying to review this big of a PR is giving my browser a heart attack, and making my eyes bleed :P

I've reviewed about 700 of the files in a somewhat random order, and all looks good to me.

GitHub makes me "load diff" for the rest of the files, and it takes foreeeeeeeever. You would think filtering by file type or filtering out "viewed" files would help, but NOPE.

@michael-s-molina michael-s-molina merged commit 0ca42a8 into apache:master Jun 5, 2024
32 checks passed
@hainenber hainenber deleted the remove-unused-react-imports branch June 5, 2024 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:frontend Requires changing the frontend dependencies:npm doc Namespace | Anything related to documentation packages plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants