Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.keys(canner).forEach(key => {
if (key === 'cannerDataType') {
if (type !== 'json') { // the component of json type is same as object, but the type can't be changed
properties.push(t.objectProperty(t.stringLiteral('type'), t.stringLiteral(canner[key])));
}
} else if (typeof canner[key] === 'string'){
properties.push(t.objectProperty(t.stringLiteral(key), t.stringLiteral(canner[key])));
} else if (typeof canner[key] === 'number'){
properties.push(t.objectProperty(t.stringLiteral(key), t.numberLiteral(canner[key])));
} else if (typeof canner[key] === 'boolean'){
properties.push(t.objectProperty(t.stringLiteral(key), t.booleanLiteral(canner[key])));
} else {
throw new Error(`Not support the type of object and array config in canner yet, but got key: ${key} with value: ${canner[key]}.`);
}
});
return properties;
Object.keys(canner).forEach(key => {
if (key === 'cannerDataType') {
if (type !== 'json') { // the component of json type is same as object, but the type can't be changed
properties.push(t.objectProperty(t.stringLiteral('type'), t.stringLiteral(canner[key])));
}
} else if (typeof canner[key] === 'string'){
properties.push(t.objectProperty(t.stringLiteral(key), t.stringLiteral(canner[key])));
} else if (typeof canner[key] === 'number'){
properties.push(t.objectProperty(t.stringLiteral(key), t.numberLiteral(canner[key])));
} else if (typeof canner[key] === 'boolean'){
properties.push(t.objectProperty(t.stringLiteral(key), t.booleanLiteral(canner[key])));
} else {
throw new Error(`Not support the type of object and array config in canner yet, but got key: ${key} with value: ${canner[key]}.`);
}
});
return properties;
specifiers.forEach(s => {
if (t.isImportDefaultSpecifier(s)) {
defaultDeclator = [t.variableDeclarator(t.identifier(s.local.name), t.objectExpression(objectPropperties))]
} else {
importItems.push(t.objectProperty(t.identifier(s.local.name), t.identifier(s.local.name)))
}
})
normalDeclator = [t.variableDeclarator(t.objectPattern(importItems), t.objectExpression(objectPropperties))]
function routeNode({ path, layout = '', component }) {
if (layout) {
return t.objectExpression([
t.objectProperty(t.stringLiteral('path'), t.stringLiteral(path)),
t.objectProperty(
t.stringLiteral('layout'),
t.identifier(upperCamelCase(layout))
),
t.objectProperty(t.stringLiteral('component'), t.identifier(component)),
]);
}
return t.objectExpression([
t.objectProperty(t.stringLiteral('path'), t.stringLiteral(path)),
t.objectProperty(t.stringLiteral('component'), t.identifier(component)),
]);
}
t.objectExpression([
t.objectProperty(
t.identifier('type'),
typeMap.ref(
props[propKey],
requiredProps.includes(propKey),
type,
propKey
)
),
])
);
});
if (!fields.length) {
fields.push(
t.objectProperty(
t.identifier('unknownShape'),
t.objectExpression([
t.objectProperty(
t.identifier('type'),
typeMap.ref({ type: 'boolean' }, false)
),
])
)
);
}
const node = t.variableDeclaration('const', [
t.variableDeclarator(
t.identifier(graphqlName),
t.newExpression(typeMap.objectTypeRef, [
t.objectExpression([
t.objectProperty(t.identifier('name'), t.stringLiteral(graphqlName)),
exit (astPath) {
const node = astPath.node
const key = node.key
const value = node.value
if (key.name !== 'state' || !t.isObjectExpression(value)) return
astPath.node.value.properties.push(t.objectProperty(
t.identifier(tabBarConfigName),
tabBar
))
}
},
const fields = Object.keys(props).map(propKey => {
return t.objectProperty(
t.identifier(propKey),
t.objectExpression([
t.objectProperty(
t.identifier('type'),
typeMap.ref(
props[propKey],
requiredProps.includes(propKey),
type,
propKey
)
),
])
);
});
if (!fields.length) {
specifiers.forEach(s => {
if (t.isImportDefaultSpecifier(s)) {
defaultDeclator = [t.variableDeclarator(t.identifier(s.local.name), t.objectExpression(objectPropperties))]
} else {
importItems.push(t.objectProperty(t.identifier(s.local.name), t.identifier(s.local.name)))
}
})
normalDeclator = [t.variableDeclarator(t.objectPattern(importItems), t.objectExpression(objectPropperties))]
t.identifier(TEMPLATE_PARAMS.CONTEXT),
memorizedId,
),
handler,
);
handler = t.logicalExpression(
'||',
memorizedId,
memorization,
);
}
return handler;
});
data.push(t.objectProperty(t.identifier('on'), onObj));
}
return t.objectExpression(data);
}
UseStatement(path) {
const useStmt = path.node,
source = useStmt.source;
if (useStmt.aliases.length) {
const members = [];
for (const { name, alias } of (useStmt.aliases: Array)) {
const aliasName = toBlockName(alias.name),
nameName = toBlockName(name.name);
this.addImportFrom(source.value, aliasName, nameName);
members.push(
t.objectProperty(
t.identifier(aliasName),
t.identifier(aliasName),
false,
true
)
);
}
const inheritBlocks = t.expressionStatement(
t.callExpression(
t.memberExpression(
t.identifier('Object'),
t.identifier('assign')
),
[
t.identifier(this.templateVariableName),
t.objectExpression(members),