Open DaniGuardiola opened 3 days ago
The same issue came up in the React compiler PR - https://github.com/WordPress/gutenberg/pull/61788#issuecomment-2142159849.
Thanks @Mamaduka, seems like there's even more reason to do something about this then.
Unless I hear different, I will remove the restriction as a first step, then create a different issue to propose a more active transition (which is pretty much just a grep+replace of imports), and if there aren't any big arguments against it I'll start transitioning imports in chunks until done, and they add the restriction in the opposite direction to enforce importing from "react"
cc @WordPress/gutenberg-core
Yeah, I'm totally ok with this change but I'm a bit concerned about losing the consistency and if we want to keep the consistency, then it's going to be a huge commit. Maybe a codemod would help.
@youknowriad I think it'll be fine to have a small transition period, and I can do my best to get PRs pumped out in quick succession. It can be done in maybe a week, as long as I can count on someone's (yours? :D) help with fast reviews.
I think a small number of commits is actually better than a big number of PRs. That way we can add these to .git-blame-ignore-revs
But let's gather more opinions here to see if we're not missing anything. cc @gziolo @jsnajdr
What benefits do we expect from these changes that justify updating the entire codebase and documentation to use React directly?
@gziolo I think the linked discussion should be relevant to your question, but to name one thing that directly impacts me: I get routinely annoyed by auto imports of react stuff resulting in eslint complaining, and having to go back and manually change it to the wrapper. I have to interrupt my flow and go and fix it.
What problem does this address?
In #54074 there was a decent amount of consensus about using (a.k.a. importing) react more directly, instead of from
@wordpress/element
. However, the @typescript-eslint/no-restricted-imports lint rule seems to prevent it.What is your proposed solution?
The rule should be removed.
Note: I think it might be worth it to go the opposite direction and restrict imports from
@wordpress/element
. Along with a full grep+replace which shouldn't be too hard (maybe in stages?). However, for the sake of keeping a reasonable scope, let's leave that for a separate issue/conversation.