Skip to content

Commit 8ea2d0e

Browse files
committed
Fix related components detection in prop-types (fixes jsx-eslint#735)
1 parent 4be546a commit 8ea2d0e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/util/variable.js

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ function variablesInScope(context) {
8181
variables = scope.childScopes[0].childScopes[0].variables.concat(variables);
8282
}
8383
}
84+
variables.reverse();
8485

8586
return variables;
8687
}

tests/lib/rules/prop-types.js

+11
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,17 @@ ruleTester.run('prop-types', rule, {
12941294
'}'
12951295
].join('\n'),
12961296
parser: 'babel-eslint'
1297+
}, {
1298+
code: [
1299+
'class Hello extends Component {}',
1300+
'Hello.Foo = ({foo}) => (',
1301+
' <div>Hello {foo}</div>',
1302+
')',
1303+
'Hello.Foo.propTypes = {',
1304+
' foo: PropTypes.node',
1305+
'}'
1306+
].join('\n'),
1307+
parser: 'babel-eslint'
12971308
}
12981309
],
12991310

0 commit comments

Comments
 (0)