function test(filename, contents, options) {
  const results = [];
  if (!options.commonTypos || options.skipTypos || options.ignoreTypos) {
    return results;
  }

  /**
   * Simple wrapper that adds a warning to the list
   *
   * @param {string} message The message to add.
   * @param {object} position The line number the warning occurred on.
   */
  function logWarning(message, position) {
    results.push({
      level: 'WARNING',
      filename: filename,
      position: position,
      message: message,
    });
  }

  options.commonTypos.forEach((typo) => {
    let flags = 'g';
    if (!typo.caseSensitive) {
      flags += 'i';
    }
    const reTypo = new RegExp(typo.typo.trim(), flags);
    const matches = wfRegEx.getMatches(reTypo, contents);
    matches.forEach((matchResult) => {
      const position = {line: getLineNumber(contents, matchResult.index)};
      const match = matchResult[0].replace(/\n/g, ' ').trim();
      let fix = typo.fix;
      if (!typo.caseSensitive) {
        fix = match.replace(reTypo, typo.fix);
        if (match.toLowerCase() === fix.toLowerCase()) {
          return;
        }
      }
      let msg = `Common typo found: '${match}'`;
      if (typo.fix) {
        msg += ` Should it be '${fix}'?`;
      }
      if (typo.british) {
        msg += ' Please use American spellings.' +
          ' See: https://developers.google.com/style/spelling';
      }
      if (typo.description) {
        msg += ' ' + typo.description;
      }
      logWarning(msg, position);
    });
  });

  return results;
}
Tests & validates the contents of an HTML or Markdown file.

@param {string} filename The name of the file to be tested
@param {string} contents The contents of the file to be tested
@param {Object} options The options object
@return {Array} An array of warnings and errors found in the file