Skip to content

Commit d04a8ea

Browse files
authored
Merge pull request #119 from fulldecent/feat/html-validate-9
try hv 9
2 parents 1a26c11 + d056846 commit d04a8ea

File tree

7 files changed

+195
-229
lines changed

7 files changed

+195
-229
lines changed

.htmlvalidate.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

.htmlvalidate.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig } from "html-validate";
2+
3+
export default defineConfig({
4+
plugins: ["<rootDir>/test/plugin.html-validate.mjs"],
5+
extends: ["html-validate:prettier", "<rootDir>/test/plugin.html-validate.mjs:recommended"],
6+
rules: {
7+
"pacific-medical-training/mailto-awesome": "error",
8+
"pacific-medical-training/external-links": "error",
9+
"pacific-medical-training/no-jquery": "error",
10+
"pacific-medical-training/canonical-link": "error",
11+
"pacific-medical-training/latest-packages": "error",
12+
"pacific-medical-training/https-links": "error",
13+
"pacific-medical-training/internal-links": "error",
14+
},
15+
});

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"license": "UNLICENSED",
33
"devDependencies": {
44
"@shopify/prettier-plugin-liquid": "^1.6.2",
5-
"better-sqlite3": "^11.6.0",
5+
"better-sqlite3": "^11.7.0",
66
"glob": "^11.0.0",
7-
"html-validate": "^8.27.0",
7+
"html-validate": "^9.0.0-rc.4",
88
"markdownlint-cli2": "^0.15.0",
99
"prettier": "^3.4.2",
1010
"shell-quote": "^1.8.2"

test/build-html-validate.mjs

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
1-
import { HtmlValidate, formatterFactory } from "html-validate";
1+
import { HtmlValidate, FileSystemConfigLoader, formatterFactory, esmResolver } from "html-validate";
22
import { glob } from "glob";
3-
import plugin from "./plugin.html-validate.mjs";
43

54
// Find and sort all HTML files in the 'build' directory
65
const targets = glob.sync("build/**/*.html").sort();
76

87
// Initialize HtmlValidate instance
9-
const htmlValidate = new HtmlValidate({
10-
extends: ["html-validate:prettier"],
11-
plugins: [plugin],
12-
rules: {
13-
"mailto-awesome": "error",
14-
"external-links": "error",
15-
"no-jquery": "error",
16-
"canonical-link": "error",
17-
"latest-packages": "error",
18-
"https-links": "error",
19-
"internal-links": "error",
20-
},
21-
});
22-
8+
const resolver = esmResolver();
9+
const loader = new FileSystemConfigLoader([resolver]);
10+
const htmlValidate = new HtmlValidate(loader);
2311
const formatter = formatterFactory("stylish");
2412
let allTestsPassed = true;
2513

2614
// Validate each target file
27-
for (const target of targets) {
15+
const outcomes = targets.map(async (target) => {
2816
try {
2917
const report = await htmlValidate.validateFile(target);
3018
if (!report.valid) {
@@ -37,10 +25,14 @@ for (const target of targets) {
3725
console.error(`Error validating ${target}:`, error);
3826
allTestsPassed = false;
3927
}
40-
}
28+
});
4129

42-
if (allTestsPassed) {
43-
console.log("✨✨ All tests passed! ✨✨");
44-
} else {
45-
process.exit(1);
46-
}
30+
console.log("🧪 Testing pages");
31+
Promise.all(outcomes).then(() => {
32+
if (allTestsPassed) {
33+
console.log("✨ All tests passed!\n");
34+
} else {
35+
console.log("❌ Some tests failed.");
36+
process.exit(1);
37+
}
38+
});

0 commit comments

Comments
 (0)