Skip to content

Commit 37fc544

Browse files
committed
Fix this usage in jsx-no-undef (fixes #489)
1 parent 259fab4 commit 37fc544

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/rules/jsx-no-undef.js

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ module.exports = function(context) {
3232
var i;
3333
var len;
3434

35+
// Ignore 'this' keyword (also maked as JSXIdentifier when used in JSX)
36+
if (node.name === 'this') {
37+
return;
38+
}
39+
3540
while (scope.type !== 'global') {
3641
scope = scope.upper;
3742
variables = scope.variables.concat(variables);

tests/lib/rules/jsx-no-undef.js

+11
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ ruleTester.run('jsx-no-undef', rule, {
4545
}, {
4646
code: '/*eslint no-undef:1*/ var React, app; React.render(<app.foo.Bar />);',
4747
parserOptions: parserOptions
48+
}, {
49+
code: [
50+
'/*eslint no-undef:1*/',
51+
'var React;',
52+
'class Hello extends React.Component {',
53+
' render() {',
54+
' return <this.props.tag />',
55+
' }',
56+
'}'
57+
].join('\n'),
58+
parserOptions: parserOptions
4859
}],
4960
invalid: [{
5061
code: '/*eslint no-undef:1*/ var React; React.render(<App />);',

0 commit comments

Comments
 (0)