Skip to content

Commit

Permalink
Fix this usage in jsx-no-undef (fixes #489)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Mar 14, 2016
1 parent 259fab4 commit 37fc544
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/rules/jsx-no-undef.js
Expand Up @@ -32,6 +32,11 @@ module.exports = function(context) {
var i;
var len;

// Ignore 'this' keyword (also maked as JSXIdentifier when used in JSX)
if (node.name === 'this') {
return;
}

while (scope.type !== 'global') {
scope = scope.upper;
variables = scope.variables.concat(variables);
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/rules/jsx-no-undef.js
Expand Up @@ -45,6 +45,17 @@ ruleTester.run('jsx-no-undef', rule, {
}, {
code: '/*eslint no-undef:1*/ var React, app; React.render(<app.foo.Bar />);',
parserOptions: parserOptions
}, {
code: [
'/*eslint no-undef:1*/',
'var React;',
'class Hello extends React.Component {',
' render() {',
' return <this.props.tag />',
' }',
'}'
].join('\n'),
parserOptions: parserOptions
}],
invalid: [{
code: '/*eslint no-undef:1*/ var React; React.render(<App />);',
Expand Down

0 comments on commit 37fc544

Please sign in to comment.