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

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

All files » stylus-lint/src/checks/ » checkForTrailingWhitespace.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 11051     11050 3     11047    
'use strict';
 
var
    whitespace = /[ \t]+$/,  // check for unecessary tabs or whitespace at eol
    anythingElse = /[^ \t]/; // anything BUT whitespace (we dont want to return false positives on empty lines)
 
/**
 * check for trailing whitespace
 * @param  {string} line  the line being tested
 * @return {boolean} true if whitespace found, false if not
 */
module.exports = function checkWhitespace( line ) {
    if ( typeof line !== 'string' ) { return; }
 
    // not an empty line, with whitespace at the end
    if ( anythingElse.test(line) && whitespace.test(line) ) {
        return true;
    }
    else {
        return false;
    }
}