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

Statements: 100% (13 / 13)      Branches: 95.45% (21 / 22)      Functions: 100% (1 / 1)      Lines: 100% (12 / 12)      Ignored: none     

All files » stylus-lint/src/checks/ » checkForBrackets.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31    1         1 11061     11057 142     10915   8 4     4 1     3 3        
'use strict';
 
var
    openBracket = /\{$/,
    closeBracket = /\}$/,
    interpolation = /({\S)(\S)+[}]|([{]\S[}])/;
 
module.exports = function checkForBrackets( line, areWeInAHash ) {
    if ( typeof areWeInAHash === 'undefined' || typeof line !== 'string' ) { return; }
 
    // if interpolation we cool
    if ( interpolation.test(line) ) {
        return false;
    }
    // not interpolation, has a { or }
    else if ( openBracket.test(line) || closeBracket.test(line) ) {
        // ex .someClass {
        if ( openBracket.test(line) && line.indexOf('=') === -1 ) {
            return true;
        }
        // ex } when not in a hash and not an interpolated variable
        else if ( closeBracket.test(line) && areWeInAHash ) {
            return false;
        }
        // ex } when not in a hash and not an interpolated variable
        else Eif ( closeBracket.test(line) && !areWeInAHash ) {
            return true;
        }
    }
    // else no brackets, return undefined
}