/** * @fileoverview Shared utilities for stripping string literal and comment * content from source code. Used by fitness checks to avoid false positives * from patterns appearing inside string literals or comments. * * Canonical rationale for the two-stripper split * ---------------------------------------------- * Fitness ships two complementary content-stripping families and this is * the canonical place that explains why both exist (audit 2026-05-23 F9): * * 1. **This module** — regex-based, **language-agnostic**, no AST * dependency. Used by checks that scan Python/Go/Java/C++/universal * text where a real parser would be overkill (or unavailable). Trades * off precision: edge cases like nested template literals or escaped * quotes inside comments are best-effort. * * 2. **`filterContent` in `@opensip-cli/lang-typescript`** — uses the * real TypeScript scanner, position-preserving (string content is * replaced with whitespace of equal length so line/column numbers * survive). Cached. Used exclusively by TS-aware checks where the * precision matters. * * The dispatch boundary is `applyContentFilter` in * `@opensip-cli/core/languages/content-filter-dispatch.ts` — checks * declare a `contentFilter` mode (`'strip-strings'`, * `'strip-strings-and-comments'`, `'raw'`) and the language adapter for * the file's extension routes to the right family. New strippers plug in * by implementing the `LanguageAdapter` contract; nothing in the check * layer needs to change. */ /** * Strip string literal contents from a single line. * Replaces content inside '...', "...", and `...` with empty strings. * Used by checks for per-line pattern matching to avoid false positives * from patterns appearing inside string literals. */ export declare function stripStringLiterals(line: string): string; /** * Position-preserving variant of {@link stripStringLiterals}: blanks each string * literal's INTERIOR with equal-length spaces while keeping the delimiters and * any interior newlines, so the output has the SAME length and line structure as * the input. Use this — NOT `stripStringLiterals`, which collapses `'…'`→`''` and * so shifts the column of everything after a literal — whenever a check reports a * `column` derived from the stripped content (mirrors the strings+comments * {@link stripStringsAndCommentsPreservingPositions}). */ export declare function stripStringLiteralsPreservingPositions(line: string): string; /** * Strip string literals and single-line comments from full file content. * Used by checks for quick-filter gates to avoid matching keywords * that only appear in documentation strings or comments. */ /** * Check if a position in a line is inside a string literal. * Scans characters before the match position for unescaped quotes/backticks. * Used by checks to avoid false positives from suggestion/description text. */ export declare function isInsideStringLiteral(line: string, matchIndex: number): boolean; /** * Strip string literals and single-line comments from full file content. * Used by checks for quick-filter gates to avoid matching keywords * that only appear in documentation strings or comments. */ export declare function stripStringsAndComments(content: string): string; /** * Strip strings, single-line comments, AND block comments while preserving * BOTH character positions and line numbers. Each stripped character is * replaced with a space (non-newline) so the output has identical length * and line offsets to the input. Use this when downstream processing * needs to map a match index back to a line number in the ORIGINAL * source — `stripStringsAndComments` collapses string literals to empty * pairs, which shifts indexes and breaks `getLineNumber(content, idx)`. * * Strips: * - Single-quoted, double-quoted, and template-literal string contents * - Single-line `// ...` comments (to end of line) * - Block `/* ... *\/` comments (including JSDoc `/** ... *\/`) * * Preserves: newlines, total character count, character positions of * code OUTSIDE these regions. */ export declare function stripStringsAndCommentsPreservingPositions(content: string): string; //# sourceMappingURL=strip-literals.d.ts.map