-class LintHtml {
- constructor(logger, ...args) {
- this.logger = logger;
- this.htmlValidate = new HtmlValidate(...args);
- }
-
- async lint(html) {
- const ruleViolations = [];
- const report = await this.htmlValidate.validateString(html);
- report.results.forEach((m) => {
- ruleViolations.push(m.ruleId);
- stubLogger?.debug('LintHtml', 'message', m);
- })
- assert(report.valid, '' + ruleViolations.join(', '));
+/**
+ * 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<void>}
+ */
+function makeHtmlLint(logger, htmlValidate) {
+ function note(violations, message) {
+ violations.push(message.ruleId);
+ logger.debug('HtmlLint', message);