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

Handle undefined tag #839

Closed
wants to merge 1 commit into from
Closed

Handle undefined tag #839

wants to merge 1 commit into from

Conversation

pfhayes
Copy link
Contributor

@pfhayes pfhayes commented Sep 15, 2016

I have observed this error:

Cannot read property '0' of undefined
TypeError: Cannot read property '0' of undefined
    at EventEmitter.JSXAttribute (/Users/patrick/sigopt-api/node_modules/eslint-plugin-react/lib/rules/forbid-component-props.js:51:16)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.enterNode (/Users/patrick/sigopt-api/node_modules/eslint/lib/util/node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode (/Users/patrick/sigopt-api/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at CommentEventGenerator.enterNode (/Users/patrick/sigopt-api/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
    at Controller.enter (/Users/patrick/sigopt-api/node_modules/eslint/lib/eslint.js:918:36)
    at Controller.__execute (/Users/patrick/sigopt-api/node_modules/eslint/node_modules/estraverse/estraverse.js:397:31)
    at Controller.traverse (/Users/patrick/sigopt-api/node_modules/eslint/node_modules/estraverse/estraverse.js:501:28)
    at Controller.Traverser.contMakefile:37: recipe for target 'eslint' failed

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Could you provide a test that fails without this change?

@ljharb ljharb added the bug label Sep 16, 2016
@pfhayes
Copy link
Contributor Author

pfhayes commented Sep 16, 2016

Here is a minimal example that causes the error for me:

const Parent = React.createClass({
  render: function() {
    return <Child a={this.props.a}/>;
  }
});

However, I tried adding this as a test and the test appears to pass with the existing code. I'm not sure what would cause this or how to induce this error in test-mode, but I can repeatedly generate this error in my environment.

@ljharb
Copy link
Member

ljharb commented Sep 16, 2016

Is your environment in strict or sloppy mode?

@pfhayes
Copy link
Contributor Author

pfhayes commented Sep 16, 2016

How do I check that? I assume it is whatever the default is because I haven't configured anything like that to my knowledge

@ljharb
Copy link
Member

ljharb commented Sep 16, 2016

@pfhayes if you have 'use strict', or if you've configured eslint to use sourceType modules, then it's in strict mode. Otherwise it'd be in sloppy mode.

If you add 'use strict'; to the top of the test code, does it fail?

@pfhayes
Copy link
Contributor Author

pfhayes commented Sep 17, 2016

I don't believe I have configured eslint to use sourceType modules because I do not know how to do that. I am also not using 'use strict'

@ljharb
Copy link
Member

ljharb commented Sep 17, 2016

@pfhayes are you using babel? any code inside class, or any file using import or export is automatically in strict mode.

@pfhayes
Copy link
Contributor Author

pfhayes commented Sep 18, 2016

Yes, the code is being compiled with babel. The example provided has no imports/exports or class declarations (the example provided was the entire contents of the file that introduced the error)

I tried to reproduce this error recently and was unable to. I'm not sure what the cause was - perhaps an error in a dependent module that was fixed by an npm install. i'm fine closing this

@EdwardDrapkin
Copy link

Here's one way to replicate it:

foo(bar) {
    return <bar.baz className="error goes here" />;
}

@lencioni lencioni closed this Oct 2, 2016
@lencioni
Copy link
Collaborator

lencioni commented Oct 2, 2016

Thanks for the contribution. Feel free to re-open with a test!

@xeodou
Copy link
Contributor

xeodou commented Oct 12, 2016

Got the exactly the same issue here , seems @pfhayes 's PR been closed, but issue still exist. So how do I solve this @lencioni ?

@ljharb
Copy link
Member

ljharb commented Oct 12, 2016

@xeodou if you can provide a test case in a PR, or better, a test case with a fix, then we'd love to merge it!

@xeodou
Copy link
Contributor

xeodou commented Oct 12, 2016

Sure @ljharb i'll do.

@xeodou
Copy link
Contributor

xeodou commented Oct 12, 2016

Hi @ljharb I just found the use case and create pull request, please feel free to make some comments.

ljharb added a commit that referenced this pull request Oct 18, 2016
[Fix] handle self-referencing jsx tag names

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

Successfully merging this pull request may close these issues.

5 participants