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