Initialize the False Positive Detector
Optionalconfig: FalsePositiveDetectorConfigOptional configuration options
Add a custom pattern to the detector
Allows extending the detector with project-specific patterns without modifying the built-in pattern set.
The false positive pattern to add
Filter false positives from an array of syntax errors
This method processes all errors and separates genuine errors from false positives based on the registered patterns.
Array of syntax errors to filter
Complete file content for context
Object containing genuine errors and filtered false positives
const result = detector.filterFalsePositives(
[
{ message: 'Import statement missing', line: 15, column: 5 },
{ message: 'Unexpected token', line: 20, column: 10 }
],
fileContent
);
console.info(`Genuine: ${result.genuine.length}`);
console.info(`False positives: ${result.falsePositives.length}`);
console.info('Filtered by context:', result.filteredByContext);
Get statistics about pattern matches
Syntax errors to analyze
File content
Statistics about which patterns matched
Get count of registered patterns
Total number of patterns
Get all registered patterns
Array of all patterns (built-in + custom)
Check if a single error is a false positive
The error message from the parser
The source code line where error occurred
The 1-based line number (reserved for future use)
The matched pattern if false positive, null if genuine error
Security: Lines longer than maxLineLength are skipped to prevent ReDoS attacks.
Remove a pattern by index
Index of the pattern to remove
Remove all patterns matching a specific context
Only removes custom patterns; built-in patterns are preserved.
The context type to remove
Number of patterns removed
Reset to built-in patterns only
Removes all custom patterns added via addPattern()
False Positive Detector
Detects and filters false positive syntax errors that occur due to parser limitations with external decorator architectures and complex code patterns.
Remarks
Security: Regex patterns are designed to prevent ReDoS attacks. Lines longer than maxLineLength (default: 1000) are skipped to prevent performance degradation.
Use Cases
Constructor Parameters with "import" keyword
Super Calls with "import" variables
Multiple Decorators
Path Aliases in Imports
Architecture
Example