Skip to content

Commit 7d77422

Browse files
authored
Merge pull request #828 from jpsc/master
feat(a11y): add warning missing lang on html tag
2 parents cc7bf6f + c872234 commit 7d77422

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/validate/html/a11y.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ export default function a11y(
143143
shouldHaveAttribute(['title']);
144144
}
145145

146+
// html-has-lang
147+
if (node.name === 'html') {
148+
shouldHaveAttribute(['lang']);
149+
}
150+
146151
// no-distracting-elements
147152
if (node.name === 'marquee' || node.name === 'blink') {
148153
validator.warn(`A11y: Avoid <${node.name}> elements`, node.start);
@@ -168,4 +173,4 @@ function getValue(attribute: Node) {
168173
if (attribute.value.length === 1 && attribute.value[0].type === 'Text') return attribute.value[0].data;
169174

170175
return null;
171-
}
176+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<html lang="en"></html>
2+
<html lang="en-US"></html>
3+
<html lang={{language}}></html>
4+
5+
<html></html>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"loc": {
4+
"column": 0,
5+
"line": 5
6+
},
7+
"message": "A11y: <html> element should have a lang attribute",
8+
"pos": 82
9+
}
10+
]

0 commit comments

Comments
 (0)