UNPKG

583 BJavaScriptView Raw
1'use strict';
2
3var format = require('util').format,
4 MAX_LENGTH = 256;
5
6function 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 // report too long comments
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
21rule.description = 'Reports too long CSS comments';
22module.exports = rule;