Code coverage report for stylus-lint/src/checks/checkCommentStyle.js

Statements: 100% (10 / 10)      Branches: 100% (12 / 12)      Functions: 100% (1 / 1)      Lines: 100% (9 / 9)      Ignored: none     

All files » stylus-lint/src/checks/ » checkCommentStyle.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22      1   1 6   5   4 1     3 1     2      
'use strict';
 
// check for space after comment line
var comment = /\/\/\s/;
 
module.exports = function checkCommentStyle( line ) {
    if ( typeof line !== 'string' ) { return; }
 
    if ( line.indexOf('//') !== -1 ) {
        // check for space after comment on it's own line, if no space, return warning
        if ( line.indexOf('//') === 0 && !comment.test(line) ) {
            return false;
        }
        // check for space after comment if on same line, if no space, return warning
        else if ( line.indexOf('http://') === -1 && !comment.test(line) ) {
            return false;
        }
        else {
            return true;
        }
    }
}