<commit_before>var listSequences = require('./list-sequences');
var shouldIgnoreRule = require('./should-ignore-rule');
var shouldIgnoreSelector = require('./should-ignore-selector');
var toInterpoloatedRegexp = require('./to-interpolated-regexp');

/**
 * @param {Object} config
 * @param {Rule} config.rule - PostCSS Rule
 * @param {String} config.componentName
 * @param {Boolean} config.weakMode
 * @param {Object} config.selectorPattern
 * @param {Object} config.selectorPatternOptions
 * @param {RegExp} config.ignorePattern
 * @param {Result} config.result - PostCSS Result, for registering warnings
 */
module.exports = function(config) {
  if (shouldIgnoreRule(config.rule)) return;

  var initialPattern = (config.selectorPattern.initial)
    ? toInterpoloatedRegexp(config.selectorPattern.initial)(config.componentName, config.selectorPatternOptions)
    : toInterpoloatedRegexp(config.selectorPattern)(config.componentName, config.selectorPatternOptions);
  var combinedPattern = (config.selectorPattern.combined)
    ? toInterpoloatedRegexp(config.selectorPattern.combined)(config.componentName, config.selectorPatternOptions)
    : toInterpoloatedRegexp(initialPattern);
  var selectors = config.rule.selectors;

  selectors.forEach(function(selector) {
    // Don't bother with :root
    if (selector === ':root') return;

    var allSequences = listSequences(selector);
    var sequence;
    for (var i = 0, l = allSequences.length; i < l; i++) {
      if (config.weakMode && i !== 0) return;
      sequence = allSequences[i];
      if (config.ignorePattern && shouldIgnoreSelector(sequence, config.ignorePattern)) continue;
      if (i === 0 && initialPattern.test(sequence)) continue;
      if (i !== 0 && combinedPattern.test(sequence)) continue;

      config.result.warn(
        'Invalid component selector "' + selector + '"',
        {
          node: config.rule,
          word: selector,
        }
      );
      return;
    }
  });
}
<commit_msg>Add a var to reference config.rule<commit_after>var listSequences = require('./list-sequences');
var shouldIgnoreRule = require('./should-ignore-rule');
var shouldIgnoreSelector = require('./should-ignore-selector');
var toInterpoloatedRegexp = require('./to-interpolated-regexp');

/**
 * @param {Object} config
 * @param {Rule} config.rule - PostCSS Rule
 * @param {String} config.componentName
 * @param {Boolean} config.weakMode
 * @param {Object} config.selectorPattern
 * @param {Object} config.selectorPatternOptions
 * @param {RegExp} config.ignorePattern
 * @param {Result} config.result - PostCSS Result, for registering warnings
 */
module.exports = function(config) {
  if (shouldIgnoreRule(config.rule)) return;
  var rule = config.rule;

  var initialPattern = (config.selectorPattern.initial)
    ? toInterpoloatedRegexp(config.selectorPattern.initial)(config.componentName, config.selectorPatternOptions)
    : toInterpoloatedRegexp(config.selectorPattern)(config.componentName, config.selectorPatternOptions);
  var combinedPattern = (config.selectorPattern.combined)
    ? toInterpoloatedRegexp(config.selectorPattern.combined)(config.componentName, config.selectorPatternOptions)
    : toInterpoloatedRegexp(initialPattern);
  var selectors = rule.selectors;

  selectors.forEach(function(selector) {
    // Don't bother with :root
    if (selector === ':root') return;

    var allSequences = listSequences(selector);
    var sequence;
    for (var i = 0, l = allSequences.length; i < l; i++) {
      if (config.weakMode && i !== 0) return;
      sequence = allSequences[i];
      if (config.ignorePattern && shouldIgnoreSelector(sequence, config.ignorePattern)) continue;
      if (i === 0 && initialPattern.test(sequence)) continue;
      if (i !== 0 && combinedPattern.test(sequence)) continue;

      config.result.warn(
        'Invalid component selector "' + selector + '"',
        {
          node: rule,
          word: selector,
        }
      );
      return;
    }
  });
}

{'fraction_non_alphanumeric': 0.12861090178347148, 'fraction_numerical': 0.002009545340366742, 'mean_word_length': 4.092071611253197, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3796323', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1106, 'n_words': 246}