From d101acf833913faa81868f0458058bf9de5c7047 Mon Sep 17 00:00:00 2001 From: Andy Armstrong Date: Fri, 15 Dec 2023 17:00:43 +0000 Subject: [PATCH] fix(linter): prefer-string-starts-ends-with: ignore `i` and `m` modifiers. (#1688) Fixes: #1687 --- .../src/rules/unicorn/prefer_string_starts_ends_with.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/oxc_linter/src/rules/unicorn/prefer_string_starts_ends_with.rs b/crates/oxc_linter/src/rules/unicorn/prefer_string_starts_ends_with.rs index e2bdc900d..cc10b1116 100644 --- a/crates/oxc_linter/src/rules/unicorn/prefer_string_starts_ends_with.rs +++ b/crates/oxc_linter/src/rules/unicorn/prefer_string_starts_ends_with.rs @@ -90,7 +90,9 @@ enum ErrorKind { } fn check_regex(regexp_lit: &RegExpLiteral) -> Option { - if regexp_lit.regex.flags.contains(RegExpFlags::I | RegExpFlags::M) { + if regexp_lit.regex.flags.contains(RegExpFlags::I) + || regexp_lit.regex.flags.contains(RegExpFlags::M) + { return None; } @@ -131,6 +133,7 @@ fn test() { r"foo()()", r"if (foo.match(/^foo/)) {}", r"if (/^foo/.exec(foo)) {}", + r"/^http/i.test(uri)", ]; let fail = vec![