-
-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
2 changed files
with
100 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.