Skip to content

Commit

Permalink
feat(linter): accept more valid regex
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed May 25, 2024
1 parent d971c9c commit a764274
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)",
Expand Down

0 comments on commit a764274

Please sign in to comment.