lib/rules/selector-descendant-combinator-no-non-space/index.js
function isActuallyCombinator(combinatorNode) {
  // `.foo  /*comment*/, .bar`
  //      ^^
  // If include comments, this spaces is a combinator, but it is not combinators.
  if (!/^\s+$/.test(combinatorNode.value)) {
    return true;
  }

  let next = combinatorNode.next();

  while (skipTest(next)) {
    next = next.next();
  }

  if (isNonTarget(next)) {
    return false;
  }

  let prev = combinatorNode.prev();

  while (skipTest(prev)) {
    prev = prev.prev();
  }

  if (isNonTarget(prev)) {
    return false;
  }

  return true;

  function skipTest(node) {
    if (!node) {
      return false;
    }

    if (node.type === "comment") {
      return true;
    }

    if (node.type === "combinator" && /^\s+$/.test(node.value)) {
      return true;
    }

    return false;
  }

  function isNonTarget(node) {
    if (!node) {
      return true;
    }

    if (node.type === "combinator" && !/^\s+$/.test(node.value)) {
      return true;
    }

    return false;
  }
}
function isActuallyCombinator(combinatorNode) {
  // `.foo  /*comment*/, .bar`
  //      ^^
  // If include comments, this spaces is a combinator, but it is not combinators.
  if (!/^\s+$/.test(combinatorNode.value)) {
    return true;
  }

  let next = combinatorNode.next();

  while (skipTest(next)) {
    next = next.next();
  }

  if (isNonTarget(next)) {
    return false;
  }

  let prev = combinatorNode.prev();

  while (skipTest(prev)) {
    prev = prev.prev();
  }

  if (isNonTarget(prev)) {
    return false;
  }

  return true;

  function skipTest(node) {
    if (!node) {
      return false;
    }

    if (node.type === "comment") {
      return true;
    }

    if (node.type === "combinator" && /^\s+$/.test(node.value)) {
      return true;
    }

    return false;
  }

  function isNonTarget(node) {
    if (!node) {
      return true;
    }

    if (node.type === "combinator" && !/^\s+$/.test(node.value)) {
      return true;
    }

    return false;
  }
}
function isActuallyCombinator ( combinatorNode ) { // `.foo  /*comment*/, .bar` //      ^^ // If include comments, this spaces is a combinator, but it is not combinators. if ( ! / ^\s+$ / . test ( combinatorNode . value ) ) { return true ; } let next = combinatorNode . next ( ) ; while ( skipTest ( next ) ) { next = next . next ( ) ; } if ( isNonTarget ( next ) ) { return false ; } let prev = combinatorNode . prev ( ) ; while ( skipTest ( prev ) ) { prev = prev . prev ( ) ; } if ( isNonTarget ( prev ) ) { return false ; } return true ; function skipTest ( node ) { if ( ! node ) { return false ; } if ( node . type === "comment" ) { return true ; } if ( node . type === "combinator" && / ^\s+$ / . test ( node . value ) ) { return true ; } return false ; } function isNonTarget ( node ) { if ( ! node ) { return true ; } if ( node . type === "combinator" && ! / ^\s+$ / . test ( node . value ) ) { return true ; } return false ; } }
Check whether is actually a combinator.
@param {Node} combinatorNode The combinator node
@returns {boolean} `true` if is actually a combinator.
Check whether is actually a combinator .