`regexpp` is a specialized library for parsing and validating ECMAScript regular expressions, generating an Abstract Syntax Tree (AST) that precisely conforms to the ECMAScript specification. It provides robust tools for static analysis of regex patterns, including a parser (`RegExpParser`), a validator (`RegExpValidator`), and a visitor pattern (`RegExpVisitor`) for AST traversal. The current stable version, 3.2.0, actively receives updates to support the latest ECMAScript features and Unicode versions. This package differentiates itself by offering fine-grained control over the parsing process, allowing specification of ECMAScript version targets and Unicode flags, making it invaluable for linters, code transformers, and tools that require a deep, standards-compliant understanding and manipulation of regular expressions. Its release cadence is active, with significant updates roughly yearly for major versions and minor releases as needed to keep pace with spec changes and bug fixes.
npm install vscode-regexppVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a regular expression literal, validating it, and then traversing its Abstract Syntax Tree (AST) using the visitor pattern.
Upgrade Node.js to version 8 or newer.
Explicitly pass `ecmaVersion` in parser/validator options (e.g., `{ ecmaVersion: 2018 }`) if compatibility with older ECMAScript versions is required, or update regex patterns to conform to ES2020.Update any code that directly traverses or manipulates the AST to reflect the new node types and property names (e.g., use `node.alternatives` instead of `node.elements`).
Ensure regular expression patterns do not end with an unescaped backslash. Correct the pattern to escape the backslash (`\\`) if it's intended as a literal, or remove it if it's an incomplete escape sequence.
Verify that regular expressions using Unicode features behave as expected after upgrading. Explicitly set `ecmaVersion` and `unicode` (if applicable) in parser options for consistent behavior if precise historical Unicode conformance is critical.
Review the regular expression pattern for syntax errors. When using `RegExpParser` or `parseRegExpLiteral`, ensure the `ecmaVersion` option matches the target ECMAScript standard for the regex.
Update AST traversal or manipulation logic to use the new property names (e.g., `alternatives` instead of `elements`) and current node types as defined in `regexpp` v2.0.0 and above.
Use ES Module `import` syntax (`import { parseRegExpLiteral } from 'regexpp'`) in modern Node.js environments or with a bundler. Ensure your project is configured for ESM by using `.mjs` files or `"type": "module"` in `package.json`.Upgrade Node.js to version 8 or newer to meet the minimum engine requirements for `regexpp` v3.x.
No dependency data recorded yet.