Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/oxc_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ impl<'a> Codegen<'a> {
/// NOTE: you must call [`Codegen::with_source_text`] before calling this method
#[inline]
pub fn print_expression(&mut self, expr: &Expression<'_>) {
debug_assert!(!self.source_text.is_empty());
expr.print_expr(self, Precedence::Lowest, Context::empty());
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/fixer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ impl<'c, 'a: 'c> RuleFixer<'c, 'a> {
self.new_fix(CompositeFix::Single(fix), message)
}

#[expect(clippy::unused_self)]
#[must_use]
pub fn codegen(self) -> Codegen<'a> {
Codegen::new()
.with_source_text(self.source_text())
.with_options(CodegenOptions { single_quote: true, ..CodegenOptions::default() })
}

Expand Down
5 changes: 5 additions & 0 deletions crates/oxc_linter/src/rules/unicorn/prefer_spread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ fn test() {
// `string.split()`
(r#""🦄".split("")"#, r#"[..."🦄"]"#, None),
(r#""foo bar baz".split("")"#, r#"[..."foo bar baz"]"#, None),
(
r"Array.from(path.matchAll(/\{([^{}?]+\??)\}/g))",
"[...path.matchAll(/\\{([^{}?]+\\??)\\}/g)]",
None,
),
];

Tester::new(PreferSpread::NAME, PreferSpread::PLUGIN, pass, fail)
Expand Down
Loading