Skip to content

Conversation

mikabytes
Copy link
Collaborator

Much inspiration from #580, thanks @madox2!

This PR never includes implicit React imports, unlike that PR. See issue for more information.

@trotzig Do you have some React projects where you could try this out in a sharp real-life environment? I don't do React, so I can't be too sure. All the tests are passing fine.

@mikabytes mikabytes linked an issue Jan 24, 2024 that may be closed by this pull request
@mikabytes
Copy link
Collaborator Author

I verified this today running the steps below. I think this should be good to merge, but I'm not 100% sure as I haven't worked with React since some 8 years ago.

Steps to test:

mkdir test ; cd test

npm init

echo "const a = <Test />" > test.js

importjs fix test.js

cat test.js

Result before PR:

{"messages":["Imported React from 'react'"],"fileContent":"import React from 'react'\n\nconst a = <Test />;\n","unresolvedImports":{}}

Result after PR:

{"messages":[],"fileContent":"const a = <Test />\n","unresolvedImports":{}}

@trotzig
Copy link
Collaborator

trotzig commented Jan 25, 2024

Glad you tried it out yourself -- I'm dealing with a family emergency and will likely be less active for a while. 🙏

@mikabytes
Copy link
Collaborator Author

No worries @trotzig, glad to hear you're keeping those priorities straight 👍

@mikabytes mikabytes merged commit 4793888 into master Jan 25, 2024
@trotzig trotzig deleted the 597-react-imports-on-jsx branch November 8, 2024 09:33
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.

React Imports on JSX
2 participants