How to use the babel-types.isMemberExpression function in babel-types

To help you get started, we’ve selected a few babel-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cssinjs / jss / packages / babel-plugin / src / utils / serializeNode.js View on Github external
const key = getPropertyName(path, property)
        serialized[key] = value
      }
      return serialized
    }, {})
  }

  // injectSheet({a:  {margin: [0, 1]}})
  if (t.isArrayExpression(node)) {
    return node.elements.map(elementNode => serializeNode(path, elementNode, theme))
  }

  // Styles are defined by a function whith a theme argument
  // `injectSheet((theme) => ({a: {color: theme.primary}}))`.
  // We enter this on `theme.primary`.
  if (t.isMemberExpression(node)) {
    const {object, props} = serializePropAccess(node)

    if (props[0] in path.scope.bindings) {
      const data = serializeNode(path, path.scope.bindings[props[0]].identifier, theme)
      if (!data) return null
      return getValueByPath(path, data, props.slice(1))
    }

    // When object name we are accessing is the argument name.
    const firstArgNode = resolveRef(path, path.node.arguments[0])
    if (t.isFunction(firstArgNode) && hasThemeArg(firstArgNode, object.name)) {
      return getValueByPath(path, theme, props.slice(1))
    }
  }

  // injectSheet({a:  {left: 1 + 2}}) || injectSheet(getStyles(5))
github ssneilss / babel-plugin-styled-components-dataset / src / index.js View on Github external
const isStyled = (tag, state) => {
  if (
    t.isCallExpression(tag) &&
    t.isMemberExpression(tag.callee) &&
    tag.callee.property.name !== 'default' /** ignore default for #93 below */
  ) {
    // styled.something()
    return isStyled(tag.callee.object, state);
  }

  return (
    (t.isMemberExpression(tag) && tag.object.name === importLocalName('default', state)) ||
    (t.isCallExpression(tag) && tag.callee.name === importLocalName('default', state)) ||
    (t.isCallExpression(tag) &&
      t.isCallExpression(tag.callee.object) &&
      tag.callee.object.callee.name === 'require' &&
      tag.callee.object.arguments[0].value === 'styled-components')
  );
};
github forivall / tacoscript / packages / tacotruck / src / printer / types / expressions.js View on Github external
export function MemberExpression(node) {
  this.print(node, "object");

  if (!node.computed && t.isMemberExpression(node.property)) {
    throw new TypeError("Got a MemberExpression for MemberExpression property");
  }

  let computed = node.computed;
  if (t.isLiteral(node.property) && isNumber(node.property.value)) {
    computed = true;
  }

  if (computed) {
    this.push("[");
    this.print(node, "property");
    this.push("]");
  } else {
    if (t.isLiteral(node.object)) {
      let val = this._stringLiteral(node.object);
      if (isInteger(+val) && !SCIENTIFIC_NOTATION.test(val) && !this.endsWith(".")) {
github babel / babel / packages / babel-helper-replace-supers / src / index.js View on Github external
function isMemberExpressionSuper(node) {
  return t.isMemberExpression(node) && t.isSuper(node.object);
}
github captainwz / react-pocket / src / interpreter / resolver.js View on Github external
} else if (t.isIdentifier(p.node.declaration)) {
                    
                    className = p.node.declaration.name;

                }

                objArr.forEach(obj => {
                    if (obj.className == className || obj.alias == className) {
                        exportObj = obj;
                    }
                })

            }

            if (t.isAssignmentExpression(p.node) &&
                t.isMemberExpression(p.node.left) &&
                t.isIdentifier(p.node.left.object) &&
                p.node.left.object.name == 'module' &&
                t.isIdentifier(p.node.left.property) &&
                p.node.left.property.name == 'exports' &&
                t.isIdentifier(p.node.right)
            ) {

                let className = p.node.name;

                objArr.forEach(obj => {
                    if (obj.className == className || obj.alias == className) {
                        exportObj = obj;
                    }
                })

            }
github bradyhouse / house / fiddles / nativeScript / fiddle-0000-Template / template / platforms / android / build-tools / android-static-binding-generator / parser / visitors / es5-visitors.js View on Github external
function _resolveInterfacePath(node) {
        var subNode = "";

        if (t.isMemberExpression(node)) {
            if (t.isMemberExpression(node.object)) {
                subNode += _resolveInterfacePath(node.object);
                subNode += node.property.name + ".";
            } else {
                subNode += node.object.name + ".";
                subNode += node.property.name + ".";
            }
        }

        return subNode;
    }
github alibaba / rax / packages / sfc-compiler / src / codegen / withScope.js View on Github external
CallExpression(path) {
      const { node } = path;
      if (Array.isArray(node.arguments)) {
        for (let i = 0, l = node.arguments.length; i < l; i++) {
          add(node.arguments[i]);

          if (t.isMemberExpression(node.arguments[i])) {
            add(node.arguments[i].object);
          }
        }
      }

      add(node.callee);
    },
    BinaryExpression(path) {
github Tencent / omi / packages / cax-omip / scripts / taro-transformer-wx / lib / src / utils.js View on Github external
function isArrayMapCallExpression(callExpression) {
    return callExpression &&
        t.isCallExpression(callExpression.node) &&
        t.isMemberExpression(callExpression.node.callee) &&
        t.isIdentifier(callExpression.node.callee.property, { name: 'map' });
}
exports.isArrayMapCallExpression = isArrayMapCallExpression;