UNPKG

monaco-html-linter-plugin

Version:

Simple HTML Linter for the Monaco Editor.

1,856 lines 139 kB
function L(r) { if (r.__esModule) return r; var a = r.default; if (typeof a == "function") { var e = function i() { return this instanceof i ? Reflect.construct(a, arguments, this.constructor) : a.apply(this, arguments); }; e.prototype = a.prototype; } else e = {}; return Object.defineProperty(e, "__esModule", { value: !0 }), Object.keys(r).forEach(function(i) { var t = Object.getOwnPropertyDescriptor(r, i); Object.defineProperty(e, i, t.get ? t : { enumerable: !0, get: function() { return r[i]; } }); }), e; } var he = {}, T = {}; Object.defineProperty(T, "__esModule", { value: !0 }); class ze { constructor() { this._listeners = {}, this._mapCdataTags = this.makeMap("script,style"), this._arrBlocks = [], this.lastEvent = null; } makeMap(a) { const e = {}, i = a.split(","); for (let t = 0; t < i.length; t++) e[i[t]] = !0; return e; } parse(a) { const e = this._mapCdataTags, i = /<(?:\/([^\s>]+)\s*|!--([\s\S]*?)--|!([^>]*?)|([\w\-:]+)((?:\s+[^\s"'>\/=\x00-\x0F\x7F\x80-\x9F]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]*))?)*?)\s*(\/?))>/g, t = /\s*([^\s"'>\/=\x00-\x0F\x7F\x80-\x9F]+)(?:\s*=\s*(?:(")([^"]*)"|(')([^']*)'|([^\s"'>]*)))?/g, n = /\r?\n/g; let o, l, s = 0, c, d, f = null, u, p = [], b = 0, h, k = 0, m = 1; const _ = this._arrBlocks; this.fire("start", { pos: 0, line: 1, col: 1 }); const x = () => { const v = d.find((g) => g.name === "type") || { value: "" }; return e[c] && v.value.indexOf("text/ng-template") === -1; }, y = (v, g, q, w) => { const j = q - k + 1; for (w === void 0 && (w = {}), w.raw = g, w.pos = q, w.line = m, w.col = j, _.push(w), this.fire(v, w); n.exec(g); ) m++, k = q + n.lastIndex; }; for (; o = i.exec(a); ) { if (l = o.index, l > s && (h = a.substring(s, l), f ? p.push(h) : y("text", h, s)), s = i.lastIndex, (c = o[1]) && (f && c === f && (h = p.join(""), y("cdata", h, b, { tagName: f, attrs: u }), f = null, u = void 0, p = []), !f)) { y("tagend", o[0], l, { tagName: c }); continue; } if (f) p.push(o[0]); else if (c = o[4]) { d = []; const v = o[5]; let g, q = 0; for (; g = t.exec(v); ) { const w = g[1], j = g[2] ? g[2] : g[4] ? g[4] : "", R = g[3] ? g[3] : g[5] ? g[5] : g[6] ? g[6] : ""; d.push({ name: w, value: R, quote: j, index: g.index, raw: g[0] }), q += g[0].length; } q === v.length ? (y("tagstart", o[0], l, { tagName: c, attrs: d, close: o[6] }), x() && (f = c, u = d.concat(), p = [], b = s)) : y("text", o[0], l); } else (o[2] || o[3]) && y("comment", o[0], l, { content: o[2] || o[3], long: !!o[2] }); } a.length > s && (h = a.substring(s, a.length), y("text", h, s)), this.fire("end", { pos: s, line: m, col: a.length - k + 1 }); } addListener(a, e) { const i = this._listeners, t = a.split(/[,\s]/); let n; for (let o = 0, l = t.length; o < l; o++) n = t[o], i[n] === void 0 && (i[n] = []), i[n].push(e); } fire(a, e) { e === void 0 && (e = {}), e.type = a; let i = []; const t = this._listeners[a], n = this._listeners.all; t !== void 0 && (i = i.concat(t)), n !== void 0 && (i = i.concat(n)); const o = this.lastEvent; o !== null && (delete o.lastEvent, e.lastEvent = o), this.lastEvent = e; for (let l = 0, s = i.length; l < s; l++) i[l].call(this, e); } removeListener(a, e) { const i = this._listeners[a]; if (i !== void 0) { for (let t = 0, n = i.length; t < n; t++) if (i[t] === e) { i.splice(t, 1); break; } } } fixPos(a, e) { const t = a.raw.substr(0, e).split(/\r?\n/), n = t.length - 1; let o = a.line, l; return n > 0 ? (o += n, l = t[n].length + 1) : l = a.col + e, { line: o, col: l }; } getMapAttrs(a) { const e = {}; let i; for (let t = 0, n = a.length; t < n; t++) i = a[t], e[i.name] = i.value; return e; } } T.default = ze; var A = {}; Object.defineProperty(A, "__esModule", { value: !0 }); class Le { constructor(a, e) { this.html = a, this.lines = a.split(/\r?\n/); const i = /\r?\n/.exec(a); this.brLen = i !== null ? i[0].length : 0, this.ruleset = e, this.messages = []; } info(a, e, i, t, n) { this.report("info", a, e, i, t, n); } warn(a, e, i, t, n) { this.report("warning", a, e, i, t, n); } error(a, e, i, t, n) { this.report("error", a, e, i, t, n); } report(a, e, i, t, n, o) { const l = this.lines, s = this.brLen; let c = "", d = 0; for (let f = i - 1, u = l.length; f < u && (c = l[f], d = c.length, t > d && i < u); f++) i++, t -= d, t !== 1 && (t -= s); this.messages.push({ type: a, message: e, raw: o, evidence: c, line: i, col: t, rule: { id: n.id, description: n.description, link: `https://htmlhint.com/docs/user-guide/rules/${n.id}` } }); } } A.default = Le; var me = {}, M = {}; Object.defineProperty(M, "__esModule", { value: !0 }); M.default = { id: "alt-require", description: "The alt attribute of an <img> element must be present and alt attribute of area[href] and input[type=image] must have a value.", init(r, a) { r.addListener("tagstart", (e) => { const i = e.tagName.toLowerCase(), t = r.getMapAttrs(e.attrs), n = e.col + i.length + 1; let o; i === "img" && !("alt" in t) ? a.warn("An alt attribute must be present on <img> elements.", e.line, n, this, e.raw) : (i === "area" && "href" in t || i === "input" && t.type === "image") && (!("alt" in t) || t.alt === "") && (o = i === "area" ? "area[href]" : "input[type=image]", a.warn(`The alt attribute of ${o} must have a value.`, e.line, n, this, e.raw)); }); } }; var C = {}; Object.defineProperty(C, "__esModule", { value: !0 }); const Re = [ "allowReorder", "attributeName", "attributeType", "autoReverse", "baseFrequency", "baseProfile", "calcMode", "clipPath", "clipPathUnits", "contentScriptType", "contentStyleType", "diffuseConstant", "edgeMode", "externalResourcesRequired", "filterRes", "filterUnits", "glyphRef", "gradientTransform", "gradientUnits", "kernelMatrix", "kernelUnitLength", "keyPoints", "keySplines", "keyTimes", "lengthAdjust", "limitingConeAngle", "markerHeight", "markerUnits", "markerWidth", "maskContentUnits", "maskUnits", "numOctaves", "onBlur", "onChange", "onClick", "onFocus", "onKeyUp", "onLoad", "pathLength", "patternContentUnits", "patternTransform", "patternUnits", "pointsAtX", "pointsAtY", "pointsAtZ", "preserveAlpha", "preserveAspectRatio", "primitiveUnits", "refX", "refY", "repeatCount", "repeatDur", "requiredExtensions", "requiredFeatures", "specularConstant", "specularExponent", "spreadMethod", "startOffset", "stdDeviation", "stitchTiles", "surfaceScale", "systemLanguage", "tableValues", "targetX", "targetY", "textLength", "viewBox", "viewTarget", "xChannelSelector", "yChannelSelector", "zoomAndPan" ]; function Te(r, a) { if (a instanceof RegExp) return a.test(r) ? { match: r, pattern: a } : !1; const e = a[0], i = a[a.length - 1], t = a[a.length - 2], n = e === "/" && (i === "/" || t === "/" && i === "i"), o = n && i === "i"; return n ? o ? new RegExp(a.slice(1, -2), "i").test(r) : new RegExp(a.slice(1, -1)).test(r) : r === a; } C.default = { id: "attr-lowercase", description: "All attribute names must be in lowercase.", init(r, a, e) { const i = (Array.isArray(e) ? e : []).concat(Re); r.addListener("tagstart", (t) => { const n = t.attrs; let o; const l = t.col + t.tagName.length + 1; for (let s = 0, c = n.length; s < c; s++) { o = n[s]; const d = o.name; !i.find((f) => Te(d, f)) && d !== d.toLowerCase() && a.error(`The attribute name of [ ${d} ] must be in lowercase.`, t.line, l + o.index, this, o.raw); } }); } }; var O = {}; Object.defineProperty(O, "__esModule", { value: !0 }); O.default = { id: "attr-sorted", description: "Attribute tags must be in proper order.", init(r, a) { const e = {}, i = [ "class", "id", "name", "src", "for", "type", "href", "value", "title", "alt", "role" ]; for (let t = 0; t < i.length; t++) e[i[t]] = t; r.addListener("tagstart", (t) => { const n = t.attrs, o = []; for (let s = 0; s < n.length; s++) o.push(n[s].name); const l = JSON.stringify(o); o.sort((s, c) => e[s] == null && e[c] == null ? 0 : e[s] == null ? 1 : e[c] == null ? -1 : e[s] - e[c] || s.localeCompare(c)), l !== JSON.stringify(o) && a.error(`Inaccurate order ${l} should be in hierarchy ${JSON.stringify(o)} `, t.line, t.col, this, t.raw); }); } }; var F = {}; Object.defineProperty(F, "__esModule", { value: !0 }); F.default = { id: "attr-no-duplication", description: "Elements cannot have duplicate attributes.", init(r, a) { r.addListener("tagstart", (e) => { const i = e.attrs; let t, n; const o = e.col + e.tagName.length + 1, l = {}; for (let s = 0, c = i.length; s < c; s++) t = i[s], n = t.name, l[n] === !0 && a.error(`Duplicate of attribute name [ ${t.name} ] was found.`, e.line, o + t.index, this, t.raw), l[n] = !0; }); } }; var P = {}; Object.defineProperty(P, "__esModule", { value: !0 }); P.default = { id: "attr-unsafe-chars", description: "Attribute values cannot contain unsafe chars.", init(r, a) { r.addListener("tagstart", (e) => { const i = e.attrs; let t; const n = e.col + e.tagName.length + 1, o = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/; let l; for (let s = 0, c = i.length; s < c; s++) if (t = i[s], l = o.exec(t.value), l !== null) { const d = escape(l[0]).replace(/%u/, "\\u").replace(/%/, "\\x"); a.warn(`The value of attribute [ ${t.name} ] cannot contain an unsafe char [ ${d} ].`, e.line, n + t.index, this, t.raw); } }); } }; var E = {}; Object.defineProperty(E, "__esModule", { value: !0 }); E.default = { id: "attr-value-double-quotes", description: "Attribute values must be in double quotes.", init(r, a) { r.addListener("tagstart", (e) => { const i = e.attrs; let t; const n = e.col + e.tagName.length + 1; for (let o = 0, l = i.length; o < l; o++) t = i[o], (t.value !== "" && t.quote !== '"' || t.value === "" && t.quote === "'") && a.error(`The value of attribute [ ${t.name} ] must be in double quotes.`, e.line, n + t.index, this, t.raw); }); } }; var $ = {}; Object.defineProperty($, "__esModule", { value: !0 }); $.default = { id: "attr-value-not-empty", description: "All attributes must have values.", init(r, a) { r.addListener("tagstart", (e) => { const i = e.attrs; let t; const n = e.col + e.tagName.length + 1; for (let o = 0, l = i.length; o < l; o++) t = i[o], t.quote === "" && t.value === "" && a.warn(`The attribute [ ${t.name} ] must have a value.`, e.line, n + t.index, this, t.raw); }); } }; var N = {}; Object.defineProperty(N, "__esModule", { value: !0 }); N.default = { id: "attr-value-single-quotes", description: "Attribute values must be in single quotes.", init(r, a) { r.addListener("tagstart", (e) => { const i = e.attrs; let t; const n = e.col + e.tagName.length + 1; for (let o = 0, l = i.length; o < l; o++) t = i[o], (t.value !== "" && t.quote !== "'" || t.value === "" && t.quote === '"') && a.error(`The value of attribute [ ${t.name} ] must be in single quotes.`, e.line, n + t.index, this, t.raw); }); } }; var S = {}; Object.defineProperty(S, "__esModule", { value: !0 }); S.default = { id: "attr-whitespace", description: "All attributes should be separated by only one space and not have leading/trailing whitespace.", init(r, a, e) { const i = Array.isArray(e) ? e : []; r.addListener("tagstart", (t) => { const n = t.attrs; let o; const l = t.col + t.tagName.length + 1; n.forEach((s) => { o = s; const c = s.name; i.indexOf(c) === -1 && (s.value.trim() !== s.value && a.error(`The attributes of [ ${c} ] must not have leading or trailing whitespace.`, t.line, l + o.index, this, o.raw), s.value.replace(/ +(?= )/g, "") !== s.value && a.error(`The attributes of [ ${c} ] must be separated by only one space.`, t.line, l + o.index, this, o.raw)); }); }); } }; var D = {}; Object.defineProperty(D, "__esModule", { value: !0 }); D.default = { id: "doctype-first", description: "Doctype must be declared first.", init(r, a) { const e = (i) => { i.type === "start" || i.type === "text" && /^\s*$/.test(i.raw) || ((i.type !== "comment" && i.long === !1 || /^DOCTYPE\s+/i.test(i.content) === !1) && a.error("Doctype must be declared first.", i.line, i.col, this, i.raw), r.removeListener("all", e)); }; r.addListener("all", e); } }; var H = {}; Object.defineProperty(H, "__esModule", { value: !0 }); H.default = { id: "doctype-html5", description: 'Invalid doctype. Use: "<!DOCTYPE html>"', init(r, a) { const e = (t) => { t.long === !1 && t.content.toLowerCase() !== "doctype html" && a.warn('Invalid doctype. Use: "<!DOCTYPE html>"', t.line, t.col, this, t.raw); }, i = () => { r.removeListener("comment", e), r.removeListener("tagstart", i); }; r.addListener("all", e), r.addListener("tagstart", i); } }; var I = {}; Object.defineProperty(I, "__esModule", { value: !0 }); I.default = { id: "head-script-disabled", description: "The <script> tag cannot be used in a <head> tag.", init(r, a) { const e = /^(text\/javascript|application\/javascript)$/i; let i = !1; const t = (o) => { const s = r.getMapAttrs(o.attrs).type, c = o.tagName.toLowerCase(); c === "head" && (i = !0), i === !0 && c === "script" && (!s || e.test(s) === !0) && a.warn("The <script> tag cannot be used in a <head> tag.", o.line, o.col, this, o.raw); }, n = (o) => { o.tagName.toLowerCase() === "head" && (r.removeListener("tagstart", t), r.removeListener("tagend", n)); }; r.addListener("tagstart", t), r.addListener("tagend", n); } }; var U = {}; Object.defineProperty(U, "__esModule", { value: !0 }); U.default = { id: "href-abs-or-rel", description: "An href attribute must be either absolute or relative.", init(r, a, e) { const i = e === "abs" ? "absolute" : "relative"; r.addListener("tagstart", (t) => { const n = t.attrs; let o; const l = t.col + t.tagName.length + 1; for (let s = 0, c = n.length; s < c; s++) if (o = n[s], o.name === "href") { (i === "absolute" && /^\w+?:/.test(o.value) === !1 || i === "relative" && /^https?:\/\//.test(o.value) === !0) && a.warn(`The value of the href attribute [ ${o.value} ] must be ${i}.`, t.line, l + o.index, this, o.raw); break; } }); } }; var B = {}; Object.defineProperty(B, "__esModule", { value: !0 }); const Ae = "(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)", Me = "(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)", Ce = `(?<grandfathered>${Me}|${Ae})`, Oe = "(?<privateUse>x(-[A-Za-z0-9]{1,8})+)", Fe = "(?<privateUse2>x(-[A-Za-z0-9]{1,8})+)", Pe = "[0-9A-WY-Za-wy-z]", Ee = `(?<extension>${Pe}(-[A-Za-z0-9]{2,8})+)`, $e = "(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3})", Ne = "(?<region>[A-Za-z]{2}|[0-9]{3})", Se = "(?<script>[A-Za-z]{4})", De = "(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2})", He = `(?<language>([A-Za-z]{2,3}(-${De})?)|[A-Za-z]{4}|[A-Za-z]{5,8})`, Ie = `(${He}(-${Se})?(-${Ne})?(-${$e})*(-${Ee})*(-${Oe})?)`, Ue = `(${Ce}|${Ie}|${Fe})`; B.default = { id: "html-lang-require", description: "The lang attribute of an <html> element must be present and should be valid.", init(r, a) { r.addListener("tagstart", (e) => { const i = e.tagName.toLowerCase(), t = r.getMapAttrs(e.attrs), n = e.col + i.length + 1, o = new RegExp(Ue, "g"); i === "html" && ("lang" in t ? t.lang ? o.test(t.lang) || a.warn("The lang attribute value of <html> element must be a valid BCP47.", e.line, n, this, e.raw) : a.warn("The lang attribute of <html> element must have a value.", e.line, n, this, e.raw) : a.warn("An lang attribute must be present on <html> elements.", e.line, n, this, e.raw)); }); } }; var V = {}; Object.defineProperty(V, "__esModule", { value: !0 }); V.default = { id: "id-class-ad-disabled", description: "The id and class attributes cannot use the ad keyword, it will be blocked by adblock software.", init(r, a) { r.addListener("tagstart", (e) => { const i = e.attrs; let t, n; const o = e.col + e.tagName.length + 1; for (let l = 0, s = i.length; l < s; l++) t = i[l], n = t.name, /^(id|class)$/i.test(n) && /(^|[-_])ad([-_]|$)/i.test(t.value) && a.warn(`The value of attribute ${n} cannot use the ad keyword.`, e.line, o + t.index, this, t.raw); }); } }; var G = {}; Object.defineProperty(G, "__esModule", { value: !0 }); G.default = { id: "id-class-value", description: "The id and class attribute values must meet the specified rules.", init(r, a, e) { const i = { underline: { regId: /^[a-z\d]+(_[a-z\d]+)*$/, message: "The id and class attribute values must be in lowercase and split by an underscore." }, dash: { regId: /^[a-z\d]+(-[a-z\d]+)*$/, message: "The id and class attribute values must be in lowercase and split by a dash." }, hump: { regId: /^[a-z][a-zA-Z\d]*([A-Z][a-zA-Z\d]*)*$/, message: "The id and class attribute values must meet the camelCase style." } }; let t; if (typeof e == "string" ? t = i[e] : t = e, typeof t == "object" && t.regId) { let n = t.regId; const o = t.message; n instanceof RegExp || (n = new RegExp(n)), r.addListener("tagstart", (l) => { const s = l.attrs; let c; const d = l.col + l.tagName.length + 1; for (let f = 0, u = s.length; f < u; f++) if (c = s[f], c.name.toLowerCase() === "id" && n.test(c.value) === !1 && a.warn(o, l.line, d + c.index, this, c.raw), c.name.toLowerCase() === "class") { const p = c.value.split(/\s+/g); let b; for (let h = 0, k = p.length; h < k; h++) b = p[h], b && n.test(b) === !1 && a.warn(o, l.line, d + c.index, this, b); } }); } } }; var Z = {}; Object.defineProperty(Z, "__esModule", { value: !0 }); Z.default = { id: "id-unique", description: "The value of id attributes must be unique.", init(r, a) { const e = {}; r.addListener("tagstart", (i) => { const t = i.attrs; let n, o; const l = i.col + i.tagName.length + 1; for (let s = 0, c = t.length; s < c; s++) if (n = t[s], n.name.toLowerCase() === "id") { o = n.value, o && (e[o] === void 0 ? e[o] = 1 : e[o]++, e[o] > 1 && a.error(`The id value [ ${o} ] must be unique.`, i.line, l + n.index, this, n.raw)); break; } }); } }; var W = {}; Object.defineProperty(W, "__esModule", { value: !0 }); W.default = { id: "inline-script-disabled", description: "Inline script cannot be used.", init(r, a) { r.addListener("tagstart", (e) => { const i = e.attrs; let t; const n = e.col + e.tagName.length + 1; let o; const l = /^on(unload|message|submit|select|scroll|resize|mouseover|mouseout|mousemove|mouseleave|mouseenter|mousedown|load|keyup|keypress|keydown|focus|dblclick|click|change|blur|error)$/i; for (let s = 0, c = i.length; s < c; s++) t = i[s], o = t.name.toLowerCase(), l.test(o) === !0 ? a.warn(`Inline script [ ${t.raw} ] cannot be used.`, e.line, n + t.index, this, t.raw) : (o === "src" || o === "href") && /^\s*javascript:/i.test(t.value) && a.warn(`Inline script [ ${t.raw} ] cannot be used.`, e.line, n + t.index, this, t.raw); }); } }; var Y = {}; Object.defineProperty(Y, "__esModule", { value: !0 }); Y.default = { id: "inline-style-disabled", description: "Inline style cannot be used.", init(r, a) { r.addListener("tagstart", (e) => { const i = e.attrs; let t; const n = e.col + e.tagName.length + 1; for (let o = 0, l = i.length; o < l; o++) t = i[o], t.name.toLowerCase() === "style" && a.warn(`Inline style [ ${t.raw} ] cannot be used.`, e.line, n + t.index, this, t.raw); }); } }; var X = {}; Object.defineProperty(X, "__esModule", { value: !0 }); X.default = { id: "input-requires-label", description: "All [ input ] tags must have a corresponding [ label ] tag. ", init(r, a) { const e = [], i = []; r.addListener("tagstart", (n) => { const o = n.tagName.toLowerCase(), l = r.getMapAttrs(n.attrs), s = n.col + o.length + 1; o === "input" && l.type !== "hidden" && i.push({ event: n, col: s, id: l.id }), o === "label" && "for" in l && l.for !== "" && e.push({ event: n, col: s, forValue: l.for }); }), r.addListener("end", () => { i.forEach((n) => { t(n) || a.warn("No matching [ label ] tag found.", n.event.line, n.col, this, n.event.raw); }); }); function t(n) { let o = !1; return e.forEach((l) => { n.id && n.id === l.forValue && (o = !0); }), o; } } }; var Q = {}; Object.defineProperty(Q, "__esModule", { value: !0 }); Q.default = { id: "script-disabled", description: "The <script> tag cannot be used.", init(r, a) { r.addListener("tagstart", (e) => { e.tagName.toLowerCase() === "script" && a.error("The <script> tag cannot be used.", e.line, e.col, this, e.raw); }); } }; var J = {}; Object.defineProperty(J, "__esModule", { value: !0 }); J.default = { id: "space-tab-mixed-disabled", description: "Do not mix tabs and spaces for indentation.", init(r, a, e) { let i = "nomix", t = null; if (typeof e == "string") { const n = /^([a-z]+)(\d+)?/.exec(e); n && (i = n[1], t = n[2] && parseInt(n[2], 10)); } r.addListener("text", (n) => { const o = n.raw, l = /(^|\r?\n)([ \t]+)/g; let s; for (; s = l.exec(o); ) { const c = r.fixPos(n, s.index + s[1].length); if (c.col !== 1) continue; const d = s[2]; i === "space" ? t ? (/^ +$/.test(d) === !1 || d.length % t !== 0) && a.warn(`Please use space for indentation and keep ${t} length.`, c.line, 1, this, n.raw) : /^ +$/.test(d) === !1 && a.warn("Please use space for indentation.", c.line, 1, this, n.raw) : i === "tab" && /^\t+$/.test(d) === !1 ? a.warn("Please use tab for indentation.", c.line, 1, this, n.raw) : / +\t|\t+ /.test(d) === !0 && a.warn("Do not mix tabs and spaces for indentation.", c.line, 1, this, n.raw); } }); } }; var K = {}; Object.defineProperty(K, "__esModule", { value: !0 }); K.default = { id: "spec-char-escape", description: "Special characters must be escaped.", init(r, a) { r.addListener("text", (e) => { const i = e.raw, t = /([<>])|( \& )/g; let n; for (; n = t.exec(i); ) { const o = r.fixPos(e, n.index); a.error(`Special characters must be escaped : [ ${n[0]} ].`, o.line, o.col, this, e.raw); } }); } }; var ee = {}; Object.defineProperty(ee, "__esModule", { value: !0 }); ee.default = { id: "src-not-empty", description: "The src attribute of an img(script,link) must have a value.", init(r, a) { r.addListener("tagstart", (e) => { const i = e.tagName, t = e.attrs; let n; const o = e.col + i.length + 1; for (let l = 0, s = t.length; l < s; l++) n = t[l], (/^(img|script|embed|bgsound|iframe)$/.test(i) === !0 && n.name === "src" || i === "link" && n.name === "href" || i === "object" && n.name === "data") && n.value === "" && a.error(`The attribute [ ${n.name} ] of the tag [ ${i} ] must have a value.`, e.line, o + n.index, this, n.raw); }); } }; var te = {}; Object.defineProperty(te, "__esModule", { value: !0 }); te.default = { id: "style-disabled", description: "<style> tags cannot be used.", init(r, a) { r.addListener("tagstart", (e) => { e.tagName.toLowerCase() === "style" && a.warn("The <style> tag cannot be used.", e.line, e.col, this, e.raw); }); } }; var ie = {}; Object.defineProperty(ie, "__esModule", { value: !0 }); ie.default = { id: "tag-pair", description: "Tag must be paired.", init(r, a) { const e = [], i = r.makeMap("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed,track,command,source,keygen,wbr"); r.addListener("tagstart", (t) => { const n = t.tagName.toLowerCase(); i[n] === void 0 && !t.close && e.push({ tagName: n, line: t.line, raw: t.raw }); }), r.addListener("tagend", (t) => { const n = t.tagName.toLowerCase(); let o; for (o = e.length - 1; o >= 0 && e[o].tagName !== n; o--) ; if (o >= 0) { const l = []; for (let s = e.length - 1; s > o; s--) l.push(`</${e[s].tagName}>`); if (l.length > 0) { const s = e[e.length - 1]; a.error(`Tag must be paired, missing: [ ${l.join("")} ], start tag match failed [ ${s.raw} ] on line ${s.line}.`, t.line, t.col, this, t.raw); } e.length = o; } else a.error(`Tag must be paired, no start tag: [ ${t.raw} ]`, t.line, t.col, this, t.raw); }), r.addListener("end", (t) => { const n = []; for (let o = e.length - 1; o >= 0; o--) n.push(`</${e[o].tagName}>`); if (n.length > 0) { const o = e[e.length - 1]; a.error(`Tag must be paired, missing: [ ${n.join("")} ], open tag match failed [ ${o.raw} ] on line ${o.line}.`, t.line, t.col, this, ""); } }); } }; var re = {}; Object.defineProperty(re, "__esModule", { value: !0 }); re.default = { id: "tag-self-close", description: "Empty tags must be self closed.", init(r, a) { const e = r.makeMap("area,base,basefont,bgsound,br,col,frame,hr,img,input,isindex,link,meta,param,embed,track,command,source,keygen,wbr"); r.addListener("tagstart", (i) => { const t = i.tagName.toLowerCase(); e[t] !== void 0 && (i.close || a.warn(`The empty tag : [ ${t} ] must be self closed.`, i.line, i.col, this, i.raw)); }); } }; var oe = {}; Object.defineProperty(oe, "__esModule", { value: !0 }); oe.default = { id: "empty-tag-not-self-closed", description: "Empty tags must not use self closed syntax.", init(r, a) { const e = r.makeMap("area,base,basefont,bgsound,br,col,frame,hr,img,input,isindex,link,meta,param,embed,track,command,source,keygen,wbr"); r.addListener("tagstart", (i) => { const t = i.tagName.toLowerCase(); e[t] !== void 0 && i.close && a.error(`The empty tag : [ ${t} ] must not use self closed syntax.`, i.line, i.col, this, i.raw); }); } }; var ne = {}; Object.defineProperty(ne, "__esModule", { value: !0 }); ne.default = { id: "tagname-lowercase", description: "All html element names must be in lowercase.", init(r, a, e) { const i = Array.isArray(e) ? e : []; r.addListener("tagstart,tagend", (t) => { const n = t.tagName; i.indexOf(n) === -1 && n !== n.toLowerCase() && a.error(`The html element name of [ ${n} ] must be in lowercase.`, t.line, t.col, this, t.raw); }); } }; var ae = {}; Object.defineProperty(ae, "__esModule", { value: !0 }); ae.default = { id: "tagname-specialchars", description: "All special characters must be escaped.", init(r, a) { const e = /[^a-zA-Z0-9\-:_]/; r.addListener("tagstart,tagend", (i) => { const t = i.tagName; e.test(t) && a.error(`The html element name of [ ${t} ] contains special character.`, i.line, i.col, this, i.raw); }); } }; var le = {}; Object.defineProperty(le, "__esModule", { value: !0 }); le.default = { id: "title-require", description: "<title> must be present in <head> tag.", init(r, a) { let e = !1, i = !1; const t = (o) => { const l = o.tagName.toLowerCase(); l === "head" ? e = !0 : l === "title" && e && (i = !0); }, n = (o) => { const l = o.tagName.toLowerCase(); if (i && l === "title") { const s = o.lastEvent; (s.type !== "text" || s.type === "text" && /^\s*$/.test(s.raw) === !0) && a.error("<title></title> must not be empty.", o.line, o.col, this, o.raw); } else l === "head" && (i === !1 && a.error("<title> must be present in <head> tag.", o.line, o.col, this, o.raw), r.removeListener("tagstart", t), r.removeListener("tagend", n)); }; r.addListener("tagstart", t), r.addListener("tagend", n); } }; var se = {}; Object.defineProperty(se, "__esModule", { value: !0 }); let z = { a: { selfclosing: !1, attrsRequired: ["href", "title"], redundantAttrs: ["alt"] }, div: { selfclosing: !1 }, main: { selfclosing: !1, redundantAttrs: ["role"] }, nav: { selfclosing: !1, redundantAttrs: ["role"] }, script: { attrsOptional: [ ["async", "async"], ["defer", "defer"] ] }, img: { selfclosing: !0, attrsRequired: ["src", "alt", "title"] } }; se.default = { id: "tags-check", description: "Checks html tags.", init(r, a, e) { z = Object.assign(Object.assign({}, z), e), r.addListener("tagstart", (i) => { const t = i.attrs, n = i.col + i.tagName.length + 1, o = i.tagName.toLowerCase(); if (z[o]) { const l = z[o]; l.selfclosing === !0 && !i.close ? a.warn(`The <${o}> tag must be selfclosing.`, i.line, i.col, this, i.raw) : l.selfclosing === !1 && i.close && a.warn(`The <${o}> tag must not be selfclosing.`, i.line, i.col, this, i.raw), Array.isArray(l.attrsRequired) && l.attrsRequired.forEach((c) => { if (Array.isArray(c)) { const d = c.map((p) => p), f = d.shift(), u = d; t.some((p) => p.name === f) ? t.forEach((p) => { p.name === f && u.indexOf(p.value) === -1 && a.error(`The <${o}> tag must have attr '${f}' with one value of '${u.join("' or '")}'.`, i.line, n, this, i.raw); }) : a.error(`The <${o}> tag must have attr '${f}'.`, i.line, n, this, i.raw); } else t.some((d) => c.split("|").indexOf(d.name) !== -1) || a.error(`The <${o}> tag must have attr '${c}'.`, i.line, n, this, i.raw); }), Array.isArray(l.attrsOptional) && l.attrsOptional.forEach((c) => { if (Array.isArray(c)) { const d = c.map((p) => p), f = d.shift(), u = d; t.some((p) => p.name === f) && t.forEach((p) => { p.name === f && u.indexOf(p.value) === -1 && a.error(`The <${o}> tag must have optional attr '${f}' with one value of '${u.join("' or '")}'.`, i.line, n, this, i.raw); }); } }), Array.isArray(l.redundantAttrs) && l.redundantAttrs.forEach((c) => { t.some((d) => d.name === c) && a.error(`The attr '${c}' is redundant for <${o}> and should be omitted.`, i.line, n, this, i.raw); }); } }); } }; var ce = {}; Object.defineProperty(ce, "__esModule", { value: !0 }); ce.default = { id: "attr-no-unnecessary-whitespace", description: "No spaces between attribute names and values.", init(r, a, e) { const i = Array.isArray(e) ? e : []; r.addListener("tagstart", (t) => { const n = t.attrs, o = t.col + t.tagName.length + 1; for (let l = 0; l < n.length; l++) if (i.indexOf(n[l].name) === -1) { const s = /(\s*)=(\s*)/.exec(n[l].raw.trim()); s && (s[1].length !== 0 || s[2].length !== 0) && a.error(`The attribute '${n[l].name}' must not have spaces between the name and value.`, t.line, o + n[l].index, this, n[l].raw); } }); } }; var de = {}; const Be = { "*": [ "accesskey", "autocapitalize", "autofocus", "class", "contenteditable", "dir", "draggable", "enterkeyhint", "hidden", "id", "inert", "inputmode", "is", "itemid", "itemprop", "itemref", "itemscope", "itemtype", "lang", "nonce", "popover", "slot", "spellcheck", "style", "tabindex", "title", "translate" ], a: [ "charset", "coords", "download", "href", "hreflang", "name", "ping", "referrerpolicy", "rel", "rev", "shape", "target", "type" ], applet: [ "align", "alt", "archive", "code", "codebase", "height", "hspace", "name", "object", "vspace", "width" ], area: [ "alt", "coords", "download", "href", "hreflang", "nohref", "ping", "referrerpolicy", "rel", "shape", "target", "type" ], audio: [ "autoplay", "controls", "crossorigin", "loop", "muted", "preload", "src" ], base: ["href", "target"], basefont: ["color", "face", "size"], blockquote: ["cite"], body: ["alink", "background", "bgcolor", "link", "text", "vlink"], br: ["clear"], button: [ "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "name", "popovertarget", "popovertargetaction", "type", "value" ], canvas: ["height", "width"], caption: ["align"], col: ["align", "char", "charoff", "span", "valign", "width"], colgroup: ["align", "char", "charoff", "span", "valign", "width"], data: ["value"], del: ["cite", "datetime"], details: ["open"], dialog: ["open"], dir: ["compact"], div: ["align"], dl: ["compact"], embed: ["height", "src", "type", "width"], fieldset: ["disabled", "form", "name"], font: ["color", "face", "size"], form: [ "accept", "accept-charset", "action", "autocomplete", "enctype", "method", "name", "novalidate", "target" ], frame: [ "frameborder", "longdesc", "marginheight", "marginwidth", "name", "noresize", "scrolling", "src" ], frameset: ["cols", "rows"], h1: ["align"], h2: ["align"], h3: ["align"], h4: ["align"], h5: ["align"], h6: ["align"], head: ["profile"], hr: ["align", "noshade", "size", "width"], html: ["manifest", "version"], iframe: [ "align", "allow", "allowfullscreen", "allowpaymentrequest", "allowusermedia", "frameborder", "height", "loading", "longdesc", "marginheight", "marginwidth", "name", "referrerpolicy", "sandbox", "scrolling", "src", "srcdoc", "width" ], img: [ "align", "alt", "border", "crossorigin", "decoding", "fetchpriority", "height", "hspace", "ismap", "loading", "longdesc", "name", "referrerpolicy", "sizes", "src", "srcset", "usemap", "vspace", "width" ], input: [ "accept", "align", "alt", "autocomplete", "checked", "dirname", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "height", "ismap", "list", "max", "maxlength", "min", "minlength", "multiple", "name", "pattern", "placeholder", "popovertarget", "popovertargetaction", "readonly", "required", "size", "src", "step", "type", "usemap", "value", "width" ], ins: ["cite", "datetime"], isindex: ["prompt"], label: ["for", "form"], legend: ["align"], li: ["type", "value"], link: [ "as", "blocking", "charset", "color", "crossorigin", "disabled", "fetchpriority", "href", "hreflang", "imagesizes", "imagesrcset", "integrity", "media", "referrerpolicy", "rel", "rev", "sizes", "target", "type" ], map: ["name"], menu: ["compact"], meta: ["charset", "content", "http-equiv", "media", "name", "scheme"], meter: ["high", "low", "max", "min", "optimum", "value"], object: [ "align", "archive", "border", "classid", "codebase", "codetype", "data", "declare", "form", "height", "hspace", "name", "standby", "type", "typemustmatch", "usemap", "vspace", "width" ], ol: ["compact", "reversed", "start", "type"], optgroup: ["disabled", "label"], option: ["disabled", "label", "selected", "value"], output: ["for", "form", "name"], p: ["align"], param: ["name", "type", "value", "valuetype"], pre: ["width"], progress: ["max", "value"], q: ["cite"], script: [ "async", "blocking", "charset", "crossorigin", "defer", "fetchpriority", "integrity", "language", "nomodule", "referrerpolicy", "src", "type" ], select: [ "autocomplete", "disabled", "form", "multiple", "name", "required", "size" ], slot: ["name"], source: ["height", "media", "sizes", "src", "srcset", "type", "width"], style: ["blocking", "media", "type"], table: [ "align", "bgcolor", "border", "cellpadding", "cellspacing", "frame", "rules", "summary", "width" ], tbody: ["align", "char", "charoff", "valign"], td: [ "abbr", "align", "axis", "bgcolor", "char", "charoff", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign", "width" ], textarea: [ "autocomplete", "cols", "dirname", "disabled", "form", "maxlength", "minlength", "name", "placeholder", "readonly", "required", "rows", "wrap" ], tfoot: ["align", "char", "charoff", "valign"], th: [ "abbr", "align", "axis", "bgcolor", "char", "charoff", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign", "width" ], thead: ["align", "char", "charoff", "valign"], time: ["datetime"], tr: ["align", "bgcolor", "char", "charoff", "valign"], track: ["default", "kind", "label", "src", "srclang"], ul: ["compact", "type"], video: [ "autoplay", "controls", "crossorigin", "height", "loop", "muted", "playsinline", "poster", "preload", "src", "width" ] }, Ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, htmlElementAttributes: Be }, Symbol.toStringTag, { value: "Module" })), Ge = /* @__PURE__ */ L(Ve), Ze = [ "onabort", "onafterprint", "onauxclick", "onbeforematch", "onbeforeprint", "onbeforeunload", "onblur", "oncancel", "oncanplay", "oncanplaythrough", "onchange", "onclick", "onclose", "oncontextlost", "oncontextmenu", "oncontextrestored", "oncopy", "oncuechange", "oncut", "ondblclick", "ondrag", "ondragend", "ondragenter", "ondragleave", "ondragover", "ondragstart", "ondrop", "ondurationchange", "onemptied", "onended", "onerror", "onfocus", "onformdata", "onhashchange", "oninput", "oninvalid", "onkeydown", "onkeypress", "onkeyup", "onlanguagechange", "onload", "onloadeddata", "onloadedmetadata", "onloadstart", "onmessage", "onmessageerror", "onmousedown", "onmouseenter", "onmouseleave", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "onoffline", "ononline", "onpagehide", "onpageshow", "onpaste", "onpause", "onplay", "onplaying", "onpopstate", "onprogress", "onratechange", "onrejectionhandled", "onreset", "onresize", "onscroll", "onscrollend", "onsecuritypolicyviolation", "onseeked", "onseeking", "onselect", "onslotchange", "onstalled", "onstorage", "onsubmit", "onsuspend", "ontimeupdate", "ontoggle", "onunhandledrejection", "onunload", "onvolumechange", "onwaiting", "onwheel" ], We = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, htmlEventAttributes: Ze }, Symbol.toStringTag, { value: "Module" })), Ye = /* @__PURE__ */ L(We), Xe = { "*": [ "about", "class", "content", "datatype", "id", "lang", "property", "rel", "resource", "rev", "style", "tabindex", "typeof" ], a: [ "alignment-baseline", "baseline-shift", "clip", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cursor", "direction", "display", "dominant-baseline", "download", "enable-background", "externalResourcesRequired", "fill", "fill-opacity", "fill-rule", "filter", "flood-color", "flood-opacity", "focusHighlight", "focusable", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "glyph-orientation-horizontal", "glyph-orientation-vertical", "href", "hreflang", "image-rendering", "kerning", "letter-spacing", "lighting-color", "marker-end", "marker-mid", "marker-start", "mask", "nav-down", "nav-down-left", "nav-down-right", "nav-left", "nav-next", "nav-prev", "nav-right", "nav-up", "nav-up-left", "nav-up-right", "opacity", "overflow", "ping", "pointer-events", "referrerpolicy", "requiredExtensions", "requiredFeatures", "requiredFonts", "requiredFormats", "shape-rendering", "stop-color", "stop-opacity", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "target", "text-anchor", "text-decoration", "text-rendering", "transform", "type", "unicode-bidi", "visibility", "word-spacing", "writing-mode" ], altGlyph: [ "alignment-baseline", "baseline-shift", "clip", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cursor", "direction", "display", "dominant-baseline", "dx", "dy", "enable-background", "externalResourcesRequired", "fill", "fill-opacity", "fill-rule", "filter", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "format", "glyph-orientation-horizontal", "glyph-orientation-vertical", "glyphRef", "image-rendering", "kerning", "letter-spacing", "lighting-color", "marker-end", "marker-mid", "marker-start", "mask", "opacity", "overflow", "pointer-events", "requiredExtensions", "requiredFeatures", "rotate", "shape-rendering", "stop-color", "stop-opacity", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "text-anchor", "text-decoration", "text-rendering", "unicode-bidi", "visibility", "word-spacing", "writing-mode", "x", "y" ], altGlyphDef: [], altGlyphItem: [], animate: [ "accumulate", "additive", "alignment-baseline", "attributeName", "attributeType", "baseline-shift", "begin", "by", "calcMode", "clip", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cursor", "direction", "display", "dominant-baseline", "dur", "enable-background", "end", "externalResourcesRequired", "fill", "fill-opacity", "fill-rule", "filter", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "from", "glyph-orientation-horizontal", "glyph-orientation-vertical", "href", "image-rendering", "kerning", "keySplines", "keyTimes", "letter-spacing", "lighting-color", "marker-end", "marker-mid", "marker-start", "mask", "max", "min", "opacity", "overflow", "pointer-events", "repeatCount", "repeatDur", "requiredExtensions", "requiredFeatures", "requiredFonts", "requiredFormats", "restart", "shape-rendering", "stop-color", "stop-opacity", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "text-anchor", "text-decoration", "text-rendering", "to", "unicode-bidi", "values", "visibility", "word-spacing", "writing-mode" ], animateColor: [ "accumulate", "additive", "alignment-baseline", "attributeName", "attributeType", "baseline-shift", "begin", "by", "calcMode", "clip", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cursor", "direction", "display", "dominant-baseline", "dur", "enable-background", "end", "externalResourcesRequired", "fill", "fill-opacity", "fill-rule", "filter", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "from", "glyph-orientation-horizontal", "glyph-orientation-vertical", "image-rendering", "kerning", "keySplines", "keyTimes", "letter-spacing", "lighting-color", "marker-end", "marker-mid", "marker-start", "mask", "max", "min", "opacity", "overflow", "pointer-events", "repeatCount", "repeatDur", "requiredExtensions", "requiredFeatures", "requiredFonts", "requiredFormats", "restart", "shape-rendering", "stop-color", "stop-opacity", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "text-anchor", "text-decoration", "text-rendering", "to", "unicode-bidi", "values", "visibility", "word-spacing", "writing-mode" ], animateMotion: [ "accumulate", "additive", "begin", "by", "calcMode", "dur", "end", "externalResourcesRequired", "fill", "from", "href", "keyPoints", "keySplines", "keyTimes", "max", "min", "origin", "path", "repeatCount", "repeatDur", "requiredExtensions", "requiredFeatures", "requiredFonts", "requiredFormats", "restart", "rotate", "systemLanguage", "to", "values" ], animateTransform: [ "accumulate", "additive", "attributeName", "attributeType", "begin", "by", "calcMode", "dur", "end", "externalResourcesRequired", "fill", "from", "href", "keySplines", "keyTimes", "max", "min", "repeatCount", "repeatDur", "requiredExtensions", "requiredFeatures", "requiredFonts", "requiredFormats", "restart", "systemLanguage", "to", "type", "values" ], animation: [ "begin", "dur", "end", "externalResourcesRequired", "fill", "focusHighlight", "focusable", "height", "initialVisibility", "max", "min", "nav-down", "nav-down-left", "nav-down-right", "nav-left", "nav-next", "nav-prev", "nav-right", "nav-up", "nav-up-left", "nav-up-right", "preserveAspectRatio", "repeatCount", "repeatDur", "requiredExtensions", "requiredFeatures", "requiredFonts", "requiredFormats", "restart", "syncBehavior", "syncMaster", "syncTolerance", "systemLanguage", "transform", "width", "x", "y" ], audio: [ "begin", "dur", "end", "externalResourcesRequired", "fill", "max", "min", "repeatCount", "repeatDur", "requiredExtensions", "requiredFeatures", "requiredFonts", "requiredFormats", "restart", "syncBehavior", "syncMaster", "syncTolerance", "systemLanguage", "type" ], canvas: ["preserveAspectRatio", "requiredExtensions", "systemLanguage"], circle: [ "alignment-baseline", "baseline-shift", "clip", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cursor", "cx", "cy", "direction", "display", "dominant-baseline", "enable-background", "ex