We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Boshen
Dunqing
camc314
leaysgur
Learn more about funding links in repositories.
Report abuse
unicorn/prefer-string-replace-all
1 parent f51cbad commit e0a3378Copy full SHA for e0a3378
crates/oxc_linter/src/rules/unicorn/prefer_string_replace_all.rs
@@ -130,6 +130,7 @@ fn get_pattern_replacement<'a>(
130
.regex
131
.pattern
132
.as_pattern()
133
+ .filter(|pattern| pattern.body.body.len() == 1)
134
.and_then(|pattern| pattern.body.body.first().map(|it| &it.body))?;
135
let is_simple_string = pattern_terms.iter().all(|term| matches!(term, Term::Character(_)));
136
@@ -150,6 +151,7 @@ fn test() {
150
151
let pass = vec![
152
r"foo.replace(/a/, bar)",
153
r"foo.replaceAll(/a/, bar)",
154
+ r"foo.replaceAll(/a|b/g, bar)",
155
r#"foo.replace("string", bar)"#,
156
r#"foo.replaceAll("string", bar)"#,
157
r"foo.replace(/a/g)",
0 commit comments