Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
traverseFast(ast, node => {
if (
node.type === 'TaggedTemplateExpression' &&
types.isIdentifier(node.tag) &&
node.tag.name === localizeName
) {
const messageParts = utils.unwrapMessagePartsFromTemplateLiteral(node.quasi.quasis);
positions.push({
// tslint:disable-next-line: no-non-null-assertion
start: node.start!,
// tslint:disable-next-line: no-non-null-assertion
end: node.end!,
messageParts,
expressions: node.quasi.expressions,
});
}
});
}
function areSame(defaultExportProperty, matchingNamedExport) {
const defaultExportValue = defaultExportProperty.value;
const declaration = matchingNamedExport.declaration; // i.e. 'export const a = 1' or 'export let a = b'
if (!defaultExportValue) {
// i.e. object method
return false; // always a conflict
} else if (t.isIdentifier(defaultExportValue)) {
const valueName = defaultExportValue.name;
if (valueName === matchingNamedExport.value.name) {
// Same identifier reference. Safe to ignore
return true;
} else if (
declaration &&
t.isIdentifier(declaration.init) &&
declaration.init.name === valueName
) {
// i.e. 'export let a = b', and default value for a is 'b'.
return true;
}
} else if (t.isLiteral(defaultExportValue)) {
// i.e. { a: 1 } or { a: '1' }
// See if the original declaration for the matching export was for the same literal
if (
t.isLiteral(declaration.init) &&
declaration.init.value === defaultExportValue.value
) {
// i.e. 'export const a = 1'
// Same literal. Safe to ignore
return true;
}
function areSame(defaultExportProperty, matchingNamedExport) {
const defaultExportValue = defaultExportProperty.value;
const declaration = matchingNamedExport.declaration; // i.e. 'export const a = 1' or 'export let a = b'
if (!defaultExportValue) {
// i.e. object method
return false; // always a conflict
} else if (t.isIdentifier(defaultExportValue)) {
const valueName = defaultExportValue.name;
if (valueName === matchingNamedExport.value.name) {
// Same identifier reference. Safe to ignore
return true;
} else if (
declaration &&
t.isIdentifier(declaration.init) &&
declaration.init.name === valueName
) {
// i.e. 'export let a = b', and default value for a is 'b'.
return true;
}
} else if (t.isLiteral(defaultExportValue)) {
// i.e. { a: 1 } or { a: '1' }
// See if the original declaration for the matching export was for the same literal
if (
function getKey(node) {
if (node.computed) {
return node.key;
} else if (t.isIdentifier(node.key)) {
return t.stringLiteral(node.key.name);
} else {
return t.stringLiteral(String(node.key.value));
}
}
defaultProps.right.properties.forEach(prop => {
if (t.isProperty(prop) && t.isIdentifier(prop.key)) {
defaultPropsKeyList.push(prop.key.name);
}
});
}
this.getType = node => {
if (t.isIdentifier(node) && this.directImported.has(node.name)) {
return this.directImported.get(node.name);
} else if (
t.isMemberExpression(node) &&
t.isIdentifier(node.object) &&
this.reactNamespace.has(node.object.name) &&
t.isIdentifier(node.property)
) {
return node.property.name;
}
};
return memberPaths.map(tsEnumMemberPath => {
const tsEnumMember = tsEnumMemberPath.node;
let value;
let valueNode;
if (tsEnumMember.initializer) {
if (
types.isNumericLiteral(tsEnumMember.initializer) ||
types.isStringLiteral(tsEnumMember.initializer)
) {
value = tsEnumMember.initializer.value;
} else if (types.isIdentifier(tsEnumMember.initializer)) {
value = constEnum[tsEnumMember.initializer.name];
validateConstEnumMemberAccess(tsEnumMemberPath, value);
} else if (
isNumericUnaryExpression(tsEnumMember.initializer) ||
isNumericBinaryExpression(tsEnumMember.initializer)
) {
if (isStringEnum) {
throw tsEnumMemberPath.buildCodeFrameError(
'Computed values are not permitted in an enum with string valued members.',
);
}
tsEnumMemberPath
.get('initializer')
.traverse(accessConstEnumMemberVisitor, { constEnum });
value = eval(generate(tsEnumMember.initializer).code);
const keyIndex = props.properties.findIndex(prop =>
t.isIdentifier(prop.key, { name: "key" }),
);
path.node.arguments.filter(types.isStringLiteral).forEach(arg => {
const moduleId = arg.value;
const nameSpace = [moduleId];
let currPath = path;
do {
let id = currPath.parent.id;
if (!id) {
id = currPath.parent.left;
if (id) {
id = path.scope.getBindingIdentifier(id.name) || id;
} else {
if (types.isIdentifier(currPath.parent.property)) {
nameSpace.push(currPath.parent.property.name);
}
currPath = currPath.parentPath;
continue;
}
};
setSpecifier(id, nameSpace);
break;
} while (currPath);
});
} else if (!tplCallee.has(callee) && isStylePath(path.get("callee"))) {
export function isIdentifierNamed(node, name) {
return t.isIdentifier(node, { name: name });
}