diff --git a/apps/oxfmt/src/core/format.rs b/apps/oxfmt/src/core/format.rs index 70f773446ba29..c7d603799b15e 100644 --- a/apps/oxfmt/src/core/format.rs +++ b/apps/oxfmt/src/core/format.rs @@ -1,3 +1,4 @@ +use std::borrow::Cow; use std::path::Path; use serde_json::Value; @@ -279,17 +280,17 @@ impl SourceFormatter { external_options: Value, sort_options: Option<&sort_package_json::SortOptions>, ) -> Result { - let source_text: std::borrow::Cow<'_, str> = if let Some(options) = sort_options { + let source_text: Cow<'_, str> = if let Some(options) = sort_options { match sort_package_json::sort_package_json_with_options(source_text, options) { - Ok(sorted) => std::borrow::Cow::Owned(sorted), + Ok(sorted) => Cow::Owned(sorted), // `sort_package_json` can only handle strictly valid JSON. // On the other hand, Prettier's `json-stringify` parser is very permissive. // It can format JSON like input even with unquoted keys or trailing commas. // Therefore, rather than bailing out due to a sorting failure, we opt to format without sorting. - Err(_) => std::borrow::Cow::Borrowed(source_text), + Err(_) => Cow::Borrowed(source_text), } } else { - std::borrow::Cow::Borrowed(source_text) + Cow::Borrowed(source_text) }; self.format_by_external_formatter(&source_text, path, parser_name, external_options)