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

feat: Option to track JSX components as references #646

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Feb 12, 2025

Prerequisites checklist

What is the purpose of this pull request?

What changes did you make? (Give an overview)

  • Added a new jsx option to analyze().
  • Updated Referencer to track JSX references.
  • Added tests to verify the behavior.

Related Issues

fixes #645

Is there anything you'd like reviewers to focus on?

Please double-check that I'm covering enough scenarios in the tests. I'm not very familiar with JSX, so it's possible I missed some cases.

Comment on lines 672 to 675
JSXOpeningElement(node) {
const name = node.name.name;

if (this.scopeManager.__isJSXEnabled() && name[0].toUpperCase() === name[0]) {
Copy link
Member

Choose a reason for hiding this comment

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

This would crash if node.name is not a JSXIdentifier. For example: <obj.prop/>.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, didn't even know that syntax was possible. I'll update it.

@nzakas
Copy link
Member Author

nzakas commented Feb 24, 2025

Updated and also added a few tests to ensure that JSX references are being tracked the same way regular references are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

Change Request: Support JSX references
2 participants