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

elementType(node) returns "undefined.ComponentName" #9

Closed
julienben opened this issue Nov 15, 2016 · 4 comments
Closed

elementType(node) returns "undefined.ComponentName" #9

julienben opened this issue Nov 15, 2016 · 4 comments
Labels

Comments

@julienben
Copy link

Hey Ethan,

Thanks for this great tool!

I'm building an ESLint rule for a project to warn our team when we use <this.ComponentName /> in JSX. (Because JSX tag names should always start with a capital and it sometimes compiles to "(void 0).ComponentName" which obviously won't run.)

However, elementType(node) returns "undefined.ComponentName" in a few cases:
<Component.Child.RenderThisGuy /> becomes "undefined.RenderThisGuy"
<this.props.Component> becomes "undefined.Component"

I can't check for names that start with "undefined" because, as you can see above, the first would be a false positive. And if I check only names that start with "this", I'm missing some instances.

Do you have any idea what could be causing this? And do you need any further info about the code I'm testing?

Thanks for any assistance!

Julien

@beefancohen
Copy link
Contributor

hey julien - pumped that you're using it! thanks for filing the issue. this is a bug in elementType, where we aren't recursively checking for JSXMemberExpressions (X.Y) as the element. we just assume that it starts with one (i.e. <Component.Child />). Will work on a fix right now!

@beefancohen
Copy link
Contributor

Fixed in v1.3.4, thanks for reporting! 😄

@julienben
Copy link
Author

Thanks so much for your crazy fast response! Shalom from Tel Aviv!

@beefancohen
Copy link
Contributor

shalom achi 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants