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

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

All files » stylus-lint/src/checks/ » checkForUniversal.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    1                     1 11051   11050   54       10     44       10996    
'use strict';
 
var
	starS = /(\* )/,                  // check for space after star (inside a docblockr comment)
	starO = /(\/\*\*)/ || /(\/\*)/,   // check for star selector as opening comment
	starR = /(\*=)/,                  // check for use in regex
	starE = /(\*\/)/;                 // finally, check for star selector as closing comment
 
/**
* check for * selector.
* technically this is used as part of resets often, for good reason, despite its slowness
* which is why i'm setting it up as a warning as it won't break code but maybe you prefer to not use it
*/
module.exports = function checkForUniversal( line ) {
	if ( typeof line !== 'string' ) { return; }
 
	if ( line.indexOf('*') !== -1 ) {
		// check for various places where the * is valid (just comment checks atm)
		if ( !starS.test( line ) &&
			!starO.test( line ) &&
			!starR.test( line ) &&
			!starE.test( line ) ) {
				return true;
		}
		else {
			return false;
		}
	}
	else {
		return false;
	}
 }