Skip to content

Commit 4d889b3

Browse files
committed
docs: fix broken error message in playground
1 parent de5ef44 commit 4d889b3

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/website/src/scripts/playground/helpers.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ export function toMarker(message) {
3333
];
3434
}
3535

36+
/**
37+
* @param {string} str
38+
* @returns {string}
39+
*/
40+
export function escapeHTML(str) {
41+
return str
42+
.replace(/&/g, "&")
43+
.replace(/</g, "&lt;")
44+
.replace(/>/g, "&gt;");
45+
}
46+
3647
export const INITIAL_HTML = html`<!DOCTYPE html>
3748
<html>
3849
<head>

packages/website/src/scripts/playground/view.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import "codemirror/mode/htmlmixed/htmlmixed.js";
33
import "codemirror/mode/javascript/javascript.js";
44
import CodeMirror from "codemirror";
55
import {
6-
toMarker
6+
toMarker,
7+
escapeHTML
78
} from "./helpers";
89
import {
910
html
@@ -115,7 +116,7 @@ export class View {
115116
}
116117

117118
return html`<li class="bg-red-100 text-red-800 px-2 py-1 my-1 rounded">
118-
${line}:${column} - ${message}(
119+
${line}:${column} - ${escapeHTML(message)}(
119120
<a href="/docs/rules/${ruleId.replace(
120121
"@html-eslint/",
121122
""

0 commit comments

Comments
 (0)