|
|
@ -17,23 +17,22 @@ export default function validateJs ( validator, js ) {
|
|
|
|
|
|
|
|
|
|
|
|
if ( node.type === 'ExportDefaultDeclaration' ) {
|
|
|
|
if ( node.type === 'ExportDefaultDeclaration' ) {
|
|
|
|
if ( validator.defaultExport ) {
|
|
|
|
if ( validator.defaultExport ) {
|
|
|
|
validator.error( `Duplicate default export`, node.start );
|
|
|
|
return validator.error( `Duplicate default export`, node.start );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
validator.defaultExport = node;
|
|
|
|
if ( node.declaration.type !== 'ObjectExpression' ) {
|
|
|
|
|
|
|
|
return validator.error( `Default export must be an object literal`, node.declaration.start );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ensure all exported props are valid
|
|
|
|
checkForComputedKeys( validator, node.declaration.properties );
|
|
|
|
if ( validator.defaultExport ) {
|
|
|
|
checkForDupes( validator, node.declaration.properties );
|
|
|
|
checkForComputedKeys( validator, validator.defaultExport.declaration.properties );
|
|
|
|
|
|
|
|
checkForDupes( validator, validator.defaultExport.declaration.properties );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
validator.defaultExport.declaration.properties.forEach( prop => {
|
|
|
|
node.declaration.properties.forEach( prop => {
|
|
|
|
validator.templateProperties[ prop.key.name ] = prop;
|
|
|
|
validator.templateProperties[ prop.key.name ] = prop;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
validator.defaultExport.declaration.properties.forEach( prop => {
|
|
|
|
// ensure all exported props are valid
|
|
|
|
|
|
|
|
node.declaration.properties.forEach( prop => {
|
|
|
|
const propValidator = propValidators[ prop.key.name ];
|
|
|
|
const propValidator = propValidators[ prop.key.name ];
|
|
|
|
|
|
|
|
|
|
|
|
if ( propValidator ) {
|
|
|
|
if ( propValidator ) {
|
|
|
@ -54,5 +53,8 @@ export default function validateJs ( validator, js ) {
|
|
|
|
const ns = validator.templateProperties.namespace.value.value;
|
|
|
|
const ns = validator.templateProperties.namespace.value.value;
|
|
|
|
validator.namespace = namespaces[ ns ] || ns;
|
|
|
|
validator.namespace = namespaces[ ns ] || ns;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
validator.defaultExport = node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|