Statically tracks specific method calls (like app.use middleware hooks) on a line-by-line basis.
The Line Auditor Story (V4) utilizes multiline regex flags to identify configuration lines, method invocations, or middleware mount hooks (such as app.use(...)) strictly formatted at the start of code lines.
The auditor accepts code content along with a multiline RegExp pattern. By using the multiline flag m combined with line anchors ^ or $, it processes search strings line-by-line to extract matching method statements while ignoring mid-line strings or commented references.
Key Parameters:
fileContent (string): The code content to scan.searchString (RegExp): A multiline regular expression using the global flag (e.g. /^[ \t]*app\.use\s*\(/gm).Below is the configuration and corresponding matches output:
import patternCollector from 'pattern-collector';
const matches = patternCollector({
fileContent: codeText,
searchString: /^[ \t]*app\.use\s*\(/gm
});
[
"app.use("
]
Input code and a line RegExp to see targeted line matches immediately.
The diagram below represents how the line analyzer accesses the base package in the ecosystem to collect matching lines: