From a5594c1710da9c9acf8a15b867978bc5a61631fc Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Fri, 19 Feb 2016 15:50:02 +0000 Subject: [PATCH 1/2] Added failing test for false positive result --- tests/lib/rules/jsx-key.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/lib/rules/jsx-key.js b/tests/lib/rules/jsx-key.js index a6855698be..0fdba3cfde 100644 --- a/tests/lib/rules/jsx-key.js +++ b/tests/lib/rules/jsx-key.js @@ -34,7 +34,8 @@ ruleTester.run('jsx-key', rule, { {code: '[1, 2, 3].map(x => { return });', parserOptions: parserOptions}, {code: '[1, 2, 3].foo(x => );', parserOptions: parserOptions}, {code: 'var App = () =>
;', parserOptions: parserOptions}, - {code: '[1, 2, 3].map(function(x) { return; });', parserOptions: parserOptions} + {code: '[1, 2, 3].map(function(x) { return; });', parserOptions: parserOptions}, + {code: 'foo(() =>
);', parserOptions: parserOptions} ], invalid: [ {code: '[];', From 0d2d1629382cf6f499b5ff06d39c2a01845f7ac5 Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Fri, 19 Feb 2016 16:07:22 +0000 Subject: [PATCH 2/2] Added check for MemberExpression --- lib/rules/jsx-key.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rules/jsx-key.js b/lib/rules/jsx-key.js index b6da20ec51..b08ed53922 100644 --- a/lib/rules/jsx-key.js +++ b/lib/rules/jsx-key.js @@ -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; }