scripts/lib/ExtensionValidator.js
/**
 * Check the extension for any properties that are not on the allow list.
 * @param {ExtensionWithFilename} extensionWithFilename
 * @returns {string[]}
 */
Check the extension for any properties that are not on the allow list.
Check the extension for any properties that are not on the allow list .
function validateExtension(extensionWithFilename) {
  const errors = [];
  const { extension, filename } = extensionWithFilename;
  const name = extension.name;
  if (name.endsWith('Extension')) {
    errors.push(
      `Extension names should not finish with \"Extension\". Please rename '${name}' to '${name.slice(
        0,
        -9
      )}'.`
    );
  }
  const expectedFilename = name + '.json';
  if (expectedFilename !== filename) {
    errors.push(
      `Extension filename should be exactly the name of the extension (with .json extension). Please rename '${filename}' to '${expectedFilename}'.`
    );
  }
  const disallowedPropertyErrors =
    checkExtensionForDisallowedProperties(extension);
  if (disallowedPropertyErrors.length > 0) {
    const reducedError = disallowedPropertyErrors
      .reduce(
        (accumulator, current) =>
          accumulator + inspect(current, undefined, undefined, true) + '\n',
        `Found disallowed properties in extension '${name}':\n`
      )
      .slice(0, -1);
    errors.push(reducedError);
  }
  checkExtensionAgainstBestPractices(extension, errors);
  return errors;
}
function validateExtension ( extensionWithFilename ) { const errors = [ ] ; const { extension , filename } = extensionWithFilename ; const name = extension . name ; if ( name . endsWith ( 'Extension' ) ) { errors . push ( ` \" \" ${ name } ${ name . slice ( 0 , - 9 ) } ` ) ; } const expectedFilename = name + '.json' ; if ( expectedFilename !== filename ) { errors . push ( ` ${ filename } ${ expectedFilename } ` ) ; } const disallowedPropertyErrors = checkExtensionForDisallowedProperties ( extension ) ; if ( disallowedPropertyErrors . length > 0 ) { const reducedError = disallowedPropertyErrors . reduce ( ( accumulator , current ) => accumulator + inspect ( current , undefined , undefined , true ) + '\n' , ` ${ name } \n ` ) . slice ( 0 , - 1 ) ; errors . push ( reducedError ) ; } checkExtensionAgainstBestPractices ( extension , errors ) ; return errors ; }
Check the extension for any properties that are not on the allow list.
Check the extension for any properties that are not on the allow list .
/** @type {string[]} */ /** @type {string} */ // Do some base consistency checks. // Check for disallowed properties // Remove the last \n // Check against extension best practices