code: function validateMessageFormat(message) {
    function validateTypeStructure(message) {
      const typeParts = message.type.split('.'),
        baseType = typeParts[0],
        typeDepth = typeParts.length;
  
      if (typeDepth > 2)
        throw new Error(
          'Message type has too many dot separated sections: ' + message.type
        );
  
      const previousDepth = messageTypeDepths[baseType];
  
      if (previousDepth && previousDepth !== typeDepth) {
        throw new Error(
          `All messages of type ${baseType} must have the same structure. ` +
            `${
              message.type
            } has ${typeDepth} part(s), but earlier messages had ${previousDepth} part(s).`
        );
      }
  
      messageTypeDepths[baseType] = typeDepth;
    }
  
    function validatePageSummary(message) {
      const type = message.type;
      if (!type.endsWith('.pageSummary')) return;
  
      if (!message.url)
        throw new Error(`Page summary message (${type}) didn't specify a url`);
  
      if (!message.group)
        throw new Error(`Page summary message (${type}) didn't specify a group.`);
    }
  
    function validateSummaryMessage(message) {
      const type = message.type;
      if (!type.endsWith('.summary')) return;
  
      if (message.url)
        throw new Error(
          `Summary message (${type}) shouldn't be url specific, use .pageSummary instead.`
        );
  
      if (!message.group)
        throw new Error(`Summary message (${type}) didn't specify a group.`);
  
      const groups = groupsPerSummaryType[type] || [];
      if (groups.includes(message.group)) {
        throw new Error(
          `Multiple summary messages of type ${type} and group ${message.group}`
        );
      }
      groupsPerSummaryType[type] = groups.concat(message.group);
    }
  
    validateTypeStructure(message);
    validatePageSummary(message);
    validateSummaryMessage(message);
  }
docs: Check some message format best practices that applies to sitespeed.io.
  Throws an error if message doesn't follow the rules.
  @param message the message to check