Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Always munge non-computed properties of MemberExpressions
// (a la preventing access of properties of unowned objects)
if (path[0].type === Syntax.MemberExpression && path[0].object !== node
&& path[0].computed === false) {
return true;
}
// Always munge identifiers that were declared within the method function
// scope
if (utils.identWithinLexicalScope(node.name, state, state.methodFuncNode)) {
return true;
}
// Always munge private keys on object literals defined within a method's
// scope.
if (path[0].type === Syntax.Property
&& path[1].type === Syntax.ObjectExpression) {
return true;
}
// Always munge function parameters
if (path[0].type === Syntax.FunctionExpression
|| path[0].type === Syntax.FunctionDeclaration
|| path[0].type === Syntax.ArrowFunctionExpression) {
for (var i = 0; i < path[0].params.length; i++) {
if (path[0].params[i] === node) {
return true;
}
}
}
}
return false;
// Always munge non-computed properties of MemberExpressions
// (a la preventing access of properties of unowned objects)
if (path[0].type === Syntax.MemberExpression && path[0].object !== node
&& path[0].computed === false) {
return true;
}
// Always munge identifiers that were declared within the method function
// scope
if (utils.identWithinLexicalScope(node.name, state, state.methodFuncNode)) {
return true;
}
// Always munge private keys on object literals defined within a method's
// scope.
if (path[0].type === Syntax.Property
&& path[1].type === Syntax.ObjectExpression) {
return true;
}
// Always munge function parameters
if (path[0].type === Syntax.FunctionExpression
|| path[0].type === Syntax.FunctionDeclaration
|| path[0].type === Syntax.ArrowFunctionExpression) {
for (var i = 0; i < path[0].params.length; i++) {
if (path[0].params[i] === node) {
return true;
}
}
}
}
return false;
true // previousWasSpread
);
utils.append((lastWasSpread ? '' : '}') + ')', state);
ii = nextComputedPropertyIndex - 1;
continue;
// short notation / dot access
} else if (
property.type === Syntax.Property &&
property.key.type === Syntax.Identifier &&
!property.computed
) {
utils.append(obj + '.' + property.key.name + '=', state);
// literals / computed properties
} else if (property.type === Syntax.Property) {
utils.append(obj + '[', state);
process(traverse, property.key, path, state);
utils.append(']=', state);
}
// concise methods
if (property.method === true) {
utils.catchupWhiteSpace(property.key.range[1], state);
es6ObjectConciseMethods.renderConciseMethod(traverse, property, path, state);
}
process(traverse, property.value, path, state);
}
utils.catchupWhiteSpace(node.range[1], state);
utils.append(',' + obj + ')', state);
return false;
}
);
}
break;
case Syntax.MemberExpression:
// skips: `foo.undefined` but not `foo[undefined]`
if (node === path[0].property && !path[0].computed) {
return false;
}
break;
case Syntax.VariableDeclarator:
// skips: `var undefined`
if (node !== path[0].init) {
return false;
}
break;
case Syntax.Property:
// skips: `undefined: foo`
if (node === path[0].key) {
return false;
}
break;
}
}
return true;
}
return false;
};
visitReactDisplayName.test = function(object, path, state) {
return (
object.type === Syntax.AssignmentExpression ||
object.type === Syntax.Property ||
object.type === Syntax.VariableDeclarator
);
};
visitObjectConciseMethod.test = function(node, path, state) {
return node.type === Syntax.Property &&
node.value.type === Syntax.FunctionExpression &&
node.method === true;
};
visitObjectConciseMethod.test = function(node, path, state) {
return node.type === Syntax.Property &&
node.value.type === Syntax.FunctionExpression &&
node.method === true;
};
visitObjectLiteralShortNotation.test = function(node, path, state) {
return node.type === Syntax.Property &&
node.kind === 'init' &&
node.shorthand === true &&
path[0].type !== Syntax.ObjectPattern;
};
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);
};
visitObjectConciseMethod.test = function(node, path, state) {
return node.type === Syntax.Property &&
node.value.type === Syntax.FunctionExpression &&
node.method === true;
};