-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[core] Enforce import * as React #34878
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
da0x
requested review from
michaldudak,
mnajdova,
siriwatknp and
hbjORbj
as code owners
October 24, 2022 23:27
I got curious, it doesn't seem that we can enforce this with eslint, unfortunately, eslint/eslint#15895. |
oliviertassinari
changed the title
Fix typescript import warnings
[core] Fix React import
Oct 25, 2022
oliviertassinari
added
core
Infrastructure work going on behind the scenes
and removed
typescript
labels
Oct 25, 2022
Tip: you use no-restricted-syntax 🙂 {
"rules": {
"no-restricted-syntax": [
"error",
{
"message": "Do not import default from React. Use a namespace import (* as) instead.",
"selector": "ImportDeclaration[source.value=\"react\"] ImportDefaultSpecifier"
}
]
}
} |
@JoshuaKGoldberg Oh nice, I didn't realize we could use an AST selector. |
michaldudak
approved these changes
Oct 25, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency FTW! Thanks for your contribution!
|
oliviertassinari
changed the title
[core] Fix React imports
[core] Enforce import * as React
Oct 25, 2022
Closed
1 task
oliviertassinari
approved these changes
Oct 29, 2022
daniel-rabe
pushed a commit
to daniel-rabe/material-ui
that referenced
this pull request
Nov 29, 2022
feliperli
pushed a commit
to jesrodri/material-ui
that referenced
this pull request
Dec 6, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It's the way forward: https://twitter.com/dan_abramov/status/1308739731551858689 & facebook/react#18102
As a side note, JSX no longer needs to have
React.createElement
in the scope thanks to the Babel plugin (for the bundlers that include it) described in: https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.htm.