Skip to content

Commit

Permalink
warn if options.name does not begin with a capital letter; tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Apr 10, 2017
1 parent e76f4fe commit 4fe0365
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/validate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ export default function validate ( parsed, source, { onerror, onwarn, name, file
onerror( error );
}

if ( name && !/^[A-Z]/.test( name ) ) {
const message = `options.name should be capitalised`;
onwarn({
message,
filename,
toString: () => message
});
}

if ( parsed.js ) {
validateJs( validator, parsed.js );
}
Expand Down
3 changes: 1 addition & 2 deletions src/validate/js/propValidators/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export default function components ( validator, prop ) {
checkForComputedKeys( validator, prop.value.properties );

prop.value.properties.forEach( component => {
const char = component.key.name[0];
if ( char === char.toLowerCase() ) {
if ( !/^[A-Z]/.test( component.key.name ) ) {
validator.warn( `Component names should be capitalised`, component.start );
}
});
Expand Down

0 comments on commit 4fe0365

Please sign in to comment.