nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: yannickcr/eslint-plugin-react
Pull request #456 (2016-02-19 16:32:54)

False positive jsx key rule
Identified and added a fix for a false positive from the `jsx-key` rule. Happens when you pass a function that returns a `JSXElement` as the first parameter.


Patch:
diff --git a/lib/rules/jsx-key.js b/lib/rules/jsx-key.js
index b6da20ec..b08ed539 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;
       }


Test patch:
diff --git a/tests/lib/rules/jsx-key.js b/tests/lib/rules/jsx-key.js
index a6855698..0fdba3cf 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 <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 />];',
Repository: yannickcr/eslint-plugin-react
Pull request #761 (2016-08-11 21:17:28)

Fix jsx-uses-var to handle nested object properties
When importing an object and using a deeply nested property as a component, mark that variable as used.


Patch:
diff --git a/lib/rules/jsx-uses-vars.js b/lib/rules/jsx-uses-vars.js
index bd877e58..530e1b48 100644
--- a/lib/rules/jsx-uses-vars.js
+++ b/lib/rules/jsx-uses-vars.js
@@ -38,9 +38,13 @@ module.exports = {
         } else if (node.name.name) {
           // <Foo>
           name = node.name.name;
-        } else if (node.name.object && node.name.object.name) {
-          // <Foo.Bar> - node.name.object.name
-          name = node.name.object.name;
+        } else if (node.name.object) {
+          // <Foo...Bar>
+          var parent = node.name.object;
+          while (parent.object) {
+            parent = parent.object;
+          }
+          name = parent.name;
         } else {
           return;
         }


