denoland / deno_lint

Blazing fast linter for JavaScript and TypeScript written in Rust
https://lint.deno.land/
MIT License
1.53k stars 172 forks source link

Rule suggestion: remove `no-control-regex` from defaults #1143

Open lionel-rowe opened 1 year ago

lionel-rowe commented 1 year ago

The regex /[\x00-\x1f\x7f]/ gives this warning:

Unexpected control character(s) in regular expression: \x0. Disable the rule if the control character (\x... or \u00..) was intentional, otherwise rework your RegExp deno-lint(no-control-regex)

Aside from the fact the warning is wrong (it's \x00, not \x0; also it doesn't trigger if \x7f is the only control char in the regex), regexes such as /[\x00-\x1f\x7f]/ are a somewhat common occurrence and a completely reasonable thing to want to write, particularly if you're doing something like parsing raw IO from stdin/stdout.

Alternatively: change the rule to only trigger for control character literals, which impede readability due to rendering as tofu in most fonts, and are much more likely to be there erroneously, whether in regexes or elsewhere.