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

Statements: 100% (8 / 8)      Branches: 100% (10 / 10)      Functions: 100% (1 / 1)      Lines: 100% (7 / 7)      Ignored: none     

All files » stylus-lint/src/checks/ » checkCommaStyle.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21    1         1 11051     11050   310 9     301      
'use strict';
 
var
    spaceAfter = /,[a-zA-Z]/,
    spaceAfterNum = /,(?:\d*\.)?\d+/;
 
// check that commas are followed by spaces
module.exports = function checkCommaStyle( line ) {
    if ( typeof line !== 'string' ) { return; }
 
    // if , is present on line
    if ( line.indexOf(',') !== -1 && line.indexOf(',') !== line.length - 1 ) {
        // if no space after or space below
        if ( spaceAfter.test(line) || spaceAfterNum.test(line) ) {
            return false;
        }
        else {
            return true;
        }
    }
}