Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 87 additions & 77 deletions dist/htmlhint.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,29 @@
a.d(n, 'attrLowercase', function() {
return o;
}),
a.d(n, 'attrNoDuplication', function() {
a.d(n, 'attrSortedn', function() {
return l;
}),
a.d(n, 'attrUnsafeChars', function() {
a.d(n, 'attrNoDuplication', function() {
return u;
}),
a.d(n, 'attrValueDoubleQuotes', function() {
a.d(n, 'attrUnsafeChars', function() {
return c;
}),
a.d(n, 'attrValueNotEmpty', function() {
a.d(n, 'attrValueDoubleQuotes', function() {
return d;
}),
a.d(n, 'attrWhitespace', function() {
a.d(n, 'attrValueNotEmpty', function() {
return f;
}),
a.d(n, 'csslint', function() {
return g;
}),
a.d(n, 'doctypeFirst', function() {
return p;
return m;
}),
a.d(n, 'doctypeHTML5', function() {
return m;
return p;
}),
a.d(n, 'headScriptDisabled', function() {
return v;
Expand Down Expand Up @@ -135,13 +135,13 @@
return j;
}),
a.d(n, 'specCharEscape', function() {
return A;
return S;
}),
a.d(n, 'srcNotEmpty', function() {
return q;
}),
a.d(n, 'styleDisabled', function() {
return S;
return A;
}),
a.d(n, 'tagPair', function() {
return M;
Expand All @@ -150,10 +150,10 @@
return E;
}),
a.d(n, 'tagnameLowercase', function() {
return _;
return I;
}),
a.d(n, 'titleRequire', function() {
return D;
return O;
});
var r = class {
constructor() {
Expand Down Expand Up @@ -182,12 +182,12 @@
f = /\s*([^\s"'>\/=\x00-\x0F\x7F\x80-\x9F]+)(?:\s*=\s*(?:(")([^"]*)"|(')([^']*)'|([^\s"'>]*)))?/g,
h = /\r?\n/g,
g = 0,
p = 0,
m = 0,
p = 0,
v = 1,
b = u._arrBlocks;
function w(e, t, a, n) {
var r = a - m + 1;
var r = a - p + 1;
for (
void 0 === n && (n = {}),
n.raw = t,
Expand All @@ -199,7 +199,7 @@
h.exec(t);

)
v++, (m = a + h.lastIndex);
v++, (p = a + h.lastIndex);
}
for (u.fire('start', { pos: 0, line: 1, col: 1 }); (t = d.exec(e)); )
if (
Expand All @@ -209,7 +209,7 @@
!(n = t[1]) ||
(i &&
n === i &&
(w('cdata', (l = o.join('')), p, { tagName: i, attrs: s }),
(w('cdata', (l = o.join('')), m, { tagName: i, attrs: s }),
(i = null),
(s = null),
(o = null)),
Expand Down Expand Up @@ -237,7 +237,7 @@
attrs: r,
close: t[6]
}),
c[n] && ((i = n), (s = r.concat()), (o = []), (p = g)))
c[n] && ((i = n), (s = r.concat()), (o = []), (m = g)))
: w('text', t[0], a);
} else
(t[2] || t[3]) &&
Expand All @@ -247,7 +247,7 @@
});
else w('tagend', t[0], a, { tagName: n });
e.length > g && w('text', (l = e.substring(g, e.length)), g),
u.fire('end', { pos: g, line: v, col: e.length - m + 1 });
u.fire('end', { pos: g, line: v, col: e.length - p + 1 });
}
addListener(e, t) {
for (
Expand Down Expand Up @@ -394,6 +394,58 @@
}
},
l = {
id: 'attr-sorted',
description: 'Attribute tags must be in proper order.',
init: function(e, t) {
for (
var a = this,
n = {},
r = [
'class',
'id',
'name',
'src',
'for',
'type',
'href',
'value',
'title',
'alt',
'role'
],
i = 0;
i < r.length;
i++
)
n[r[i]] = i;
e.addListener('tagstart', function(e) {
for (var r = e.attrs, i = [], s = 0; s < r.length; s++)
i.push(r[s].name);
var o = JSON.stringify(i);
i.sort(function(e, t) {
return null == n[e] && null == n[t]
? 0
: null == n[e]
? 1
: null == n[t]
? -1
: n[e] - n[t] || e.localeCompare(t);
}),
o !== JSON.stringify(i) &&
t.error(
'Inaccurate order ' +
o +
' should be in hierarchy ' +
JSON.stringify(i) +
' ',
e.line,
e.col,
a
);
});
}
},
u = {
id: 'attr-no-duplication',
description: 'Elements cannot have duplicate attributes.',
init: function(e, t) {
Expand Down Expand Up @@ -422,7 +474,7 @@
});
}
},
u = {
c = {
id: 'attr-unsafe-chars',
description: 'Attribute values cannot contain unsafe chars.',
init: function(e, t) {
Expand Down Expand Up @@ -458,7 +510,7 @@
});
}
},
c = {
d = {
id: 'attr-value-double-quotes',
description: 'Attribute values must be in double quotes.',
init: function(e, t) {
Expand Down Expand Up @@ -487,7 +539,7 @@
});
}
},
d = {
f = {
id: 'attr-value-not-empty',
description: 'All attributes must have values.',
init: function(e, t) {
Expand All @@ -514,48 +566,6 @@
});
}
},
f = {
id: 'attr-whitespace',
description:
'All attributes should be separated by only one space and not have leading/trailing whitespace.',
init: function(e, t, a) {
var n = this,
r = Array.isArray(a) ? a : [];
e.addListener('tagstart', function(e) {
var a,
i = e.attrs,
s = e.col + e.tagName.length + 1;
i.forEach(function(i) {
a = i;
var o = i.name;
-1 === r.indexOf(o) &&
(console.log('Here'),
i.value.trim(i.value) !== i.value &&
(console.log('Here3'),
t.error(
'The attributes of [ ' +
o +
' ] must not have trailing whitespace.',
e.line,
s + a.index,
n,
a.raw
)),
i.value.replace(/ +(?= )/g, '') !== i.value &&
(console.log('Here2'),
t.error(
'The attributes of [ ' +
o +
' ] must be separated by only one space.',
e.line,
s + a.index,
n,
a.raw
)));
});
});
}
},
h = a(0),
g = {
id: 'csslint',
Expand Down Expand Up @@ -585,7 +595,7 @@
});
}
},
p = {
m = {
id: 'doctype-first',
description: 'Doctype must be declared first.',
init: function(e, t) {
Expand All @@ -607,7 +617,7 @@
e.addListener('all', n);
}
},
m = {
p = {
id: 'doctype-html5',
description: 'Invalid doctype. Use: "<!DOCTYPE html>"',
init: function(e, t) {
Expand Down Expand Up @@ -1000,7 +1010,7 @@
});
}
},
A = {
S = {
id: 'spec-char-escape',
description: 'Special characters must be escaped.',
init: function(e, t) {
Expand Down Expand Up @@ -1056,7 +1066,7 @@
});
}
},
S = {
A = {
id: 'style-disabled',
description: '<style> tags cannot be used.',
init: function(e, t) {
Expand Down Expand Up @@ -1160,7 +1170,7 @@
});
}
},
_ = {
I = {
id: 'tagname-lowercase',
description: 'All html element names must be in lowercase.',
init: function(e, t, a) {
Expand All @@ -1182,7 +1192,7 @@
});
}
},
D = {
O = {
id: 'title-require',
description: '<title> must be present in <head> tag.',
init: function(e, t) {
Expand Down Expand Up @@ -1212,7 +1222,7 @@
}
};
a.d(t, 'HTMLHint', function() {
return I;
return _;
}),
a.d(t, 'HTMLRules', function() {
return n;
Expand All @@ -1223,7 +1233,7 @@
a.d(t, 'HTMLParser', function() {
return r;
});
class I {
class _ {
constructor() {
(this.rules = {}),
(this.defaultRuleset = {
Expand Down Expand Up @@ -1288,14 +1298,14 @@
(t = t.replace(/\t/g, ' ').substring(l - 1, u)),
l > 1 && ((t = '...' + t), (l -= 3)),
u < o && (t += '...'),
a.push(n.white + H(r) + 'L' + i + ' |' + n.grey + t + n.reset);
a.push(n.white + D(r) + 'L' + i + ' |' + n.grey + t + n.reset);
var c = s - l,
d = t.substring(0, c).match(/[^\u0000-\u00ff]/g);
null !== d && (c += d.length),
a.push(
n.white +
H(r) +
H(String(i).length + 3 + c) +
D(r) +
D(String(i).length + 3 + c) +
'^ ' +
n.red +
e.message +
Expand All @@ -1309,14 +1319,14 @@
);
}
}
function H(e, t) {
function D(e, t) {
return new Array(e + 1).join(t || ' ');
}
const O = new I();
const P = new _();
Object.values(n).forEach(e => {
O.addRule(e);
P.addRule(e);
});
t.default = O;
t.default = P;
}
]);
});
Loading