|
|
|
@ -3,7 +3,7 @@ import validateHtml from './html/index.js';
|
|
|
|
|
import { getLocator } from 'locate-character';
|
|
|
|
|
import getCodeFrame from '../utils/getCodeFrame.js';
|
|
|
|
|
|
|
|
|
|
export default function validate ( parsed, source, { onerror, onwarn, filename } ) {
|
|
|
|
|
export default function validate ( parsed, source, { onerror, onwarn, name, filename } ) {
|
|
|
|
|
const locator = getLocator( source );
|
|
|
|
|
|
|
|
|
|
const validator = {
|
|
|
|
@ -47,6 +47,16 @@ export default function validate ( parsed, source, { onerror, onwarn, filename }
|
|
|
|
|
namespace: null
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if ( name && !/^[a-zA-Z_$][a-zA-Z_$0-9]*$/.test( name ) ) {
|
|
|
|
|
const error = new Error( `options.name must be a valid identifier` );
|
|
|
|
|
|
|
|
|
|
if ( onerror ) {
|
|
|
|
|
onerror( error );
|
|
|
|
|
} else {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( parsed.js ) {
|
|
|
|
|
validateJs( validator, parsed.js );
|
|
|
|
|
}
|
|
|
|
|