You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the regex parser completed, we have now started using oxc_regular_expression in the linter for parsing patterns instead of handwritten pattern matching and parsing code.
However, it is difficult to traverse the regex AST and visit each node (term/disjunction/alternative/etc.). We should implement the visitor pattern for the regex AST, so it is easier to write some code that visits every node.
Ideally, we should be able to replace code like this:
…ST (#6055)
- resolves#5977
- supersedes #5951
To facilitate easier traversal of the Regex AST, this PR defines a `Visit` trait with default implementations that will walk the entirety of the Regex AST. Methods in the `Visit` trait can be overridden with custom implementations to do things like analyzing only certain nodes in a regular expression, which will be useful for regex-related `oxc_linter` rules.
In the future, we should consider automatically generating this code as it is very repetitive, but for now a handwritten visitor is sufficient.
With the regex parser completed, we have now started using
oxc_regular_expression
in the linter for parsing patterns instead of handwritten pattern matching and parsing code.However, it is difficult to traverse the regex AST and visit each node (term/disjunction/alternative/etc.). We should implement the visitor pattern for the regex AST, so it is easier to write some code that visits every node.
Ideally, we should be able to replace code like this:
oxc/crates/oxc_linter/src/rules/eslint/no_regex_spaces.rs
Lines 119 to 146 in 74d8714
oxc/crates/oxc_linter/src/rules/eslint/no_regex_spaces.rs
Lines 171 to 206 in 74d8714
The text was updated successfully, but these errors were encountered: