Skip to content

Commit

Permalink
Fix variables detection when searching for related components (fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Nov 16, 2015
1 parent 4787aa0 commit 48f67ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/util/Components.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'use strict';

var util = require('util');
var variableUtil = require('./variable');

/**
* Components
Expand Down Expand Up @@ -265,7 +266,7 @@ function componentRule(rule, context) {
return null;
}
var variableInScope;
var variables = context.getScope().variables;
var variables = variableUtil.variablesInScope(context);
for (i = 0, j = variables.length; i < j; i++) {
if (variables[i].name === variableName) {
variableInScope = variables[i];
Expand Down
13 changes: 13 additions & 0 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,19 @@ ruleTester.run('prop-types', rule, {
'}'
].join('\n'),
parser: 'babel-eslint'
}, {
code: [
'export default function FooBar(props) {',
' const bar = props.bar;',
' return (<div bar={bar}><div {...props}/></div>);',
'}',
'if (process.env.NODE_ENV !== \'production\') {',
' FooBar.propTypes = {',
' bar: React.PropTypes.string',
' }',
'}'
].join('\n'),
parser: 'babel-eslint'
}
],

Expand Down

0 comments on commit 48f67ad

Please sign in to comment.