module.exports = babelPluginTransformReactEs6ClassDisplayName;

function babelPluginTransformReactEs6ClassDisplayName (babel) {
  return {
    visitor: {
      ClassDeclaration: function (path) {
        addDisplayName.call(path, babel.types);
      }
    }
  };
}

function addDisplayName (t) {
  if (
    this.node.superClass.name === 'Component' ||
    (
      this.node.superClass.object &&
      this.node.superClass.object.name === 'React' &&
      this.node.superClass.property.name === 'Component'
    )
  ) {
    this.insertAfter([
      t.expressionStatement(t.assignmentExpression(
        '=',
        t.memberExpression(this.node.id, t.identifier('displayName')),
        t.stringLiteral(this.node.id.name)
      ))
    ]);
  }
}

@@ -296,16 +296,52 @@
 %0A  if (%0A
+    this.node.superClass &&%0A    (%0A  
     this
@@ -381,32 +381,34 @@
 ent' %7C%7C%0A    
+  
 (%0A      
 this.node.su
@@ -387,32 +387,34 @@
 %7C%0A      (%0A      
+ 
+ 
 this.node.superC
@@ -424,24 +424,26 @@
 s.object &&%0A
+  
       this.n
@@ -486,24 +486,26 @@
 t' &&%0A      
+ 
+ 
 this.node.su
@@ -543,16 +543,24 @@
 ponent'%0A
+      )%0A
     )%0A  

Add checks and balances