X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Flint-html.js;h=57f8241200a8d7beee76e491a3e02cb54129d54d;hb=refs%2Fheads%2Fmaster;hp=50abb84784ff732d266577718906fa6227dc17ce;hpb=9fc15beb6ed18e19e07ba49893ac472b411b8fb0;p=squeep-html-template-helper diff --git a/test/lint-html.js b/test/lint-html.js index 50abb84..57f8241 100644 --- a/test/lint-html.js +++ b/test/lint-html.js @@ -6,13 +6,27 @@ const assert = require('node:assert'); +/** + * @typedef {object} ConsoleLike + * @property {Function} debug debug + */ + +/** + * @typedef {import('html-validate')} HtmlValidateModule + */ + /** * Given an instance of html-validate, returns a function which asserts validity of some HTML. - * @param {ConsoleLike} logger - * @param {HtmlValidate} htmlValidate - * @returns {(html: String) => Promise} + * @param {ConsoleLike} logger logger + * @param {HtmlValidateModule.HtmlValidate} htmlValidate html-validate instance + * @returns {(html: string) => Promise} function which lints html */ function makeHtmlLint(logger, htmlValidate) { + /** + * + * @param {any[]} violations array of violations to add to + * @param {any} message violation to add + */ function note(violations, message) { violations.push(message.ruleId); logger.debug('HtmlLint', message); @@ -22,7 +36,7 @@ function makeHtmlLint(logger, htmlValidate) { const report = await htmlValidate.validateString(html); report.results.forEach((r) => { if (Array.isArray(r)) { - result.forEach((m) => { + r.forEach((m) => { note(violations, m); }); } else {