Repository: yannickcr/eslint-plugin-react (js)

Issue:
Cannot read property 'name' of undefined at getPropName
env: 
"eslint": "^5.0.0",
"eslint-plugin-react": "^7.10.0",


I got a error when use eslint --ext .js src; 
the error is happened in `eslint-plugin-react\lib\rules\jsx-props-no-multi-spaces.js getPropName `  function, this function like can't handle the Node type, and I console the Node type, there is

<code>
{
  type: 'JSXMemberExpression',
  start: 1243,
  end: 1252,
  loc:
   SourceLocation {
     start: Position { line: 43, column: 9 },
     end: Position { line: 43, column: 18 } },
  range: [ 1243, 1252 ],
  object:
   Node {
     type: 'JSXIdentifier',
     start: 1243,
     end: 1247,
     loc: SourceLocation { start: [Object], end: [Object] },
     range: [ 1243, 1247 ],
     name: 'Menu',
     _babelType: 'JSXIdentifier',
     parent: [Circular] },
  property:
   Node {
     type: 'JSXIdentifier',
     start: 1248,
     end: 1252,
     loc: SourceLocation { start: [Object], end: [Object] },
     range: [ 1248, 1252 ],
     name: 'Item',
     _babelType: 'JSXIdentifier',
     parent: [Circular] },
  _babelType: 'JSXMemberExpression',
  parent:
   Node {
     type: 'JSXOpeningElement',
     start: 1242,
     end: 1269,
     loc: SourceLocation { start: [Object], end: [Object] },
     range: [ 1242, 1269 ],
     attributes: [ [Object] ],
     name: [Circular],
     selfClosing: false,
     _babelType: 'JSXOpeningElement',
     parent:
      Node {
        type: 'JSXElement',
        start: 1242,
        end: 1325,
        loc: [Object],
        range: [Array],
        openingElement: [Circular],
        closingElement: [Object],
        children: [Array],
        _babelType: 'JSXElement',
        parent: [Object] } } }
</code> 



Pull request:
Handle member expressions in jsx-props-no-multi-spaces
Resolves #1881

Patch:
diff --git a/lib/rules/jsx-props-no-multi-spaces.js b/lib/rules/jsx-props-no-multi-spaces.js
index e9a55893..bd36dc68 100644
--- a/lib/rules/jsx-props-no-multi-spaces.js
+++ b/lib/rules/jsx-props-no-multi-spaces.js
@@ -27,12 +27,16 @@ module.exports = {
     const sourceCode = context.getSourceCode();
 
     function getPropName(propNode) {
-      if (propNode.type === 'JSXSpreadAttribute') {
-        return sourceCode.getText(propNode.argument);
-      } else if (propNode.type === 'JSXIdentifier') {
-        return propNode.name;
+      switch (propNode.type) {
+        case 'JSXSpreadAttribute':
+          return sourceCode.getText(propNode.argument);
+        case 'JSXIdentifier':
+          return propNode.name;
+        case 'JSXMemberExpression':
+          return `${getPropName(propNode.object)}.${propNode.property.name}`;
+        default:
+          return propNode.name.name;
       }
-      return propNode.name.name;
     }
 
     function checkSpacing(prev, node) {


Test patch:
diff --git a/tests/lib/rules/jsx-props-no-multi-spaces.js b/tests/lib/rules/jsx-props-no-multi-spaces.js
index bb0834ad..3b3cbd7a 100644
--- a/tests/lib/rules/jsx-props-no-multi-spaces.js
+++ b/tests/lib/rules/jsx-props-no-multi-spaces.js
@@ -58,6 +58,10 @@ ruleTester.run('jsx-props-no-multi-spaces', rule, {
       '  foo {...test}',
       '  bar />'
     ].join('\n')
+  }, {
+    code: '<Foo.Bar baz="quux" />'
+  }, {
+    code: '<Foobar.Foo.Bar.Baz.Qux.Quux.Quuz.Corge.Grault.Garply.Waldo.Fred.Plugh xyzzy="thud" />'
   }],
 
   invalid: [{
@@ -106,5 +110,17 @@ ruleTester.run('jsx-props-no-multi-spaces', rule, {
       {message: 'Expected only one space between "foo" and "test"'},
       {message: 'Expected only one space between "test" and "bar"'}
     ]
+  }, {
+    code: '<Foo.Bar  baz="quux" />',
+    output: '<Foo.Bar baz="quux" />',
+    errors: [
+      {message: 'Expected only one space between "Foo.Bar" and "baz"'}
+    ]
+  }, {
+    code: '<Foobar.Foo.Bar.Baz.Qux.Quux.Quuz.Corge.Grault.Garply.Waldo.Fred.Plugh  xyzzy="thud" />',
+    output: '<Foobar.Foo.Bar.Baz.Qux.Quux.Quuz.Corge.Grault.Garply.Waldo.Fred.Plugh xyzzy="thud" />',
+    errors: [
+      {message: 'Expected only one space between "Foobar.Foo.Bar.Baz.Qux.Quux.Quuz.Corge.Grault.Garply.Waldo.Fred.Plugh" and "xyzzy"'}
+    ]
   }]
 });