-
Notifications
You must be signed in to change notification settings - Fork 0
/
predefined-rules.js
49 lines (41 loc) · 1.41 KB
/
predefined-rules.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const {
TagCountRule,
TagWithoutAttributeRule,
TagCountExceedThresholdRule
} = require('./rules');
const ImgTagWithoutAltRule = new TagWithoutAttributeRule((n) => {
return `There ${n > 1 ? 'are' : 'is'} ${n} <img> tag without alt attribute.`;
}, 'img', 'alt');
const ATagWithoutRelRule = new TagWithoutAttributeRule((n) => {
return `There ${n > 1 ? 'are' : 'is'} ${n} <a> tag without rel attribute.`
}, 'a', 'rel');
const MissingTitleInHeadTagRule = new TagCountRule((n) => {
return 'There are head tag without title tag.'
}, 'head:not(:has(>title))', (n) => {
return n > 0;
});
const MissingDescriptionInHeadTagRule = new TagCountRule((n) => {
return 'There are head tag without descriptions.'
}, 'head:not(:has(>meta[name="descriptions"]))', (n) => {
return n > 0;
});
const MissingKeywordsInHeadTagRule = new TagCountRule((n) => {
return 'There are head tag without keywords.'
}, 'head:not(:has(>meta[name="keywords"]))', (n) => {
return n > 0;
});
const MoreThan15StrongTagRule = new TagCountExceedThresholdRule((n) => {
return 'This HTML have more than 15 <strong> tag.';
}, 'strong', 15);
const MultipleH1TagRule = new TagCountExceedThresholdRule((n) => {
return 'This HTML have more than 1 <h1> tag.';
}, 'h1', 1);
module.exports = {
ImgTagWithoutAltRule,
ATagWithoutRelRule,
MissingTitleInHeadTagRule,
MissingDescriptionInHeadTagRule,
MissingKeywordsInHeadTagRule,
MoreThan15StrongTagRule,
MultipleH1TagRule
};