Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(linter): use regexp AST visitor in no-control-regex #6129

Commits on Sep 28, 2024

  1. refactor(linter): use regexp AST visitor in no-control-regex (#6129)

    - closes #5416
    
    Rewrites the `no-control-regex` rule to use a regular expression AST visitor instead of the `regex` crate and parsing by hand. This change simplifies the code and makes it easier to maintain.
    
    One notable change in the snapshots is the printing of the control characters. Previously, we always printed from the source text. Now, we print a representation of the control character itself based on its numeric value. This resulted in the nonprintable chars being printed, which are invisible. The other reason for this change is that the spans output by the regex parser for unicode escapes do not match 1:1 when raw strings and escapes are involved. This resulted in goofy looking spans in the output:
    
    ```
      ⚠ eslint(no-control-regex): Unexpected control character: '*\\x'
       ╭─[no_control_regex.tsx:1:22]
     1 │ new RegExp('\\u{1111}*\\x1F', 'u')
       ·                      ────
       ╰────
    ```
    
    Not sure where the bug lies there yet.
    camchenry committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    db751f0 View commit details
    Browse the repository at this point in the history