How to use the esprima-fb.Syntax.Identifier function in esprima-fb

To help you get started, we’ve selected a few esprima-fb 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 facebookarchive / jstransform / visitors / react-display-name-visitors.js View on Github external
function shouldAddDisplayName(object) {
  if (object &&
      object.type === Syntax.CallExpression &&
      object.callee.type === Syntax.MemberExpression &&
      object.callee.object.type === Syntax.Identifier &&
      object.callee.object.name === 'React' &&
      object.callee.property.type === Syntax.Identifier &&
      object.callee.property.name === 'createClass' &&
      object.arguments.length === 1 &&
      object.arguments[0].type === Syntax.ObjectExpression) {
    // Verify that the displayName property isn't already set
    var properties = object.arguments[0].properties;
    var safe = properties.every(function(property) {
      var value = property.key.type === Syntax.Identifier ?
        property.key.name :
        property.key.value;
      return value !== 'displayName';
    });
    return safe;
  }
  return false;
github Caltech-IPAC / firefly / node_modules / react / node_modules / envify / node_modules / jstransform / visitors / es6-destructuring-visitors.js View on Github external
if (item.type === Syntax.SpreadProperty) {
      var restExpression = restPropertyHelpers.renderRestExpression(
        utils.getTempVar(tmpIndex),
        patternItems
      );
      components.push(item.argument.name + '=' + restExpression);
      continue;
    }

    // Depending on pattern type (Array or Object), we get
    // corresponding pattern item parts.
    var accessor = getPatternItemAccessor(node, item, tmpIndex, idx);
    var value = getPatternItemValue(node, item);

    // TODO(dmitrys): implement default values: {x, y=5}
    if (value.type === Syntax.Identifier) {
      // Simple pattern item.
      components.push(value.name + '=' + accessor);
    } else {
      // Complex sub-structure.
      components.push(
        utils.getTempVar(++state.localScope.tempVarIndex) + '=' + accessor +
        ',' + getDestructuredComponents(value, state)
      );
    }
  }

  return components.join(',');
}
github guptag / FinCharts / app / node_modules / react / node_modules / envify / node_modules / jstransform / visitors / es6-class-visitors.js View on Github external
function _getSuperClassInfo(node, state) {
  var ret = {
    name: null,
    expression: null
  };
  if (node.superClass) {
    if (node.superClass.type === Syntax.Identifier) {
      ret.name = node.superClass.name;
    } else {
      // Extension from an expression
      ret.name = _generateAnonymousClassName(state);
      ret.expression = state.g.source.substring(
        node.superClass.range[0],
        node.superClass.range[1]
      );
    }
  }
  return ret;
}
github joshuaslate / saas-tutorial / node_modules / jstransform / visitors / es6-class-visitors.js View on Github external
function _isConstructorMethod(classElement) {
  return classElement.type === Syntax.MethodDefinition &&
         classElement.key.type === Syntax.Identifier &&
         classElement.key.name === 'constructor';
}
github computers-are-fast / computers-are-fast.github.io / jspm_packages / npm / jstransform@10.1.0 / visitors / es6-call-spread-visitors.js View on Github external
function visitCallSpread(traverse, node, path, state) {
    utils.catchup(node.range[0], state);
    if (node.type === Syntax.NewExpression) {
      utils.append('new (Function.prototype.bind.apply(', state);
      process(traverse, node.callee, path, state);
    } else if (node.callee.type === Syntax.MemberExpression) {
      var tempVar = utils.injectTempVar(state);
      utils.append('(' + tempVar + ' = ', state);
      process(traverse, node.callee.object, path, state);
      utils.append(')', state);
      if (node.callee.property.type === Syntax.Identifier) {
        utils.append('.', state);
        process(traverse, node.callee.property, path, state);
      } else {
        utils.append('[', state);
        process(traverse, node.callee.property, path, state);
        utils.append(']', state);
      }
      utils.append('.apply(' + tempVar, state);
    } else {
      var needsToBeWrappedInParenthesis = node.callee.type === Syntax.FunctionDeclaration || node.callee.type === Syntax.FunctionExpression;
      if (needsToBeWrappedInParenthesis) {
        utils.append('(', state);
      }
      process(traverse, node.callee, path, state);
      if (needsToBeWrappedInParenthesis) {
        utils.append(')', state);
github zillow / react-slider / node_modules / jstransform / visitors / reserved-words-visitors.js View on Github external
visitProperty.test = function(node) {
  return node.type === Syntax.Property &&
    node.key.type === Syntax.Identifier &&
    !node.method &&
    !node.shorthand &&
    !node.computed &&
    reserverdWordsHelper.isES3ReservedWord(node.key.name);
};
github Lapple / ErrorBoard / node_modules / react-tools / node_modules / jstransform / visitors / es6-arrow-function-visitors.js View on Github external
utils.containsChildMatching(node.body, function(node) {
      return node.type === Syntax.ThisExpression
             || (node.type === Syntax.Identifier
                 && node.name === "super");
    });
github Caltech-IPAC / firefly / node_modules / react / node_modules / envify / node_modules / jstransform / visitors / reserved-words-visitors.js View on Github external
visitMemberExpression.test = function(node) {
  return node.type === Syntax.MemberExpression &&
    node.property.type === Syntax.Identifier &&
    reserverdWordsHelper.isES3ReservedWord(node.property.name);
};
github facebookarchive / jstransform / visitors / es7-rest-property-helpers.js View on Github external
function getPropertyNames(properties) {
  var names = [];
  for (var i = 0; i < properties.length; i++) {
    var property = properties[i];
    if (property.type === Syntax.SpreadProperty) {
      continue;
    }
    if (property.type === Syntax.Identifier) {
      names.push(property.name);
    } else {
      names.push(property.key.name);
    }
  }
  return names;
}
github Zach417 / churchetto-web / node_modules / envify / node_modules / jstransform / visitors / reserved-words-visitors.js View on Github external
visitProperty.test = function(node) {
  return node.type === Syntax.Property &&
    node.key.type === Syntax.Identifier &&
    !node.method &&
    !node.shorthand &&
    !node.computed &&
    reserverdWordsHelper.isES3ReservedWord(node.key.name);
};