Skip to content

Commit 99cec3e

Browse files
authored
Merge pull request #905 from xeodou/master
[Fix] handle self-referencing jsx tag names Fixes #839.
2 parents 00553b5 + 9002a7e commit 99cec3e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/rules/forbid-component-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = {
4848
return {
4949
JSXAttribute: function(node) {
5050
var tag = node.parent.name.name;
51-
if (tag[0] !== tag[0].toUpperCase()) {
51+
if (tag && tag[0] !== tag[0].toUpperCase()) {
5252
// This is a DOM node, not a Component, so exit.
5353
return;
5454
}

tests/lib/rules/forbid-component-props.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,33 @@ ruleTester.run('forbid-component-props', rule, {
8181
].join('\n'),
8282
options: [{forbid: ['style', 'foo']}],
8383
parserOptions: parserOptions
84+
}, {
85+
code: [
86+
'var First = React.createClass({',
87+
' propTypes: externalPropTypes,',
88+
' render: function() {',
89+
' return <this.Foo bar="baz" />;',
90+
' }',
91+
'});'
92+
].join('\n'),
93+
parserOptions: parserOptions
94+
}, {
95+
code: [
96+
'class First extends React.createClass {',
97+
' render() {',
98+
' return <this.foo className="bar" />;',
99+
' }',
100+
'}'
101+
].join('\n'),
102+
options: [{forbid: ['style']}],
103+
parserOptions: parserOptions
104+
}, {
105+
code: [
106+
'const First = (props) => (',
107+
' <this.Foo {...props} />',
108+
');'
109+
].join('\n'),
110+
parserOptions: parserOptions
84111
}],
85112

86113
invalid: [{

0 commit comments

Comments
 (0)