You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/compiler/validate/js/propValidators/components.js

20 lines
659 B

8 years ago
import checkForDupes from '../utils/checkForDupes.js';
import checkForComputedKeys from '../utils/checkForComputedKeys.js';
8 years ago
export default function components ( validator, prop ) {
8 years ago
if ( prop.value.type !== 'ObjectExpression' ) {
validator.error( `The 'components' property must be an object literal`, prop.start );
return;
}
checkForDupes( validator, prop.value.properties );
checkForComputedKeys( validator, prop.value.properties );
8 years ago
8 years ago
prop.value.properties.forEach( component => {
const char = component.key.name[0];
if ( char === char.toLowerCase() ) {
validator.warn( `Component names should be capitalised`, component.start );
}
});
8 years ago
}