fix(linter): Accept more valid regex (#3408)

- Closes: #3405
This commit is contained in:
magic-akari 2024-05-25 18:33:56 +08:00 committed by GitHub
parent aa26ce9151
commit 74b06a71da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -123,7 +123,7 @@ fn is_simple_string(str: &str) -> bool {
fn is_useless_case_sensitive_regex_flag(regexp_lit: &RegExpLiteral) -> bool {
// ignore `^` and `$` (start and end of string)
let pat = regexp_lit.regex.pattern.trim_start_matches('^').trim_end_matches('$');
pat.chars().all(|c| c.is_ascii_alphabetic())
pat.chars().any(|c| c.is_ascii_alphabetic())
}
#[test]
@ -154,6 +154,7 @@ fn test() {
r"/foo.$/.test(bar)",
r"/\^foo/.test(bar)",
r"/^foo/i.test(bar)",
r"/^foo0/i.test(bar)",
r"/^foo/m.test(bar)",
r"/^foo/im.test(bar)",
r"/^A|B/.test(bar)",