diff --git a/dprint_plugin/src/lib.rs b/dprint_plugin/src/lib.rs index d8ca29a..8a4fdde 100644 --- a/dprint_plugin/src/lib.rs +++ b/dprint_plugin/src/lib.rs @@ -6,7 +6,10 @@ use dprint_core::{ configuration::{ConfigKeyMap, GlobalConfiguration, ResolveConfigurationResult}, plugins::{FileMatchingInfo, PluginInfo, SyncPluginHandler, SyncPluginInfo}, }; -use markup_fmt::{config::FormatOptions, detect_language, format_text, FormatError}; +use markup_fmt::{ + config::{FormatOptions, Quotes}, + detect_language, format_text, FormatError, +}; use std::path::Path; mod config; @@ -75,14 +78,26 @@ impl SyncPluginHandler for MarkupFmtPluginHandler { let mut additional_config = ConfigKeyMap::new(); additional_config.insert("lineWidth".into(), (print_width as i32).into()); additional_config.insert("printWidth".into(), (print_width as i32).into()); - if let Some("expr.ts" | "binding.ts" | "type_params.ts") = - path.file_name().and_then(|s| s.to_str()) - { + + let file_name = path.file_name().and_then(|s| s.to_str()); + if let Some("expr.ts" | "binding.ts" | "type_params.ts") = &file_name { // dprint-plugin-typescript additional_config.insert("semiColons".into(), "asi".into()); // Biome additional_config.insert("semicolons".into(), "asNeeded".into()); } + if let Some("attr_expr.tsx") = &file_name { + // Only for dprint-plugin-typescript currently, + // because it conflicts with the `quoteStyle` option in Biome. + match config.language.quotes { + Quotes::Double => { + additional_config.insert("quoteStyle".into(), "alwaysSingle".into()); + } + Quotes::Single => { + additional_config.insert("quoteStyle".into(), "alwaysDouble".into()); + } + } + } format_with_host(path, code.into(), &additional_config).and_then(|result| { match result { diff --git a/dprint_plugin/tests/integration/biome/quotes.vue.snap b/dprint_plugin/tests/integration/biome/quotes.vue.snap new file mode 100644 index 0000000..8ce5e99 --- /dev/null +++ b/dprint_plugin/tests/integration/biome/quotes.vue.snap @@ -0,0 +1,7 @@ +--- +source: dprint_plugin/tests/integration.rs +--- + diff --git a/dprint_plugin/tests/integration/dprint_ts/basic.vue.snap b/dprint_plugin/tests/integration/dprint_ts/basic.vue.snap index b95e171..cea9589 100644 --- a/dprint_plugin/tests/integration/dprint_ts/basic.vue.snap +++ b/dprint_plugin/tests/integration/dprint_ts/basic.vue.snap @@ -10,7 +10,7 @@ function greet(msg: string) {