Skip to content

Commit

Permalink
Merge pull request #456 from jkimbo/false-positive-jsx-key-rule
Browse files Browse the repository at this point in the history
Fix false positive in jsx-key
  • Loading branch information
yannickcr committed Feb 21, 2016
2 parents c392099 + 0d2d162 commit 3b56239
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/rules/jsx-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ module.exports = function(context) {

// Array.prototype.map
CallExpression: function (node) {
if (node.callee && node.callee.type !== 'MemberExpression') {
return;
}

if (node.callee && node.callee.property && node.callee.property.name !== 'map') {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/rules/jsx-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ ruleTester.run('jsx-key', rule, {
{code: '[1, 2, 3].map(x => { return <App key={x} /> });', parserOptions: parserOptions},
{code: '[1, 2, 3].foo(x => <App />);', parserOptions: parserOptions},
{code: 'var App = () => <div />;', parserOptions: parserOptions},
{code: '[1, 2, 3].map(function(x) { return; });', parserOptions: parserOptions}
{code: '[1, 2, 3].map(function(x) { return; });', parserOptions: parserOptions},
{code: 'foo(() => <div />);', parserOptions: parserOptions}
],
invalid: [
{code: '[<App />];',
Expand Down

0 comments on commit 3b56239

Please sign in to comment.