diff options
Diffstat (limited to 'cli/tools/fmt.rs')
-rw-r--r-- | cli/tools/fmt.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index 36828e23c..084da7fd4 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -523,7 +523,7 @@ fn get_resolved_typescript_config( if let Some(single_quote) = options.single_quote { if single_quote { builder.quote_style( - dprint_plugin_typescript::configuration::QuoteStyle::AlwaysSingle, + dprint_plugin_typescript::configuration::QuoteStyle::PreferSingle, ); } } @@ -792,4 +792,23 @@ mod test { assert_eq!(result, Some("11".to_string())); } + + #[test] + fn test_single_quote_true_prefers_single_quote() { + let file_text = format_file( + &PathBuf::from("test.ts"), + "console.log(\"there's\");\nconsole.log('hi');\nconsole.log(\"bye\")\n", + &FmtOptionsConfig { + single_quote: Some(true), + ..Default::default() + }, + ) + .unwrap() + .unwrap(); + assert_eq!( + file_text, + // should use double quotes for the string with a single quote + "console.log(\"there's\");\nconsole.log('hi');\nconsole.log('bye');\n", + ); + } } |