From 1d1c18059991261111317845119c44a9ad2b0885 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 4 Jul 2024 17:18:56 +0100 Subject: [PATCH] fix(ui-templates): validate templates with `html-validate` (#28024) --- packages/ui-templates/lib/render.ts | 1 + packages/ui-templates/package.json | 2 +- .../ui-templates/templates/loading/index.html | 4 +- .../ui-templates/templates/welcome/index.html | 8 +-- ...ts.spec.ts.snap => templates.spec.ts.snap} | 26 +++---- packages/ui-templates/test/snapshots.spec.ts | 36 ---------- packages/ui-templates/test/templates.spec.ts | 69 ++++++++++++++++++ pnpm-lock.yaml | 70 ++++++++++++++++++- 8 files changed, 158 insertions(+), 58 deletions(-) rename packages/ui-templates/test/__snapshots__/{snapshots.spec.ts.snap => templates.spec.ts.snap} (97%) delete mode 100644 packages/ui-templates/test/snapshots.spec.ts create mode 100644 packages/ui-templates/test/templates.spec.ts diff --git a/packages/ui-templates/lib/render.ts b/packages/ui-templates/lib/render.ts index d81ffe873c..ccd40c9dd0 100644 --- a/packages/ui-templates/lib/render.ts +++ b/packages/ui-templates/lib/render.ts @@ -48,6 +48,7 @@ export const RenderPlugin = () => { // Apply critters to inline styles html = await critters.process(html) } + html = html.replace(/]*>/, '') // We no longer need references to external CSS html = html.replace(/]*>/g, '') diff --git a/packages/ui-templates/package.json b/packages/ui-templates/package.json index f62a0f0778..055f204980 100644 --- a/packages/ui-templates/package.json +++ b/packages/ui-templates/package.json @@ -12,7 +12,6 @@ "scripts": { "build": "vite build", "dev": "vite", - "lint": "eslint --ext .ts,.js .", "optimize-assets": "npx svgo public/assets/**/*.svg", "postinstall": "pnpm build", "prerender": "pnpm build && jiti ./lib/prerender", @@ -26,6 +25,7 @@ "execa": "9.3.0", "globby": "14.0.2", "html-minifier": "4.0.0", + "html-validate": "^8.20.1", "jiti": "1.21.6", "knitwork": "1.1.0", "lodash-es": "4.17.21", diff --git a/packages/ui-templates/templates/loading/index.html b/packages/ui-templates/templates/loading/index.html index bda8016b70..b84d48d41e 100644 --- a/packages/ui-templates/templates/loading/index.html +++ b/packages/ui-templates/templates/loading/index.html @@ -75,13 +75,13 @@
- - +