You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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!
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
The text was updated successfully, but these errors were encountered: