Skip to content

Commit 00d5b85

Browse files
committed
Fix react-in-jsx-scope in Node.js env
1 parent e546008 commit 00d5b85

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/rules/react-in-jsx-scope.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ module.exports = function(context) {
3030
scope = scope.upper;
3131
variables = scope.variables.concat(variables);
3232
}
33+
if (scope.childScopes.length) {
34+
variables = scope.childScopes[0].variables.concat(variables);
35+
}
3336

3437
return variables;
3538
}

tests/lib/rules/react-in-jsx-scope.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ eslintTester.addRuleTest('lib/rules/react-in-jsx-scope', {
2323
{code: 'var React; <img />;', args: [1, {vars: 'all'}], ecmaFeatures: {jsx: true}},
2424
{code: 'var React; <x-gif />;', args: [1, {vars: 'all'}], ecmaFeatures: {jsx: true}},
2525
{code: 'var React, App, a=1; <App attr={a} />;', ecmaFeatures: {jsx: true}},
26-
{code: 'var React, App, a=1; function elem() { return <App attr={a} />; }',
27-
ecmaFeatures: {jsx: true}}
26+
{code: 'var React, App, a=1; function elem() { return <App attr={a} />; }', ecmaFeatures: {jsx: true}},
27+
{code: 'var React, App; <App />;', args: [1, {vars: 'all'}], ecmaFeatures: {globalReturn: true, jsx: true}}
2828
],
2929
invalid: [
3030
{code: 'var App, a = <App />;',

0 commit comments

Comments
 (0)