Skip to content

Commit 621cc46

Browse files
committed
wip
1 parent cc8efaa commit 621cc46

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

crates/oxc_linter/src/fixer/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ impl<'a> Fixer<'a> {
318318

319319
#[cfg(test)]
320320
mod test {
321+
use cow_utils::CowUtils;
321322
use std::borrow::Cow;
322323

323324
use oxc_diagnostics::OxcDiagnostic;
@@ -417,7 +418,7 @@ mod test {
417418
get_fix_result(vec![create_message(insert_at_middle(), Some(INSERT_AT_MIDDLE))]);
418419
assert_eq!(
419420
result.fixed_code,
420-
TEST_CODE.replace("6 *", &format!("{}{}", INSERT_AT_MIDDLE.content, "6 *"))
421+
TEST_CODE.cow_replace("6 *", &format!("{}{}", INSERT_AT_MIDDLE.content, "6 *"))
421422
);
422423
assert_eq!(result.messages.len(), 0);
423424
}

crates/oxc_linter/src/rules/unicorn/prefer_spread.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ fn is_not_array(expr: &Expression, ctx: &LintContext) -> bool {
232232
_ => return false,
233233
};
234234

235-
if ident.cow_to_ascii_uppercase() != ident {
235+
if ident.starts_with(|c: char| c.is_ascii_uppercase())
236+
&& ident.cow_to_ascii_uppercase() != ident
237+
{
236238
return true;
237239
}
238240

crates/oxc_linter/src/tester.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::{
33
path::{Path, PathBuf},
44
};
55

6+
use cow_utils::CowUtils;
67
use oxc_allocator::Allocator;
78
use oxc_diagnostics::{DiagnosticService, GraphicalReportHandler, GraphicalTheme, NamedSource};
89
use serde::Deserialize;
@@ -185,7 +186,7 @@ impl Tester {
185186
expect_pass: Vec<T>,
186187
expect_fail: Vec<T>,
187188
) -> Self {
188-
let rule_path = PathBuf::from(rule_name.replace('-', "_")).with_extension("tsx");
189+
let rule_path = PathBuf::from(rule_name.cow_replace('-', "_")).with_extension("tsx");
189190
let expect_pass = expect_pass.into_iter().map(Into::into).collect::<Vec<_>>();
190191
let expect_fail = expect_fail.into_iter().map(Into::into).collect::<Vec<_>>();
191192
let current_working_directory =
@@ -294,7 +295,7 @@ impl Tester {
294295
}
295296

296297
fn snapshot(&self) {
297-
let name = self.rule_name.replace('-', "_");
298+
let name = self.rule_name.cow_replace('-', "_");
298299
let mut settings = insta::Settings::clone_current();
299300

300301
settings.set_prepend_module_to_snapshot(false);

crates/oxc_sourcemap/src/sourcemap_visualizer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl<'a> SourcemapVisualizer<'a> {
180180
}
181181
}
182182

183-
let replaced: Cow<str> = s.as_str().cow_replace("\r", "");
183+
let replaced: Cow<str> = s.cow_replace("\r", "");
184184

185185
// Windows: Replace "\r\n" and replace with "\n"
186186
Cow::Owned(replaced.into_owned())

0 commit comments

Comments
 (0)