Test patch:
diff --git a/tests/lib/rules/jsx-uses-vars.js b/tests/lib/rules/jsx-uses-vars.js
index 95598ed1..ac61a449 100644
--- a/tests/lib/rules/jsx-uses-vars.js
+++ b/tests/lib/rules/jsx-uses-vars.js
@@ -97,6 +97,26 @@ ruleTester.run('no-unused-vars', rule, {
         }\
         <HelloMessage />',
       parserOptions: parserOptions
+    }, {
+      code: '\
+        /*eslint jsx-uses-vars:1*/\
+        function foo() {\
+          var App = { Foo: { Bar: {}}};\
+          var bar = React.render(<App.Foo.Bar/>);\
+          return bar;\
+        };\
+        foo()',
+      parserOptions: parserOptions
+    }, {
+      code: '\
+        /*eslint jsx-uses-vars:1*/\
+        function foo() {\
+          var App = { Foo: { Bar: { Baz: {}}}};\
+          var bar = React.render(<App.Foo.Bar.Baz/>);\
+          return bar;\
+        };\
+        foo()',
+      parserOptions: parserOptions
     }
   ],
   invalid: [
Repository: yannickcr/eslint-plugin-react
Pull request #862 (2016-09-23 20:20:13)

Handle spread props in no-children-prop rule
Nodes of type `ExperimentalSpreadProperty` don’t have a `key` property, causing the `no-children-prop` to raise a “Cannot read property ‘name’ of undefined” error.

Code such as:

```
return React.createElement(
  elementType,
  { className: classNames, ...otherProps },
  children
)
```

will trigger the error.


Patch:
diff --git a/docs/rules/prefer-stateless-function.md b/docs/rules/prefer-stateless-function.md
index ddaab95d..3efee0ca 100644
--- a/docs/rules/prefer-stateless-function.md
+++ b/docs/rules/prefer-stateless-function.md
@@ -1,6 +1,6 @@
 # Enforce stateless React Components to be written as a pure function (prefer-stateless-function)
 
-Stateless functional components are more simple than class based components and will benefit from future React performance optimizations specific to these components.
+Stateless functional components are simpler than class based components and will benefit from future React performance optimizations specific to these components.
 
 ## Rule Details
 
diff --git a/lib/rules/no-children-prop.js b/lib/rules/no-children-prop.js
index 31d1b965..54540db7 100644
--- a/lib/rules/no-children-prop.js
+++ b/lib/rules/no-children-prop.js
@@ -54,7 +54,7 @@ module.exports = {
 
         var props = node.arguments[1].properties;
         var childrenProp = props.find(function(prop) {
-          return prop.key.name === 'children';
+          return prop.key && prop.key.name === 'children';
         });
 
         if (childrenProp) {


Test patch:
diff --git a/tests/lib/rules/no-children-prop.js b/tests/lib/rules/no-children-prop.js
index d0073dc0..dbcb684d 100644
--- a/tests/lib/rules/no-children-prop.js
+++ b/tests/lib/rules/no-children-prop.js
@@ -15,6 +15,7 @@ var RuleTester = require('eslint').RuleTester;
 var parserOptions = {
   ecmaVersion: 6,
   ecmaFeatures: {
+    experimentalObjectRestSpread: true,
     jsx: true
   }
 };
@@ -170,6 +171,14 @@ ruleTester.run('no-children-prop', rule, {
     {
       code: 'React.createElement(MyComponent, {className: "class-name"}, "Children");',
       parserOptions: parserOptions
+    },
+    {
+      code: '<MyComponent className="class-name" {...props} />;',
+      parserOptions: parserOptions
+    },
+    {
+      code: 'React.createElement(MyComponent, {className: "class-name", ...props});',
+      parserOptions: parserOptions
     }
   ],
   invalid: [
@@ -232,6 +241,16 @@ ruleTester.run('no-children-prop', rule, {
       code: 'React.createElement(MyComponent, {children: "Children", className: "class-name"});',
       errors: [{message: CREATE_ELEMENT_ERROR}],
       parserOptions: parserOptions
+    },
+    {
+      code: '<MyComponent {...props} children="Children" />;',
+      errors: [{message: JSX_ERROR}],
+      parserOptions: parserOptions
+    },
+    {
+      code: 'React.createElement(MyComponent, {...props, children: "Children"})',
+      errors: [{message: CREATE_ELEMENT_ERROR}],
+      parserOptions: parserOptions
     }
   ]
 });
Repository: yannickcr/eslint-plugin-react
Pull request #905 (2016-10-12 06:58:23)

Valid self reference jsx element.
Please check the information here https://github.com/yannickcr/eslint-plugin-react/pull/839 

I'm trying to include [xo](https://github.com/sindresorhus/xo) in one of our projects, i hit the issue exactly the same as @pfhayes . And after dig into the codebase, i found we have a self reference linked jsx element and that cause the issue, Like this 
```
class Foo extends React.createClass {
   render() {
       return <this.Bar  className='demo' />
   }
}
```

That's cause the issue. I don't think it's a best practice, but at least it shouldn't crash the workflow.


Patch:
diff --git a/lib/rules/forbid-component-props.js b/lib/rules/forbid-component-props.js
index 4218112c..8d6ba9f9 100644
--- a/lib/rules/forbid-component-props.js
+++ b/lib/rules/forbid-component-props.js
@@ -48,7 +48,7 @@ module.exports = {
     return {
       JSXAttribute: function(node) {
         var tag = node.parent.name.name;
-        if (tag[0] !== tag[0].toUpperCase()) {
+        if (tag && tag[0] !== tag[0].toUpperCase()) {
           // This is a DOM node, not a Component, so exit.
           return;
         }


Test patch:
diff --git a/tests/lib/rules/forbid-component-props.js b/tests/lib/rules/forbid-component-props.js
index 9483f80e..227e4e90 100644
--- a/tests/lib/rules/forbid-component-props.js
+++ b/tests/lib/rules/forbid-component-props.js
@@ -81,6 +81,33 @@ ruleTester.run('forbid-component-props', rule, {
     ].join('\n'),
     options: [{forbid: ['style', 'foo']}],
     parserOptions: parserOptions
+  }, {
+    code: [
+      'var First = React.createClass({',
+      '  propTypes: externalPropTypes,',
+      '  render: function() {',
+      '    return <this.Foo bar="baz" />;',
+      '  }',
+      '});'
+    ].join('\n'),
+    parserOptions: parserOptions
+  }, {
+    code: [
+      'class First extends React.createClass {',
+      '  render() {',
+      '    return <this.foo className="bar" />;',
+      '  }',
+      '}'
+    ].join('\n'),
+    options: [{forbid: ['style']}],
+    parserOptions: parserOptions
+  }, {
+    code: [
+      'const First = (props) => (',
+      '  <this.Foo {...props} />',
+      ');'
+    ].join('\n'),
+    parserOptions: parserOptions
   }],
 
   invalid: [{
Repository: yannickcr/eslint-plugin-react
Pull request #989 (2016-12-02 19:00:32)

Don't treat async functions as components
This is just a silly little thing – there's no way for async functions to be components.


Patch:
diff --git a/lib/util/Components.js b/lib/util/Components.js
index 181dfa24..37816a3b 100644
--- a/lib/util/Components.js
+++ b/lib/util/Components.js
@@ -496,6 +496,10 @@ function componentRule(rule, context) {
     },
 
     FunctionExpression: function(node) {
+      if (node.async) {
+        components.add(node, 0);
+        return;
+      }
       var component = utils.getParentComponent();
       if (
         !component ||
@@ -509,6 +513,10 @@ function componentRule(rule, context) {
     },
 
     FunctionDeclaration: function(node) {
+      if (node.async) {
+        components.add(node, 0);
+        return;
+      }
       node = utils.getParentComponent();
       if (!node) {
         return;
@@ -517,6 +525,10 @@ function componentRule(rule, context) {
     },
 
     ArrowFunctionExpression: function(node) {
+      if (node.async) {
+        components.add(node, 0);
+        return;
+      }
       var component = utils.getParentComponent();
       if (
         !component ||


Test patch:
diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js
index 3a60db4a..04cbc97e 100644
--- a/tests/lib/rules/prop-types.js
+++ b/tests/lib/rules/prop-types.js
@@ -1361,6 +1361,30 @@ ruleTester.run('prop-types', rule, {
       ].join('\n'),
       options: [{skipUndeclared: false}],
       parserOptions: parserOptions
+    }, {
+      // Async functions can't be components.
+      code: [
+        'var Hello = async function(props) {',
+        '  return <div>Hello {props.name}</div>;',
+        '}'
+      ].join('\n'),
+      parser: 'babel-eslint'
+    }, {
+      // Async functions can't be components.
+      code: [
+        'async function Hello(props) {',
+        '  return <div>Hello {props.name}</div>;',
+        '}'
+      ].join('\n'),
+      parser: 'babel-eslint'
+    }, {
+      // Async functions can't be components.
+      code: [
+        'var Hello = async (props) => {',
+        '  return <div>Hello {props.name}</div>;',
+        '}'
+      ].join('\n'),
+      parser: 'babel-eslint'
     }
   ],
Repository: yannickcr/eslint-plugin-react
Pull request #1018 (2017-01-11 00:25:27)

Fix `require-default-props` rule when using Flow type from assignment
This fixes the issue I reported in #1017.

The condition I added is hit when code like the following is used:

```js
type Props = Message
```

This just takes the right side of the annotation (`Message`) and tries to find that variable in scope and then continues on.

wyze: Hey @EvNaverniouk, can you check the failing case I added? Seems a bit off as I needed to provide `errors: []` because it is under `invalid` key in the test suite, but it doesn't actually output any errors.

Patch:
diff --git a/lib/rules/require-default-props.js b/lib/rules/require-default-props.js
index 550ac4b8..ea9c6975 100644
--- a/lib/rules/require-default-props.js
+++ b/lib/rules/require-default-props.js
@@ -141,7 +141,12 @@ module.exports = {
       switch (node.typeAnnotation.type) {
         case 'GenericTypeAnnotation':
           var annotation = resolveGenericTypeAnnotation(node.typeAnnotation);
-          properties = annotation ? annotation.properties : [];
+
+          if (annotation && annotation.id) {
+            annotation = findVariableByName(annotation.id.name);
+          }
+
+          properties = annotation ? (annotation.properties || []) : [];
           break;
 
         case 'UnionTypeAnnotation':


Test patch:
diff --git a/tests/lib/rules/require-default-props.js b/tests/lib/rules/require-default-props.js
index 991913e8..57d918be 100644
--- a/tests/lib/rules/require-default-props.js
+++ b/tests/lib/rules/require-default-props.js
@@ -676,6 +676,39 @@ ruleTester.run('require-default-props', rule, {
         '}'
       ].join('\n'),
       parser: 'babel-eslint'
+    },
+    {
+      code: [
+        'import type ImportedProps from "fake";',
+        'type Props = ImportedProps;',
+        'function Hello(props: Props) {',
+        '  return <div>Hello {props.name.firstname}</div>;',
+        '}'
+      ].join('\n'),
+      parser: 'babel-eslint'
+    },
+    // don't error when variable is not in scope
+    {
+      code: [
+        'import type { ImportedType } from "fake";',
+        'type Props = ImportedType;',
+        'function Hello(props: Props) {',
+        '  return <div>Hello {props.name.firstname}</div>;',
+        '}'
+      ].join('\n'),
+      parser: 'babel-eslint'
+    },
+    // make sure error is not thrown with multiple assignments
+    {
+      code: [
+        'import type ImportedProps from "fake";',
+        'type NestedProps = ImportedProps;',
+        'type Props = NestedProps;',
+        'function Hello(props: Props) {',
+        '  return <div>Hello {props.name.firstname}</div>;',
+        '}'
+      ].join('\n'),
+      parser: 'babel-eslint'
     }
   ],
Repository: yannickcr/eslint-plugin-react
Pull request #1023 (2017-01-13 13:49:04)

Fix no-array-index-key rule exception

wKich: Fix #1021 
wKich: Done
ljharb: The appveyor build seems to have failed due to Github issues; @wKich if you can force push a new SHA (perhaps via a rebase) then it should trigger the new build. I don't think anyone but @yannickcr can initiate a rerun of the current build.

Patch:
diff --git a/lib/rules/no-array-index-key.js b/lib/rules/no-array-index-key.js
index ecc97264..625cd064 100644
--- a/lib/rules/no-array-index-key.js
+++ b/lib/rules/no-array-index-key.js
@@ -143,7 +143,8 @@ module.exports = {
           }
 
           props.properties.forEach(function (prop) {
-            if (prop.key.name !== 'key') {
+            if (!prop.key || prop.key.name !== 'key') {
+              // { ...foo }
               // { foo: bar }
               return;
             }


Test patch:
diff --git a/tests/lib/rules/no-array-index-key.js b/tests/lib/rules/no-array-index-key.js
index ee59d6c3..7bb37b49 100644
--- a/tests/lib/rules/no-array-index-key.js
+++ b/tests/lib/rules/no-array-index-key.js
@@ -15,6 +15,7 @@ var RuleTester = require('eslint').RuleTester;
 var parserOptions = {
   ecmaVersion: 6,
   ecmaFeatures: {
+    experimentalObjectRestSpread: true,
     jsx: true
   }
 };
@@ -61,6 +62,11 @@ ruleTester.run('no-array-index-key', rule, {
       parserOptions: parserOptions
     },
 
+    {
+      code: 'foo.map((baz, i) => React.cloneElement(someChild, { ...someChild.props }))',
+      parserOptions: parserOptions
+    },
+
     {
       code: [
         'foo.map((item, i) => {',
@@ -69,7 +75,6 @@ ruleTester.run('no-array-index-key', rule, {
         '  })',
         '})'
       ].join('\n'),
-      errors: [{message: 'Do not use Array index in keys'}],
       parserOptions: parserOptions
     },
 
@@ -131,6 +136,12 @@ ruleTester.run('no-array-index-key', rule, {
       parserOptions: parserOptions
     },
 
+    {
+      code: 'foo.map((baz, i) => React.cloneElement(someChild, { ...someChild.props, key: i }))',
+      errors: [{message: 'Do not use Array index in keys'}],
+      parserOptions: parserOptions
+    },
+
     {
       code: [
         'foo.map((item, i) => {',
Repository: yannickcr/eslint-plugin-react
Pull request #1081 (2017-02-21 07:15:42)

Fix jsx-indent single line jsx
Also adds test


Patch:
diff --git a/lib/rules/jsx-indent.js b/lib/rules/jsx-indent.js
index 773e979d..f6ed3ac5 100644
--- a/lib/rules/jsx-indent.js
+++ b/lib/rules/jsx-indent.js
@@ -325,7 +325,7 @@ module.exports = {
         checkNodesIndent(node, parentNodeIndent + indentSize);
       },
       Literal: function(node) {
-        if (!node.parent || node.parent.type !== 'JSXElement') {
+        if (!node.parent || node.parent.type !== 'JSXElement' || node.loc.start.line === node.parent.loc.start.line) {
           return;
         }
         var parentElementIndent = getOpeningElementIndent(node.parent.openingElement);


Test patch:
diff --git a/tests/lib/rules/jsx-indent.js b/tests/lib/rules/jsx-indent.js
index 737fdf45..960a1009 100644
--- a/tests/lib/rules/jsx-indent.js
+++ b/tests/lib/rules/jsx-indent.js
@@ -451,6 +451,14 @@ ruleTester.run('jsx-indent', rule, {
     ].join('\n'),
     options: [2],
     parserOptions: parserOptions
+  }, {
+    code: [
+      'function foo() {',
+      '  <span>Text</span>',
+      '}'
+    ].join('\n'),
+    options: [2],
+    parserOptions: parserOptions
   }],
 
   invalid: [{
Repository: yannickcr/eslint-plugin-react
Pull request #1195 (2017-05-15 21:34:20)

fix: void-dom-elements-no-children
For some reason, we were using the following pattern that eslint **don't like**:
```js
const props = {}
React.createElement('img', props)
```


Patch:
diff --git a/lib/rules/void-dom-elements-no-children.js b/lib/rules/void-dom-elements-no-children.js
index e2783b71..fcc1c3f6 100644
--- a/lib/rules/void-dom-elements-no-children.js
+++ b/lib/rules/void-dom-elements-no-children.js
@@ -110,7 +110,7 @@ module.exports = {
           return;
         }
 
-        if (args.length < 2) {
+        if (args.length < 2 || args[1].type !== 'ObjectExpression') {
           return;
         }
 


Test patch:
diff --git a/tests/lib/rules/void-dom-elements-no-children.js b/tests/lib/rules/void-dom-elements-no-children.js
index 5ed098c3..d3d0b23e 100644
--- a/tests/lib/rules/void-dom-elements-no-children.js
+++ b/tests/lib/rules/void-dom-elements-no-children.js
@@ -53,33 +53,35 @@ ruleTester.run('void-dom-elements-no-children', rule, {
       code: 'document.createElement("img")'
     }, {
       code: 'React.createElement("img");'
+    }, {
+      code: [
+        'const props = {}',
+        'React.createElement("img", props)'
+      ].join('\n')
     }, {
       code: [
         'import React from "react";',
         'const { createElement } = React;',
         'createElement("div")'
-      ].join('\n'),
-      parser: 'babel-eslint'
+      ].join('\n')
     }, {
       code: [
         'import React from "react";',
         'const { createElement } = React;',
         'createElement("img")'
-      ].join('\n'),
-      parser: 'babel-eslint'
+      ].join('\n')
     }, {
       code: [
         'import React, {createElement, PureComponent} from \'react\';',
         'class Button extends PureComponent {',
-        '  handleClick = ev => {',
+        '  handleClick(ev) {',
         '    ev.preventDefault();',
         '  }',
         '  render() {',
         '    return <div onClick={this.handleClick}>Hello</div>;',
         '  }',
         '}'
-      ].join('\n'),
-      parser: 'babel-eslint'
+      ].join('\n')
     }
   ],
   invalid: [
Repository: yannickcr/eslint-plugin-react
Pull request #1226 (2017-05-27 19:39:33)

Fix void-dom-elements-no-children crash
`React.createElement()` currently crashes the linter with the following error and linting doesn't happen:

![image](https://cloud.githubusercontent.com/assets/25284557/26523944/7c8f2c5e-42f2-11e7-8234-b09dea2cdc70.png)

```
events.js:106 Cannot read property 'value' of undefined TypeError: Cannot read property 'value' of undefined
```

Of course ``React.createElement()`` will cause a runtime error, but it shouldn't crash the linter. 


Patch:
diff --git a/lib/rules/void-dom-elements-no-children.js b/lib/rules/void-dom-elements-no-children.js
index 71dd4ac9..2ee11320 100644
--- a/lib/rules/void-dom-elements-no-children.js
+++ b/lib/rules/void-dom-elements-no-children.js
@@ -103,6 +103,12 @@ module.exports = {
         }
 
         const args = node.arguments;
+
+        if (args.length < 1) {
+          // React.createElement() should not crash linter
+          return;
+        }
+
         const elementName = args[0].value;
 
         if (!isVoidDOMElement(elementName)) {


Test patch:
diff --git a/tests/lib/rules/void-dom-elements-no-children.js b/tests/lib/rules/void-dom-elements-no-children.js
index 2350ef70..c54e56b7 100644
--- a/tests/lib/rules/void-dom-elements-no-children.js
+++ b/tests/lib/rules/void-dom-elements-no-children.js
@@ -55,6 +55,10 @@ ruleTester.run('void-dom-elements-no-children', rule, {
     },
     {
       code: 'React.createElement("img");'
+    }, {
+      code: 'React.createElement();'
+    }, {
+      code: 'document.createElement();'
     }, {
       code: `
         const props = {};
Repository: yannickcr/eslint-plugin-react
Pull request #1237 (2017-06-04 10:08:01)

#969 fix: exception for jsx-no-duplicate-props
jsx-no-duplicate-props is causing error. 
TypeError: name.toLowerCase is not a function. 
When <Element {...props}> is used.

ljharb: Sorry for the inconvenience; I've just merged a refactor to start using arrow functions. Would you mind rebasing?

I'll merge within the next day or so, if no objections, after that's done.

Patch:
diff --git a/lib/rules/jsx-no-duplicate-props.js b/lib/rules/jsx-no-duplicate-props.js
index 7e1e0ddf..a57d236c 100644
--- a/lib/rules/jsx-no-duplicate-props.js
+++ b/lib/rules/jsx-no-duplicate-props.js
@@ -45,6 +45,10 @@ module.exports = {
 
           let name = decl.name.name;
 
+          if (typeof name !== 'string') {
+            return;
+          }
+
           if (ignoreCase) {
             name = name.toLowerCase();
           }


Test patch:
diff --git a/tests/lib/rules/jsx-no-duplicate-props.js b/tests/lib/rules/jsx-no-duplicate-props.js
index 1344391a..c3e544cd 100644
--- a/tests/lib/rules/jsx-no-duplicate-props.js
+++ b/tests/lib/rules/jsx-no-duplicate-props.js
@@ -49,7 +49,8 @@ ruleTester.run('jsx-no-duplicate-props', rule, {
     {code: '<App c="a" {...this.props} a="c" b="b" />;'},
     {code: '<App A a />;'},
     {code: '<App A b a />;'},
-    {code: '<App A="a" b="b" B="B" />;'}
+    {code: '<App A="a" b="b" B="B" />;'},
+    {code: '<App a:b="c" />;', options: ignoreCaseArgs}
   ],
   invalid: [
     {code: '<App a a />;', errors: [expectedError]},
Repository: yannickcr/eslint-plugin-react
Pull request #1244 (2017-06-07 07:36:44)

Treat "key" without value as a valid case instead for "no-array-index-key"
Fixes https://github.com/yannickcr/eslint-plugin-react/issues/1242


Patch:
diff --git a/lib/rules/no-array-index-key.js b/lib/rules/no-array-index-key.js
index 1e4602ad..d5e9241a 100644
--- a/lib/rules/no-array-index-key.js
+++ b/lib/rules/no-array-index-key.js
@@ -177,8 +177,8 @@ module.exports = {
         }
 
         var value = node.value;
-        if (value.type !== 'JSXExpressionContainer') {
-          // key='foo'
+        if (!value || value.type !== 'JSXExpressionContainer') {
+          // key='foo' or just simply 'key'
           return;
         }
 


Test patch:
diff --git a/tests/lib/rules/no-array-index-key.js b/tests/lib/rules/no-array-index-key.js
index 3bcd6048..fbf41deb 100644
--- a/tests/lib/rules/no-array-index-key.js
+++ b/tests/lib/rules/no-array-index-key.js
@@ -30,6 +30,7 @@ ruleTester.run('no-array-index-key', rule, {
   valid: [
     {code: '<Foo key="foo" />;'},
     {code: '<Foo key={i} />;'},
+    {code: '<Foo key />;'},
     {code: '<Foo key={`foo-${i}`} />;'},
     {code: '<Foo key={\'foo-\' + i} />;'},
 
@@ -71,6 +72,10 @@ ruleTester.run('no-array-index-key', rule, {
       ].join('\n')
     },
 
+    {
+      code: 'foo.map((baz, i) => <Foo key />)'
+    },
+
     {
       code: 'foo.reduce((a, b) => a.concat(<Foo key={b.id} />), [])'
     },