50abb84784ff732d266577718906fa6227dc17ce
4 * A brief assertion wrapper around html-validate.
7 const assert
= require('node:assert');
10 * Given an instance of html-validate, returns a function which asserts validity of some HTML.
11 * @param {ConsoleLike} logger
12 * @param {HtmlValidate} htmlValidate
13 * @returns {(html: String) => Promise<void>}
15 function makeHtmlLint(logger
, htmlValidate
) {
16 function note(violations
, message
) {
17 violations
.push(message
.ruleId
);
18 logger
.debug('HtmlLint', message
);
20 return async
function HtmlLint(html
) {
21 const violations
= [];
22 const report
= await htmlValidate
.validateString(html
);
23 report
.results
.forEach((r
) => {
24 if (Array
.isArray(r
)) {
25 result
.forEach((m
) => {
32 assert(report
.valid
, 'HTML violations: ' + violations
.join(', '));