Skip to content

Commit

Permalink
Merge pull request jsx-eslint#905 from xeodou/master
Browse files Browse the repository at this point in the history
[Fix] handle self-referencing jsx tag names

Fixes jsx-eslint#839.
  • Loading branch information
ljharb authored Oct 18, 2016
2 parents 00553b5 + 9002a7e commit 99cec3e
Show file tree
Hide file tree
Showing 2 changed files with 28 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
27 changes: 27 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,33 @@ 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 bar="baz" />;',
' }',
'});'
].join('\n'),
parserOptions: parserOptions
}, {
code: [
'class First extends React.createClass {',
' render() {',
' return <this.foo className="bar" />;',
' }',
'}'
].join('\n'),
options: [{forbid: ['style']}],
parserOptions: parserOptions
}, {
code: [
'const First = (props) => (',
' <this.Foo {...props} />',
');'
].join('\n'),
parserOptions: parserOptions
}],

invalid: [{
Expand Down

0 comments on commit 99cec3e

Please sign in to comment.