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

Statements: 100% (9 / 9)      Branches: 90.91% (10 / 11)      Functions: 100% (1 / 1)      Lines: 100% (8 / 8)      Ignored: none     

All files » stylus-lint/src/checks/ » checkVarStyle.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 32 33 34 35 36 37 38    1           1 11     10   3           3 2     1                          
'use strict';
 
var
    eqEnd = /=$|=\s$/,
    hash = /\{$/,
    varCheck = /\$\w+/;
 
// check that $ is used when declaring vars
module.exports = function checkVarStyle( line ) {
    if ( typeof line !== 'string' ) { return; }
 
    // check if = is present on line at all
    if ( line.indexOf(' = ') !== -1 ) {
        // if so, make sure it's not a block or hash
        Eif ( line.indexOf('@block') === -1
            && !hash.test(line)
            && !eqEnd.test(line) ) {
 
            // at this point assume this line is defining a var and we check that the line starts with a $
            // and that it doesn't end with = (meaning its a block)
            if ( varCheck.test( line ) ) {
                return true;
            }
            else {
                return false;
            }
        }
    }
    // if not defining a var, we might be using in a mixin or if block
    // else if ( arr[0].indexOf('(') !== -1 ) {
    //     if ( varCheck.test( line ) ) {
    //         return true;
    //     }
    //     else {
    //         return false;
    //     }
    // }
}