packages/babel-plugin-transform-class-display-name/lib/index.js
function isReactClass (node) {
    if (!node || !t.isCallExpression(node)) return false

    // not _createClass call
    if (!node.callee || node.callee.name !== '_createClass') return false

    // no call arguments
    const args = node.arguments
    if (!args || args.length !== 2) return false
    if (!t.isIdentifier(args[0])) return false
    if (!t.isArrayExpression(args[1])) return false

    // no render method
    if (!args[1].elements || !args[1].elements.some((el) => {
      return isRenderMethod(el.properties)
    })) return false

    return true
  }
function isReactClass (node) {
    if (!node || !t.isCallExpression(node)) return false

    // not _createClass call
    if (!node.callee || node.callee.name !== '_createClass') return false

    // no call arguments
    const args = node.arguments
    if (!args || args.length !== 2) return false
    if (!t.isIdentifier(args[0])) return false
    if (!t.isArrayExpression(args[1])) return false

    // no render method
    if (!args[1].elements || !args[1].elements.some((el) => {
      return isRenderMethod(el.properties)
    })) return false

    return true
  }
function isReactClass ( node ) { if ( ! node || ! t . isCallExpression ( node ) ) return false // not _createClass call if ( ! node . callee || node . callee . name !== '_createClass' ) return false // no call arguments const args = node . arguments if ( ! args || args . length !== 2 ) return false if ( ! t . isIdentifier ( args [ 0 ] ) ) return false if ( ! t . isArrayExpression ( args [ 1 ] ) ) return false // no render method if ( ! args [ 1 ] . elements || ! args [ 1 ] . elements . some ( ( el ) => { return isRenderMethod ( el . properties ) } ) ) return false return true }
Determine if an AST node is likely a class extending React.Component
Determine if an AST node is likely a class extending React . Component