INNER CODE UNIT · JavaScript

hash

karanb192/claude-code-hooks · plugins/bounty-board/bounty-board.js:143

  const hash = line.match(/(?:^|\s)#(?!!)/);
  if (hash) candidates.push(hash.index + hash[0].length - 1);
  const html = line.indexOf('<!--');
  if (html !== -1) candidates.push(html);
  const lead = line.match(/^\s*(?:\*|--|;)/);
  if (lead) candidates.push(lead[0].length - 1);
  return candidates.length ? Math.min(...candidates) : -1;
}

/**
 * Scan a single line; returns the first matching rule or null.
 * Comment-kind rules (TODO/FIXME/…) only match inside a comment span, so
 * `const url = "https://x.com/TODO"` or a TODO in a string literal doesn't
 * become a bounty. Test/lint rules match code constructs, so they see the
 * whole line.
 */
function classifyLine(line) {
  if (!line || line.length > MAX_LINE_LEN) return null;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…