1 | "use strict";
|
2 |
|
3 | const format = require("util").format,
|
4 | MAX_LENGTH = 256;
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function rule(analyzer) {
|
10 | analyzer.setMetric("comments");
|
11 | analyzer.setMetric("commentsLength");
|
12 |
|
13 | analyzer.on("comment", function (comment) {
|
14 | analyzer.incrMetric("comments");
|
15 | analyzer.incrMetric("commentsLength", comment.length);
|
16 |
|
17 |
|
18 | if (comment.length > MAX_LENGTH) {
|
19 | analyzer.addOffender(
|
20 | "comments",
|
21 | format(
|
22 | '"%s" is too long (%d characters)',
|
23 | comment.substr(0, 100),
|
24 | comment.length
|
25 | )
|
26 | );
|
27 | }
|
28 | });
|
29 | }
|
30 |
|
31 | rule.description = "Reports too long CSS comments";
|
32 | module.exports = rule;
|