Skip to content

Commit

Permalink
Valid self reference jsx element.
Browse files Browse the repository at this point in the history
  • Loading branch information
xeodou committed Oct 12, 2016
1 parent 9a657cc commit 83bd290
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/forbid-component-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = {
return {
JSXAttribute: function(node) {
var tag = node.parent.name.name;
if (tag[0] !== tag[0].toUpperCase()) {
if (tag && tag[0] !== tag[0].toUpperCase()) {
// This is a DOM node, not a Component, so exit.
return;
}
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/rules/forbid-component-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ ruleTester.run('forbid-component-props', rule, {
].join('\n'),
options: [{forbid: ['style', 'foo']}],
parserOptions: parserOptions
}, {
code: [
'var First = React.createClass({',
' propTypes: externalPropTypes,',
' render: function() {',
' return <this.Foo className="bar" />;',
' }',
'});'
].join('\n'),
options: [{forbid: ['style', 'foo']}],
parserOptions: parserOptions
}],

invalid: [{
Expand Down

0 comments on commit 83bd290

Please sign in to comment.