X-Git-Url: http://git.squeep.com/?p=squeep-html-template-helper;a=blobdiff_plain;f=test%2Flint-html.js;fp=test%2Flint-html.js;h=26cfed2aed97b19f2c89a2b0fb6e6f69cda119e6;hp=0000000000000000000000000000000000000000;hb=12a56b9b35eeb6181ce1d4b4fa2a0536984374d8;hpb=f02188f99140aabbd289b610d5968145c83fd057
diff --git a/test/lint-html.js b/test/lint-html.js
new file mode 100644
index 0000000..26cfed2
--- /dev/null
+++ b/test/lint-html.js
@@ -0,0 +1,28 @@
+'use strict';
+
+/**
+ * A brief wrapper around html-validate
+ */
+
+const assert = require('node:assert');
+const { HtmlValidate } = require('html-validate'); // eslint-disable-line node/no-unpublished-require
+const stubLogger = require('./stub-logger');
+
+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(', '));
+ }
+}
+
+module.exports = LintHtml;
\ No newline at end of file