Skip to content

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

@lionel-rowe

Description

@lionel-rowe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions