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

Statements: 100% (18 / 18)      Branches: 100% (8 / 8)      Functions: 100% (3 / 3)      Lines: 100% (18 / 18)      Ignored: none     

All files » stylus-lint/src/checks/ » zIndexr.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 39 40 411       1   11140 1     11139   11139       42042         11139 29   29 23 23     29 406 44 44       29     11139  
var cache = [],
    num = 0;
 
// check for z-index values and recommend normalized ones
module.exports = function zIndexr( line, arr ) {
    'use strict';
    if ( typeof line === 'undefined' ) {
        return;
    }
 
    var res, zIndexValue;
 
    arr = line.split(/[\s\t,:]/),
    // remove white space
    arr = arr.filter(
        function( str ) {
            return str.length > 0;
        }
    );
 
    // the most basic of checks, throw warning if zindex value not normalized
    if ( line.indexOf('z-index') !== -1 ) {
        zIndexValue = arr[ arr.length - 1 ];
 
        if ( zIndexValue % this.config.zIndexr !== 0 ) {
            res = 'normalize';
            console.log( 'not normalized' );
        }
 
        cache.forEach(function( val, i ) {
            if ( cache[ i ] === zIndexValue ) {
                res = 'duplicate';
                console.log( 'dupe found' );
            }
        });
 
        cache.push( zIndexValue );
    }
 
    return res;
}